diff --git a/.coveragerc b/.coveragerc index 9e66f2146..d505ff27e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -11,7 +11,7 @@ omit = [report] show_missing = true # TODO bump back to 79 -fail_under = 60 +fail_under = 70 precision = 2 # Regexes for lines to exclude from consideration diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..05cc10ff7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +@reflex-dev/reflex-team diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4ba472338..b3966b5d0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,6 @@ name: Bug report about: Create a report to help us improve title: '' -labels: bug assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/enhancement_request.md b/.github/ISSUE_TEMPLATE/enhancement_request.md new file mode 100644 index 000000000..409524feb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement_request.md @@ -0,0 +1,19 @@ +--- +name: Enhancement Request +about: Suggest an enhancement for an existing Reflex feature. +title: '' +labels: 'enhancement' +assignees: '' +--- + +**Describe the Enhancement you want** +A clear and concise description of what the improvement does. + +- Which feature do you want to improve? (and what problem does it have) + +- What is the benefit of the enhancement? + +- Show an example/usecase were the improvement are needed. + +**Additional context** +Add any other context here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..7e217d83a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature Request +about: Suggest a new feature for Reflex +title: '' +labels: 'feature request' +assignees: '' + +--- + +**Describe the Features** +A clear and concise description of what the features does. + +- What is the purpose of the feature? + +- Show an example / use cases for the new feature. + +**Additional context** +Add any other context here. diff --git a/.github/actions/setup_build_env/action.yml b/.github/actions/setup_build_env/action.yml index 560b53749..d983a4daa 100644 --- a/.github/actions/setup_build_env/action.yml +++ b/.github/actions/setup_build_env/action.yml @@ -6,7 +6,7 @@ # # Exit conditions: # - Python of version `python-version` is ready to be invoked as `python`. -# - Poetry of version `poetry-version` is ready ot be invoked as `poetry`. +# - Poetry of version `poetry-version` is ready to be invoked as `poetry`. # - If `run-poetry-install` is true, deps as defined in `pyproject.toml` will have been installed into the venv at `create-venv-at-path`. name: 'Setup Reflex build environment' @@ -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 diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b849dd328..f743b7cbd 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -80,31 +80,25 @@ jobs: 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, macos-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' # keep only one python version for MacOS - - os: macos-latest - python-version: '3.8.18' - os: macos-latest python-version: '3.9.18' - os: macos-latest python-version: '3.10.13' - - os: macos-12 + - os: macos-latest python-version: '3.12.0' 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: @@ -161,7 +155,7 @@ jobs: fail-fast: false matrix: # Show OS combos first in GUI - os: [ubuntu-latest, windows-latest, macos-12] + os: [ubuntu-latest, windows-latest, macos-latest] python-version: ['3.11.5'] runs-on: ${{ matrix.os }} diff --git a/.github/workflows/check_node_latest.yml b/.github/workflows/check_node_latest.yml new file mode 100644 index 000000000..1cf9f6fdf --- /dev/null +++ b/.github/workflows/check_node_latest.yml @@ -0,0 +1,43 @@ +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'] + split_index: [1, 2] + node-version: ['node'] + fail-fast: false + + 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 pytest-split + poetry run playwright install --with-deps + - run: | + poetry run pytest tests/test_node_version.py + poetry run pytest tests/integration --splits 2 --group ${{matrix.split_index}} + + + diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml new file mode 100644 index 000000000..a7465defb --- /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 psycopg + - 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/integration_app_harness.yml b/.github/workflows/integration_app_harness.yml index e92fdb6d0..e6ea79377 100644 --- a/.github/workflows/integration_app_harness.yml +++ b/.github/workflows/integration_app_harness.yml @@ -6,13 +6,13 @@ concurrency: on: push: - branches: ['main'] + branches: ["main"] paths-ignore: - - '**/*.md' + - "**/*.md" pull_request: - branches: ['main'] + branches: ["main"] paths-ignore: - - '**/*.md' + - "**/*.md" permissions: contents: read @@ -23,8 +23,10 @@ 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', '3.13.0'] + split_index: [1, 2] + fail-fast: false + runs-on: ubuntu-22.04 services: # Label used to access the service container redis: @@ -45,13 +47,14 @@ jobs: python-version: ${{ matrix.python-version }} run-poetry-install: true create-venv-at-path: .venv - - run: poetry run uv pip install pyvirtualdisplay pillow + - run: poetry run uv pip install pyvirtualdisplay pillow pytest-split - name: Run app harness tests env: - SCREENSHOT_DIR: /tmp/screenshots + SCREENSHOT_DIR: /tmp/screenshots/${{ matrix.state_manager }}/${{ matrix.python-version }}/${{ matrix.split_index }} 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 --splits 2 --group ${{matrix.split_index}} - 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 58f7a668a..b2304d463 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -42,22 +42,18 @@ jobs: 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', '3.13.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: @@ -77,7 +73,7 @@ jobs: run: | poetry run uv pip install -r requirements.txt - name: Install additional dependencies for DB access - run: poetry run uv pip install psycopg2-binary + run: poetry run uv pip install psycopg - name: Check export --backend-only before init for counter example working-directory: ./reflex-examples/counter run: | @@ -126,7 +122,7 @@ jobs: 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: @@ -149,9 +145,9 @@ jobs: - name: Install Requirements for reflex-web working-directory: ./reflex-web - run: poetry run uv pip install -r requirements.txt + run: poetry run uv pip install $(grep -ivE "reflex " requirements.txt) - name: Install additional dependencies for DB access - run: poetry run uv pip install psycopg2-binary + run: poetry run uv pip install psycopg - name: Init Website for reflex-web working-directory: ./reflex-web run: poetry run reflex init @@ -165,4 +161,74 @@ jobs: 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 + --app-name "reflex-web" --path ./reflex-web/.web + + rx-shout-from-template: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup_build_env + with: + python-version: '3.11.4' + run-poetry-install: true + create-venv-at-path: .venv + - name: Create app directory + run: mkdir rx-shout-from-template + - name: Init reflex-web from template + run: poetry run reflex init --template https://github.com/masenf/rx_shout + working-directory: ./rx-shout-from-template + - name: ignore reflex pin in requirements + run: sed -i -e '/reflex==/d' requirements.txt + working-directory: ./rx-shout-from-template + - name: Install additional dependencies + run: poetry run uv pip install -r requirements.txt + working-directory: ./rx-shout-from-template + - name: Run Website and Check for errors + run: | + # Check that npm is home + npm -v + poetry run bash scripts/integration.sh ./rx-shout-from-template prod + + + 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-latest + 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 psycopg + - 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 6750fcd46..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} 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 f49a9b279..25f5723f3 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', '3.13.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,44 @@ 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 uv pip install "pydantic~=1.10" - poetry run pytest tests --cov --no-cov-on-fail --cov-report= - - run: poetry run coverage html + 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: + # Note: py39, py310 versions chosen due to available arm64 darwin builds. + python-version: ['3.9.13', '3.10.11', '3.11.5', '3.12.0', '3.13.0'] + runs-on: macos-latest + 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 bbaa8f0c9..0f7d9e5ff 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ assets/external/* dist/* examples/ +.web .idea .vscode .coverage diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbd88c485..ac25a335e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,14 +3,20 @@ fail_fast: true repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.4.10 + rev: v0.8.2 hooks: - id: ruff-format - args: [integration, reflex, tests] + args: [reflex, tests] - id: ruff args: ["--fix", "--exit-non-zero-on-fix"] exclude: '^integration/benchmarks/' + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: ["reflex"] + # Run pyi check before pyright because pyright can fail if pyi files are wrong. - repo: local hooks: @@ -25,7 +31,7 @@ repos: rev: v1.1.313 hooks: - id: pyright - args: [integration, reflex, tests] + args: [reflex, tests] language: system - repo: https://github.com/terrencepreilly/darglint diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 253076695..d22d91973 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -5,7 +5,7 @@ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, +identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e57c0a249..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. @@ -87,7 +87,7 @@ poetry run ruff format . ``` 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.8. +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 2c5b14087..5e098b2d3 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) | [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) +[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 @@ -229,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)  
@@ -250,7 +249,7 @@ We welcome contributions of any size! Below are some good ways to get started in - **GitHub Discussions**: A great way to talk about features you want added or things that are confusing/need clarification. - **GitHub Issues**: [Issues](https://github.com/reflex-dev/reflex/issues) are an excellent way to report bugs. Additionally, you can try and solve an existing issue and submit a PR. -We are actively looking for contributors, no matter your skill level or experience. To contribute check out [CONTIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) +We are actively looking for contributors, no matter your skill level or experience. To contribute check out [CONTRIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) ## All Thanks To Our Contributors: diff --git a/benchmarks/benchmark_compile_times.py b/benchmarks/benchmark_compile_times.py index 2273bd5c8..56cb4e4cc 100644 --- a/benchmarks/benchmark_compile_times.py +++ b/benchmarks/benchmark_compile_times.py @@ -5,6 +5,7 @@ from __future__ import annotations import argparse import json import os +from pathlib import Path from utils import send_data_to_posthog @@ -18,7 +19,7 @@ def extract_stats_from_json(json_file: str) -> list[dict]: Returns: list[dict]: The stats for each test. """ - with open(json_file, "r") as file: + with Path(json_file).open() as file: json_data = json.load(file) # Load the JSON data if it is a string, otherwise assume it's already a dictionary diff --git a/benchmarks/benchmark_imports.py b/benchmarks/benchmark_imports.py index 4706c0cf6..8c3f9f46c 100644 --- a/benchmarks/benchmark_imports.py +++ b/benchmarks/benchmark_imports.py @@ -5,6 +5,7 @@ from __future__ import annotations import argparse import json import os +from pathlib import Path from utils import send_data_to_posthog @@ -18,7 +19,7 @@ def extract_stats_from_json(json_file: str) -> dict: Returns: dict: The stats for each test. """ - with open(json_file, "r") as file: + with Path(json_file).open() as file: json_data = json.load(file) # Load the JSON data if it is a string, otherwise assume it's already a dictionary diff --git a/benchmarks/benchmark_lighthouse.py b/benchmarks/benchmark_lighthouse.py index 72f486b6f..d428c16e6 100644 --- a/benchmarks/benchmark_lighthouse.py +++ b/benchmarks/benchmark_lighthouse.py @@ -3,8 +3,8 @@ from __future__ import annotations import json -import os import sys +from pathlib import Path from utils import send_data_to_posthog @@ -28,7 +28,7 @@ def insert_benchmarking_data( send_data_to_posthog("lighthouse_benchmark", properties) -def get_lighthouse_scores(directory_path: str) -> dict: +def get_lighthouse_scores(directory_path: str | Path) -> dict: """Extracts the Lighthouse scores from the JSON files in the specified directory. Args: @@ -38,24 +38,20 @@ def get_lighthouse_scores(directory_path: str) -> dict: dict: The Lighthouse scores. """ scores = {} - + directory_path = Path(directory_path) 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"], - } + 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} diff --git a/benchmarks/benchmark_package_size.py b/benchmarks/benchmark_package_size.py index 8e2704355..778b52769 100644 --- a/benchmarks/benchmark_package_size.py +++ b/benchmarks/benchmark_package_size.py @@ -2,11 +2,12 @@ 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, os_name): +def get_package_size(venv_path: Path, os_name): """Get the size of a specified package. Args: @@ -26,14 +27,12 @@ def get_package_size(venv_path, os_name): is_windows = "windows" in os_name - full_path = ( - ["lib", f"python{python_version}", "site-packages"] + package_dir: Path = ( + venv_path / "lib" / f"python{python_version}" / "site-packages" if not is_windows - else ["Lib", "site-packages"] + else venv_path / "Lib" / "site-packages" ) - - package_dir = os.path.join(venv_path, *full_path) - if not os.path.exists(package_dir): + if not package_dir.exists(): raise ValueError( "Error: Virtual environment does not exist or is not activated." ) @@ -63,9 +62,9 @@ def insert_benchmarking_data( path: The path to the dir or file to check size. """ if "./dist" in path: - size = get_directory_size(path) + size = get_directory_size(Path(path)) else: - size = get_package_size(path, os_type_version) + size = get_package_size(Path(path), os_type_version) # Prepare the event data properties = { diff --git a/benchmarks/benchmark_web_size.py b/benchmarks/benchmark_web_size.py index 6c2f40bbc..3ceccecf8 100644 --- a/benchmarks/benchmark_web_size.py +++ b/benchmarks/benchmark_web_size.py @@ -2,6 +2,7 @@ import argparse import os +from pathlib import Path from utils import get_directory_size, send_data_to_posthog @@ -28,7 +29,7 @@ def insert_benchmarking_data( pr_id: The id of the PR. path: The path to the dir or file to check size. """ - size = get_directory_size(path) + size = get_directory_size(Path(path)) # Prepare the event data properties = { diff --git a/benchmarks/test_benchmark_compile_pages.py b/benchmarks/test_benchmark_compile_pages.py index 3a0164b2f..292882b74 100644 --- a/benchmarks/test_benchmark_compile_pages.py +++ b/benchmarks/test_benchmark_compile_pages.py @@ -144,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( @@ -210,9 +210,9 @@ def app_with_one_page( Yields: an AppHarness instance """ - root = tmp_path_factory.mktemp(f"app1") + root = tmp_path_factory.mktemp("app1") - yield AppHarness.create(root=root, app_source=AppWithOnePage) # type: ignore + yield AppHarness.create(root=root, app_source=AppWithOnePage) @pytest.fixture(scope="session") @@ -227,7 +227,7 @@ def app_with_ten_pages( Yields: an AppHarness instance """ - root = tmp_path_factory.mktemp(f"app10") + root = tmp_path_factory.mktemp("app10") yield AppHarness.create( root=root, app_source=functools.partial( @@ -249,7 +249,7 @@ def app_with_hundred_pages( Yields: an AppHarness instance """ - root = tmp_path_factory.mktemp(f"app100") + root = tmp_path_factory.mktemp("app100") yield AppHarness.create( root=root, @@ -272,11 +272,11 @@ def app_with_thousand_pages( Yields: an AppHarness instance """ - root = tmp_path_factory.mktemp(f"app1000") + root = tmp_path_factory.mktemp("app1000") yield AppHarness.create( root=root, - app_source=functools.partial( # type: ignore + app_source=functools.partial( AppWithThousandPages, render_comp=render_multiple_pages, # type: ignore ), @@ -295,7 +295,7 @@ def app_with_ten_thousand_pages( Yields: running AppHarness instance """ - root = tmp_path_factory.mktemp(f"app10000") + root = tmp_path_factory.mktemp("app10000") yield AppHarness.create( root=root, diff --git a/benchmarks/utils.py b/benchmarks/utils.py index 7b02c8cc8..bfadf5b4e 100644 --- a/benchmarks/utils.py +++ b/benchmarks/utils.py @@ -2,12 +2,13 @@ import os import subprocess +from pathlib import Path import httpx from httpx import HTTPError -def get_python_version(venv_path, os_name): +def get_python_version(venv_path: Path, os_name): """Get the python version of python in a virtual env. Args: @@ -18,13 +19,13 @@ def get_python_version(venv_path, os_name): The python version. """ python_executable = ( - os.path.join(venv_path, "bin", "python") + venv_path / "bin" / "python" if "windows" not in os_name - else os.path.join(venv_path, "Scripts", "python.exe") + else venv_path / "Scripts" / "python.exe" ) try: output = subprocess.check_output( - [python_executable, "--version"], stderr=subprocess.STDOUT + [str(python_executable), "--version"], stderr=subprocess.STDOUT ) python_version = output.decode("utf-8").strip().split()[1] return ".".join(python_version.split(".")[:-1]) @@ -32,7 +33,7 @@ def get_python_version(venv_path, os_name): return None -def get_directory_size(directory): +def get_directory_size(directory: Path): """Get the size of a directory in bytes. Args: @@ -44,8 +45,8 @@ def get_directory_size(directory): 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) + fp = Path(dirpath) / f + total_size += fp.stat().st_size return total_size 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..284c9eab8 --- /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.13 as init + +ARG uv=/root/.local/bin/uv + +# Install `uv` for faster package bootstrapping +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.13-slim +WORKDIR /app +RUN adduser --disabled-password --home /app reflex +COPY --chown=reflex --from=init /app /app +# Install libpq-dev for psycopg (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 79% rename from docker-example/prod.Dockerfile rename to docker-example/production-compose/Dockerfile index 2cde12ca0..196e135a7 100644 --- a/docker-example/prod.Dockerfile +++ b/docker-example/production-compose/Dockerfile @@ -2,11 +2,11 @@ # instance of a Reflex app. # Stage 1: init -FROM python:3.11 as init +FROM python:3.13 as init -ARG uv=/root/.cargo/bin/uv +ARG uv=/root/.local/bin/uv -# Install `uv` for faster package boostrapping +# Install `uv` for faster package bootstrapping ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh RUN /install.sh && rm /install.sh @@ -35,17 +35,18 @@ RUN rm -rf .web && mkdir .web RUN mv /tmp/_static .web/_static # Stage 2: copy artifacts into slim image -FROM python:3.11-slim +FROM python:3.13-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). +# Install libpq-dev for psycopg (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 88% rename from docker-example/compose.prod.yaml rename to docker-example/production-compose/compose.prod.yaml index 225539515..7ed5b4eca 100644 --- a/docker-example/compose.prod.yaml +++ b/docker-example/production-compose/compose.prod.yaml @@ -15,7 +15,7 @@ services: app: environment: - DB_URL: postgresql+psycopg2://postgres:secret@db/postgres + DB_URL: postgresql+psycopg://postgres:secret@db/postgres REDIS_URL: redis://redis:6379 depends_on: - db 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/production-one-port/.dockerignore b/docker-example/production-one-port/.dockerignore new file mode 100644 index 000000000..26ae41b83 --- /dev/null +++ b/docker-example/production-one-port/.dockerignore @@ -0,0 +1,3 @@ +.web +!.web/bun.lockb +!.web/package.json diff --git a/docker-example/production-one-port/Caddyfile b/docker-example/production-one-port/Caddyfile new file mode 100644 index 000000000..28fb01861 --- /dev/null +++ b/docker-example/production-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 +} diff --git a/docker-example/production-one-port/Dockerfile b/docker-example/production-one-port/Dockerfile new file mode 100644 index 000000000..f5e157bae --- /dev/null +++ b/docker-example/production-one-port/Dockerfile @@ -0,0 +1,62 @@ +# This Dockerfile is used to deploy a single-container Reflex app instance +# to services like Render, Railway, Heroku, GCP, and others. + +# If the service expects a different port, provide it here (f.e Render expects port 10000) +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 + +# It uses a reverse proxy to serve the frontend statically and proxy to backend +# from a single exposed port, expecting TLS termination to be handled at the +# edge by the given platform. +FROM python:3.13 as builder + +RUN mkdir -p /app/.web +RUN python -m venv /app/.venv +ENV PATH="/app/.venv/bin:$PATH" + +WORKDIR /app + +# Install python app requirements and reflex in the container +COPY requirements.txt . +RUN pip install -r requirements.txt + +# Install reflex helper utilities like bun/fnm/node +COPY rxconfig.py ./ +RUN reflex init + +# Install pre-cached frontend dependencies (if exist) +COPY *.web/bun.lockb *.web/package.json .web/ +RUN if [ -f .web/bun.lockb ]; then cd .web && ~/.local/share/reflex/bun/bin/bun install --frozen-lockfile; fi + +# Copy local context to `/app` inside container (see .dockerignore) +COPY . . + +ARG PORT API_URL +# Download other npm dependencies and compile frontend +RUN API_URL=${API_URL:-http://localhost:$PORT} reflex export --loglevel debug --frontend-only --no-zip && mv .web/_static/* /srv/ && rm -rf .web + + +# Final image with only necessary files +FROM python:3.13-slim + +# 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/* + +ARG PORT API_URL +ENV PATH="/app/.venv/bin:$PATH" PORT=$PORT API_URL=${API_URL:-http://localhost:$PORT} REDIS_URL=redis://localhost PYTHONUNBUFFERED=1 + +WORKDIR /app +COPY --from=builder /app /app +COPY --from=builder /srv /srv + +# Needed until Reflex properly passes SIGTERM on backend. +STOPSIGNAL SIGKILL + +EXPOSE $PORT + +# Apply migrations before starting the backend. +CMD [ -d alembic ] && reflex db migrate; \ + caddy start && \ + redis-server --daemonize yes && \ + exec reflex run --env prod --backend-only diff --git a/docker-example/production-one-port/README.md b/docker-example/production-one-port/README.md new file mode 100644 index 000000000..f6f76620a --- /dev/null +++ b/docker-example/production-one-port/README.md @@ -0,0 +1,37 @@ +# production-one-port + +This docker deployment runs Reflex in prod mode, exposing a single HTTP port: + * `8080` (`$PORT`) - Caddy server hosting the frontend statically and proxying requests to the backend. + +The deployment also runs a local Redis server to store state for each user. + +Conceptually it is similar to the `simple-one-port` example except it: + * has layer caching for python, reflex, and node dependencies + * uses multi-stage build to reduce the size of the final image + +Using this method may be preferable for deploying in memory constrained +environments, because it serves a static frontend export, rather than running +the NextJS server via node. + +## Build + +```console +docker build -t reflex-production-one-port . +``` + +## Run + +```console +docker run -p 8080:8080 reflex-production-one-port +``` + +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. + +## Usage + +This container should be used with an existing load balancer or reverse proxy to +terminate TLS. + +It is also useful for deploying to simple app platforms, such as Render or Heroku. \ No newline at end of file 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..28fb01861 --- /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 +} diff --git a/docker-example/app.Dockerfile b/docker-example/simple-one-port/Dockerfile similarity index 66% rename from docker-example/app.Dockerfile rename to docker-example/simple-one-port/Dockerfile index 4aae2f31d..0b6dba0c4 100644 --- a/docker-example/app.Dockerfile +++ b/docker-example/simple-one-port/Dockerfile @@ -4,37 +4,19 @@ # It uses a reverse proxy to serve the frontend statically and proxy to backend # from a single exposed port, expecting TLS termination to be handled at the # edge by the given platform. -FROM python:3.11 +FROM python:3.13 # If the service expects a different port, provide it here (f.e Render expects port 10000) 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 + +
+ +### **✨ Ứ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 3edb81976..e114bc1e2 100644 --- a/docs/zh/zh_cn/README.md +++ b/docs/zh/zh_cn/README.md @@ -10,7 +10,6 @@ ### **✨ 使用 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) @@ -35,7 +34,7 @@ Reflex 是一个使用纯Python构建全栈web应用的库。 ## ⚙️ 安装 -打开一个终端并且运行(要求Python3.8+): +打开一个终端并且运行(要求Python3.9+): ```bash pip install reflex diff --git a/docs/zh/zh_tw/README.md b/docs/zh/zh_tw/README.md index 388631dd2..83f6b2ae2 100644 --- a/docs/zh/zh_tw/README.md +++ b/docs/zh/zh_tw/README.md @@ -11,7 +11,6 @@ **✨ 使用 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) @@ -37,7 +36,7 @@ Reflex 是一個可以用純 Python 構建全端網頁應用程式的函式庫 ## ⚙️ 安裝 -開啟一個終端機並且執行 (需要 Python 3.8+): +開啟一個終端機並且執行 (需要 Python 3.9+): ```bash pip install reflex diff --git a/integration/test_component_state.py b/integration/test_component_state.py deleted file mode 100644 index 77b8b3fa1..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) - assert AppHarness._poll_for(lambda: ss.get("token") is not None), "token not found" - - 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 c513c9d56..000000000 --- a/integration/test_table.py +++ /dev/null @@ -1,171 +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 bcf17fe41..000000000 --- a/integration/test_urls.py +++ /dev/null @@ -1,68 +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 3c2def5b7..cc778d19b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,19 +1,17 @@ -# This file is automatically @generated by Poetry 1.8.2 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 = "alembic" -version = "1.13.2" +version = "1.14.0" description = "A database migration tool for SQLAlchemy." optional = false python-versions = ">=3.8" files = [ - {file = "alembic-1.13.2-py3-none-any.whl", hash = "sha256:6b8733129a6224a9a711e17c99b08462dbf7cc9670ba8f2e2ae9af860ceb1953"}, - {file = "alembic-1.13.2.tar.gz", hash = "sha256:1ff0ae32975f4fd96028c39ed9bb3c867fe3af956bd7bb37343b54c9fe7445ef"}, + {file = "alembic-1.14.0-py3-none-any.whl", hash = "sha256:99bd884ca390466db5e27ffccff1d179ec5c05c965cfefc0607e69f9e411cb25"}, + {file = "alembic-1.14.0.tar.gz", hash = "sha256:b00892b53b3642d0b8dbedba234dbf1924b69be83a9a769d5a624b01094e304b"}, ] [package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.9\""} -importlib-resources = {version = "*", markers = "python_version < \"3.9\""} Mako = "*" SQLAlchemy = ">=1.3.0" typing-extensions = ">=4" @@ -32,40 +30,37 @@ files = [ {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} - [[package]] name = "anyio" -version = "4.4.0" +version = "4.7.0" 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.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"}, - {file = "anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94"}, + {file = "anyio-4.7.0-py3-none-any.whl", hash = "sha256:ea60c3723ab42ba6fff7e8ccb0488c898ec538ff4df1f1d5e642c3601d07e352"}, + {file = "anyio-4.7.0.tar.gz", hash = "sha256:2f834749c602966b7d456a7567cafcb309f96482b5081d14ac93ccd457f9dd48"}, ] [package.dependencies] exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""} idna = ">=2.8" sniffio = ">=1.1" -typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} +typing_extensions = {version = ">=4.5", markers = "python_version < \"3.13\""} [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)"] +trio = ["trio (>=0.26.1)"] [[package]] name = "async-timeout" -version = "4.0.3" +version = "5.0.1" description = "Timeout context manager for asyncio programs" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"}, - {file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"}, + {file = "async_timeout-5.0.1-py3-none-any.whl", hash = "sha256:39e3809566ff85354557ec2398b55e096c8364bacac9405a7a1fa429e77fe76c"}, + {file = "async_timeout-5.0.1.tar.gz", hash = "sha256:d9321a7a3d5a6a5e187e824d2fa0793ce379a202935782d555d6e9d2735677d3"}, ] [[package]] @@ -81,22 +76,22 @@ 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" @@ -126,13 +121,13 @@ files = [ [[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] @@ -151,74 +146,89 @@ virtualenv = ["virtualenv (>=20.0.35)"] [[package]] name = "certifi" -version = "2024.6.2" +version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, - {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, + {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] @@ -237,101 +247,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]] @@ -361,63 +386,73 @@ files = [ [[package]] name = "coverage" -version = "7.5.4" +version = "7.6.9" description = "Code coverage measurement for Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "coverage-7.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6cfb5a4f556bb51aba274588200a46e4dd6b505fb1a5f8c5ae408222eb416f99"}, - {file = "coverage-7.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2174e7c23e0a454ffe12267a10732c273243b4f2d50d07544a91198f05c48f47"}, - {file = "coverage-7.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2214ee920787d85db1b6a0bd9da5f8503ccc8fcd5814d90796c2f2493a2f4d2e"}, - {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1137f46adb28e3813dec8c01fefadcb8c614f33576f672962e323b5128d9a68d"}, - {file = "coverage-7.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b385d49609f8e9efc885790a5a0e89f2e3ae042cdf12958b6034cc442de428d3"}, - {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b4a474f799456e0eb46d78ab07303286a84a3140e9700b9e154cfebc8f527016"}, - {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:5cd64adedf3be66f8ccee418473c2916492d53cbafbfcff851cbec5a8454b136"}, - {file = "coverage-7.5.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e564c2cf45d2f44a9da56f4e3a26b2236504a496eb4cb0ca7221cd4cc7a9aca9"}, - {file = "coverage-7.5.4-cp310-cp310-win32.whl", hash = "sha256:7076b4b3a5f6d2b5d7f1185fde25b1e54eb66e647a1dfef0e2c2bfaf9b4c88c8"}, - {file = "coverage-7.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:018a12985185038a5b2bcafab04ab833a9a0f2c59995b3cec07e10074c78635f"}, - {file = "coverage-7.5.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:db14f552ac38f10758ad14dd7b983dbab424e731588d300c7db25b6f89e335b5"}, - {file = "coverage-7.5.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3257fdd8e574805f27bb5342b77bc65578e98cbc004a92232106344053f319ba"}, - {file = "coverage-7.5.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a6612c99081d8d6134005b1354191e103ec9705d7ba2754e848211ac8cacc6b"}, - {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d45d3cbd94159c468b9b8c5a556e3f6b81a8d1af2a92b77320e887c3e7a5d080"}, - {file = "coverage-7.5.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed550e7442f278af76d9d65af48069f1fb84c9f745ae249c1a183c1e9d1b025c"}, - {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7a892be37ca35eb5019ec85402c3371b0f7cda5ab5056023a7f13da0961e60da"}, - {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8192794d120167e2a64721d88dbd688584675e86e15d0569599257566dec9bf0"}, - {file = "coverage-7.5.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:820bc841faa502e727a48311948e0461132a9c8baa42f6b2b84a29ced24cc078"}, - {file = "coverage-7.5.4-cp311-cp311-win32.whl", hash = "sha256:6aae5cce399a0f065da65c7bb1e8abd5c7a3043da9dceb429ebe1b289bc07806"}, - {file = "coverage-7.5.4-cp311-cp311-win_amd64.whl", hash = "sha256:d2e344d6adc8ef81c5a233d3a57b3c7d5181f40e79e05e1c143da143ccb6377d"}, - {file = "coverage-7.5.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:54317c2b806354cbb2dc7ac27e2b93f97096912cc16b18289c5d4e44fc663233"}, - {file = "coverage-7.5.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:042183de01f8b6d531e10c197f7f0315a61e8d805ab29c5f7b51a01d62782747"}, - {file = "coverage-7.5.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a6bb74ed465d5fb204b2ec41d79bcd28afccf817de721e8a807d5141c3426638"}, - {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3d45ff86efb129c599a3b287ae2e44c1e281ae0f9a9bad0edc202179bcc3a2e"}, - {file = "coverage-7.5.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5013ed890dc917cef2c9f765c4c6a8ae9df983cd60dbb635df8ed9f4ebc9f555"}, - {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1014fbf665fef86cdfd6cb5b7371496ce35e4d2a00cda501cf9f5b9e6fced69f"}, - {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3684bc2ff328f935981847082ba4fdc950d58906a40eafa93510d1b54c08a66c"}, - {file = "coverage-7.5.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:581ea96f92bf71a5ec0974001f900db495488434a6928a2ca7f01eee20c23805"}, - {file = "coverage-7.5.4-cp312-cp312-win32.whl", hash = "sha256:73ca8fbc5bc622e54627314c1a6f1dfdd8db69788f3443e752c215f29fa87a0b"}, - {file = "coverage-7.5.4-cp312-cp312-win_amd64.whl", hash = "sha256:cef4649ec906ea7ea5e9e796e68b987f83fa9a718514fe147f538cfeda76d7a7"}, - {file = "coverage-7.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdd31315fc20868c194130de9ee6bfd99755cc9565edff98ecc12585b90be882"}, - {file = "coverage-7.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:02ff6e898197cc1e9fa375581382b72498eb2e6d5fc0b53f03e496cfee3fac6d"}, - {file = "coverage-7.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d05c16cf4b4c2fc880cb12ba4c9b526e9e5d5bb1d81313d4d732a5b9fe2b9d53"}, - {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5986ee7ea0795a4095ac4d113cbb3448601efca7f158ec7f7087a6c705304e4"}, - {file = "coverage-7.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5df54843b88901fdc2f598ac06737f03d71168fd1175728054c8f5a2739ac3e4"}, - {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:ab73b35e8d109bffbda9a3e91c64e29fe26e03e49addf5b43d85fc426dde11f9"}, - {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:aea072a941b033813f5e4814541fc265a5c12ed9720daef11ca516aeacd3bd7f"}, - {file = "coverage-7.5.4-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:16852febd96acd953b0d55fc842ce2dac1710f26729b31c80b940b9afcd9896f"}, - {file = "coverage-7.5.4-cp38-cp38-win32.whl", hash = "sha256:8f894208794b164e6bd4bba61fc98bf6b06be4d390cf2daacfa6eca0a6d2bb4f"}, - {file = "coverage-7.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:e2afe743289273209c992075a5a4913e8d007d569a406ffed0bd080ea02b0633"}, - {file = "coverage-7.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b95c3a8cb0463ba9f77383d0fa8c9194cf91f64445a63fc26fb2327e1e1eb088"}, - {file = "coverage-7.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3d7564cc09dd91b5a6001754a5b3c6ecc4aba6323baf33a12bd751036c998be4"}, - {file = "coverage-7.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44da56a2589b684813f86d07597fdf8a9c6ce77f58976727329272f5a01f99f7"}, - {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e16f3d6b491c48c5ae726308e6ab1e18ee830b4cdd6913f2d7f77354b33f91c8"}, - {file = "coverage-7.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbc5958cb471e5a5af41b0ddaea96a37e74ed289535e8deca404811f6cb0bc3d"}, - {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:a04e990a2a41740b02d6182b498ee9796cf60eefe40cf859b016650147908029"}, - {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ddbd2f9713a79e8e7242d7c51f1929611e991d855f414ca9996c20e44a895f7c"}, - {file = "coverage-7.5.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b1ccf5e728ccf83acd313c89f07c22d70d6c375a9c6f339233dcf792094bcbf7"}, - {file = "coverage-7.5.4-cp39-cp39-win32.whl", hash = "sha256:56b4eafa21c6c175b3ede004ca12c653a88b6f922494b023aeb1e836df953ace"}, - {file = "coverage-7.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:65e528e2e921ba8fd67d9055e6b9f9e34b21ebd6768ae1c1723f4ea6ace1234d"}, - {file = "coverage-7.5.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:79b356f3dd5b26f3ad23b35c75dbdaf1f9e2450b6bcefc6d0825ea0aa3f86ca5"}, - {file = "coverage-7.5.4.tar.gz", hash = "sha256:a44963520b069e12789d0faea4e9fdb1e410cdc4aab89d94f7f55cbb7fef0353"}, + {file = "coverage-7.6.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:85d9636f72e8991a1706b2b55b06c27545448baf9f6dbf51c4004609aacd7dcb"}, + {file = "coverage-7.6.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:608a7fd78c67bee8936378299a6cb9f5149bb80238c7a566fc3e6717a4e68710"}, + {file = "coverage-7.6.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:96d636c77af18b5cb664ddf12dab9b15a0cfe9c0bde715da38698c8cea748bfa"}, + {file = "coverage-7.6.9-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d75cded8a3cff93da9edc31446872d2997e327921d8eed86641efafd350e1df1"}, + {file = "coverage-7.6.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f7b15f589593110ae767ce997775d645b47e5cbbf54fd322f8ebea6277466cec"}, + {file = "coverage-7.6.9-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:44349150f6811b44b25574839b39ae35291f6496eb795b7366fef3bd3cf112d3"}, + {file = "coverage-7.6.9-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:d891c136b5b310d0e702e186d70cd16d1119ea8927347045124cb286b29297e5"}, + {file = "coverage-7.6.9-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:db1dab894cc139f67822a92910466531de5ea6034ddfd2b11c0d4c6257168073"}, + {file = "coverage-7.6.9-cp310-cp310-win32.whl", hash = "sha256:41ff7b0da5af71a51b53f501a3bac65fb0ec311ebed1632e58fc6107f03b9198"}, + {file = "coverage-7.6.9-cp310-cp310-win_amd64.whl", hash = "sha256:35371f8438028fdccfaf3570b31d98e8d9eda8bb1d6ab9473f5a390969e98717"}, + {file = "coverage-7.6.9-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:932fc826442132dde42ee52cf66d941f581c685a6313feebed358411238f60f9"}, + {file = "coverage-7.6.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:085161be5f3b30fd9b3e7b9a8c301f935c8313dcf928a07b116324abea2c1c2c"}, + {file = "coverage-7.6.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ccc660a77e1c2bf24ddbce969af9447a9474790160cfb23de6be4fa88e3951c7"}, + {file = "coverage-7.6.9-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c69e42c892c018cd3c8d90da61d845f50a8243062b19d228189b0224150018a9"}, + {file = "coverage-7.6.9-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0824a28ec542a0be22f60c6ac36d679e0e262e5353203bea81d44ee81fe9c6d4"}, + {file = "coverage-7.6.9-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4401ae5fc52ad8d26d2a5d8a7428b0f0c72431683f8e63e42e70606374c311a1"}, + {file = "coverage-7.6.9-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:98caba4476a6c8d59ec1eb00c7dd862ba9beca34085642d46ed503cc2d440d4b"}, + {file = "coverage-7.6.9-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ee5defd1733fd6ec08b168bd4f5387d5b322f45ca9e0e6c817ea6c4cd36313e3"}, + {file = "coverage-7.6.9-cp311-cp311-win32.whl", hash = "sha256:f2d1ec60d6d256bdf298cb86b78dd715980828f50c46701abc3b0a2b3f8a0dc0"}, + {file = "coverage-7.6.9-cp311-cp311-win_amd64.whl", hash = "sha256:0d59fd927b1f04de57a2ba0137166d31c1a6dd9e764ad4af552912d70428c92b"}, + {file = "coverage-7.6.9-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:99e266ae0b5d15f1ca8d278a668df6f51cc4b854513daab5cae695ed7b721cf8"}, + {file = "coverage-7.6.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9901d36492009a0a9b94b20e52ebfc8453bf49bb2b27bca2c9706f8b4f5a554a"}, + {file = "coverage-7.6.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:abd3e72dd5b97e3af4246cdada7738ef0e608168de952b837b8dd7e90341f015"}, + {file = "coverage-7.6.9-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ff74026a461eb0660366fb01c650c1d00f833a086b336bdad7ab00cc952072b3"}, + {file = "coverage-7.6.9-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65dad5a248823a4996724a88eb51d4b31587aa7aa428562dbe459c684e5787ae"}, + {file = "coverage-7.6.9-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:22be16571504c9ccea919fcedb459d5ab20d41172056206eb2994e2ff06118a4"}, + {file = "coverage-7.6.9-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:0f957943bc718b87144ecaee70762bc2bc3f1a7a53c7b861103546d3a403f0a6"}, + {file = "coverage-7.6.9-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0ae1387db4aecb1f485fb70a6c0148c6cdaebb6038f1d40089b1fc84a5db556f"}, + {file = "coverage-7.6.9-cp312-cp312-win32.whl", hash = "sha256:1a330812d9cc7ac2182586f6d41b4d0fadf9be9049f350e0efb275c8ee8eb692"}, + {file = "coverage-7.6.9-cp312-cp312-win_amd64.whl", hash = "sha256:b12c6b18269ca471eedd41c1b6a1065b2f7827508edb9a7ed5555e9a56dcfc97"}, + {file = "coverage-7.6.9-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:899b8cd4781c400454f2f64f7776a5d87bbd7b3e7f7bda0cb18f857bb1334664"}, + {file = "coverage-7.6.9-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:61f70dc68bd36810972e55bbbe83674ea073dd1dcc121040a08cdf3416c5349c"}, + {file = "coverage-7.6.9-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8a289d23d4c46f1a82d5db4abeb40b9b5be91731ee19a379d15790e53031c014"}, + {file = "coverage-7.6.9-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7e216d8044a356fc0337c7a2a0536d6de07888d7bcda76febcb8adc50bdbbd00"}, + {file = "coverage-7.6.9-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c026eb44f744acaa2bda7493dad903aa5bf5fc4f2554293a798d5606710055d"}, + {file = "coverage-7.6.9-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:e77363e8425325384f9d49272c54045bbed2f478e9dd698dbc65dbc37860eb0a"}, + {file = "coverage-7.6.9-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:777abfab476cf83b5177b84d7486497e034eb9eaea0d746ce0c1268c71652077"}, + {file = "coverage-7.6.9-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:447af20e25fdbe16f26e84eb714ba21d98868705cb138252d28bc400381f6ffb"}, + {file = "coverage-7.6.9-cp313-cp313-win32.whl", hash = "sha256:d872ec5aeb086cbea771c573600d47944eea2dcba8be5f3ee649bfe3cb8dc9ba"}, + {file = "coverage-7.6.9-cp313-cp313-win_amd64.whl", hash = "sha256:fd1213c86e48dfdc5a0cc676551db467495a95a662d2396ecd58e719191446e1"}, + {file = "coverage-7.6.9-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:ba9e7484d286cd5a43744e5f47b0b3fb457865baf07bafc6bee91896364e1419"}, + {file = "coverage-7.6.9-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e5ea1cf0872ee455c03e5674b5bca5e3e68e159379c1af0903e89f5eba9ccc3a"}, + {file = "coverage-7.6.9-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d10e07aa2b91835d6abec555ec8b2733347956991901eea6ffac295f83a30e4"}, + {file = "coverage-7.6.9-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:13a9e2d3ee855db3dd6ea1ba5203316a1b1fd8eaeffc37c5b54987e61e4194ae"}, + {file = "coverage-7.6.9-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c38bf15a40ccf5619fa2fe8f26106c7e8e080d7760aeccb3722664c8656b030"}, + {file = "coverage-7.6.9-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:d5275455b3e4627c8e7154feaf7ee0743c2e7af82f6e3b561967b1cca755a0be"}, + {file = "coverage-7.6.9-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:8f8770dfc6e2c6a2d4569f411015c8d751c980d17a14b0530da2d7f27ffdd88e"}, + {file = "coverage-7.6.9-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8d2dfa71665a29b153a9681edb1c8d9c1ea50dfc2375fb4dac99ea7e21a0bcd9"}, + {file = "coverage-7.6.9-cp313-cp313t-win32.whl", hash = "sha256:5e6b86b5847a016d0fbd31ffe1001b63355ed309651851295315031ea7eb5a9b"}, + {file = "coverage-7.6.9-cp313-cp313t-win_amd64.whl", hash = "sha256:97ddc94d46088304772d21b060041c97fc16bdda13c6c7f9d8fcd8d5ae0d8611"}, + {file = "coverage-7.6.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:adb697c0bd35100dc690de83154627fbab1f4f3c0386df266dded865fc50a902"}, + {file = "coverage-7.6.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:be57b6d56e49c2739cdf776839a92330e933dd5e5d929966fbbd380c77f060be"}, + {file = "coverage-7.6.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f1592791f8204ae9166de22ba7e6705fa4ebd02936c09436a1bb85aabca3e599"}, + {file = "coverage-7.6.9-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4e12ae8cc979cf83d258acb5e1f1cf2f3f83524d1564a49d20b8bec14b637f08"}, + {file = "coverage-7.6.9-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb5555cff66c4d3d6213a296b360f9e1a8e323e74e0426b6c10ed7f4d021e464"}, + {file = "coverage-7.6.9-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:b9389a429e0e5142e69d5bf4a435dd688c14478a19bb901735cdf75e57b13845"}, + {file = "coverage-7.6.9-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:592ac539812e9b46046620341498caf09ca21023c41c893e1eb9dbda00a70cbf"}, + {file = "coverage-7.6.9-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:a27801adef24cc30871da98a105f77995e13a25a505a0161911f6aafbd66e678"}, + {file = "coverage-7.6.9-cp39-cp39-win32.whl", hash = "sha256:8e3c3e38930cfb729cb8137d7f055e5a473ddaf1217966aa6238c88bd9fd50e6"}, + {file = "coverage-7.6.9-cp39-cp39-win_amd64.whl", hash = "sha256:e28bf44afa2b187cc9f41749138a64435bf340adfcacb5b2290c070ce99839d4"}, + {file = "coverage-7.6.9-pp39.pp310-none-any.whl", hash = "sha256:f3ca78518bc6bc92828cd11867b121891d75cae4ea9e908d72030609b996db1b"}, + {file = "coverage-7.6.9.tar.gz", hash = "sha256:4a8d8977b0c6ef5aeadcb644da9e69ae0dcfe66ec7f368c89c72e058bd71164d"}, ] [package.dependencies] @@ -428,43 +463,38 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "42.0.8" +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.8-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:81d8a521705787afe7a18d5bfb47ea9d9cc068206270aad0b96a725022e18d2e"}, - {file = "cryptography-42.0.8-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:961e61cefdcb06e0c6d7e3a1b22ebe8b996eb2bf50614e89384be54c48c6b63d"}, - {file = "cryptography-42.0.8-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3ec3672626e1b9e55afd0df6d774ff0e953452886e06e0f1eb7eb0c832e8902"}, - {file = "cryptography-42.0.8-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e599b53fd95357d92304510fb7bda8523ed1f79ca98dce2f43c115950aa78801"}, - {file = "cryptography-42.0.8-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:5226d5d21ab681f432a9c1cf8b658c0cb02533eece706b155e5fbd8a0cdd3949"}, - {file = "cryptography-42.0.8-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:6b7c4f03ce01afd3b76cf69a5455caa9cfa3de8c8f493e0d3ab7d20611c8dae9"}, - {file = "cryptography-42.0.8-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:2346b911eb349ab547076f47f2e035fc8ff2c02380a7cbbf8d87114fa0f1c583"}, - {file = "cryptography-42.0.8-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:ad803773e9df0b92e0a817d22fd8a3675493f690b96130a5e24f1b8fabbea9c7"}, - {file = "cryptography-42.0.8-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:2f66d9cd9147ee495a8374a45ca445819f8929a3efcd2e3df6428e46c3cbb10b"}, - {file = "cryptography-42.0.8-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d45b940883a03e19e944456a558b67a41160e367a719833c53de6911cabba2b7"}, - {file = "cryptography-42.0.8-cp37-abi3-win32.whl", hash = "sha256:a0c5b2b0585b6af82d7e385f55a8bc568abff8923af147ee3c07bd8b42cda8b2"}, - {file = "cryptography-42.0.8-cp37-abi3-win_amd64.whl", hash = "sha256:57080dee41209e556a9a4ce60d229244f7a66ef52750f813bfbe18959770cfba"}, - {file = "cryptography-42.0.8-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:dea567d1b0e8bc5764b9443858b673b734100c2871dc93163f58c46a97a83d28"}, - {file = "cryptography-42.0.8-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c4783183f7cb757b73b2ae9aed6599b96338eb957233c58ca8f49a49cc32fd5e"}, - {file = "cryptography-42.0.8-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0608251135d0e03111152e41f0cc2392d1e74e35703960d4190b2e0f4ca9c70"}, - {file = "cryptography-42.0.8-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:dc0fdf6787f37b1c6b08e6dfc892d9d068b5bdb671198c72072828b80bd5fe4c"}, - {file = "cryptography-42.0.8-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:9c0c1716c8447ee7dbf08d6db2e5c41c688544c61074b54fc4564196f55c25a7"}, - {file = "cryptography-42.0.8-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:fff12c88a672ab9c9c1cf7b0c80e3ad9e2ebd9d828d955c126be4fd3e5578c9e"}, - {file = "cryptography-42.0.8-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:cafb92b2bc622cd1aa6a1dce4b93307792633f4c5fe1f46c6b97cf67073ec961"}, - {file = "cryptography-42.0.8-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:31f721658a29331f895a5a54e7e82075554ccfb8b163a18719d342f5ffe5ecb1"}, - {file = "cryptography-42.0.8-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b297f90c5723d04bcc8265fc2a0f86d4ea2e0f7ab4b6994459548d3a6b992a14"}, - {file = "cryptography-42.0.8-cp39-abi3-win32.whl", hash = "sha256:2f88d197e66c65be5e42cd72e5c18afbfae3f741742070e3019ac8f4ac57262c"}, - {file = "cryptography-42.0.8-cp39-abi3-win_amd64.whl", hash = "sha256:fa76fbb7596cc5839320000cdd5d0955313696d9511debab7ee7278fc8b5c84a"}, - {file = "cryptography-42.0.8-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:ba4f0a211697362e89ad822e667d8d340b4d8d55fae72cdd619389fb5912eefe"}, - {file = "cryptography-42.0.8-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:81884c4d096c272f00aeb1f11cf62ccd39763581645b0812e99a91505fa48e0c"}, - {file = "cryptography-42.0.8-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:c9bb2ae11bfbab395bdd072985abde58ea9860ed84e59dbc0463a5d0159f5b71"}, - {file = "cryptography-42.0.8-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:7016f837e15b0a1c119d27ecd89b3515f01f90a8615ed5e9427e30d9cdbfed3d"}, - {file = "cryptography-42.0.8-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:5a94eccb2a81a309806027e1670a358b99b8fe8bfe9f8d329f27d72c094dde8c"}, - {file = "cryptography-42.0.8-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:dec9b018df185f08483f294cae6ccac29e7a6e0678996587363dc352dc65c842"}, - {file = "cryptography-42.0.8-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:343728aac38decfdeecf55ecab3264b015be68fc2816ca800db649607aeee648"}, - {file = "cryptography-42.0.8-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:013629ae70b40af70c9a7a5db40abe5d9054e6f4380e50ce769947b73bf3caad"}, - {file = "cryptography-42.0.8.tar.gz", hash = "sha256:8d09d05439ce7baa8e9e95b07ec5b6c886f548deb7e0f69ef25f64b3bce842f2"}, + {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] @@ -477,7 +507,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]] @@ -493,13 +523,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] @@ -508,13 +538,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]] @@ -530,21 +560,24 @@ files = [ [[package]] name = "docutils" -version = "0.20.1" +version = "0.21.2" description = "Docutils -- Python Documentation Utilities" optional = false -python-versions = "*" -files = [] +python-versions = ">=3.9" +files = [ + {file = "docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"}, + {file = "docutils-0.21.2.tar.gz", hash = "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f"}, +] [[package]] name = "exceptiongroup" -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] @@ -552,104 +585,120 @@ test = ["pytest (>=6)"] [[package]] name = "fastapi" -version = "0.110.3" +version = "0.115.6" 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.6-py3-none-any.whl", hash = "sha256:e9240b29e36fa8f4bb7290316988e90c381e5092e0cbe84e7818cc3713bcf305"}, + {file = "fastapi-0.115.6.tar.gz", hash = "sha256:9ec46f7addc14ea472958a96aae5b5de65f39721a46aaf5705c480d9a8b76654"}, ] [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.15.4" +version = "3.16.1" description = "A platform independent file lock." optional = false python-versions = ">=3.8" files = [ - {file = "filelock-3.15.4-py3-none-any.whl", hash = "sha256:6ca1fffae96225dab4c6eaf1c4f4f28cd2568d3ec2a44e15a08520504de468e7"}, - {file = "filelock-3.15.4.tar.gz", hash = "sha256:2207938cbc1844345cb01a5a95524dae30f0ce089eba5b00378295a17e3e90cb"}, + {file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"}, + {file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"}, ] [package.extras] -docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-asyncio (>=0.21)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)", "virtualenv (>=20.26.2)"] -typing = ["typing-extensions (>=4.8)"] +docs = ["furo (>=2024.8.6)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4.1)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.6.1)", "diff-cover (>=9.2)", "pytest (>=8.3.3)", "pytest-asyncio (>=0.24)", "pytest-cov (>=5)", "pytest-mock (>=3.14)", "pytest-timeout (>=2.3.1)", "virtualenv (>=20.26.4)"] +typing = ["typing-extensions (>=4.12.2)"] [[package]] name = "greenlet" -version = "3.0.3" +version = "3.1.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] @@ -658,13 +707,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] @@ -690,13 +739,13 @@ files = [ [[package]] name = "httpcore" -version = "1.0.5" +version = "1.0.7" 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.7-py3-none-any.whl", hash = "sha256:a3fff8f43dc260d5bd363d9f9cf1830fa3a458b332856f34282de498ed420edd"}, + {file = "httpcore-1.0.7.tar.gz", hash = "sha256:8551cb62a169ec7162ac7be8d4817d561f60e08eaa485234898414bb5a8a0b4c"}, ] [package.dependencies] @@ -707,17 +756,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.28.1" 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.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad"}, + {file = "httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc"}, ] [package.dependencies] @@ -725,23 +774,23 @@ anyio = "*" certifi = "*" httpcore = "==1.*" idna = "*" -sniffio = "*" [package.extras] 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.3" description = "File identification library for Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" 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.3-py2.py3-none-any.whl", hash = "sha256:9edba65473324c2ea9684b1f944fe3191db3345e50b6d04571d10ed164f8d7bd"}, + {file = "identify-2.6.3.tar.gz", hash = "sha256:62f5dae9b5fef52c84cc188514e9ea4f3f636b1d8799ab5ebc475471f9e47a02"}, ] [package.extras] @@ -749,51 +798,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 = "8.0.0" +version = "8.5.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-8.0.0-py3-none-any.whl", hash = "sha256:15584cf2b1bf449d98ff8a6ff1abef57bf20f3ac6454f431736cd3e660921b2f"}, - {file = "importlib_metadata-8.0.0.tar.gz", hash = "sha256:188bd24e4c346d3f0a933f275c2fec67050326a856b9a359881d7c2a697e8812"}, + {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] +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"] -test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] - -[[package]] -name = "importlib-resources" -version = "6.4.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" @@ -826,39 +864,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" @@ -894,18 +936,17 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "keyring" -version = "25.2.1" +version = "25.5.0" description = "Store and access your passwords safely." optional = false python-versions = ">=3.8" files = [ - {file = "keyring-25.2.1-py3-none-any.whl", hash = "sha256:2458681cdefc0dbc0b7eb6cf75d0b98e59f9ad9b2d4edd319d18f68bdca95e50"}, - {file = "keyring-25.2.1.tar.gz", hash = "sha256:daaffd42dbda25ddafb1ad5fec4024e5bbcfe424597ca1ca452b299861e49f1b"}, + {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" = "*" @@ -914,9 +955,13 @@ pywin32-ctypes = {version = ">=0.2.0", markers = "sys_platform == \"win32\""} SecretStorage = {version = ">=3.2", markers = "sys_platform == \"linux\""} [package.extras] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] completion = ["shtab (>=1.1.0)"] -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" @@ -939,13 +984,13 @@ test = ["pytest (>=7.4)", "pytest-cov (>=4.1)"] [[package]] name = "mako" -version = "1.3.5" +version = "1.3.8" 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.5-py3-none-any.whl", hash = "sha256:260f1dbc3a519453a9c856dedfe4beb4e50bd5a26d96386cb6c80856556bb91a"}, - {file = "Mako-1.3.5.tar.gz", hash = "sha256:48dbc20568c1d276a2698b36d968fa76161bf127194907ea6fc594fa81f943bc"}, + {file = "Mako-1.3.8-py3-none-any.whl", hash = "sha256:42f48953c7eb91332040ff567eb7eea69b22e7a4affbc5ba8e845e8f730f6627"}, + {file = "mako-1.3.8.tar.gz", hash = "sha256:577b97e414580d3e088d47c2dbbe9594aa7a5146ed2875d4dfa9075af2dd3cc8"}, ] [package.dependencies] @@ -982,71 +1027,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]] @@ -1062,38 +1108,45 @@ files = [ [[package]] name = "more-itertools" -version = "10.3.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.3.0.tar.gz", hash = "sha256:e5d93ef411224fbcef366a6e8ddc4c5781bc6359d43412a65dd5964e46111463"}, - {file = "more_itertools-10.3.0-py3-none-any.whl", hash = "sha256:ea6a02e24a9161e51faad17a8782b92a0df82c12c1c8886fec7f0c3fa1a1b320"}, + {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 = "nh3" -version = "0.2.17" +version = "0.2.19" 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.19-cp313-cp313t-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:ec9c8bf86e397cb88c560361f60fdce478b5edb8b93f04ead419b72fbe937ea6"}, + {file = "nh3-0.2.19-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0adf00e2b2026fa10a42537b60d161e516f206781c7515e4e97e09f72a8c5d0"}, + {file = "nh3-0.2.19-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:3805161c4e12088bd74752ba69630e915bc30fe666034f47217a2f16b16efc37"}, + {file = "nh3-0.2.19-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:e3dedd7858a21312f7675841529941035a2ac91057db13402c8fe907aa19205a"}, + {file = "nh3-0.2.19-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:0b6820fc64f2ff7ef3e7253a093c946a87865c877b3889149a6d21d322ed8dbd"}, + {file = "nh3-0.2.19-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:833b3b5f1783ce95834a13030300cea00cbdfd64ea29260d01af9c4821da0aa9"}, + {file = "nh3-0.2.19-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:5d4f5e2189861b352b73acb803b5f4bb409c2f36275d22717e27d4e0c217ae55"}, + {file = "nh3-0.2.19-cp313-cp313t-win32.whl", hash = "sha256:2b926f179eb4bce72b651bfdf76f8aa05d167b2b72bc2f3657fd319f40232adc"}, + {file = "nh3-0.2.19-cp313-cp313t-win_amd64.whl", hash = "sha256:ac536a4b5c073fdadd8f5f4889adabe1cbdae55305366fb870723c96ca7f49c3"}, + {file = "nh3-0.2.19-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:c2e3f0d18cc101132fe10ab7ef5c4f41411297e639e23b64b5e888ccaad63f41"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:11270b16c1b012677e3e2dd166c1aa273388776bf99a3e3677179db5097ee16a"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fc483dd8d20f8f8c010783a25a84db3bebeadced92d24d34b40d687f8043ac69"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d53a4577b6123ca1d7e8483fad3e13cb7eda28913d516bd0a648c1a473aa21a9"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fdb20740d24ab9f2a1341458a00a11205294e97e905de060eeab1ceca020c09c"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d8325d51e47cb5b11f649d55e626d56c76041ba508cd59e0cb1cf687cc7612f1"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8eb7affc590e542fa7981ef508cd1644f62176bcd10d4429890fc629b47f0bc"}, + {file = "nh3-0.2.19-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2eb021804e9df1761abeb844bb86648d77aa118a663c82f50ea04110d87ed707"}, + {file = "nh3-0.2.19-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:a7b928862daddb29805a1010a0282f77f4b8b238a37b5f76bc6c0d16d930fd22"}, + {file = "nh3-0.2.19-cp38-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:ed06ed78f6b69d57463b46a04f68f270605301e69d80756a8adf7519002de57d"}, + {file = "nh3-0.2.19-cp38-abi3-musllinux_1_2_i686.whl", hash = "sha256:df8eac98fec80bd6f5fd0ae27a65de14f1e1a65a76d8e2237eb695f9cd1121d9"}, + {file = "nh3-0.2.19-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:00810cd5275f5c3f44b9eb0e521d1a841ee2f8023622de39ffc7d88bd533d8e0"}, + {file = "nh3-0.2.19-cp38-abi3-win32.whl", hash = "sha256:7e98621856b0a911c21faa5eef8f8ea3e691526c2433f9afc2be713cb6fbdb48"}, + {file = "nh3-0.2.19-cp38-abi3-win_amd64.whl", hash = "sha256:75c7cafb840f24430b009f7368945cb5ca88b2b54bb384ebfba495f16bc9c121"}, ] [[package]] @@ -1109,93 +1162,120 @@ files = [ [[package]] name = "numpy" -version = "1.24.4" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "numpy-1.24.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c0bfb52d2169d58c1cdb8cc1f16989101639b34c7d3ce60ed70b19c63eba0b64"}, - {file = "numpy-1.24.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ed094d4f0c177b1b8e7aa9cba7d6ceed51c0e569a5318ac0ca9a090680a6a1b1"}, - {file = "numpy-1.24.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79fc682a374c4a8ed08b331bef9c5f582585d1048fa6d80bc6c35bc384eee9b4"}, - {file = "numpy-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7ffe43c74893dbf38c2b0a1f5428760a1a9c98285553c89e12d70a96a7f3a4d6"}, - {file = "numpy-1.24.4-cp310-cp310-win32.whl", hash = "sha256:4c21decb6ea94057331e111a5bed9a79d335658c27ce2adb580fb4d54f2ad9bc"}, - {file = "numpy-1.24.4-cp310-cp310-win_amd64.whl", hash = "sha256:b4bea75e47d9586d31e892a7401f76e909712a0fd510f58f5337bea9572c571e"}, - {file = "numpy-1.24.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f136bab9c2cfd8da131132c2cf6cc27331dd6fae65f95f69dcd4ae3c3639c810"}, - {file = "numpy-1.24.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e2926dac25b313635e4d6cf4dc4e51c8c0ebfed60b801c799ffc4c32bf3d1254"}, - {file = "numpy-1.24.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:222e40d0e2548690405b0b3c7b21d1169117391c2e82c378467ef9ab4c8f0da7"}, - {file = "numpy-1.24.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7215847ce88a85ce39baf9e89070cb860c98fdddacbaa6c0da3ffb31b3350bd5"}, - {file = "numpy-1.24.4-cp311-cp311-win32.whl", hash = "sha256:4979217d7de511a8d57f4b4b5b2b965f707768440c17cb70fbf254c4b225238d"}, - {file = "numpy-1.24.4-cp311-cp311-win_amd64.whl", hash = "sha256:b7b1fc9864d7d39e28f41d089bfd6353cb5f27ecd9905348c24187a768c79694"}, - {file = "numpy-1.24.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1452241c290f3e2a312c137a9999cdbf63f78864d63c79039bda65ee86943f61"}, - {file = "numpy-1.24.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:04640dab83f7c6c85abf9cd729c5b65f1ebd0ccf9de90b270cd61935eef0197f"}, - {file = "numpy-1.24.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5425b114831d1e77e4b5d812b69d11d962e104095a5b9c3b641a218abcc050e"}, - {file = "numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd80e219fd4c71fc3699fc1dadac5dcf4fd882bfc6f7ec53d30fa197b8ee22dc"}, - {file = "numpy-1.24.4-cp38-cp38-win32.whl", hash = "sha256:4602244f345453db537be5314d3983dbf5834a9701b7723ec28923e2889e0bb2"}, - {file = "numpy-1.24.4-cp38-cp38-win_amd64.whl", hash = "sha256:692f2e0f55794943c5bfff12b3f56f99af76f902fc47487bdfe97856de51a706"}, - {file = "numpy-1.24.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2541312fbf09977f3b3ad449c4e5f4bb55d0dbf79226d7724211acc905049400"}, - {file = "numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9667575fb6d13c95f1b36aca12c5ee3356bf001b714fc354eb5465ce1609e62f"}, - {file = "numpy-1.24.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3a86ed21e4f87050382c7bc96571755193c4c1392490744ac73d660e8f564a9"}, - {file = "numpy-1.24.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d11efb4dbecbdf22508d55e48d9c8384db795e1b7b51ea735289ff96613ff74d"}, - {file = "numpy-1.24.4-cp39-cp39-win32.whl", hash = "sha256:6620c0acd41dbcb368610bb2f4d83145674040025e5536954782467100aa8835"}, - {file = "numpy-1.24.4-cp39-cp39-win_amd64.whl", hash = "sha256:befe2bf740fd8373cf56149a5c23a0f601e82869598d41f8e188a0e9869926f8"}, - {file = "numpy-1.24.4-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:31f13e25b4e304632a4619d0e0777662c2ffea99fcae2029556b17d8ff958aef"}, - {file = "numpy-1.24.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95f7ac6540e95bc440ad77f56e520da5bf877f87dca58bd095288dce8940532a"}, - {file = "numpy-1.24.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e98f220aa76ca2a977fe435f5b04d7b3470c0a2e6312907b37ba6068f26787f2"}, - {file = "numpy-1.24.4.tar.gz", hash = "sha256:80f5e3a4e498641401868df4208b74581206afbee7cf7b8329daae82676d9463"}, -] - -[[package]] -name = "numpy" -version = "2.0.0" +version = "2.0.2" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.9" files = [ - {file = "numpy-2.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:04494f6ec467ccb5369d1808570ae55f6ed9b5809d7f035059000a37b8d7e86f"}, - {file = "numpy-2.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2635dbd200c2d6faf2ef9a0d04f0ecc6b13b3cad54f7c67c61155138835515d2"}, - {file = "numpy-2.0.0-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:0a43f0974d501842866cc83471bdb0116ba0dffdbaac33ec05e6afed5b615238"}, - {file = "numpy-2.0.0-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:8d83bb187fb647643bd56e1ae43f273c7f4dbcdf94550d7938cfc32566756514"}, - {file = "numpy-2.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79e843d186c8fb1b102bef3e2bc35ef81160ffef3194646a7fdd6a73c6b97196"}, - {file = "numpy-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d7696c615765091cc5093f76fd1fa069870304beaccfd58b5dcc69e55ef49c1"}, - {file = "numpy-2.0.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b4c76e3d4c56f145d41b7b6751255feefae92edbc9a61e1758a98204200f30fc"}, - {file = "numpy-2.0.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:acd3a644e4807e73b4e1867b769fbf1ce8c5d80e7caaef0d90dcdc640dfc9787"}, - {file = "numpy-2.0.0-cp310-cp310-win32.whl", hash = "sha256:cee6cc0584f71adefe2c908856ccc98702baf95ff80092e4ca46061538a2ba98"}, - {file = "numpy-2.0.0-cp310-cp310-win_amd64.whl", hash = "sha256:ed08d2703b5972ec736451b818c2eb9da80d66c3e84aed1deeb0c345fefe461b"}, - {file = "numpy-2.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ad0c86f3455fbd0de6c31a3056eb822fc939f81b1618f10ff3406971893b62a5"}, - {file = "numpy-2.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e7f387600d424f91576af20518334df3d97bc76a300a755f9a8d6e4f5cadd289"}, - {file = "numpy-2.0.0-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:34f003cb88b1ba38cb9a9a4a3161c1604973d7f9d5552c38bc2f04f829536609"}, - {file = "numpy-2.0.0-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:b6f6a8f45d0313db07d6d1d37bd0b112f887e1369758a5419c0370ba915b3871"}, - {file = "numpy-2.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f64641b42b2429f56ee08b4f427a4d2daf916ec59686061de751a55aafa22e4"}, - {file = "numpy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a7039a136017eaa92c1848152827e1424701532ca8e8967fe480fe1569dae581"}, - {file = "numpy-2.0.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:46e161722e0f619749d1cd892167039015b2c2817296104487cd03ed4a955995"}, - {file = "numpy-2.0.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0e50842b2295ba8414c8c1d9d957083d5dfe9e16828b37de883f51fc53c4016f"}, - {file = "numpy-2.0.0-cp311-cp311-win32.whl", hash = "sha256:2ce46fd0b8a0c947ae047d222f7136fc4d55538741373107574271bc00e20e8f"}, - {file = "numpy-2.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:fbd6acc766814ea6443628f4e6751d0da6593dae29c08c0b2606164db026970c"}, - {file = "numpy-2.0.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:354f373279768fa5a584bac997de6a6c9bc535c482592d7a813bb0c09be6c76f"}, - {file = "numpy-2.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4d2f62e55a4cd9c58c1d9a1c9edaedcd857a73cb6fda875bf79093f9d9086f85"}, - {file = "numpy-2.0.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:1e72728e7501a450288fc8e1f9ebc73d90cfd4671ebbd631f3e7857c39bd16f2"}, - {file = "numpy-2.0.0-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:84554fc53daa8f6abf8e8a66e076aff6ece62de68523d9f665f32d2fc50fd66e"}, - {file = "numpy-2.0.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c73aafd1afca80afecb22718f8700b40ac7cab927b8abab3c3e337d70e10e5a2"}, - {file = "numpy-2.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49d9f7d256fbc804391a7f72d4a617302b1afac1112fac19b6c6cec63fe7fe8a"}, - {file = "numpy-2.0.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0ec84b9ba0654f3b962802edc91424331f423dcf5d5f926676e0150789cb3d95"}, - {file = "numpy-2.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:feff59f27338135776f6d4e2ec7aeeac5d5f7a08a83e80869121ef8164b74af9"}, - {file = "numpy-2.0.0-cp312-cp312-win32.whl", hash = "sha256:c5a59996dc61835133b56a32ebe4ef3740ea5bc19b3983ac60cc32be5a665d54"}, - {file = "numpy-2.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:a356364941fb0593bb899a1076b92dfa2029f6f5b8ba88a14fd0984aaf76d0df"}, - {file = "numpy-2.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e61155fae27570692ad1d327e81c6cf27d535a5d7ef97648a17d922224b216de"}, - {file = "numpy-2.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4554eb96f0fd263041baf16cf0881b3f5dafae7a59b1049acb9540c4d57bc8cb"}, - {file = "numpy-2.0.0-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:903703372d46bce88b6920a0cd86c3ad82dae2dbef157b5fc01b70ea1cfc430f"}, - {file = "numpy-2.0.0-cp39-cp39-macosx_14_0_x86_64.whl", hash = "sha256:3e8e01233d57639b2e30966c63d36fcea099d17c53bf424d77f088b0f4babd86"}, - {file = "numpy-2.0.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1cde1753efe513705a0c6d28f5884e22bdc30438bf0085c5c486cdaff40cd67a"}, - {file = "numpy-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:821eedb7165ead9eebdb569986968b541f9908979c2da8a4967ecac4439bae3d"}, - {file = "numpy-2.0.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9a1712c015831da583b21c5bfe15e8684137097969c6d22e8316ba66b5baabe4"}, - {file = "numpy-2.0.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:9c27f0946a3536403efb0e1c28def1ae6730a72cd0d5878db38824855e3afc44"}, - {file = "numpy-2.0.0-cp39-cp39-win32.whl", hash = "sha256:63b92c512d9dbcc37f9d81b123dec99fdb318ba38c8059afc78086fe73820275"}, - {file = "numpy-2.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:3f6bed7f840d44c08ebdb73b1825282b801799e325bcbdfa6bc5c370e5aecc65"}, - {file = "numpy-2.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:9416a5c2e92ace094e9f0082c5fd473502c91651fb896bc17690d6fc475128d6"}, - {file = "numpy-2.0.0-pp39-pypy39_pp73-macosx_14_0_x86_64.whl", hash = "sha256:17067d097ed036636fa79f6a869ac26df7db1ba22039d962422506640314933a"}, - {file = "numpy-2.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:38ecb5b0582cd125f67a629072fed6f83562d9dd04d7e03256c9829bdec027ad"}, - {file = "numpy-2.0.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:cef04d068f5fb0518a77857953193b6bb94809a806bd0a14983a8f12ada060c9"}, - {file = "numpy-2.0.0.tar.gz", hash = "sha256:cf5d1c9e6837f8af9f92b6bd3e86d513cdc11f60fd62185cc49ec7d1aba34864"}, + {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.2.0" +description = "Fundamental package for array computing in Python" +optional = false +python-versions = ">=3.10" +files = [ + {file = "numpy-2.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1e25507d85da11ff5066269d0bd25d06e0a0f2e908415534f3e603d2a78e4ffa"}, + {file = "numpy-2.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a62eb442011776e4036af5c8b1a00b706c5bc02dc15eb5344b0c750428c94219"}, + {file = "numpy-2.2.0-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:b606b1aaf802e6468c2608c65ff7ece53eae1a6874b3765f69b8ceb20c5fa78e"}, + {file = "numpy-2.2.0-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:36b2b43146f646642b425dd2027730f99bac962618ec2052932157e213a040e9"}, + {file = "numpy-2.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7fe8f3583e0607ad4e43a954e35c1748b553bfe9fdac8635c02058023277d1b3"}, + {file = "numpy-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:122fd2fcfafdefc889c64ad99c228d5a1f9692c3a83f56c292618a59aa60ae83"}, + {file = "numpy-2.2.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3f2f5cddeaa4424a0a118924b988746db6ffa8565e5829b1841a8a3bd73eb59a"}, + {file = "numpy-2.2.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:7fe4bb0695fe986a9e4deec3b6857003b4cfe5c5e4aac0b95f6a658c14635e31"}, + {file = "numpy-2.2.0-cp310-cp310-win32.whl", hash = "sha256:b30042fe92dbd79f1ba7f6898fada10bdaad1847c44f2dff9a16147e00a93661"}, + {file = "numpy-2.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:54dc1d6d66f8d37843ed281773c7174f03bf7ad826523f73435deb88ba60d2d4"}, + {file = "numpy-2.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9874bc2ff574c40ab7a5cbb7464bf9b045d617e36754a7bc93f933d52bd9ffc6"}, + {file = "numpy-2.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0da8495970f6b101ddd0c38ace92edea30e7e12b9a926b57f5fabb1ecc25bb90"}, + {file = "numpy-2.2.0-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:0557eebc699c1c34cccdd8c3778c9294e8196df27d713706895edc6f57d29608"}, + {file = "numpy-2.2.0-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:3579eaeb5e07f3ded59298ce22b65f877a86ba8e9fe701f5576c99bb17c283da"}, + {file = "numpy-2.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40deb10198bbaa531509aad0cd2f9fadb26c8b94070831e2208e7df543562b74"}, + {file = "numpy-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c2aed8fcf8abc3020d6a9ccb31dbc9e7d7819c56a348cc88fd44be269b37427e"}, + {file = "numpy-2.2.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:a222d764352c773aa5ebde02dd84dba3279c81c6db2e482d62a3fa54e5ece69b"}, + {file = "numpy-2.2.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4e58666988605e251d42c2818c7d3d8991555381be26399303053b58a5bbf30d"}, + {file = "numpy-2.2.0-cp311-cp311-win32.whl", hash = "sha256:4723a50e1523e1de4fccd1b9a6dcea750c2102461e9a02b2ac55ffeae09a4410"}, + {file = "numpy-2.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:16757cf28621e43e252c560d25b15f18a2f11da94fea344bf26c599b9cf54b73"}, + {file = "numpy-2.2.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cff210198bb4cae3f3c100444c5eaa573a823f05c253e7188e1362a5555235b3"}, + {file = "numpy-2.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:58b92a5828bd4d9aa0952492b7de803135038de47343b2aa3cc23f3b71a3dc4e"}, + {file = "numpy-2.2.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:ebe5e59545401fbb1b24da76f006ab19734ae71e703cdb4a8b347e84a0cece67"}, + {file = "numpy-2.2.0-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:e2b8cd48a9942ed3f85b95ca4105c45758438c7ed28fff1e4ce3e57c3b589d8e"}, + {file = "numpy-2.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57fcc997ffc0bef234b8875a54d4058afa92b0b0c4223fc1f62f24b3b5e86038"}, + {file = "numpy-2.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85ad7d11b309bd132d74397fcf2920933c9d1dc865487128f5c03d580f2c3d03"}, + {file = "numpy-2.2.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:cb24cca1968b21355cc6f3da1a20cd1cebd8a023e3c5b09b432444617949085a"}, + {file = "numpy-2.2.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0798b138c291d792f8ea40fe3768610f3c7dd2574389e37c3f26573757c8f7ef"}, + {file = "numpy-2.2.0-cp312-cp312-win32.whl", hash = "sha256:afe8fb968743d40435c3827632fd36c5fbde633b0423da7692e426529b1759b1"}, + {file = "numpy-2.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:3a4199f519e57d517ebd48cb76b36c82da0360781c6a0353e64c0cac30ecaad3"}, + {file = "numpy-2.2.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f8c8b141ef9699ae777c6278b52c706b653bf15d135d302754f6b2e90eb30367"}, + {file = "numpy-2.2.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0f0986e917aca18f7a567b812ef7ca9391288e2acb7a4308aa9d265bd724bdae"}, + {file = "numpy-2.2.0-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:1c92113619f7b272838b8d6702a7f8ebe5edea0df48166c47929611d0b4dea69"}, + {file = "numpy-2.2.0-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:5a145e956b374e72ad1dff82779177d4a3c62bc8248f41b80cb5122e68f22d13"}, + {file = "numpy-2.2.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18142b497d70a34b01642b9feabb70156311b326fdddd875a9981f34a369b671"}, + {file = "numpy-2.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a7d41d1612c1a82b64697e894b75db6758d4f21c3ec069d841e60ebe54b5b571"}, + {file = "numpy-2.2.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a98f6f20465e7618c83252c02041517bd2f7ea29be5378f09667a8f654a5918d"}, + {file = "numpy-2.2.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e09d40edfdb4e260cb1567d8ae770ccf3b8b7e9f0d9b5c2a9992696b30ce2742"}, + {file = "numpy-2.2.0-cp313-cp313-win32.whl", hash = "sha256:3905a5fffcc23e597ee4d9fb3fcd209bd658c352657548db7316e810ca80458e"}, + {file = "numpy-2.2.0-cp313-cp313-win_amd64.whl", hash = "sha256:a184288538e6ad699cbe6b24859206e38ce5fba28f3bcfa51c90d0502c1582b2"}, + {file = "numpy-2.2.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:7832f9e8eb00be32f15fdfb9a981d6955ea9adc8574c521d48710171b6c55e95"}, + {file = "numpy-2.2.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:f0dd071b95bbca244f4cb7f70b77d2ff3aaaba7fa16dc41f58d14854a6204e6c"}, + {file = "numpy-2.2.0-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:b0b227dcff8cdc3efbce66d4e50891f04d0a387cce282fe1e66199146a6a8fca"}, + {file = "numpy-2.2.0-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:6ab153263a7c5ccaf6dfe7e53447b74f77789f28ecb278c3b5d49db7ece10d6d"}, + {file = "numpy-2.2.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e500aba968a48e9019e42c0c199b7ec0696a97fa69037bea163b55398e390529"}, + {file = "numpy-2.2.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:440cfb3db4c5029775803794f8638fbdbf71ec702caf32735f53b008e1eaece3"}, + {file = "numpy-2.2.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:a55dc7a7f0b6198b07ec0cd445fbb98b05234e8b00c5ac4874a63372ba98d4ab"}, + {file = "numpy-2.2.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:4bddbaa30d78c86329b26bd6aaaea06b1e47444da99eddac7bf1e2fab717bd72"}, + {file = "numpy-2.2.0-cp313-cp313t-win32.whl", hash = "sha256:30bf971c12e4365153afb31fc73f441d4da157153f3400b82db32d04de1e4066"}, + {file = "numpy-2.2.0-cp313-cp313t-win_amd64.whl", hash = "sha256:d35717333b39d1b6bb8433fa758a55f1081543de527171543a2b710551d40881"}, + {file = "numpy-2.2.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:e12c6c1ce84628c52d6367863773f7c8c8241be554e8b79686e91a43f1733773"}, + {file = "numpy-2.2.0-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:b6207dc8fb3c8cb5668e885cef9ec7f70189bec4e276f0ff70d5aa078d32c88e"}, + {file = "numpy-2.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a50aeff71d0f97b6450d33940c7181b08be1441c6c193e678211bff11aa725e7"}, + {file = "numpy-2.2.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:df12a1f99b99f569a7c2ae59aa2d31724e8d835fc7f33e14f4792e3071d11221"}, + {file = "numpy-2.2.0.tar.gz", hash = "sha256:140dd80ff8981a583a60980be1a655068f8adebf7a45a06a6858c873fcdcd4a0"}, ] [[package]] @@ -1214,95 +1294,64 @@ attrs = ">=19.2.0" [[package]] name = "packaging" -version = "24.1" +version = "24.2" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, - {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, ] [[package]] name = "pandas" -version = "1.5.3" -description = "Powerful data structures for data analysis, time series, and statistics" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3ac844a0fe00bfaeb2c9b51ab1424e5c8744f89860b138434a363b1f620f354"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a0a56cef15fd1586726dace5616db75ebcfec9179a3a55e78f72c5639fa2a23"}, - {file = "pandas-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:478ff646ca42b20376e4ed3fa2e8d7341e8a63105586efe54fa2508ee087f328"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6973549c01ca91ec96199e940495219c887ea815b2083722821f1d7abfa2b4dc"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c39a8da13cede5adcd3be1182883aea1c925476f4e84b2807a46e2775306305d"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f76d097d12c82a535fda9dfe5e8dd4127952b45fea9b0276cb30cca5ea313fbc"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e474390e60ed609cec869b0da796ad94f420bb057d86784191eefc62b65819ae"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f2b952406a1588ad4cad5b3f55f520e82e902388a6d5a4a91baa8d38d23c7f6"}, - {file = "pandas-1.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:bc4c368f42b551bf72fac35c5128963a171b40dce866fb066540eeaf46faa003"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:14e45300521902689a81f3f41386dc86f19b8ba8dd5ac5a3c7010ef8d2932813"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9842b6f4b8479e41968eced654487258ed81df7d1c9b7b870ceea24ed9459b31"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:26d9c71772c7afb9d5046e6e9cf42d83dd147b5cf5bcb9d97252077118543792"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fbcb19d6fceb9e946b3e23258757c7b225ba450990d9ed63ccceeb8cae609f7"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:565fa34a5434d38e9d250af3c12ff931abaf88050551d9fbcdfafca50d62babf"}, - {file = "pandas-1.5.3-cp38-cp38-win32.whl", hash = "sha256:87bd9c03da1ac870a6d2c8902a0e1fd4267ca00f13bc494c9e5a9020920e1d51"}, - {file = "pandas-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:41179ce559943d83a9b4bbacb736b04c928b095b5f25dd2b7389eda08f46f373"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c74a62747864ed568f5a82a49a23a8d7fe171d0c69038b38cedf0976831296fa"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c4c00e0b0597c8e4f59e8d461f797e5d70b4d025880516a8261b2817c47759ee"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a50d9a4336a9621cab7b8eb3fb11adb82de58f9b91d84c2cd526576b881a0c5a"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd05f7783b3274aa206a1af06f0ceed3f9b412cf665b7247eacd83be41cf7bf0"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f69c4029613de47816b1bb30ff5ac778686688751a5e9c99ad8c7031f6508e5"}, - {file = "pandas-1.5.3-cp39-cp39-win32.whl", hash = "sha256:7cec0bee9f294e5de5bbfc14d0573f65526071029d036b753ee6507d2a21480a"}, - {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, - {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, -] - -[package.dependencies] -numpy = {version = ">=1.20.3", markers = "python_version < \"3.10\""} -python-dateutil = ">=2.8.1" -pytz = ">=2020.1" - -[package.extras] -test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] - -[[package]] -name = "pandas" -version = "2.2.2" +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] @@ -1342,84 +1391,90 @@ xml = ["lxml (>=4.9.2)"] [[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"] @@ -1428,13 +1483,13 @@ xmp = ["defusedxml"] [[package]] name = "pip" -version = "24.1.1" +version = "24.3.1" description = "The PyPA recommended tool for installing Python packages." optional = false python-versions = ">=3.8" files = [ - {file = "pip-24.1.1-py3-none-any.whl", hash = "sha256:efca15145a95e95c00608afeab66311d40bfb73bb2266a855befd705e6bb15a0"}, - {file = "pip-24.1.1.tar.gz", hash = "sha256:5aa64f65e1952733ee0a9a9b1f52496ebdb3f3077cc46f80a16d983b58d1180a"}, + {file = "pip-24.3.1-py3-none-any.whl", hash = "sha256:3790624780082365f47549d032f3770eeb2b1e8bd1f7b2e02dace1afa361b4ed"}, + {file = "pip-24.3.1.tar.gz", hash = "sha256:ebcb60557f2aefabc2e0f918751cd24ea0d56d8ec5445fe1807f1d2109660b99"}, ] [[package]] @@ -1457,13 +1512,13 @@ test = ["covdefaults (>=2.3)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pyte [[package]] name = "pkginfo" -version = "1.10.0" +version = "1.12.0" description = "Query metadata from sdists / bdists / installed packages." optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pkginfo-1.10.0-py3-none-any.whl", hash = "sha256:889a6da2ed7ffc58ab5b900d888ddce90bce912f2d2de1dc1c26f4cb9fe65097"}, - {file = "pkginfo-1.10.0.tar.gz", hash = "sha256:5df73835398d10db79f8eecd5cd86b1f6d29317589ea70796994d49399af6297"}, + {file = "pkginfo-1.12.0-py3-none-any.whl", hash = "sha256:dcd589c9be4da8973eceffa247733c144812759aa67eaf4bbf97016a02f39088"}, + {file = "pkginfo-1.12.0.tar.gz", hash = "sha256:8ad91a0445a036782b9366ef8b8c2c50291f83a553478ba8580c73d3215700cf"}, ] [package.extras] @@ -1471,29 +1526,49 @@ testing = ["pytest", "pytest-cov", "wheel"] [[package]] name = "platformdirs" -version = "4.2.2" +version = "4.3.6" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" files = [ - {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, - {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, + {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, + {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, ] [package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] -type = ["mypy (>=1.8)"] +docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.2)", "pytest-cov (>=5)", "pytest-mock (>=3.14)"] +type = ["mypy (>=1.11.2)"] + +[[package]] +name = "playwright" +version = "1.49.1" +description = "A high-level API to automate web browsers" +optional = false +python-versions = ">=3.9" +files = [ + {file = "playwright-1.49.1-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:1041ffb45a0d0bc44d698d3a5aa3ac4b67c9bd03540da43a0b70616ad52592b8"}, + {file = "playwright-1.49.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:9f38ed3d0c1f4e0a6d1c92e73dd9a61f8855133249d6f0cec28648d38a7137be"}, + {file = "playwright-1.49.1-py3-none-macosx_11_0_universal2.whl", hash = "sha256:3be48c6d26dc819ca0a26567c1ae36a980a0303dcd4249feb6f59e115aaddfb8"}, + {file = "playwright-1.49.1-py3-none-manylinux1_x86_64.whl", hash = "sha256:753ca90ee31b4b03d165cfd36e477309ebf2b4381953f2a982ff612d85b147d2"}, + {file = "playwright-1.49.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd9bc8dab37aa25198a01f555f0a2e2c3813fe200fef018ac34dfe86b34994b9"}, + {file = "playwright-1.49.1-py3-none-win32.whl", hash = "sha256:43b304be67f096058e587dac453ece550eff87b8fbed28de30f4f022cc1745bb"}, + {file = "playwright-1.49.1-py3-none-win_amd64.whl", hash = "sha256:47b23cb346283278f5b4d1e1990bcb6d6302f80c0aa0ca93dd0601a1400191df"}, +] + +[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] @@ -1517,13 +1592,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] @@ -1535,32 +1610,33 @@ virtualenv = ">=20.10.0" [[package]] name = "psutil" -version = "6.0.0" +version = "6.1.0" description = "Cross-platform lib for process and system monitoring in Python." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" files = [ - {file = "psutil-6.0.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a021da3e881cd935e64a3d0a20983bda0bb4cf80e4f74fa9bfcb1bc5785360c6"}, - {file = "psutil-6.0.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:1287c2b95f1c0a364d23bc6f2ea2365a8d4d9b726a3be7294296ff7ba97c17f0"}, - {file = "psutil-6.0.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:a9a3dbfb4de4f18174528d87cc352d1f788b7496991cca33c6996f40c9e3c92c"}, - {file = "psutil-6.0.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:6ec7588fb3ddaec7344a825afe298db83fe01bfaaab39155fa84cf1c0d6b13c3"}, - {file = "psutil-6.0.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:1e7c870afcb7d91fdea2b37c24aeb08f98b6d67257a5cb0a8bc3ac68d0f1a68c"}, - {file = "psutil-6.0.0-cp27-none-win32.whl", hash = "sha256:02b69001f44cc73c1c5279d02b30a817e339ceb258ad75997325e0e6169d8b35"}, - {file = "psutil-6.0.0-cp27-none-win_amd64.whl", hash = "sha256:21f1fb635deccd510f69f485b87433460a603919b45e2a324ad65b0cc74f8fb1"}, - {file = "psutil-6.0.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:c588a7e9b1173b6e866756dde596fd4cad94f9399daf99ad8c3258b3cb2b47a0"}, - {file = "psutil-6.0.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ed2440ada7ef7d0d608f20ad89a04ec47d2d3ab7190896cd62ca5fc4fe08bf0"}, - {file = "psutil-6.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fd9a97c8e94059b0ef54a7d4baf13b405011176c3b6ff257c247cae0d560ecd"}, - {file = "psutil-6.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e2e8d0054fc88153ca0544f5c4d554d42e33df2e009c4ff42284ac9ebdef4132"}, - {file = "psutil-6.0.0-cp36-cp36m-win32.whl", hash = "sha256:fc8c9510cde0146432bbdb433322861ee8c3efbf8589865c8bf8d21cb30c4d14"}, - {file = "psutil-6.0.0-cp36-cp36m-win_amd64.whl", hash = "sha256:34859b8d8f423b86e4385ff3665d3f4d94be3cdf48221fbe476e883514fdb71c"}, - {file = "psutil-6.0.0-cp37-abi3-win32.whl", hash = "sha256:a495580d6bae27291324fe60cea0b5a7c23fa36a7cd35035a16d93bdcf076b9d"}, - {file = "psutil-6.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:33ea5e1c975250a720b3a6609c490db40dae5d83a4eb315170c4fe0d8b1f34b3"}, - {file = "psutil-6.0.0-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:ffe7fc9b6b36beadc8c322f84e1caff51e8703b88eee1da46d1e3a6ae11b4fd0"}, - {file = "psutil-6.0.0.tar.gz", hash = "sha256:8faae4f310b6d969fa26ca0545338b21f73c6b15db7c4a8d934a5482faa818f2"}, + {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" @@ -1586,114 +1662,153 @@ files = [ [[package]] name = "pydantic" -version = "2.7.4" +version = "2.10.3" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, - {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, + {file = "pydantic-2.10.3-py3-none-any.whl", hash = "sha256:be04d85bbc7b65651c5f8e6b9976ed9c6f41782a55524cef079a34a0bb82144d"}, + {file = "pydantic-2.10.3.tar.gz", hash = "sha256:cb5ac360ce894ceacd69c403187900a02c4b20b693a9dd1d643e1effab9eadf9"}, ] [package.dependencies] -annotated-types = ">=0.4.0" -pydantic-core = "2.18.4" -typing-extensions = ">=4.6.1" +annotated-types = ">=0.6.0" +pydantic-core = "2.27.1" +typing-extensions = ">=4.12.2" [package.extras] email = ["email-validator (>=2.0.0)"] +timezone = ["tzdata"] [[package]] name = "pydantic-core" -version = "2.18.4" +version = "2.27.1" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.18.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:f76d0ad001edd426b92233d45c746fd08f467d56100fd8f30e9ace4b005266e4"}, - {file = "pydantic_core-2.18.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:59ff3e89f4eaf14050c8022011862df275b552caef8082e37b542b066ce1ff26"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a55b5b16c839df1070bc113c1f7f94a0af4433fcfa1b41799ce7606e5c79ce0a"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d0dcc59664fcb8974b356fe0a18a672d6d7cf9f54746c05f43275fc48636851"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8951eee36c57cd128f779e641e21eb40bc5073eb28b2d23f33eb0ef14ffb3f5d"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4701b19f7e3a06ea655513f7938de6f108123bf7c86bbebb1196eb9bd35cf724"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e00a3f196329e08e43d99b79b286d60ce46bed10f2280d25a1718399457e06be"}, - {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:97736815b9cc893b2b7f663628e63f436018b75f44854c8027040e05230eeddb"}, - {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6891a2ae0e8692679c07728819b6e2b822fb30ca7445f67bbf6509b25a96332c"}, - {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bc4ff9805858bd54d1a20efff925ccd89c9d2e7cf4986144b30802bf78091c3e"}, - {file = "pydantic_core-2.18.4-cp310-none-win32.whl", hash = "sha256:1b4de2e51bbcb61fdebd0ab86ef28062704f62c82bbf4addc4e37fa4b00b7cbc"}, - {file = "pydantic_core-2.18.4-cp310-none-win_amd64.whl", hash = "sha256:6a750aec7bf431517a9fd78cb93c97b9b0c496090fee84a47a0d23668976b4b0"}, - {file = "pydantic_core-2.18.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:942ba11e7dfb66dc70f9ae66b33452f51ac7bb90676da39a7345e99ffb55402d"}, - {file = "pydantic_core-2.18.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2ebef0e0b4454320274f5e83a41844c63438fdc874ea40a8b5b4ecb7693f1c4"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a642295cd0c8df1b86fc3dced1d067874c353a188dc8e0f744626d49e9aa51c4"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f09baa656c904807e832cf9cce799c6460c450c4ad80803517032da0cd062e2"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98906207f29bc2c459ff64fa007afd10a8c8ac080f7e4d5beff4c97086a3dabd"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19894b95aacfa98e7cb093cd7881a0c76f55731efad31073db4521e2b6ff5b7d"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fbbdc827fe5e42e4d196c746b890b3d72876bdbf160b0eafe9f0334525119c8"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f85d05aa0918283cf29a30b547b4df2fbb56b45b135f9e35b6807cb28bc47951"}, - {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e85637bc8fe81ddb73fda9e56bab24560bdddfa98aa64f87aaa4e4b6730c23d2"}, - {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2f5966897e5461f818e136b8451d0551a2e77259eb0f73a837027b47dc95dab9"}, - {file = "pydantic_core-2.18.4-cp311-none-win32.whl", hash = "sha256:44c7486a4228413c317952e9d89598bcdfb06399735e49e0f8df643e1ccd0558"}, - {file = "pydantic_core-2.18.4-cp311-none-win_amd64.whl", hash = "sha256:8a7164fe2005d03c64fd3b85649891cd4953a8de53107940bf272500ba8a788b"}, - {file = "pydantic_core-2.18.4-cp311-none-win_arm64.whl", hash = "sha256:4e99bc050fe65c450344421017f98298a97cefc18c53bb2f7b3531eb39bc7805"}, - {file = "pydantic_core-2.18.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:6f5c4d41b2771c730ea1c34e458e781b18cc668d194958e0112455fff4e402b2"}, - {file = "pydantic_core-2.18.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2fdf2156aa3d017fddf8aea5adfba9f777db1d6022d392b682d2a8329e087cef"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4748321b5078216070b151d5271ef3e7cc905ab170bbfd27d5c83ee3ec436695"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:847a35c4d58721c5dc3dba599878ebbdfd96784f3fb8bb2c356e123bdcd73f34"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c40d4eaad41f78e3bbda31b89edc46a3f3dc6e171bf0ecf097ff7a0ffff7cb1"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21a5e440dbe315ab9825fcd459b8814bb92b27c974cbc23c3e8baa2b76890077"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01dd777215e2aa86dfd664daed5957704b769e726626393438f9c87690ce78c3"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b06beb3b3f1479d32befd1f3079cc47b34fa2da62457cdf6c963393340b56e9"}, - {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:564d7922e4b13a16b98772441879fcdcbe82ff50daa622d681dd682175ea918c"}, - {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0eb2a4f660fcd8e2b1c90ad566db2b98d7f3f4717c64fe0a83e0adb39766d5b8"}, - {file = "pydantic_core-2.18.4-cp312-none-win32.whl", hash = "sha256:8b8bab4c97248095ae0c4455b5a1cd1cdd96e4e4769306ab19dda135ea4cdb07"}, - {file = "pydantic_core-2.18.4-cp312-none-win_amd64.whl", hash = "sha256:14601cdb733d741b8958224030e2bfe21a4a881fb3dd6fbb21f071cabd48fa0a"}, - {file = "pydantic_core-2.18.4-cp312-none-win_arm64.whl", hash = "sha256:c1322d7dd74713dcc157a2b7898a564ab091ca6c58302d5c7b4c07296e3fd00f"}, - {file = "pydantic_core-2.18.4-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:823be1deb01793da05ecb0484d6c9e20baebb39bd42b5d72636ae9cf8350dbd2"}, - {file = "pydantic_core-2.18.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ebef0dd9bf9b812bf75bda96743f2a6c5734a02092ae7f721c048d156d5fabae"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ae1d6df168efb88d7d522664693607b80b4080be6750c913eefb77e34c12c71a"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f9899c94762343f2cc2fc64c13e7cae4c3cc65cdfc87dd810a31654c9b7358cc"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99457f184ad90235cfe8461c4d70ab7dd2680e28821c29eca00252ba90308c78"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18f469a3d2a2fdafe99296a87e8a4c37748b5080a26b806a707f25a902c040a8"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b7cdf28938ac6b8b49ae5e92f2735056a7ba99c9b110a474473fd71185c1af5d"}, - {file = "pydantic_core-2.18.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:938cb21650855054dc54dfd9120a851c974f95450f00683399006aa6e8abb057"}, - {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:44cd83ab6a51da80fb5adbd9560e26018e2ac7826f9626bc06ca3dc074cd198b"}, - {file = "pydantic_core-2.18.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:972658f4a72d02b8abfa2581d92d59f59897d2e9f7e708fdabe922f9087773af"}, - {file = "pydantic_core-2.18.4-cp38-none-win32.whl", hash = "sha256:1d886dc848e60cb7666f771e406acae54ab279b9f1e4143babc9c2258213daa2"}, - {file = "pydantic_core-2.18.4-cp38-none-win_amd64.whl", hash = "sha256:bb4462bd43c2460774914b8525f79b00f8f407c945d50881568f294c1d9b4443"}, - {file = "pydantic_core-2.18.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:44a688331d4a4e2129140a8118479443bd6f1905231138971372fcde37e43528"}, - {file = "pydantic_core-2.18.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a2fdd81edd64342c85ac7cf2753ccae0b79bf2dfa063785503cb85a7d3593223"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:86110d7e1907ab36691f80b33eb2da87d780f4739ae773e5fc83fb272f88825f"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46387e38bd641b3ee5ce247563b60c5ca098da9c56c75c157a05eaa0933ed154"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:123c3cec203e3f5ac7b000bd82235f1a3eced8665b63d18be751f115588fea30"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc1803ac5c32ec324c5261c7209e8f8ce88e83254c4e1aebdc8b0a39f9ddb443"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53db086f9f6ab2b4061958d9c276d1dbe3690e8dd727d6abf2321d6cce37fa94"}, - {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:abc267fa9837245cc28ea6929f19fa335f3dc330a35d2e45509b6566dc18be23"}, - {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a0d829524aaefdebccb869eed855e2d04c21d2d7479b6cada7ace5448416597b"}, - {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:509daade3b8649f80d4e5ff21aa5673e4ebe58590b25fe42fac5f0f52c6f034a"}, - {file = "pydantic_core-2.18.4-cp39-none-win32.whl", hash = "sha256:ca26a1e73c48cfc54c4a76ff78df3727b9d9f4ccc8dbee4ae3f73306a591676d"}, - {file = "pydantic_core-2.18.4-cp39-none-win_amd64.whl", hash = "sha256:c67598100338d5d985db1b3d21f3619ef392e185e71b8d52bceacc4a7771ea7e"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:574d92eac874f7f4db0ca653514d823a0d22e2354359d0759e3f6a406db5d55d"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1f4d26ceb5eb9eed4af91bebeae4b06c3fb28966ca3a8fb765208cf6b51102ab"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77450e6d20016ec41f43ca4a6c63e9fdde03f0ae3fe90e7c27bdbeaece8b1ed4"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d323a01da91851a4f17bf592faf46149c9169d68430b3146dcba2bb5e5719abc"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43d447dd2ae072a0065389092a231283f62d960030ecd27565672bd40746c507"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:578e24f761f3b425834f297b9935e1ce2e30f51400964ce4801002435a1b41ef"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:81b5efb2f126454586d0f40c4d834010979cb80785173d1586df845a632e4e6d"}, - {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ab86ce7c8f9bea87b9d12c7f0af71102acbf5ecbc66c17796cff45dae54ef9a5"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:90afc12421df2b1b4dcc975f814e21bc1754640d502a2fbcc6d41e77af5ec312"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:51991a89639a912c17bef4b45c87bd83593aee0437d8102556af4885811d59f5"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:293afe532740370aba8c060882f7d26cfd00c94cae32fd2e212a3a6e3b7bc15e"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b48ece5bde2e768197a2d0f6e925f9d7e3e826f0ad2271120f8144a9db18d5c8"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:eae237477a873ab46e8dd748e515c72c0c804fb380fbe6c85533c7de51f23a8f"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:834b5230b5dfc0c1ec37b2fda433b271cbbc0e507560b5d1588e2cc1148cf1ce"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e858ac0a25074ba4bce653f9b5d0a85b7456eaddadc0ce82d3878c22489fa4ee"}, - {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2fd41f6eff4c20778d717af1cc50eca52f5afe7805ee530a4fbd0bae284f16e9"}, - {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, + {file = "pydantic_core-2.27.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:71a5e35c75c021aaf400ac048dacc855f000bdfed91614b4a726f7432f1f3d6a"}, + {file = "pydantic_core-2.27.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f82d068a2d6ecfc6e054726080af69a6764a10015467d7d7b9f66d6ed5afa23b"}, + {file = "pydantic_core-2.27.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:121ceb0e822f79163dd4699e4c54f5ad38b157084d97b34de8b232bcaad70278"}, + {file = "pydantic_core-2.27.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4603137322c18eaf2e06a4495f426aa8d8388940f3c457e7548145011bb68e05"}, + {file = "pydantic_core-2.27.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a33cd6ad9017bbeaa9ed78a2e0752c5e250eafb9534f308e7a5f7849b0b1bfb4"}, + {file = "pydantic_core-2.27.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:15cc53a3179ba0fcefe1e3ae50beb2784dede4003ad2dfd24f81bba4b23a454f"}, + {file = "pydantic_core-2.27.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45d9c5eb9273aa50999ad6adc6be5e0ecea7e09dbd0d31bd0c65a55a2592ca08"}, + {file = "pydantic_core-2.27.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8bf7b66ce12a2ac52d16f776b31d16d91033150266eb796967a7e4621707e4f6"}, + {file = "pydantic_core-2.27.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:655d7dd86f26cb15ce8a431036f66ce0318648f8853d709b4167786ec2fa4807"}, + {file = "pydantic_core-2.27.1-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:5556470f1a2157031e676f776c2bc20acd34c1990ca5f7e56f1ebf938b9ab57c"}, + {file = "pydantic_core-2.27.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:f69ed81ab24d5a3bd93861c8c4436f54afdf8e8cc421562b0c7504cf3be58206"}, + {file = "pydantic_core-2.27.1-cp310-none-win32.whl", hash = "sha256:f5a823165e6d04ccea61a9f0576f345f8ce40ed533013580e087bd4d7442b52c"}, + {file = "pydantic_core-2.27.1-cp310-none-win_amd64.whl", hash = "sha256:57866a76e0b3823e0b56692d1a0bf722bffb324839bb5b7226a7dbd6c9a40b17"}, + {file = "pydantic_core-2.27.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:ac3b20653bdbe160febbea8aa6c079d3df19310d50ac314911ed8cc4eb7f8cb8"}, + {file = "pydantic_core-2.27.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a5a8e19d7c707c4cadb8c18f5f60c843052ae83c20fa7d44f41594c644a1d330"}, + {file = "pydantic_core-2.27.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f7059ca8d64fea7f238994c97d91f75965216bcbe5f695bb44f354893f11d52"}, + {file = "pydantic_core-2.27.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bed0f8a0eeea9fb72937ba118f9db0cb7e90773462af7962d382445f3005e5a4"}, + {file = "pydantic_core-2.27.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a3cb37038123447cf0f3ea4c74751f6a9d7afef0eb71aa07bf5f652b5e6a132c"}, + {file = "pydantic_core-2.27.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:84286494f6c5d05243456e04223d5a9417d7f443c3b76065e75001beb26f88de"}, + {file = "pydantic_core-2.27.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:acc07b2cfc5b835444b44a9956846b578d27beeacd4b52e45489e93276241025"}, + {file = "pydantic_core-2.27.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4fefee876e07a6e9aad7a8c8c9f85b0cdbe7df52b8a9552307b09050f7512c7e"}, + {file = "pydantic_core-2.27.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:258c57abf1188926c774a4c94dd29237e77eda19462e5bb901d88adcab6af919"}, + {file = "pydantic_core-2.27.1-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:35c14ac45fcfdf7167ca76cc80b2001205a8d5d16d80524e13508371fb8cdd9c"}, + {file = "pydantic_core-2.27.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d1b26e1dff225c31897696cab7d4f0a315d4c0d9e8666dbffdb28216f3b17fdc"}, + {file = "pydantic_core-2.27.1-cp311-none-win32.whl", hash = "sha256:2cdf7d86886bc6982354862204ae3b2f7f96f21a3eb0ba5ca0ac42c7b38598b9"}, + {file = "pydantic_core-2.27.1-cp311-none-win_amd64.whl", hash = "sha256:3af385b0cee8df3746c3f406f38bcbfdc9041b5c2d5ce3e5fc6637256e60bbc5"}, + {file = "pydantic_core-2.27.1-cp311-none-win_arm64.whl", hash = "sha256:81f2ec23ddc1b476ff96563f2e8d723830b06dceae348ce02914a37cb4e74b89"}, + {file = "pydantic_core-2.27.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:9cbd94fc661d2bab2bc702cddd2d3370bbdcc4cd0f8f57488a81bcce90c7a54f"}, + {file = "pydantic_core-2.27.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5f8c4718cd44ec1580e180cb739713ecda2bdee1341084c1467802a417fe0f02"}, + {file = "pydantic_core-2.27.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15aae984e46de8d376df515f00450d1522077254ef6b7ce189b38ecee7c9677c"}, + {file = "pydantic_core-2.27.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1ba5e3963344ff25fc8c40da90f44b0afca8cfd89d12964feb79ac1411a260ac"}, + {file = "pydantic_core-2.27.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:992cea5f4f3b29d6b4f7f1726ed8ee46c8331c6b4eed6db5b40134c6fe1768bb"}, + {file = "pydantic_core-2.27.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0325336f348dbee6550d129b1627cb8f5351a9dc91aad141ffb96d4937bd9529"}, + {file = "pydantic_core-2.27.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7597c07fbd11515f654d6ece3d0e4e5093edc30a436c63142d9a4b8e22f19c35"}, + {file = "pydantic_core-2.27.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:3bbd5d8cc692616d5ef6fbbbd50dbec142c7e6ad9beb66b78a96e9c16729b089"}, + {file = "pydantic_core-2.27.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:dc61505e73298a84a2f317255fcc72b710b72980f3a1f670447a21efc88f8381"}, + {file = "pydantic_core-2.27.1-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:e1f735dc43da318cad19b4173dd1ffce1d84aafd6c9b782b3abc04a0d5a6f5bb"}, + {file = "pydantic_core-2.27.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:f4e5658dbffe8843a0f12366a4c2d1c316dbe09bb4dfbdc9d2d9cd6031de8aae"}, + {file = "pydantic_core-2.27.1-cp312-none-win32.whl", hash = "sha256:672ebbe820bb37988c4d136eca2652ee114992d5d41c7e4858cdd90ea94ffe5c"}, + {file = "pydantic_core-2.27.1-cp312-none-win_amd64.whl", hash = "sha256:66ff044fd0bb1768688aecbe28b6190f6e799349221fb0de0e6f4048eca14c16"}, + {file = "pydantic_core-2.27.1-cp312-none-win_arm64.whl", hash = "sha256:9a3b0793b1bbfd4146304e23d90045f2a9b5fd5823aa682665fbdaf2a6c28f3e"}, + {file = "pydantic_core-2.27.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:f216dbce0e60e4d03e0c4353c7023b202d95cbaeff12e5fd2e82ea0a66905073"}, + {file = "pydantic_core-2.27.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a2e02889071850bbfd36b56fd6bc98945e23670773bc7a76657e90e6b6603c08"}, + {file = "pydantic_core-2.27.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42b0e23f119b2b456d07ca91b307ae167cc3f6c846a7b169fca5326e32fdc6cf"}, + {file = "pydantic_core-2.27.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:764be71193f87d460a03f1f7385a82e226639732214b402f9aa61f0d025f0737"}, + {file = "pydantic_core-2.27.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1c00666a3bd2f84920a4e94434f5974d7bbc57e461318d6bb34ce9cdbbc1f6b2"}, + {file = "pydantic_core-2.27.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3ccaa88b24eebc0f849ce0a4d09e8a408ec5a94afff395eb69baf868f5183107"}, + {file = "pydantic_core-2.27.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c65af9088ac534313e1963443d0ec360bb2b9cba6c2909478d22c2e363d98a51"}, + {file = "pydantic_core-2.27.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:206b5cf6f0c513baffaeae7bd817717140770c74528f3e4c3e1cec7871ddd61a"}, + {file = "pydantic_core-2.27.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:062f60e512fc7fff8b8a9d680ff0ddaaef0193dba9fa83e679c0c5f5fbd018bc"}, + {file = "pydantic_core-2.27.1-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:a0697803ed7d4af5e4c1adf1670af078f8fcab7a86350e969f454daf598c4960"}, + {file = "pydantic_core-2.27.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:58ca98a950171f3151c603aeea9303ef6c235f692fe555e883591103da709b23"}, + {file = "pydantic_core-2.27.1-cp313-none-win32.whl", hash = "sha256:8065914ff79f7eab1599bd80406681f0ad08f8e47c880f17b416c9f8f7a26d05"}, + {file = "pydantic_core-2.27.1-cp313-none-win_amd64.whl", hash = "sha256:ba630d5e3db74c79300d9a5bdaaf6200172b107f263c98a0539eeecb857b2337"}, + {file = "pydantic_core-2.27.1-cp313-none-win_arm64.whl", hash = "sha256:45cf8588c066860b623cd11c4ba687f8d7175d5f7ef65f7129df8a394c502de5"}, + {file = "pydantic_core-2.27.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:5897bec80a09b4084aee23f9b73a9477a46c3304ad1d2d07acca19723fb1de62"}, + {file = "pydantic_core-2.27.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:d0165ab2914379bd56908c02294ed8405c252250668ebcb438a55494c69f44ab"}, + {file = "pydantic_core-2.27.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b9af86e1d8e4cfc82c2022bfaa6f459381a50b94a29e95dcdda8442d6d83864"}, + {file = "pydantic_core-2.27.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f6c8a66741c5f5447e047ab0ba7a1c61d1e95580d64bce852e3df1f895c4067"}, + {file = "pydantic_core-2.27.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9a42d6a8156ff78981f8aa56eb6394114e0dedb217cf8b729f438f643608cbcd"}, + {file = "pydantic_core-2.27.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:64c65f40b4cd8b0e049a8edde07e38b476da7e3aaebe63287c899d2cff253fa5"}, + {file = "pydantic_core-2.27.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fdcf339322a3fae5cbd504edcefddd5a50d9ee00d968696846f089b4432cf78"}, + {file = "pydantic_core-2.27.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:bf99c8404f008750c846cb4ac4667b798a9f7de673ff719d705d9b2d6de49c5f"}, + {file = "pydantic_core-2.27.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8f1edcea27918d748c7e5e4d917297b2a0ab80cad10f86631e488b7cddf76a36"}, + {file = "pydantic_core-2.27.1-cp38-cp38-musllinux_1_1_armv7l.whl", hash = "sha256:159cac0a3d096f79ab6a44d77a961917219707e2a130739c64d4dd46281f5c2a"}, + {file = "pydantic_core-2.27.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:029d9757eb621cc6e1848fa0b0310310de7301057f623985698ed7ebb014391b"}, + {file = "pydantic_core-2.27.1-cp38-none-win32.whl", hash = "sha256:a28af0695a45f7060e6f9b7092558a928a28553366519f64083c63a44f70e618"}, + {file = "pydantic_core-2.27.1-cp38-none-win_amd64.whl", hash = "sha256:2d4567c850905d5eaaed2f7a404e61012a51caf288292e016360aa2b96ff38d4"}, + {file = "pydantic_core-2.27.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:e9386266798d64eeb19dd3677051f5705bf873e98e15897ddb7d76f477131967"}, + {file = "pydantic_core-2.27.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4228b5b646caa73f119b1ae756216b59cc6e2267201c27d3912b592c5e323b60"}, + {file = "pydantic_core-2.27.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b3dfe500de26c52abe0477dde16192ac39c98f05bf2d80e76102d394bd13854"}, + {file = "pydantic_core-2.27.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:aee66be87825cdf72ac64cb03ad4c15ffef4143dbf5c113f64a5ff4f81477bf9"}, + {file = "pydantic_core-2.27.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b748c44bb9f53031c8cbc99a8a061bc181c1000c60a30f55393b6e9c45cc5bd"}, + {file = "pydantic_core-2.27.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5ca038c7f6a0afd0b2448941b6ef9d5e1949e999f9e5517692eb6da58e9d44be"}, + {file = "pydantic_core-2.27.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e0bd57539da59a3e4671b90a502da9a28c72322a4f17866ba3ac63a82c4498e"}, + {file = "pydantic_core-2.27.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ac6c2c45c847bbf8f91930d88716a0fb924b51e0c6dad329b793d670ec5db792"}, + {file = "pydantic_core-2.27.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b94d4ba43739bbe8b0ce4262bcc3b7b9f31459ad120fb595627eaeb7f9b9ca01"}, + {file = "pydantic_core-2.27.1-cp39-cp39-musllinux_1_1_armv7l.whl", hash = "sha256:00e6424f4b26fe82d44577b4c842d7df97c20be6439e8e685d0d715feceb9fb9"}, + {file = "pydantic_core-2.27.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:38de0a70160dd97540335b7ad3a74571b24f1dc3ed33f815f0880682e6880131"}, + {file = "pydantic_core-2.27.1-cp39-none-win32.whl", hash = "sha256:7ccebf51efc61634f6c2344da73e366c75e735960b5654b63d7e6f69a5885fa3"}, + {file = "pydantic_core-2.27.1-cp39-none-win_amd64.whl", hash = "sha256:a57847b090d7892f123726202b7daa20df6694cbd583b67a592e856bff603d6c"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:3fa80ac2bd5856580e242dbc202db873c60a01b20309c8319b5c5986fbe53ce6"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d950caa237bb1954f1b8c9227b5065ba6875ac9771bb8ec790d956a699b78676"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0e4216e64d203e39c62df627aa882f02a2438d18a5f21d7f721621f7a5d3611d"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:02a3d637bd387c41d46b002f0e49c52642281edacd2740e5a42f7017feea3f2c"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:161c27ccce13b6b0c8689418da3885d3220ed2eae2ea5e9b2f7f3d48f1d52c27"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:19910754e4cc9c63bc1c7f6d73aa1cfee82f42007e407c0f413695c2f7ed777f"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:e173486019cc283dc9778315fa29a363579372fe67045e971e89b6365cc035ed"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:af52d26579b308921b73b956153066481f064875140ccd1dfd4e77db89dbb12f"}, + {file = "pydantic_core-2.27.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:981fb88516bd1ae8b0cbbd2034678a39dedc98752f264ac9bc5839d3923fa04c"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:5fde892e6c697ce3e30c61b239330fc5d569a71fefd4eb6512fc6caec9dd9e2f"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:816f5aa087094099fff7edabb5e01cc370eb21aa1a1d44fe2d2aefdfb5599b31"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c10c309e18e443ddb108f0ef64e8729363adbfd92d6d57beec680f6261556f3"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:98476c98b02c8e9b2eec76ac4156fd006628b1b2d0ef27e548ffa978393fd154"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c3027001c28434e7ca5a6e1e527487051136aa81803ac812be51802150d880dd"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:7699b1df36a48169cdebda7ab5a2bac265204003f153b4bd17276153d997670a"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:1c39b07d90be6b48968ddc8c19e7585052088fd7ec8d568bb31ff64c70ae3c97"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:46ccfe3032b3915586e469d4972973f893c0a2bb65669194a5bdea9bacc088c2"}, + {file = "pydantic_core-2.27.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:62ba45e21cf6571d7f716d903b5b7b6d2617e2d5d67c0923dc47b9d41369f840"}, + {file = "pydantic_core-2.27.1.tar.gz", hash = "sha256:62a763352879b84aa31058fc931884055fd75089cccbd9d58bb6afd01141b235"}, ] [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" @@ -1710,13 +1825,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]] @@ -1751,13 +1866,13 @@ files = [ [[package]] name = "pytest" -version = "7.4.4" +version = "8.3.4" 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.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, + {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, ] [package.dependencies] @@ -1765,67 +1880,85 @@ 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" -version = "4.0.0" +version = "5.1.0" description = "A ``pytest`` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer." optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" files = [ - {file = "pytest-benchmark-4.0.0.tar.gz", hash = "sha256:fb0785b83efe599a6a956361c0691ae1dbb5318018561af10f3e915caa0048d1"}, - {file = "pytest_benchmark-4.0.0-py3-none-any.whl", hash = "sha256:fdb7db64e31c8b277dff9850d2a2556d8b60bcb0ea6524e36e28ffd7c87f71d6"}, + {file = "pytest-benchmark-5.1.0.tar.gz", hash = "sha256:9ea661cdc292e8231f7cd4c10b0319e56a2118e2c09d9f50e1b3d150d2aca105"}, + {file = "pytest_benchmark-5.1.0-py3-none-any.whl", hash = "sha256:922de2dfa3033c227c96da942d1878191afa135a29485fb942e85dff1c592c89"}, ] [package.dependencies] py-cpuinfo = "*" -pytest = ">=3.8" +pytest = ">=8.1" [package.extras] aspect = ["aspectlib"] elasticsearch = ["elasticsearch"] -histogram = ["pygal", "pygaljs"] +histogram = ["pygal", "pygaljs", "setuptools"] [[package]] name = "pytest-cov" -version = "4.1.0" +version = "6.0.0" description = "Pytest plugin for measuring coverage." optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" 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-6.0.0.tar.gz", hash = "sha256:fde0b595ca248bb8e2d76f020b465f3b107c9632e6a1d1705f17834c89dcadc0"}, + {file = "pytest_cov-6.0.0-py3-none-any.whl", hash = "sha256:eee6f1b9e61008bd34975a4d5bab25801eb31898b032dd55addc93e96fcaaa35"}, ] [package.dependencies] -coverage = {version = ">=5.2.1", extras = ["toml"]} +coverage = {version = ">=7.5", 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" @@ -1844,6 +1977,23 @@ pytest = ">=6.2.5" [package.extras] dev = ["pre-commit", "pytest-asyncio", "tox"] +[[package]] +name = "pytest-playwright" +version = "0.6.2" +description = "A pytest wrapper with fixtures for Playwright to automate web browsers" +optional = false +python-versions = ">=3.9" +files = [ + {file = "pytest_playwright-0.6.2-py3-none-any.whl", hash = "sha256:0eff73bebe497b0158befed91e2f5fe94cfa17181f8b3acf575beed84e7e9043"}, + {file = "pytest_playwright-0.6.2.tar.gz", hash = "sha256:ff4054b19aa05df096ac6f74f0572591566aaf0f6d97f6cb9674db8a4d4ed06c"}, +] + +[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" @@ -1860,13 +2010,13 @@ six = ">=1.5" [[package]] name = "python-engineio" -version = "4.9.1" +version = "4.10.1" description = "Engine.IO server and client for Python" optional = false python-versions = ">=3.6" files = [ - {file = "python_engineio-4.9.1-py3-none-any.whl", hash = "sha256:f995e702b21f6b9ebde4e2000cd2ad0112ba0e5116ec8d22fe3515e76ba9dddd"}, - {file = "python_engineio-4.9.1.tar.gz", hash = "sha256:7631cf5563086076611e494c643b3fa93dd3a854634b5488be0bba0ef9b99709"}, + {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] @@ -1879,27 +2029,41 @@ docs = ["sphinx"] [[package]] name = "python-multipart" -version = "0.0.9" +version = "0.0.19" 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.19-py3-none-any.whl", hash = "sha256:f8d5b0b9c618575bf9df01c684ded1d94a338839bdd8223838afacfb4bb2082d"}, + {file = "python_multipart-0.0.19.tar.gz", hash = "sha256:905502ef39050557b7a6af411f454bc19526529ca46ae6831508438890ce12cc"}, ] +[[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.3" +version = "5.11.4" description = "Socket.IO server and client for Python" optional = false python-versions = ">=3.8" files = [ - {file = "python_socketio-5.11.3-py3-none-any.whl", hash = "sha256:2a923a831ff70664b7c502df093c423eb6aa93c1ce68b8319e840227a26d8b69"}, - {file = "python_socketio-5.11.3.tar.gz", hash = "sha256:194af8cdbb7b0768c2e807ba76c7abc288eb5bb85559b7cddee51a6bc7a65737"}, + {file = "python_socketio-5.11.4-py3-none-any.whl", hash = "sha256:42efaa3e3e0b166fc72a527488a13caaac2cefc76174252486503bd496284945"}, + {file = "python_socketio-5.11.4.tar.gz", hash = "sha256:8b0b8ff2964b2957c865835e936310190639c00310a47d77321a594d1665355e"}, ] [package.dependencies] @@ -1913,88 +2077,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" @@ -2003,31 +2180,45 @@ md = ["cmarkgfm (>=0.8.0)"] [[package]] name = "redis" -version = "5.0.7" +version = "5.2.1" 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.7-py3-none-any.whl", hash = "sha256:0e479e24da960c690be5d9b96d21f7b918a98c0cf49af3b6fafaa0753f93a0db"}, - {file = "redis-5.0.7.tar.gz", hash = "sha256:8f611490b93c8109b50adc317b31bfd84fff31def3475b92e7e80bf39f48175b"}, + {file = "redis-5.2.1-py3-none-any.whl", hash = "sha256:ee7e1056b9aea0f04c6c2ed59452947f34c4940ee025f5dd83e6a6418b6989e4"}, + {file = "redis-5.2.1.tar.gz", hash = "sha256:16f2e22dff21d5125e8481515e386711a34cbec50f0e44413dd7d9c060a54e0f"}, ] [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" -version = "0.1.13" +version = "0.1.30" description = "Reflex Hosting CLI" optional = false python-versions = "<4.0,>=3.8" files = [ - {file = "reflex_hosting_cli-0.1.13-py3-none-any.whl", hash = "sha256:5bfec7f3d7ce4bbd703989f086494e586a641ef37c9e60e60fb82bdfb07ff227"}, - {file = "reflex_hosting_cli-0.1.13.tar.gz", hash = "sha256:c5d6afdcfeb74cee046a374ddbd59116ab8ed797dae688fcc744dabae24dc571"}, + {file = "reflex_hosting_cli-0.1.30-py3-none-any.whl", hash = "sha256:778c98d635003d8668158c22eaa0f7124d2bac92c8a1aabaed710960ca97796e"}, + {file = "reflex_hosting_cli-0.1.30.tar.gz", hash = "sha256:a0fdc73e595e6b9fd661e1307ae37267fb3815cc457b7f15938ba921c12fc0b6"}, ] [package.dependencies] @@ -2039,7 +2230,7 @@ pydantic = ">=1.10.2,<3.0" python-dateutil = ">=2.8.1" rich = ">=13.0.0,<14.0" tabulate = ">=0.9.0,<0.10.0" -typer = ">=0.4.2,<1" +typer = ">=0.15.0,<1" websockets = ">=10.4" [[package]] @@ -2093,47 +2284,48 @@ idna2008 = ["idna"] [[package]] name = "rich" -version = "13.7.1" +version = "13.9.4" 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.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90"}, + {file = "rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098"}, ] [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.4.10" +version = "0.8.2" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.4.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:5c2c4d0859305ac5a16310eec40e4e9a9dec5dcdfbe92697acd99624e8638dac"}, - {file = "ruff-0.4.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a79489607d1495685cdd911a323a35871abfb7a95d4f98fc6f85e799227ac46e"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1dd1681dfa90a41b8376a61af05cc4dc5ff32c8f14f5fe20dba9ff5deb80cd6"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c75c53bb79d71310dc79fb69eb4902fba804a81f374bc86a9b117a8d077a1784"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18238c80ee3d9100d3535d8eb15a59c4a0753b45cc55f8bf38f38d6a597b9739"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d8f71885bce242da344989cae08e263de29752f094233f932d4f5cfb4ef36a81"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:330421543bd3222cdfec481e8ff3460e8702ed1e58b494cf9d9e4bf90db52b9d"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e9b6fb3a37b772628415b00c4fc892f97954275394ed611056a4b8a2631365e"}, - {file = "ruff-0.4.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f54c481b39a762d48f64d97351048e842861c6662d63ec599f67d515cb417f6"}, - {file = "ruff-0.4.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:67fe086b433b965c22de0b4259ddfe6fa541c95bf418499bedb9ad5fb8d1c631"}, - {file = "ruff-0.4.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:acfaaab59543382085f9eb51f8e87bac26bf96b164839955f244d07125a982ef"}, - {file = "ruff-0.4.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3cea07079962b2941244191569cf3a05541477286f5cafea638cd3aa94b56815"}, - {file = "ruff-0.4.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:338a64ef0748f8c3a80d7f05785930f7965d71ca260904a9321d13be24b79695"}, - {file = "ruff-0.4.10-py3-none-win32.whl", hash = "sha256:ffe3cd2f89cb54561c62e5fa20e8f182c0a444934bf430515a4b422f1ab7b7ca"}, - {file = "ruff-0.4.10-py3-none-win_amd64.whl", hash = "sha256:67f67cef43c55ffc8cc59e8e0b97e9e60b4837c8f21e8ab5ffd5d66e196e25f7"}, - {file = "ruff-0.4.10-py3-none-win_arm64.whl", hash = "sha256:dd1fcee327c20addac7916ca4e2653fbbf2e8388d8a6477ce5b4e986b68ae6c0"}, - {file = "ruff-0.4.10.tar.gz", hash = "sha256:3aa4f2bc388a30d346c56524f7cacca85945ba124945fe489952aadb6b5cd804"}, + {file = "ruff-0.8.2-py3-none-linux_armv6l.whl", hash = "sha256:c49ab4da37e7c457105aadfd2725e24305ff9bc908487a9bf8d548c6dad8bb3d"}, + {file = "ruff-0.8.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ec016beb69ac16be416c435828be702ee694c0d722505f9c1f35e1b9c0cc1bf5"}, + {file = "ruff-0.8.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f05cdf8d050b30e2ba55c9b09330b51f9f97d36d4673213679b965d25a785f3c"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:60f578c11feb1d3d257b2fb043ddb47501ab4816e7e221fbb0077f0d5d4e7b6f"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cbd5cf9b0ae8f30eebc7b360171bd50f59ab29d39f06a670b3e4501a36ba5897"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b402ddee3d777683de60ff76da801fa7e5e8a71038f57ee53e903afbcefdaa58"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:705832cd7d85605cb7858d8a13d75993c8f3ef1397b0831289109e953d833d29"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:32096b41aaf7a5cc095fa45b4167b890e4c8d3fd217603f3634c92a541de7248"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e769083da9439508833cfc7c23e351e1809e67f47c50248250ce1ac52c21fb93"}, + {file = "ruff-0.8.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fe716592ae8a376c2673fdfc1f5c0c193a6d0411f90a496863c99cd9e2ae25d"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:81c148825277e737493242b44c5388a300584d73d5774defa9245aaef55448b0"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d261d7850c8367704874847d95febc698a950bf061c9475d4a8b7689adc4f7fa"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1ca4e3a87496dc07d2427b7dd7ffa88a1e597c28dad65ae6433ecb9f2e4f022f"}, + {file = "ruff-0.8.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:729850feed82ef2440aa27946ab39c18cb4a8889c1128a6d589ffa028ddcfc22"}, + {file = "ruff-0.8.2-py3-none-win32.whl", hash = "sha256:ac42caaa0411d6a7d9594363294416e0e48fc1279e1b0e948391695db2b3d5b1"}, + {file = "ruff-0.8.2-py3-none-win_amd64.whl", hash = "sha256:2aae99ec70abf43372612a838d97bfe77d45146254568d94926e8ed5bbb409ea"}, + {file = "ruff-0.8.2-py3-none-win_arm64.whl", hash = "sha256:fb88e2a506b70cfbc2de6fae6681c4f944f7dd5f2fe87233a7233d888bad73e8"}, + {file = "ruff-0.8.2.tar.gz", hash = "sha256:b84f4f414dda8ac7f75075c1fa0b905ac0ff25361f42e6d5da681a465e0f78e5"}, ] [[package]] @@ -2153,37 +2345,42 @@ jeepney = ">=0.6" [[package]] name = "selenium" -version = "4.22.0" +version = "4.27.1" description = "Official Python bindings for Selenium WebDriver" optional = false python-versions = ">=3.8" files = [ - {file = "selenium-4.22.0-py3-none-any.whl", hash = "sha256:e424991196e9857e19bf04fe5c1c0a4aac076794ff5e74615b1124e729d93104"}, - {file = "selenium-4.22.0.tar.gz", hash = "sha256:903c8c9d61b3eea6fcc9809dc7d9377e04e2ac87709876542cc8f863e482c4ce"}, + {file = "selenium-4.27.1-py3-none-any.whl", hash = "sha256:b89b1f62b5cfe8025868556fe82360d6b649d464f75d2655cb966c8f8447ea18"}, + {file = "selenium-4.27.1.tar.gz", hash = "sha256:5296c425a75ff1b44d0d5199042b36a6d1ef76c04fb775b97b40be739a9caae2"}, ] [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.0" +websocket-client = ">=1.8,<2.0" [[package]] name = "setuptools" -version = "70.1.1" +version = "75.6.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "setuptools-70.1.1-py3-none-any.whl", hash = "sha256:a58a8fde0541dab0419750bcc521fbdf8585f6e5cb41909df3a472ef7b81ca95"}, - {file = "setuptools-70.1.1.tar.gz", hash = "sha256:937a48c7cdb7a21eb53cd7f9b59e525503aa8abaf3584c730dc5f7a5bec3a650"}, + {file = "setuptools-75.6.0-py3-none-any.whl", hash = "sha256:ce74b49e8f7110f9bf04883b730f4765b774ef3ef28f722cce7c273d253aaf7d"}, + {file = "setuptools-75.6.0.tar.gz", hash = "sha256:8199222558df7c86216af4f84c30e9b34a61d8ba19366cc914424cdbd28252f6"}, ] [package.extras] -docs = ["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"] -testing = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test", "mypy (==1.10.0)", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.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.3.2)", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)", "ruff (>=0.7.0)"] +core = ["importlib_metadata (>=6)", "jaraco.collections", "jaraco.functools (>=4)", "jaraco.text (>=3.7)", "more_itertools", "more_itertools (>=8.8)", "packaging", "packaging (>=24.2)", "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 (>=24.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,<1.14)", "pytest-mypy"] [[package]] name = "shellingham" @@ -2198,30 +2395,31 @@ 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]] name = "six" -version = "1.16.0" +version = "1.17.0" description = "Python 2 and 3 compatibility utilities" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, + {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, + {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, ] [[package]] @@ -2248,60 +2446,68 @@ files = [ [[package]] name = "sqlalchemy" -version = "2.0.31" +version = "2.0.36" description = "Database Abstraction Library" optional = false python-versions = ">=3.7" files = [ - {file = "SQLAlchemy-2.0.31-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f2a213c1b699d3f5768a7272de720387ae0122f1becf0901ed6eaa1abd1baf6c"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9fea3d0884e82d1e33226935dac990b967bef21315cbcc894605db3441347443"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3ad7f221d8a69d32d197e5968d798217a4feebe30144986af71ada8c548e9fa"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f2bee229715b6366f86a95d497c347c22ddffa2c7c96143b59a2aa5cc9eebbc"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:cd5b94d4819c0c89280b7c6109c7b788a576084bf0a480ae17c227b0bc41e109"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:750900a471d39a7eeba57580b11983030517a1f512c2cb287d5ad0fcf3aebd58"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-win32.whl", hash = "sha256:7bd112be780928c7f493c1a192cd8c5fc2a2a7b52b790bc5a84203fb4381c6be"}, - {file = "SQLAlchemy-2.0.31-cp310-cp310-win_amd64.whl", hash = "sha256:5a48ac4d359f058474fadc2115f78a5cdac9988d4f99eae44917f36aa1476327"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f68470edd70c3ac3b6cd5c2a22a8daf18415203ca1b036aaeb9b0fb6f54e8298"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2e2c38c2a4c5c634fe6c3c58a789712719fa1bf9b9d6ff5ebfce9a9e5b89c1ca"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd15026f77420eb2b324dcb93551ad9c5f22fab2c150c286ef1dc1160f110203"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2196208432deebdfe3b22185d46b08f00ac9d7b01284e168c212919891289396"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:352b2770097f41bff6029b280c0e03b217c2dcaddc40726f8f53ed58d8a85da4"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:56d51ae825d20d604583f82c9527d285e9e6d14f9a5516463d9705dab20c3740"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-win32.whl", hash = "sha256:6e2622844551945db81c26a02f27d94145b561f9d4b0c39ce7bfd2fda5776dac"}, - {file = "SQLAlchemy-2.0.31-cp311-cp311-win_amd64.whl", hash = "sha256:ccaf1b0c90435b6e430f5dd30a5aede4764942a695552eb3a4ab74ed63c5b8d3"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:3b74570d99126992d4b0f91fb87c586a574a5872651185de8297c6f90055ae42"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6f77c4f042ad493cb8595e2f503c7a4fe44cd7bd59c7582fd6d78d7e7b8ec52c"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd1591329333daf94467e699e11015d9c944f44c94d2091f4ac493ced0119449"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:74afabeeff415e35525bf7a4ecdab015f00e06456166a2eba7590e49f8db940e"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b9c01990d9015df2c6f818aa8f4297d42ee71c9502026bb074e713d496e26b67"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:66f63278db425838b3c2b1c596654b31939427016ba030e951b292e32b99553e"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-win32.whl", hash = "sha256:0b0f658414ee4e4b8cbcd4a9bb0fd743c5eeb81fc858ca517217a8013d282c96"}, - {file = "SQLAlchemy-2.0.31-cp312-cp312-win_amd64.whl", hash = "sha256:fa4b1af3e619b5b0b435e333f3967612db06351217c58bfb50cee5f003db2a5a"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:f43e93057cf52a227eda401251c72b6fbe4756f35fa6bfebb5d73b86881e59b0"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d337bf94052856d1b330d5fcad44582a30c532a2463776e1651bd3294ee7e58b"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c06fb43a51ccdff3b4006aafee9fcf15f63f23c580675f7734245ceb6b6a9e05"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:b6e22630e89f0e8c12332b2b4c282cb01cf4da0d26795b7eae16702a608e7ca1"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:79a40771363c5e9f3a77f0e28b3302801db08040928146e6808b5b7a40749c88"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-win32.whl", hash = "sha256:501ff052229cb79dd4c49c402f6cb03b5a40ae4771efc8bb2bfac9f6c3d3508f"}, - {file = "SQLAlchemy-2.0.31-cp37-cp37m-win_amd64.whl", hash = "sha256:597fec37c382a5442ffd471f66ce12d07d91b281fd474289356b1a0041bdf31d"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:dc6d69f8829712a4fd799d2ac8d79bdeff651c2301b081fd5d3fe697bd5b4ab9"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:23b9fbb2f5dd9e630db70fbe47d963c7779e9c81830869bd7d137c2dc1ad05fb"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2a21c97efcbb9f255d5c12a96ae14da873233597dfd00a3a0c4ce5b3e5e79704"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26a6a9837589c42b16693cf7bf836f5d42218f44d198f9343dd71d3164ceeeac"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:dc251477eae03c20fae8db9c1c23ea2ebc47331bcd73927cdcaecd02af98d3c3"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:2fd17e3bb8058359fa61248c52c7b09a97cf3c820e54207a50af529876451808"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-win32.whl", hash = "sha256:c76c81c52e1e08f12f4b6a07af2b96b9b15ea67ccdd40ae17019f1c373faa227"}, - {file = "SQLAlchemy-2.0.31-cp38-cp38-win_amd64.whl", hash = "sha256:4b600e9a212ed59355813becbcf282cfda5c93678e15c25a0ef896b354423238"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b6cf796d9fcc9b37011d3f9936189b3c8074a02a4ed0c0fbbc126772c31a6d4"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:78fe11dbe37d92667c2c6e74379f75746dc947ee505555a0197cfba9a6d4f1a4"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2fc47dc6185a83c8100b37acda27658fe4dbd33b7d5e7324111f6521008ab4fe"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8a41514c1a779e2aa9a19f67aaadeb5cbddf0b2b508843fcd7bafdf4c6864005"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:afb6dde6c11ea4525318e279cd93c8734b795ac8bb5dda0eedd9ebaca7fa23f1"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:3f9faef422cfbb8fd53716cd14ba95e2ef655400235c3dfad1b5f467ba179c8c"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-win32.whl", hash = "sha256:fc6b14e8602f59c6ba893980bea96571dd0ed83d8ebb9c4479d9ed5425d562e9"}, - {file = "SQLAlchemy-2.0.31-cp39-cp39-win_amd64.whl", hash = "sha256:3cb8a66b167b033ec72c3812ffc8441d4e9f5f78f5e31e54dcd4c90a4ca5bebc"}, - {file = "SQLAlchemy-2.0.31-py3-none-any.whl", hash = "sha256:69f3e3c08867a8e4856e92d7afb618b95cdee18e0bc1647b77599722c9a28911"}, - {file = "SQLAlchemy-2.0.31.tar.gz", hash = "sha256:b607489dd4a54de56984a0c7656247504bd5523d9d0ba799aef59d4add009484"}, + {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] @@ -2314,7 +2520,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"] @@ -2335,13 +2541,13 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "sqlmodel" -version = "0.0.19" +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.19-py3-none-any.whl", hash = "sha256:6c8125d4101970d031e9aae970b20cbeaf44149989f8366d939f4ab21aab8763"}, - {file = "sqlmodel-0.0.19.tar.gz", hash = "sha256:95449b0b48a40a3eecf0a629fa5735b9dfc8a5574a91090d24ca17f02246ad96"}, + {file = "sqlmodel-0.0.22-py3-none-any.whl", hash = "sha256:a1ed13e28a1f4057cbf4ff6cdb4fc09e85702621d3259ba17b3c230bfb2f941b"}, + {file = "sqlmodel-0.0.22.tar.gz", hash = "sha256:7d37c882a30c43464d143e35e9ecaf945d88035e20117bf5ec2834a23cbe505e"}, ] [package.dependencies] @@ -2350,13 +2556,13 @@ SQLAlchemy = ">=2.0.14,<2.1.0" [[package]] name = "starlette" -version = "0.37.2" +version = "0.41.3" 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.3-py3-none-any.whl", hash = "sha256:44cedb2b7c77a9de33a8b74b2b90e9f50d11fcf25d8270ea525ad71a25374ff7"}, + {file = "starlette-0.41.3.tar.gz", hash = "sha256:0e4ab3d16522a255be6b28260b938eae2482f98ce5cc934cb08dce8dc3ba5835"}, ] [package.dependencies] @@ -2368,13 +2574,13 @@ full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.7 [[package]] name = "starlette-admin" -version = "0.14.0" +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.14.0-py3-none-any.whl", hash = "sha256:b59a0d1f571898086651c2a02e0a34db8fc68c4c564de66ac66de7a0daa764fd"}, - {file = "starlette_admin-0.14.0.tar.gz", hash = "sha256:60b517ca9f73ac7eb645f354138a0126dbb84d7bdde53db23deaf38477100dff"}, + {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] @@ -2384,10 +2590,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" @@ -2405,19 +2611,30 @@ widechars = ["wcwidth"] [[package]] name = "tenacity" -version = "8.4.2" +version = "9.0.0" description = "Retry code until it succeeds" optional = false python-versions = ">=3.8" files = [ - {file = "tenacity-8.4.2-py3-none-any.whl", hash = "sha256:9e6f7cf7da729125c7437222f8a522279751cdfbe6b67bfe64f75d3a348661b2"}, - {file = "tenacity-8.4.2.tar.gz", hash = "sha256:cd80a53a79336edba8489e767f729e4f391c896956b57140b5d7511a64bbd3ef"}, + {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" @@ -2431,35 +2648,65 @@ files = [ [[package]] name = "tomli" -version = "2.0.1" +version = "2.2.1" 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.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, + {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"}, + {file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"}, + {file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"}, + {file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"}, + {file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"}, + {file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"}, + {file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"}, + {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, + {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, ] [[package]] name = "tomlkit" -version = "0.12.5" +version = "0.13.2" description = "Style preserving TOML library" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "tomlkit-0.12.5-py3-none-any.whl", hash = "sha256:af914f5a9c59ed9d0762c7b64d3b5d5df007448eb9cd2edc8a46b1eafead172f"}, - {file = "tomlkit-0.12.5.tar.gz", hash = "sha256:eef34fba39834d4d6b73c9ba7f3e4d1c417a4e56f89a7e96e090dd0d24b8fb3c"}, + {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.1" +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.1-py3-none-any.whl", hash = "sha256:e42617ba091e7b2e50c899052e83a3c403101841de925187f61e7b7eaebdf3fb"}, - {file = "trio-0.25.1.tar.gz", hash = "sha256:9f5314f014ea3af489e77b001861c535005c3858d38ec46b6b071ebfa339d7fb"}, + {file = "trio-0.27.0-py3-none-any.whl", hash = "sha256:68eabbcf8f457d925df62da780eff15ff5dc68fd6b367e2dde59f7aaf2a0b884"}, + {file = "trio-0.27.0.tar.gz", hash = "sha256:1dcc95ab1726b2da054afea8fd761af74bad79bd52381b84eae408e983c76831"}, ] [package.dependencies] @@ -2489,19 +2736,20 @@ wsproto = ">=0.14" [[package]] name = "twine" -version = "5.1.1" +version = "6.0.1" description = "Collection of utilities for publishing packages on PyPI" optional = false python-versions = ">=3.8" files = [ - {file = "twine-5.1.1-py3-none-any.whl", hash = "sha256:215dbe7b4b94c2c50a7315c0275d2258399280fbb7d04182c7e55e24b5f93997"}, - {file = "twine-5.1.1.tar.gz", hash = "sha256:9aa0825139c02b3434d913545c7b847a21c835e11597f5255842d457da2322db"}, + {file = "twine-6.0.1-py3-none-any.whl", hash = "sha256:9c6025b203b51521d53e200f4a08b116dee7500a38591668c6a6033117bdc218"}, + {file = "twine-6.0.1.tar.gz", hash = "sha256:36158b09df5406e1c9c1fb8edb24fc2be387709443e7376689b938531582ee27"}, ] [package.dependencies] -importlib-metadata = ">=3.6" -keyring = ">=15.1" -pkginfo = ">=1.8.1,<1.11" +importlib-metadata = {version = ">=3.6", markers = "python_version < \"3.10\""} +keyring = {version = ">=15.1", markers = "platform_machine != \"ppc64le\" and platform_machine != \"s390x\""} +packaging = "*" +pkginfo = ">=1.8.1" readme-renderer = ">=35.0" requests = ">=2.20" requests-toolbelt = ">=0.8.0,<0.9.0 || >0.9.0" @@ -2509,15 +2757,18 @@ rfc3986 = ">=1.4.0" rich = ">=12.0.0" urllib3 = ">=1.26.0" +[package.extras] +keyring = ["keyring (>=15.1)"] + [[package]] name = "typer" -version = "0.12.3" +version = "0.15.1" 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.15.1-py3-none-any.whl", hash = "sha256:7994fb7b8155b64d3402518560648446072864beefd44aa2dc36972a5972e847"}, + {file = "typer-0.15.1.tar.gz", hash = "sha256:a0588c0a7fa68a1978a069818657778f86abe6ff5ea6abf472f940a08bfe4f0a"}, ] [package.dependencies] @@ -2539,24 +2790,24 @@ files = [ [[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.2" +version = "2.2.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ - {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, - {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, + {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, + {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, ] [package.dependencies] @@ -2570,13 +2821,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "uvicorn" -version = "0.30.1" +version = "0.32.1" description = "The lightning-fast ASGI server." optional = false python-versions = ">=3.8" files = [ - {file = "uvicorn-0.30.1-py3-none-any.whl", hash = "sha256:cd17daa7f3b9d7a24de3617820e634d0933b69eed8e33a516071174427238c81"}, - {file = "uvicorn-0.30.1.tar.gz", hash = "sha256:d46cd8e0fd80240baffbcd9ec1012a712938754afcf81bce56c024c1656aece8"}, + {file = "uvicorn-0.32.1-py3-none-any.whl", hash = "sha256:82ad92fd58da0d12af7482ecdb5f2470a04c9c9a53ced65b9bbb4a205377602e"}, + {file = "uvicorn-0.32.1.tar.gz", hash = "sha256:ee9519c246a72b1c084cea8d3b44ed6026e78a4a309cbedae9c37e4cb9fbb175"}, ] [package.dependencies] @@ -2585,17 +2836,17 @@ 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)"] +standard = ["colorama (>=0.4)", "httptools (>=0.6.3)", "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.3" +version = "20.28.0" description = "Virtual Python Environment builder" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "virtualenv-20.26.3-py3-none-any.whl", hash = "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589"}, - {file = "virtualenv-20.26.3.tar.gz", hash = "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a"}, + {file = "virtualenv-20.28.0-py3-none-any.whl", hash = "sha256:23eae1b4516ecd610481eda647f3a7c09aea295055337331bb4e6892ecce47b0"}, + {file = "virtualenv-20.28.0.tar.gz", hash = "sha256:2c9c3262bb8e7b87ea801d715fae4495e6032450c71d2309be9550e7364049aa"}, ] [package.dependencies] @@ -2607,137 +2858,6 @@ platformdirs = ">=3.9.1,<5" docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] -[[package]] -name = "watchdog" -version = "4.0.1" -description = "Filesystem events monitoring" -optional = false -python-versions = ">=3.8" -files = [ - {file = "watchdog-4.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:da2dfdaa8006eb6a71051795856bedd97e5b03e57da96f98e375682c48850645"}, - {file = "watchdog-4.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e93f451f2dfa433d97765ca2634628b789b49ba8b504fdde5837cdcf25fdb53b"}, - {file = "watchdog-4.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ef0107bbb6a55f5be727cfc2ef945d5676b97bffb8425650dadbb184be9f9a2b"}, - {file = "watchdog-4.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:17e32f147d8bf9657e0922c0940bcde863b894cd871dbb694beb6704cfbd2fb5"}, - {file = "watchdog-4.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:03e70d2df2258fb6cb0e95bbdbe06c16e608af94a3ffbd2b90c3f1e83eb10767"}, - {file = "watchdog-4.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:123587af84260c991dc5f62a6e7ef3d1c57dfddc99faacee508c71d287248459"}, - {file = "watchdog-4.0.1-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:093b23e6906a8b97051191a4a0c73a77ecc958121d42346274c6af6520dec175"}, - {file = "watchdog-4.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:611be3904f9843f0529c35a3ff3fd617449463cb4b73b1633950b3d97fa4bfb7"}, - {file = "watchdog-4.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:62c613ad689ddcb11707f030e722fa929f322ef7e4f18f5335d2b73c61a85c28"}, - {file = "watchdog-4.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:d4925e4bf7b9bddd1c3de13c9b8a2cdb89a468f640e66fbfabaf735bd85b3e35"}, - {file = "watchdog-4.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cad0bbd66cd59fc474b4a4376bc5ac3fc698723510cbb64091c2a793b18654db"}, - {file = "watchdog-4.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a3c2c317a8fb53e5b3d25790553796105501a235343f5d2bf23bb8649c2c8709"}, - {file = "watchdog-4.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c9904904b6564d4ee8a1ed820db76185a3c96e05560c776c79a6ce5ab71888ba"}, - {file = "watchdog-4.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:667f3c579e813fcbad1b784db7a1aaa96524bed53437e119f6a2f5de4db04235"}, - {file = "watchdog-4.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d10a681c9a1d5a77e75c48a3b8e1a9f2ae2928eda463e8d33660437705659682"}, - {file = "watchdog-4.0.1-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:0144c0ea9997b92615af1d94afc0c217e07ce2c14912c7b1a5731776329fcfc7"}, - {file = "watchdog-4.0.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:998d2be6976a0ee3a81fb8e2777900c28641fb5bfbd0c84717d89bca0addcdc5"}, - {file = "watchdog-4.0.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:e7921319fe4430b11278d924ef66d4daa469fafb1da679a2e48c935fa27af193"}, - {file = "watchdog-4.0.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:f0de0f284248ab40188f23380b03b59126d1479cd59940f2a34f8852db710625"}, - {file = "watchdog-4.0.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:bca36be5707e81b9e6ce3208d92d95540d4ca244c006b61511753583c81c70dd"}, - {file = "watchdog-4.0.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:ab998f567ebdf6b1da7dc1e5accfaa7c6992244629c0fdaef062f43249bd8dee"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_aarch64.whl", hash = "sha256:dddba7ca1c807045323b6af4ff80f5ddc4d654c8bce8317dde1bd96b128ed253"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_armv7l.whl", hash = "sha256:4513ec234c68b14d4161440e07f995f231be21a09329051e67a2118a7a612d2d"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_i686.whl", hash = "sha256:4107ac5ab936a63952dea2a46a734a23230aa2f6f9db1291bf171dac3ebd53c6"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_ppc64.whl", hash = "sha256:6e8c70d2cd745daec2a08734d9f63092b793ad97612470a0ee4cbb8f5f705c57"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:f27279d060e2ab24c0aa98363ff906d2386aa6c4dc2f1a374655d4e02a6c5e5e"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_s390x.whl", hash = "sha256:f8affdf3c0f0466e69f5b3917cdd042f89c8c63aebdb9f7c078996f607cdb0f5"}, - {file = "watchdog-4.0.1-py3-none-manylinux2014_x86_64.whl", hash = "sha256:ac7041b385f04c047fcc2951dc001671dee1b7e0615cde772e84b01fbf68ee84"}, - {file = "watchdog-4.0.1-py3-none-win32.whl", hash = "sha256:206afc3d964f9a233e6ad34618ec60b9837d0582b500b63687e34011e15bb429"}, - {file = "watchdog-4.0.1-py3-none-win_amd64.whl", hash = "sha256:7577b3c43e5909623149f76b099ac49a1a01ca4e167d1785c76eb52fa585745a"}, - {file = "watchdog-4.0.1-py3-none-win_ia64.whl", hash = "sha256:d7b9f5f3299e8dd230880b6c55504a1f69cf1e4316275d1b215ebdd8187ec88d"}, - {file = "watchdog-4.0.1.tar.gz", hash = "sha256:eebaacf674fa25511e8867028d281e602ee6500045b57f43b08778082f7f8b44"}, -] - -[package.extras] -watchmedo = ["PyYAML (>=3.10)"] - -[[package]] -name = "watchfiles" -version = "0.22.0" -description = "Simple, modern and high performance file watching and code reload in python." -optional = false -python-versions = ">=3.8" -files = [ - {file = "watchfiles-0.22.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:da1e0a8caebf17976e2ffd00fa15f258e14749db5e014660f53114b676e68538"}, - {file = "watchfiles-0.22.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:61af9efa0733dc4ca462347becb82e8ef4945aba5135b1638bfc20fad64d4f0e"}, - {file = "watchfiles-0.22.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1d9188979a58a096b6f8090e816ccc3f255f137a009dd4bbec628e27696d67c1"}, - {file = "watchfiles-0.22.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2bdadf6b90c099ca079d468f976fd50062905d61fae183f769637cb0f68ba59a"}, - {file = "watchfiles-0.22.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:067dea90c43bf837d41e72e546196e674f68c23702d3ef80e4e816937b0a3ffd"}, - {file = "watchfiles-0.22.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bbf8a20266136507abf88b0df2328e6a9a7c7309e8daff124dda3803306a9fdb"}, - {file = "watchfiles-0.22.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1235c11510ea557fe21be5d0e354bae2c655a8ee6519c94617fe63e05bca4171"}, - {file = "watchfiles-0.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c2444dc7cb9d8cc5ab88ebe792a8d75709d96eeef47f4c8fccb6df7c7bc5be71"}, - {file = "watchfiles-0.22.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:c5af2347d17ab0bd59366db8752d9e037982e259cacb2ba06f2c41c08af02c39"}, - {file = "watchfiles-0.22.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:9624a68b96c878c10437199d9a8b7d7e542feddda8d5ecff58fdc8e67b460848"}, - {file = "watchfiles-0.22.0-cp310-none-win32.whl", hash = "sha256:4b9f2a128a32a2c273d63eb1fdbf49ad64852fc38d15b34eaa3f7ca2f0d2b797"}, - {file = "watchfiles-0.22.0-cp310-none-win_amd64.whl", hash = "sha256:2627a91e8110b8de2406d8b2474427c86f5a62bf7d9ab3654f541f319ef22bcb"}, - {file = "watchfiles-0.22.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:8c39987a1397a877217be1ac0fb1d8b9f662c6077b90ff3de2c05f235e6a8f96"}, - {file = "watchfiles-0.22.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a927b3034d0672f62fb2ef7ea3c9fc76d063c4b15ea852d1db2dc75fe2c09696"}, - {file = "watchfiles-0.22.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:052d668a167e9fc345c24203b104c313c86654dd6c0feb4b8a6dfc2462239249"}, - {file = "watchfiles-0.22.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e45fb0d70dda1623a7045bd00c9e036e6f1f6a85e4ef2c8ae602b1dfadf7550"}, - {file = "watchfiles-0.22.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c49b76a78c156979759d759339fb62eb0549515acfe4fd18bb151cc07366629c"}, - {file = "watchfiles-0.22.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4a65474fd2b4c63e2c18ac67a0c6c66b82f4e73e2e4d940f837ed3d2fd9d4da"}, - {file = "watchfiles-0.22.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1cc0cba54f47c660d9fa3218158b8963c517ed23bd9f45fe463f08262a4adae1"}, - {file = "watchfiles-0.22.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94ebe84a035993bb7668f58a0ebf998174fb723a39e4ef9fce95baabb42b787f"}, - {file = "watchfiles-0.22.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e0f0a874231e2839abbf473256efffe577d6ee2e3bfa5b540479e892e47c172d"}, - {file = "watchfiles-0.22.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:213792c2cd3150b903e6e7884d40660e0bcec4465e00563a5fc03f30ea9c166c"}, - {file = "watchfiles-0.22.0-cp311-none-win32.whl", hash = "sha256:b44b70850f0073b5fcc0b31ede8b4e736860d70e2dbf55701e05d3227a154a67"}, - {file = "watchfiles-0.22.0-cp311-none-win_amd64.whl", hash = "sha256:00f39592cdd124b4ec5ed0b1edfae091567c72c7da1487ae645426d1b0ffcad1"}, - {file = "watchfiles-0.22.0-cp311-none-win_arm64.whl", hash = "sha256:3218a6f908f6a276941422b035b511b6d0d8328edd89a53ae8c65be139073f84"}, - {file = "watchfiles-0.22.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:c7b978c384e29d6c7372209cbf421d82286a807bbcdeb315427687f8371c340a"}, - {file = "watchfiles-0.22.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bd4c06100bce70a20c4b81e599e5886cf504c9532951df65ad1133e508bf20be"}, - {file = "watchfiles-0.22.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:425440e55cd735386ec7925f64d5dde392e69979d4c8459f6bb4e920210407f2"}, - {file = "watchfiles-0.22.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:68fe0c4d22332d7ce53ad094622b27e67440dacefbaedd29e0794d26e247280c"}, - {file = "watchfiles-0.22.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a8a31bfd98f846c3c284ba694c6365620b637debdd36e46e1859c897123aa232"}, - {file = "watchfiles-0.22.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc2e8fe41f3cac0660197d95216c42910c2b7e9c70d48e6d84e22f577d106fc1"}, - {file = "watchfiles-0.22.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:55b7cc10261c2786c41d9207193a85c1db1b725cf87936df40972aab466179b6"}, - {file = "watchfiles-0.22.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28585744c931576e535860eaf3f2c0ec7deb68e3b9c5a85ca566d69d36d8dd27"}, - {file = "watchfiles-0.22.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:00095dd368f73f8f1c3a7982a9801190cc88a2f3582dd395b289294f8975172b"}, - {file = "watchfiles-0.22.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:52fc9b0dbf54d43301a19b236b4a4614e610605f95e8c3f0f65c3a456ffd7d35"}, - {file = "watchfiles-0.22.0-cp312-none-win32.whl", hash = "sha256:581f0a051ba7bafd03e17127735d92f4d286af941dacf94bcf823b101366249e"}, - {file = "watchfiles-0.22.0-cp312-none-win_amd64.whl", hash = "sha256:aec83c3ba24c723eac14225194b862af176d52292d271c98820199110e31141e"}, - {file = "watchfiles-0.22.0-cp312-none-win_arm64.whl", hash = "sha256:c668228833c5619f6618699a2c12be057711b0ea6396aeaece4ded94184304ea"}, - {file = "watchfiles-0.22.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:d47e9ef1a94cc7a536039e46738e17cce058ac1593b2eccdede8bf72e45f372a"}, - {file = "watchfiles-0.22.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:28f393c1194b6eaadcdd8f941307fc9bbd7eb567995232c830f6aef38e8a6e88"}, - {file = "watchfiles-0.22.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd64f3a4db121bc161644c9e10a9acdb836853155a108c2446db2f5ae1778c3d"}, - {file = "watchfiles-0.22.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2abeb79209630da981f8ebca30a2c84b4c3516a214451bfc5f106723c5f45843"}, - {file = "watchfiles-0.22.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4cc382083afba7918e32d5ef12321421ef43d685b9a67cc452a6e6e18920890e"}, - {file = "watchfiles-0.22.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d048ad5d25b363ba1d19f92dcf29023988524bee6f9d952130b316c5802069cb"}, - {file = "watchfiles-0.22.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:103622865599f8082f03af4214eaff90e2426edff5e8522c8f9e93dc17caee13"}, - {file = "watchfiles-0.22.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3e1f3cf81f1f823e7874ae563457828e940d75573c8fbf0ee66818c8b6a9099"}, - {file = "watchfiles-0.22.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:8597b6f9dc410bdafc8bb362dac1cbc9b4684a8310e16b1ff5eee8725d13dcd6"}, - {file = "watchfiles-0.22.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:0b04a2cbc30e110303baa6d3ddce8ca3664bc3403be0f0ad513d1843a41c97d1"}, - {file = "watchfiles-0.22.0-cp38-none-win32.whl", hash = "sha256:b610fb5e27825b570554d01cec427b6620ce9bd21ff8ab775fc3a32f28bba63e"}, - {file = "watchfiles-0.22.0-cp38-none-win_amd64.whl", hash = "sha256:fe82d13461418ca5e5a808a9e40f79c1879351fcaeddbede094028e74d836e86"}, - {file = "watchfiles-0.22.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:3973145235a38f73c61474d56ad6199124e7488822f3a4fc97c72009751ae3b0"}, - {file = "watchfiles-0.22.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:280a4afbc607cdfc9571b9904b03a478fc9f08bbeec382d648181c695648202f"}, - {file = "watchfiles-0.22.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a0d883351a34c01bd53cfa75cd0292e3f7e268bacf2f9e33af4ecede7e21d1d"}, - {file = "watchfiles-0.22.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9165bcab15f2b6d90eedc5c20a7f8a03156b3773e5fb06a790b54ccecdb73385"}, - {file = "watchfiles-0.22.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dc1b9b56f051209be458b87edb6856a449ad3f803315d87b2da4c93b43a6fe72"}, - {file = "watchfiles-0.22.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8dc1fc25a1dedf2dd952909c8e5cb210791e5f2d9bc5e0e8ebc28dd42fed7562"}, - {file = "watchfiles-0.22.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc92d2d2706d2b862ce0568b24987eba51e17e14b79a1abcd2edc39e48e743c8"}, - {file = "watchfiles-0.22.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97b94e14b88409c58cdf4a8eaf0e67dfd3ece7e9ce7140ea6ff48b0407a593ec"}, - {file = "watchfiles-0.22.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:96eec15e5ea7c0b6eb5bfffe990fc7c6bd833acf7e26704eb18387fb2f5fd087"}, - {file = "watchfiles-0.22.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:28324d6b28bcb8d7c1041648d7b63be07a16db5510bea923fc80b91a2a6cbed6"}, - {file = "watchfiles-0.22.0-cp39-none-win32.whl", hash = "sha256:8c3e3675e6e39dc59b8fe5c914a19d30029e36e9f99468dddffd432d8a7b1c93"}, - {file = "watchfiles-0.22.0-cp39-none-win_amd64.whl", hash = "sha256:25c817ff2a86bc3de3ed2df1703e3d24ce03479b27bb4527c57e722f8554d971"}, - {file = "watchfiles-0.22.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b810a2c7878cbdecca12feae2c2ae8af59bea016a78bc353c184fa1e09f76b68"}, - {file = "watchfiles-0.22.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:f7e1f9c5d1160d03b93fc4b68a0aeb82fe25563e12fbcdc8507f8434ab6f823c"}, - {file = "watchfiles-0.22.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:030bc4e68d14bcad2294ff68c1ed87215fbd9a10d9dea74e7cfe8a17869785ab"}, - {file = "watchfiles-0.22.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ace7d060432acde5532e26863e897ee684780337afb775107c0a90ae8dbccfd2"}, - {file = "watchfiles-0.22.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:5834e1f8b71476a26df97d121c0c0ed3549d869124ed2433e02491553cb468c2"}, - {file = "watchfiles-0.22.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:0bc3b2f93a140df6806c8467c7f51ed5e55a931b031b5c2d7ff6132292e803d6"}, - {file = "watchfiles-0.22.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8fdebb655bb1ba0122402352b0a4254812717a017d2dc49372a1d47e24073795"}, - {file = "watchfiles-0.22.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c8e0aa0e8cc2a43561e0184c0513e291ca891db13a269d8d47cb9841ced7c71"}, - {file = "watchfiles-0.22.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:2f350cbaa4bb812314af5dab0eb8d538481e2e2279472890864547f3fe2281ed"}, - {file = "watchfiles-0.22.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:7a74436c415843af2a769b36bf043b6ccbc0f8d784814ba3d42fc961cdb0a9dc"}, - {file = "watchfiles-0.22.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:00ad0bcd399503a84cc688590cdffbe7a991691314dde5b57b3ed50a41319a31"}, - {file = "watchfiles-0.22.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72a44e9481afc7a5ee3291b09c419abab93b7e9c306c9ef9108cb76728ca58d2"}, - {file = "watchfiles-0.22.0.tar.gz", hash = "sha256:988e981aaab4f3955209e7e28c7794acdb690be1efa7f16f8ea5aba7ffdadacb"}, -] - -[package.dependencies] -anyio = ">=3.0.0" - [[package]] name = "websocket-client" version = "1.8.0" @@ -2756,94 +2876,91 @@ test = ["websockets"] [[package]] name = "websockets" -version = "12.0" +version = "14.1" description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" 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-14.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a0adf84bc2e7c86e8a202537b4fd50e6f7f0e4a6b6bf64d7ccb96c4cd3330b29"}, + {file = "websockets-14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:90b5d9dfbb6d07a84ed3e696012610b6da074d97453bd01e0e30744b472c8179"}, + {file = "websockets-14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2177ee3901075167f01c5e335a6685e71b162a54a89a56001f1c3e9e3d2ad250"}, + {file = "websockets-14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f14a96a0034a27f9d47fd9788913924c89612225878f8078bb9d55f859272b0"}, + {file = "websockets-14.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f874ba705deea77bcf64a9da42c1f5fc2466d8f14daf410bc7d4ceae0a9fcb0"}, + {file = "websockets-14.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9607b9a442392e690a57909c362811184ea429585a71061cd5d3c2b98065c199"}, + {file = "websockets-14.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:bea45f19b7ca000380fbd4e02552be86343080120d074b87f25593ce1700ad58"}, + {file = "websockets-14.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:219c8187b3ceeadbf2afcf0f25a4918d02da7b944d703b97d12fb01510869078"}, + {file = "websockets-14.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:ad2ab2547761d79926effe63de21479dfaf29834c50f98c4bf5b5480b5838434"}, + {file = "websockets-14.1-cp310-cp310-win32.whl", hash = "sha256:1288369a6a84e81b90da5dbed48610cd7e5d60af62df9851ed1d1d23a9069f10"}, + {file = "websockets-14.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0744623852f1497d825a49a99bfbec9bea4f3f946df6eb9d8a2f0c37a2fec2e"}, + {file = "websockets-14.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:449d77d636f8d9c17952628cc7e3b8faf6e92a17ec581ec0c0256300717e1512"}, + {file = "websockets-14.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a35f704be14768cea9790d921c2c1cc4fc52700410b1c10948511039be824aac"}, + {file = "websockets-14.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b1f3628a0510bd58968c0f60447e7a692933589b791a6b572fcef374053ca280"}, + {file = "websockets-14.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c3deac3748ec73ef24fc7be0b68220d14d47d6647d2f85b2771cb35ea847aa1"}, + {file = "websockets-14.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7048eb4415d46368ef29d32133134c513f507fff7d953c18c91104738a68c3b3"}, + {file = "websockets-14.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6cf0ad281c979306a6a34242b371e90e891bce504509fb6bb5246bbbf31e7b6"}, + {file = "websockets-14.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:cc1fc87428c1d18b643479caa7b15db7d544652e5bf610513d4a3478dbe823d0"}, + {file = "websockets-14.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:f95ba34d71e2fa0c5d225bde3b3bdb152e957150100e75c86bc7f3964c450d89"}, + {file = "websockets-14.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9481a6de29105d73cf4515f2bef8eb71e17ac184c19d0b9918a3701c6c9c4f23"}, + {file = "websockets-14.1-cp311-cp311-win32.whl", hash = "sha256:368a05465f49c5949e27afd6fbe0a77ce53082185bbb2ac096a3a8afaf4de52e"}, + {file = "websockets-14.1-cp311-cp311-win_amd64.whl", hash = "sha256:6d24fc337fc055c9e83414c94e1ee0dee902a486d19d2a7f0929e49d7d604b09"}, + {file = "websockets-14.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:ed907449fe5e021933e46a3e65d651f641975a768d0649fee59f10c2985529ed"}, + {file = "websockets-14.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:87e31011b5c14a33b29f17eb48932e63e1dcd3fa31d72209848652310d3d1f0d"}, + {file = "websockets-14.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bc6ccf7d54c02ae47a48ddf9414c54d48af9c01076a2e1023e3b486b6e72c707"}, + {file = "websockets-14.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9777564c0a72a1d457f0848977a1cbe15cfa75fa2f67ce267441e465717dcf1a"}, + {file = "websockets-14.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a655bde548ca98f55b43711b0ceefd2a88a71af6350b0c168aa77562104f3f45"}, + {file = "websockets-14.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a3dfff83ca578cada2d19e665e9c8368e1598d4e787422a460ec70e531dbdd58"}, + {file = "websockets-14.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6a6c9bcf7cdc0fd41cc7b7944447982e8acfd9f0d560ea6d6845428ed0562058"}, + {file = "websockets-14.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:4b6caec8576e760f2c7dd878ba817653144d5f369200b6ddf9771d64385b84d4"}, + {file = "websockets-14.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:eb6d38971c800ff02e4a6afd791bbe3b923a9a57ca9aeab7314c21c84bf9ff05"}, + {file = "websockets-14.1-cp312-cp312-win32.whl", hash = "sha256:1d045cbe1358d76b24d5e20e7b1878efe578d9897a25c24e6006eef788c0fdf0"}, + {file = "websockets-14.1-cp312-cp312-win_amd64.whl", hash = "sha256:90f4c7a069c733d95c308380aae314f2cb45bd8a904fb03eb36d1a4983a4993f"}, + {file = "websockets-14.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:3630b670d5057cd9e08b9c4dab6493670e8e762a24c2c94ef312783870736ab9"}, + {file = "websockets-14.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:36ebd71db3b89e1f7b1a5deaa341a654852c3518ea7a8ddfdf69cc66acc2db1b"}, + {file = "websockets-14.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5b918d288958dc3fa1c5a0b9aa3256cb2b2b84c54407f4813c45d52267600cd3"}, + {file = "websockets-14.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:00fe5da3f037041da1ee0cf8e308374e236883f9842c7c465aa65098b1c9af59"}, + {file = "websockets-14.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8149a0f5a72ca36720981418eeffeb5c2729ea55fa179091c81a0910a114a5d2"}, + {file = "websockets-14.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77569d19a13015e840b81550922056acabc25e3f52782625bc6843cfa034e1da"}, + {file = "websockets-14.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:cf5201a04550136ef870aa60ad3d29d2a59e452a7f96b94193bee6d73b8ad9a9"}, + {file = "websockets-14.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:88cf9163ef674b5be5736a584c999e98daf3aabac6e536e43286eb74c126b9c7"}, + {file = "websockets-14.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:836bef7ae338a072e9d1863502026f01b14027250a4545672673057997d5c05a"}, + {file = "websockets-14.1-cp313-cp313-win32.whl", hash = "sha256:0d4290d559d68288da9f444089fd82490c8d2744309113fc26e2da6e48b65da6"}, + {file = "websockets-14.1-cp313-cp313-win_amd64.whl", hash = "sha256:8621a07991add373c3c5c2cf89e1d277e49dc82ed72c75e3afc74bd0acc446f0"}, + {file = "websockets-14.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:01bb2d4f0a6d04538d3c5dfd27c0643269656c28045a53439cbf1c004f90897a"}, + {file = "websockets-14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:414ffe86f4d6f434a8c3b7913655a1a5383b617f9bf38720e7c0799fac3ab1c6"}, + {file = "websockets-14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8fda642151d5affdee8a430bd85496f2e2517be3a2b9d2484d633d5712b15c56"}, + {file = "websockets-14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd7c11968bc3860d5c78577f0dbc535257ccec41750675d58d8dc66aa47fe52c"}, + {file = "websockets-14.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a032855dc7db987dff813583d04f4950d14326665d7e714d584560b140ae6b8b"}, + {file = "websockets-14.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b7e7ea2f782408c32d86b87a0d2c1fd8871b0399dd762364c731d86c86069a78"}, + {file = "websockets-14.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:39450e6215f7d9f6f7bc2a6da21d79374729f5d052333da4d5825af8a97e6735"}, + {file = "websockets-14.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ceada5be22fa5a5a4cdeec74e761c2ee7db287208f54c718f2df4b7e200b8d4a"}, + {file = "websockets-14.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:3fc753451d471cff90b8f467a1fc0ae64031cf2d81b7b34e1811b7e2691bc4bc"}, + {file = "websockets-14.1-cp39-cp39-win32.whl", hash = "sha256:14839f54786987ccd9d03ed7f334baec0f02272e7ec4f6e9d427ff584aeea8b4"}, + {file = "websockets-14.1-cp39-cp39-win_amd64.whl", hash = "sha256:d9fd19ecc3a4d5ae82ddbfb30962cf6d874ff943e56e0c81f5169be2fda62979"}, + {file = "websockets-14.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:e5dc25a9dbd1a7f61eca4b7cb04e74ae4b963d658f9e4f9aad9cd00b688692c8"}, + {file = "websockets-14.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:04a97aca96ca2acedf0d1f332c861c5a4486fdcba7bcef35873820f940c4231e"}, + {file = "websockets-14.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:df174ece723b228d3e8734a6f2a6febbd413ddec39b3dc592f5a4aa0aff28098"}, + {file = "websockets-14.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:034feb9f4286476f273b9a245fb15f02c34d9586a5bc936aff108c3ba1b21beb"}, + {file = "websockets-14.1-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:660c308dabd2b380807ab64b62985eaccf923a78ebc572bd485375b9ca2b7dc7"}, + {file = "websockets-14.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:5a42d3ecbb2db5080fc578314439b1d79eef71d323dc661aa616fb492436af5d"}, + {file = "websockets-14.1-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:ddaa4a390af911da6f680be8be4ff5aaf31c4c834c1a9147bc21cbcbca2d4370"}, + {file = "websockets-14.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:a4c805c6034206143fbabd2d259ec5e757f8b29d0a2f0bf3d2fe5d1f60147a4a"}, + {file = "websockets-14.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:205f672a6c2c671a86d33f6d47c9b35781a998728d2c7c2a3e1cf3333fcb62b7"}, + {file = "websockets-14.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5ef440054124728cc49b01c33469de06755e5a7a4e83ef61934ad95fc327fbb0"}, + {file = "websockets-14.1-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e7591d6f440af7f73c4bd9404f3772bfee064e639d2b6cc8c94076e71b2471c1"}, + {file = "websockets-14.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:25225cc79cfebc95ba1d24cd3ab86aaa35bcd315d12fa4358939bd55e9bd74a5"}, + {file = "websockets-14.1-py3-none-any.whl", hash = "sha256:4d4fc827a20abe6d544a119896f6b78ee13fe81cbfef416f3f2ddf09a03f0e2e"}, + {file = "websockets-14.1.tar.gz", hash = "sha256:398b10c77d471c0aab20a845e7a60076b6390bfdaac7a6d2edb0d2c59d75e8d8"}, ] [[package]] name = "wheel" -version = "0.43.0" +version = "0.45.1" 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.45.1-py3-none-any.whl", hash = "sha256:708e7481cc80179af0e556bbf0cc00b8444c7321e2700b8d8580231d13017248"}, + {file = "wheel-0.45.1.tar.gz", hash = "sha256:661e1abd9198507b1409a20c02106d9670b2576e916d58f520316666abca6729"}, ] [package.extras] @@ -2851,81 +2968,76 @@ test = ["pytest (>=6.0.0)", "setuptools (>=65)"] [[package]] name = "wrapt" -version = "1.16.0" +version = "1.17.0" description = "Module for decorators, wrappers and monkey patching." optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "wrapt-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ffa565331890b90056c01db69c0fe634a776f8019c143a5ae265f9c6bc4bd6d4"}, - {file = "wrapt-1.16.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e4fdb9275308292e880dcbeb12546df7f3e0f96c6b41197e0cf37d2826359020"}, - {file = "wrapt-1.16.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb2dee3874a500de01c93d5c71415fcaef1d858370d405824783e7a8ef5db440"}, - {file = "wrapt-1.16.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2a88e6010048489cda82b1326889ec075a8c856c2e6a256072b28eaee3ccf487"}, - {file = "wrapt-1.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac83a914ebaf589b69f7d0a1277602ff494e21f4c2f743313414378f8f50a4cf"}, - {file = "wrapt-1.16.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:73aa7d98215d39b8455f103de64391cb79dfcad601701a3aa0dddacf74911d72"}, - {file = "wrapt-1.16.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:807cc8543a477ab7422f1120a217054f958a66ef7314f76dd9e77d3f02cdccd0"}, - {file = "wrapt-1.16.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bf5703fdeb350e36885f2875d853ce13172ae281c56e509f4e6eca049bdfb136"}, - {file = "wrapt-1.16.0-cp310-cp310-win32.whl", hash = "sha256:f6b2d0c6703c988d334f297aa5df18c45e97b0af3679bb75059e0e0bd8b1069d"}, - {file = "wrapt-1.16.0-cp310-cp310-win_amd64.whl", hash = "sha256:decbfa2f618fa8ed81c95ee18a387ff973143c656ef800c9f24fb7e9c16054e2"}, - {file = "wrapt-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1a5db485fe2de4403f13fafdc231b0dbae5eca4359232d2efc79025527375b09"}, - {file = "wrapt-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:75ea7d0ee2a15733684badb16de6794894ed9c55aa5e9903260922f0482e687d"}, - {file = "wrapt-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a452f9ca3e3267cd4d0fcf2edd0d035b1934ac2bd7e0e57ac91ad6b95c0c6389"}, - {file = "wrapt-1.16.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:43aa59eadec7890d9958748db829df269f0368521ba6dc68cc172d5d03ed8060"}, - {file = "wrapt-1.16.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72554a23c78a8e7aa02abbd699d129eead8b147a23c56e08d08dfc29cfdddca1"}, - {file = "wrapt-1.16.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:d2efee35b4b0a347e0d99d28e884dfd82797852d62fcd7ebdeee26f3ceb72cf3"}, - {file = "wrapt-1.16.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:6dcfcffe73710be01d90cae08c3e548d90932d37b39ef83969ae135d36ef3956"}, - {file = "wrapt-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:eb6e651000a19c96f452c85132811d25e9264d836951022d6e81df2fff38337d"}, - {file = "wrapt-1.16.0-cp311-cp311-win32.whl", hash = "sha256:66027d667efe95cc4fa945af59f92c5a02c6f5bb6012bff9e60542c74c75c362"}, - {file = "wrapt-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:aefbc4cb0a54f91af643660a0a150ce2c090d3652cf4052a5397fb2de549cd89"}, - {file = "wrapt-1.16.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:5eb404d89131ec9b4f748fa5cfb5346802e5ee8836f57d516576e61f304f3b7b"}, - {file = "wrapt-1.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9090c9e676d5236a6948330e83cb89969f433b1943a558968f659ead07cb3b36"}, - {file = "wrapt-1.16.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94265b00870aa407bd0cbcfd536f17ecde43b94fb8d228560a1e9d3041462d73"}, - {file = "wrapt-1.16.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f2058f813d4f2b5e3a9eb2eb3faf8f1d99b81c3e51aeda4b168406443e8ba809"}, - {file = "wrapt-1.16.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:98b5e1f498a8ca1858a1cdbffb023bfd954da4e3fa2c0cb5853d40014557248b"}, - {file = "wrapt-1.16.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:14d7dc606219cdd7405133c713f2c218d4252f2a469003f8c46bb92d5d095d81"}, - {file = "wrapt-1.16.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:49aac49dc4782cb04f58986e81ea0b4768e4ff197b57324dcbd7699c5dfb40b9"}, - {file = "wrapt-1.16.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:418abb18146475c310d7a6dc71143d6f7adec5b004ac9ce08dc7a34e2babdc5c"}, - {file = "wrapt-1.16.0-cp312-cp312-win32.whl", hash = "sha256:685f568fa5e627e93f3b52fda002c7ed2fa1800b50ce51f6ed1d572d8ab3e7fc"}, - {file = "wrapt-1.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:dcdba5c86e368442528f7060039eda390cc4091bfd1dca41e8046af7c910dda8"}, - {file = "wrapt-1.16.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d462f28826f4657968ae51d2181a074dfe03c200d6131690b7d65d55b0f360f8"}, - {file = "wrapt-1.16.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a33a747400b94b6d6b8a165e4480264a64a78c8a4c734b62136062e9a248dd39"}, - {file = "wrapt-1.16.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b3646eefa23daeba62643a58aac816945cadc0afaf21800a1421eeba5f6cfb9c"}, - {file = "wrapt-1.16.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ebf019be5c09d400cf7b024aa52b1f3aeebeff51550d007e92c3c1c4afc2a40"}, - {file = "wrapt-1.16.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:0d2691979e93d06a95a26257adb7bfd0c93818e89b1406f5a28f36e0d8c1e1fc"}, - {file = "wrapt-1.16.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:1acd723ee2a8826f3d53910255643e33673e1d11db84ce5880675954183ec47e"}, - {file = "wrapt-1.16.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:bc57efac2da352a51cc4658878a68d2b1b67dbe9d33c36cb826ca449d80a8465"}, - {file = "wrapt-1.16.0-cp36-cp36m-win32.whl", hash = "sha256:da4813f751142436b075ed7aa012a8778aa43a99f7b36afe9b742d3ed8bdc95e"}, - {file = "wrapt-1.16.0-cp36-cp36m-win_amd64.whl", hash = "sha256:6f6eac2360f2d543cc875a0e5efd413b6cbd483cb3ad7ebf888884a6e0d2e966"}, - {file = "wrapt-1.16.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a0ea261ce52b5952bf669684a251a66df239ec6d441ccb59ec7afa882265d593"}, - {file = "wrapt-1.16.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7bd2d7ff69a2cac767fbf7a2b206add2e9a210e57947dd7ce03e25d03d2de292"}, - {file = "wrapt-1.16.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9159485323798c8dc530a224bd3ffcf76659319ccc7bbd52e01e73bd0241a0c5"}, - {file = "wrapt-1.16.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a86373cf37cd7764f2201b76496aba58a52e76dedfaa698ef9e9688bfd9e41cf"}, - {file = "wrapt-1.16.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:73870c364c11f03ed072dda68ff7aea6d2a3a5c3fe250d917a429c7432e15228"}, - {file = "wrapt-1.16.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:b935ae30c6e7400022b50f8d359c03ed233d45b725cfdd299462f41ee5ffba6f"}, - {file = "wrapt-1.16.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:db98ad84a55eb09b3c32a96c576476777e87c520a34e2519d3e59c44710c002c"}, - {file = "wrapt-1.16.0-cp37-cp37m-win32.whl", hash = "sha256:9153ed35fc5e4fa3b2fe97bddaa7cbec0ed22412b85bcdaf54aeba92ea37428c"}, - {file = "wrapt-1.16.0-cp37-cp37m-win_amd64.whl", hash = "sha256:66dfbaa7cfa3eb707bbfcd46dab2bc6207b005cbc9caa2199bcbc81d95071a00"}, - {file = "wrapt-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1dd50a2696ff89f57bd8847647a1c363b687d3d796dc30d4dd4a9d1689a706f0"}, - {file = "wrapt-1.16.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:44a2754372e32ab315734c6c73b24351d06e77ffff6ae27d2ecf14cf3d229202"}, - {file = "wrapt-1.16.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e9723528b9f787dc59168369e42ae1c3b0d3fadb2f1a71de14531d321ee05b0"}, - {file = "wrapt-1.16.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dbed418ba5c3dce92619656802cc5355cb679e58d0d89b50f116e4a9d5a9603e"}, - {file = "wrapt-1.16.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:941988b89b4fd6b41c3f0bfb20e92bd23746579736b7343283297c4c8cbae68f"}, - {file = "wrapt-1.16.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:6a42cd0cfa8ffc1915aef79cb4284f6383d8a3e9dcca70c445dcfdd639d51267"}, - {file = "wrapt-1.16.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:1ca9b6085e4f866bd584fb135a041bfc32cab916e69f714a7d1d397f8c4891ca"}, - {file = "wrapt-1.16.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d5e49454f19ef621089e204f862388d29e6e8d8b162efce05208913dde5b9ad6"}, - {file = "wrapt-1.16.0-cp38-cp38-win32.whl", hash = "sha256:c31f72b1b6624c9d863fc095da460802f43a7c6868c5dda140f51da24fd47d7b"}, - {file = "wrapt-1.16.0-cp38-cp38-win_amd64.whl", hash = "sha256:490b0ee15c1a55be9c1bd8609b8cecd60e325f0575fc98f50058eae366e01f41"}, - {file = "wrapt-1.16.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9b201ae332c3637a42f02d1045e1d0cccfdc41f1f2f801dafbaa7e9b4797bfc2"}, - {file = "wrapt-1.16.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2076fad65c6736184e77d7d4729b63a6d1ae0b70da4868adeec40989858eb3fb"}, - {file = "wrapt-1.16.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c5cd603b575ebceca7da5a3a251e69561bec509e0b46e4993e1cac402b7247b8"}, - {file = "wrapt-1.16.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b47cfad9e9bbbed2339081f4e346c93ecd7ab504299403320bf85f7f85c7d46c"}, - {file = "wrapt-1.16.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f8212564d49c50eb4565e502814f694e240c55551a5f1bc841d4fcaabb0a9b8a"}, - {file = "wrapt-1.16.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5f15814a33e42b04e3de432e573aa557f9f0f56458745c2074952f564c50e664"}, - {file = "wrapt-1.16.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:db2e408d983b0e61e238cf579c09ef7020560441906ca990fe8412153e3b291f"}, - {file = "wrapt-1.16.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:edfad1d29c73f9b863ebe7082ae9321374ccb10879eeabc84ba3b69f2579d537"}, - {file = "wrapt-1.16.0-cp39-cp39-win32.whl", hash = "sha256:ed867c42c268f876097248e05b6117a65bcd1e63b779e916fe2e33cd6fd0d3c3"}, - {file = "wrapt-1.16.0-cp39-cp39-win_amd64.whl", hash = "sha256:eb1b046be06b0fce7249f1d025cd359b4b80fc1c3e24ad9eca33e0dcdb2e4a35"}, - {file = "wrapt-1.16.0-py3-none-any.whl", hash = "sha256:6906c4100a8fcbf2fa735f6059214bb13b97f75b1a61777fcf6432121ef12ef1"}, - {file = "wrapt-1.16.0.tar.gz", hash = "sha256:5f370f952971e7d17c7d1ead40e49f32345a7f7a5373571ef44d800d06b1899d"}, + {file = "wrapt-1.17.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2a0c23b8319848426f305f9cb0c98a6e32ee68a36264f45948ccf8e7d2b941f8"}, + {file = "wrapt-1.17.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1ca5f060e205f72bec57faae5bd817a1560fcfc4af03f414b08fa29106b7e2d"}, + {file = "wrapt-1.17.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e185ec6060e301a7e5f8461c86fb3640a7beb1a0f0208ffde7a65ec4074931df"}, + {file = "wrapt-1.17.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bb90765dd91aed05b53cd7a87bd7f5c188fcd95960914bae0d32c5e7f899719d"}, + {file = "wrapt-1.17.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:879591c2b5ab0a7184258274c42a126b74a2c3d5a329df16d69f9cee07bba6ea"}, + {file = "wrapt-1.17.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:fce6fee67c318fdfb7f285c29a82d84782ae2579c0e1b385b7f36c6e8074fffb"}, + {file = "wrapt-1.17.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0698d3a86f68abc894d537887b9bbf84d29bcfbc759e23f4644be27acf6da301"}, + {file = "wrapt-1.17.0-cp310-cp310-win32.whl", hash = "sha256:69d093792dc34a9c4c8a70e4973a3361c7a7578e9cd86961b2bbf38ca71e4e22"}, + {file = "wrapt-1.17.0-cp310-cp310-win_amd64.whl", hash = "sha256:f28b29dc158ca5d6ac396c8e0a2ef45c4e97bb7e65522bfc04c989e6fe814575"}, + {file = "wrapt-1.17.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:74bf625b1b4caaa7bad51d9003f8b07a468a704e0644a700e936c357c17dd45a"}, + {file = "wrapt-1.17.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0f2a28eb35cf99d5f5bd12f5dd44a0f41d206db226535b37b0c60e9da162c3ed"}, + {file = "wrapt-1.17.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:81b1289e99cf4bad07c23393ab447e5e96db0ab50974a280f7954b071d41b489"}, + {file = "wrapt-1.17.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f2939cd4a2a52ca32bc0b359015718472d7f6de870760342e7ba295be9ebaf9"}, + {file = "wrapt-1.17.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6a9653131bda68a1f029c52157fd81e11f07d485df55410401f745007bd6d339"}, + {file = "wrapt-1.17.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:4e4b4385363de9052dac1a67bfb535c376f3d19c238b5f36bddc95efae15e12d"}, + {file = "wrapt-1.17.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bdf62d25234290db1837875d4dceb2151e4ea7f9fff2ed41c0fde23ed542eb5b"}, + {file = "wrapt-1.17.0-cp311-cp311-win32.whl", hash = "sha256:5d8fd17635b262448ab8f99230fe4dac991af1dabdbb92f7a70a6afac8a7e346"}, + {file = "wrapt-1.17.0-cp311-cp311-win_amd64.whl", hash = "sha256:92a3d214d5e53cb1db8b015f30d544bc9d3f7179a05feb8f16df713cecc2620a"}, + {file = "wrapt-1.17.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:89fc28495896097622c3fc238915c79365dd0ede02f9a82ce436b13bd0ab7569"}, + {file = "wrapt-1.17.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:875d240fdbdbe9e11f9831901fb8719da0bd4e6131f83aa9f69b96d18fae7504"}, + {file = "wrapt-1.17.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e5ed16d95fd142e9c72b6c10b06514ad30e846a0d0917ab406186541fe68b451"}, + {file = "wrapt-1.17.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18b956061b8db634120b58f668592a772e87e2e78bc1f6a906cfcaa0cc7991c1"}, + {file = "wrapt-1.17.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:daba396199399ccabafbfc509037ac635a6bc18510ad1add8fd16d4739cdd106"}, + {file = "wrapt-1.17.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:4d63f4d446e10ad19ed01188d6c1e1bb134cde8c18b0aa2acfd973d41fcc5ada"}, + {file = "wrapt-1.17.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8a5e7cc39a45fc430af1aefc4d77ee6bad72c5bcdb1322cfde852c15192b8bd4"}, + {file = "wrapt-1.17.0-cp312-cp312-win32.whl", hash = "sha256:0a0a1a1ec28b641f2a3a2c35cbe86c00051c04fffcfcc577ffcdd707df3f8635"}, + {file = "wrapt-1.17.0-cp312-cp312-win_amd64.whl", hash = "sha256:3c34f6896a01b84bab196f7119770fd8466c8ae3dfa73c59c0bb281e7b588ce7"}, + {file = "wrapt-1.17.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:714c12485aa52efbc0fc0ade1e9ab3a70343db82627f90f2ecbc898fdf0bb181"}, + {file = "wrapt-1.17.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:da427d311782324a376cacb47c1a4adc43f99fd9d996ffc1b3e8529c4074d393"}, + {file = "wrapt-1.17.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba1739fb38441a27a676f4de4123d3e858e494fac05868b7a281c0a383c098f4"}, + {file = "wrapt-1.17.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e711fc1acc7468463bc084d1b68561e40d1eaa135d8c509a65dd534403d83d7b"}, + {file = "wrapt-1.17.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:140ea00c87fafc42739bd74a94a5a9003f8e72c27c47cd4f61d8e05e6dec8721"}, + {file = "wrapt-1.17.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:73a96fd11d2b2e77d623a7f26e004cc31f131a365add1ce1ce9a19e55a1eef90"}, + {file = "wrapt-1.17.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0b48554952f0f387984da81ccfa73b62e52817a4386d070c75e4db7d43a28c4a"}, + {file = "wrapt-1.17.0-cp313-cp313-win32.whl", hash = "sha256:498fec8da10e3e62edd1e7368f4b24aa362ac0ad931e678332d1b209aec93045"}, + {file = "wrapt-1.17.0-cp313-cp313-win_amd64.whl", hash = "sha256:fd136bb85f4568fffca995bd3c8d52080b1e5b225dbf1c2b17b66b4c5fa02838"}, + {file = "wrapt-1.17.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:17fcf043d0b4724858f25b8826c36e08f9fb2e475410bece0ec44a22d533da9b"}, + {file = "wrapt-1.17.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e4a557d97f12813dc5e18dad9fa765ae44ddd56a672bb5de4825527c847d6379"}, + {file = "wrapt-1.17.0-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0229b247b0fc7dee0d36176cbb79dbaf2a9eb7ecc50ec3121f40ef443155fb1d"}, + {file = "wrapt-1.17.0-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8425cfce27b8b20c9b89d77fb50e368d8306a90bf2b6eef2cdf5cd5083adf83f"}, + {file = "wrapt-1.17.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:9c900108df470060174108012de06d45f514aa4ec21a191e7ab42988ff42a86c"}, + {file = "wrapt-1.17.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:4e547b447073fc0dbfcbff15154c1be8823d10dab4ad401bdb1575e3fdedff1b"}, + {file = "wrapt-1.17.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:914f66f3b6fc7b915d46c1cc424bc2441841083de01b90f9e81109c9759e43ab"}, + {file = "wrapt-1.17.0-cp313-cp313t-win32.whl", hash = "sha256:a4192b45dff127c7d69b3bdfb4d3e47b64179a0b9900b6351859f3001397dabf"}, + {file = "wrapt-1.17.0-cp313-cp313t-win_amd64.whl", hash = "sha256:4f643df3d4419ea3f856c5c3f40fec1d65ea2e89ec812c83f7767c8730f9827a"}, + {file = "wrapt-1.17.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:69c40d4655e078ede067a7095544bcec5a963566e17503e75a3a3e0fe2803b13"}, + {file = "wrapt-1.17.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2f495b6754358979379f84534f8dd7a43ff8cff2558dcdea4a148a6e713a758f"}, + {file = "wrapt-1.17.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:baa7ef4e0886a6f482e00d1d5bcd37c201b383f1d314643dfb0367169f94f04c"}, + {file = "wrapt-1.17.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8fc931382e56627ec4acb01e09ce66e5c03c384ca52606111cee50d931a342d"}, + {file = "wrapt-1.17.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:8f8909cdb9f1b237786c09a810e24ee5e15ef17019f7cecb207ce205b9b5fcce"}, + {file = "wrapt-1.17.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:ad47b095f0bdc5585bced35bd088cbfe4177236c7df9984b3cc46b391cc60627"}, + {file = "wrapt-1.17.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:948a9bd0fb2c5120457b07e59c8d7210cbc8703243225dbd78f4dfc13c8d2d1f"}, + {file = "wrapt-1.17.0-cp38-cp38-win32.whl", hash = "sha256:5ae271862b2142f4bc687bdbfcc942e2473a89999a54231aa1c2c676e28f29ea"}, + {file = "wrapt-1.17.0-cp38-cp38-win_amd64.whl", hash = "sha256:f335579a1b485c834849e9075191c9898e0731af45705c2ebf70e0cd5d58beed"}, + {file = "wrapt-1.17.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:d751300b94e35b6016d4b1e7d0e7bbc3b5e1751e2405ef908316c2a9024008a1"}, + {file = "wrapt-1.17.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7264cbb4a18dc4acfd73b63e4bcfec9c9802614572025bdd44d0721983fc1d9c"}, + {file = "wrapt-1.17.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:33539c6f5b96cf0b1105a0ff4cf5db9332e773bb521cc804a90e58dc49b10578"}, + {file = "wrapt-1.17.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c30970bdee1cad6a8da2044febd824ef6dc4cc0b19e39af3085c763fdec7de33"}, + {file = "wrapt-1.17.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:bc7f729a72b16ee21795a943f85c6244971724819819a41ddbaeb691b2dd85ad"}, + {file = "wrapt-1.17.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:6ff02a91c4fc9b6a94e1c9c20f62ea06a7e375f42fe57587f004d1078ac86ca9"}, + {file = "wrapt-1.17.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:2dfb7cff84e72e7bf975b06b4989477873dcf160b2fd89959c629535df53d4e0"}, + {file = "wrapt-1.17.0-cp39-cp39-win32.whl", hash = "sha256:2399408ac33ffd5b200480ee858baa58d77dd30e0dd0cab6a8a9547135f30a88"}, + {file = "wrapt-1.17.0-cp39-cp39-win_amd64.whl", hash = "sha256:4f763a29ee6a20c529496a20a7bcb16a73de27f5da6a843249c7047daf135977"}, + {file = "wrapt-1.17.0-py3-none-any.whl", hash = "sha256:d2c63b93548eda58abf5188e505ffed0229bf675f7c3090f8e36ad55b8cbc371"}, + {file = "wrapt-1.17.0.tar.gz", hash = "sha256:16187aa2317c731170a88ef35e8937ae0f533c402872c1ee5e6d079fcf320801"}, ] [[package]] @@ -2944,20 +3056,24 @@ h11 = ">=0.9.0,<1" [[package]] name = "zipp" -version = "3.19.2" +version = "3.21.0" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "zipp-3.19.2-py3-none-any.whl", hash = "sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c"}, - {file = "zipp-3.19.2.tar.gz", hash = "sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19"}, + {file = "zipp-3.21.0-py3-none-any.whl", hash = "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931"}, + {file = "zipp-3.21.0.tar.gz", hash = "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4"}, ] [package.extras] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] +cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] +type = ["pytest-mypy"] [metadata] lock-version = "2.0" -python-versions = "^3.8" -content-hash = "c17ccb320267b8b3a56c698bd07c2b02dda13824d4bf4b1657de752ad361e643" +python-versions = "^3.9" +content-hash = "d62cd1897d8f73e9aad9e907beb82be509dc5e33d8f37b36ebf26ad1f3075a9f" diff --git a/pyproject.toml b/pyproject.toml index 656ff091a..8fd1886f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,35 +1,27 @@ [tool.poetry] name = "reflex" -version = "0.5.9" +version = "0.6.8dev1" description = "Web apps in pure Python." license = "Apache-2.0" authors = [ - "Nikhil Rao ", - "Alek Petuskey ", - "Masen Furer ", - "Elijah Ahianyo ", - "Thomas Brandého ", + "Nikhil Rao ", + "Alek Petuskey ", + "Masen Furer ", + "Elijah Ahianyo ", + "Thomas Brandého ", ] readme = "README.md" homepage = "https://reflex.dev" repository = "https://github.com/reflex-dev/reflex" documentation = "https://reflex.dev/docs/getting-started/introduction" -keywords = [ - "web", - "framework", -] -classifiers = [ - "Development Status :: 4 - Beta", -] -packages = [ - {include = "reflex"} -] +keywords = ["web", "framework"] +classifiers = ["Development Status :: 4 - Beta"] +packages = [{ include = "reflex" }] [tool.poetry.dependencies] -python = "^3.8" -dill = ">=0.3.8,<0.4" -fastapi = ">=0.96.0,<0.111.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,<7.0" pydantic = ">=1.10.2,<3.0" @@ -40,49 +32,47 @@ rich = ">=13.0.0,<14.0" sqlmodel = ">=0.0.14,<0.1" typer = ">=0.4.2,<1.0" uvicorn = ">=0.20.0" -watchdog = ">=2.3.1,<5.0" -watchfiles = ">=0.19.0,<1.0" starlette-admin = ">=0.11.0,<1.0" alembic = ">=1.11.1,<2.0" platformdirs = ">=3.10.0,<5.0" -distro = {version = ">=1.8.0,<2.0", platform = "linux"} +distro = { version = ">=1.8.0,<2.0", platform = "linux" } python-engineio = "!=4.6.0" wrapt = [ - {version = ">=1.14.0,<2.0", python = ">=3.11"}, - {version = ">=1.11.0,<2.0", python = "<3.11"}, + { version = ">=1.14.0,<2.0", python = ">=3.11" }, + { version = ">=1.11.0,<2.0", python = "<3.11" }, ] packaging = ">=23.1,<25.0" -reflex-hosting-cli = ">=0.1.2,<2.0" +reflex-hosting-cli = ">=0.1.29,<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.2" +setuptools = ">=75.0" httpx = ">=0.25.1,<1.0" -twine = ">=4.0.0,<6.0" +twine = ">=4.0.0,<7.0" tomlkit = ">=0.12.4,<1.0" lazy_loader = ">=0.4" +reflex-chakra = ">=0.6.0" +typing_extensions = ">=4.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" -ruff = "^0.4.9" -pandas = [ - {version = ">=2.1.1,<3.0", python = ">=3.9,<3.13"}, - {version = ">=1.5.3,<2.0", python = ">=3.8,<3.9"}, -] -pillow = [ - {version = ">=10.0.0,<11.0", python = ">=3.8,<4.0"} -] +pytest-asyncio = ">=0.24.0" +pytest-cov = ">=4.0.0,<7.0" +ruff = "0.8.2" +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" +pytest-benchmark = ">=4.0.0,<6.0" +playwright = ">=1.46.0" +pytest-playwright = ">=0.5.1" [tool.poetry.scripts] reflex = "reflex.reflex:cli" @@ -94,14 +84,24 @@ build-backend = "poetry.core.masonry.api" [tool.pyright] [tool.ruff] -target-version = "py38" -lint.select = ["B", "D", "E", "F", "I", "SIM", "W"] -lint.ignore = ["B008", "D203", "D205", "D213", "D401", "D406", "D407", "E501", "F403", "F405", "F541"] +target-version = "py39" +output-format = "concise" +lint.isort.split-on-trailing-comma = false +lint.select = ["B", "C4", "D", "E", "ERA", "F", "FURB", "I", "PERF", "PTH", "RUF", "SIM", "W"] +lint.ignore = ["B008", "D205", "E501", "F403", "SIM115", "RUF006", "RUF012"] lint.pydocstyle.convention = "google" [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"tests/*.py" = ["D100", "D103", "D104", "B018"] +"tests/*.py" = ["D100", "D103", "D104", "B018", "PERF"] "reflex/.templates/*.py" = ["D100", "D103", "D104"] "*.pyi" = ["D301", "D415", "D417", "D418", "E742"] "*/blank.py" = ["I001"] + +[tool.pytest.ini_options] +asyncio_default_fixture_loop_scope = "function" +asyncio_mode = "auto" + +[tool.codespell] +skip = "docs/*,*.html,examples/*, *.pyi" +ignore-words-list = "te, TreeE" \ No newline at end of file diff --git a/reflex/.templates/apps/demo/.gitignore b/reflex/.templates/apps/demo/.gitignore deleted file mode 100644 index eab0d4b05..000000000 --- a/reflex/.templates/apps/demo/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.db -*.py[cod] -.web -__pycache__/ \ No newline at end of file diff --git a/reflex/.templates/apps/demo/assets/favicon.ico b/reflex/.templates/apps/demo/assets/favicon.ico deleted file mode 100644 index 166ae995e..000000000 Binary files a/reflex/.templates/apps/demo/assets/favicon.ico and /dev/null differ diff --git a/reflex/.templates/apps/demo/assets/github.svg b/reflex/.templates/apps/demo/assets/github.svg deleted file mode 100644 index 61c9d791b..000000000 --- a/reflex/.templates/apps/demo/assets/github.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/assets/icon.svg b/reflex/.templates/apps/demo/assets/icon.svg deleted file mode 100644 index b9cc89da9..000000000 --- a/reflex/.templates/apps/demo/assets/icon.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/assets/logo.svg b/reflex/.templates/apps/demo/assets/logo.svg deleted file mode 100644 index 94fe1f511..000000000 --- a/reflex/.templates/apps/demo/assets/logo.svg +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/assets/paneleft.svg b/reflex/.templates/apps/demo/assets/paneleft.svg deleted file mode 100644 index ac9c5040a..000000000 --- a/reflex/.templates/apps/demo/assets/paneleft.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/reflex/.templates/apps/demo/code/__init__.py b/reflex/.templates/apps/demo/code/__init__.py deleted file mode 100644 index e1d286346..000000000 --- a/reflex/.templates/apps/demo/code/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Base template for Reflex.""" diff --git a/reflex/.templates/apps/demo/code/demo.py b/reflex/.templates/apps/demo/code/demo.py deleted file mode 100644 index bdb1a447d..000000000 --- a/reflex/.templates/apps/demo/code/demo.py +++ /dev/null @@ -1,127 +0,0 @@ -"""Welcome to Reflex! This file outlines the steps to create a basic app.""" - -from typing import Callable - -import reflex as rx - -from .pages import chatapp_page, datatable_page, forms_page, graphing_page, home_page -from .sidebar import sidebar -from .state import State -from .styles import * - -meta = [ - { - "name": "viewport", - "content": "width=device-width, shrink-to-fit=no, initial-scale=1", - }, -] - - -def template(main_content: Callable[[], rx.Component]) -> rx.Component: - """The template for each page of the app. - - Args: - main_content (Callable[[], rx.Component]): The main content of the page. - - Returns: - rx.Component: The template for each page of the app. - """ - menu_button = rx.chakra.box( - rx.chakra.menu( - rx.chakra.menu_button( - rx.chakra.icon( - tag="hamburger", - size="4em", - color=text_color, - ), - ), - rx.chakra.menu_list( - rx.chakra.menu_item(rx.chakra.link("Home", href="/", width="100%")), - rx.chakra.menu_divider(), - rx.chakra.menu_item( - rx.chakra.link( - "About", href="https://github.com/reflex-dev", width="100%" - ) - ), - rx.chakra.menu_item( - rx.chakra.link( - "Contact", href="mailto:founders@reflex.dev", width="100%" - ) - ), - ), - ), - position="fixed", - right="1.5em", - top="1.5em", - z_index="500", - ) - - return rx.chakra.hstack( - sidebar(), - main_content(), - rx.chakra.spacer(), - menu_button, - align_items="flex-start", - transition="left 0.5s, width 0.5s", - position="relative", - left=rx.cond(State.sidebar_displayed, "0px", f"-{sidebar_width}"), - ) - - -@rx.page("/", meta=meta) -@template -def home() -> rx.Component: - """Home page. - - Returns: - rx.Component: The home page. - """ - return home_page() - - -@rx.page("/forms", meta=meta) -@template -def forms() -> rx.Component: - """Forms page. - - Returns: - rx.Component: The settings page. - """ - return forms_page() - - -@rx.page("/graphing", meta=meta) -@template -def graphing() -> rx.Component: - """Graphing page. - - Returns: - rx.Component: The graphing page. - """ - return graphing_page() - - -@rx.page("/datatable", meta=meta) -@template -def datatable() -> rx.Component: - """Data Table page. - - Returns: - rx.Component: The chatapp page. - """ - return datatable_page() - - -@rx.page("/chatapp", meta=meta) -@template -def chatapp() -> rx.Component: - """Chatapp page. - - Returns: - rx.Component: The chatapp page. - """ - return chatapp_page() - - -# Create the app. -app = rx.App(style=base_style) diff --git a/reflex/.templates/apps/demo/code/pages/__init__.py b/reflex/.templates/apps/demo/code/pages/__init__.py deleted file mode 100644 index ab6df6e3a..000000000 --- a/reflex/.templates/apps/demo/code/pages/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""The pages of the app.""" - -from .chatapp import chatapp_page -from .datatable import datatable_page -from .forms import forms_page -from .graphing import graphing_page -from .home import home_page diff --git a/reflex/.templates/apps/demo/code/pages/chatapp.py b/reflex/.templates/apps/demo/code/pages/chatapp.py deleted file mode 100644 index acd11a599..000000000 --- a/reflex/.templates/apps/demo/code/pages/chatapp.py +++ /dev/null @@ -1,31 +0,0 @@ -"""The main Chat app.""" - -import reflex as rx - -from ..styles import * -from ..webui import styles -from ..webui.components import chat, modal, navbar, sidebar - - -def chatapp_page() -> rx.Component: - """The main app. - - Returns: - The UI for the main app. - """ - return rx.chakra.box( - rx.chakra.vstack( - navbar(), - chat.chat(), - chat.action_bar(), - sidebar(), - modal(), - bg=styles.bg_dark_color, - color=styles.text_light_color, - min_h="100vh", - align_items="stretch", - spacing="0", - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/pages/datatable.py b/reflex/.templates/apps/demo/code/pages/datatable.py deleted file mode 100644 index 53351ecf3..000000000 --- a/reflex/.templates/apps/demo/code/pages/datatable.py +++ /dev/null @@ -1,360 +0,0 @@ -"""The settings page for the template.""" - -from typing import Any - -import reflex as rx -from reflex.components.datadisplay.dataeditor import DataEditorTheme - -from ..styles import * -from ..webui.state import State - - -class DataTableState(State): - """Datatable state.""" - - cols: list[Any] = [ - {"title": "Title", "type": "str"}, - { - "title": "Name", - "type": "str", - "group": "Data", - "width": 300, - }, - { - "title": "Birth", - "type": "str", - "group": "Data", - "width": 150, - }, - { - "title": "Human", - "type": "bool", - "group": "Data", - "width": 80, - }, - { - "title": "House", - "type": "str", - "group": "Data", - }, - { - "title": "Wand", - "type": "str", - "group": "Data", - "width": 250, - }, - { - "title": "Patronus", - "type": "str", - "group": "Data", - }, - { - "title": "Blood status", - "type": "str", - "group": "Data", - "width": 200, - }, - ] - - data = [ - [ - "1", - "Harry James Potter", - "31 July 1980", - True, - "Gryffindor", - "11' Holly phoenix feather", - "Stag", - "Half-blood", - ], - [ - "2", - "Ronald Bilius Weasley", - "1 March 1980", - True, - "Gryffindor", - "12' Ash unicorn tail hair", - "Jack Russell terrier", - "Pure-blood", - ], - [ - "3", - "Hermione Jean Granger", - "19 September, 1979", - True, - "Gryffindor", - "10¾' vine wood dragon heartstring", - "Otter", - "Muggle-born", - ], - [ - "4", - "Albus Percival Wulfric Brian Dumbledore", - "Late August 1881", - True, - "Gryffindor", - "15' Elder Thestral tail hair core", - "Phoenix", - "Half-blood", - ], - [ - "5", - "Rubeus Hagrid", - "6 December 1928", - False, - "Gryffindor", - "16' Oak unknown core", - "None", - "Part-Human (Half-giant)", - ], - [ - "6", - "Fred Weasley", - "1 April, 1978", - True, - "Gryffindor", - "Unknown", - "Unknown", - "Pure-blood", - ], - [ - "7", - "George Weasley", - "1 April, 1978", - True, - "Gryffindor", - "Unknown", - "Unknown", - "Pure-blood", - ], - ] - - -code_show = """rx.chakra.hstack( - rx.chakra.divider(orientation="vertical", height="100vh", border="solid black 1px"), - rx.chakra.vstack( - rx.chakra.box( - rx.data_editor( - columns=DataTableState.cols, - data=DataTableState.data, - draw_focus_ring=True, - row_height=50, - smooth_scroll_x=True, - smooth_scroll_y=True, - column_select="single", - # style - theme=DataEditorTheme(**darkTheme), - width="80vw", - height="80vh", - ), - ), - rx.chakra.spacer(), - height="100vh", - spacing="25", - ), -)""" - -state_show = """class DataTableState(State): - cols: list[Any] = [ - {"title": "Title", "type": "str"}, - { - "title": "Name", - "type": "str", - "group": "Data", - "width": 300, - }, - { - "title": "Birth", - "type": "str", - "group": "Data", - "width": 150, - }, - { - "title": "Human", - "type": "bool", - "group": "Data", - "width": 80, - }, - { - "title": "House", - "type": "str", - "group": "Data", - }, - { - "title": "Wand", - "type": "str", - "group": "Data", - "width": 250, - }, - { - "title": "Patronus", - "type": "str", - "group": "Data", - }, - { - "title": "Blood status", - "type": "str", - "group": "Data", - "width": 200, - }, - ]""" - -data_show = """[ - ["1", "Harry James Potter", "31 July 1980", True, "Gryffindor", "11' Holly phoenix feather", "Stag", "Half-blood"], - ["2", "Ronald Bilius Weasley", "1 March 1980", True,"Gryffindor", "12' Ash unicorn tail hair", "Jack Russell terrier", "Pure-blood"], - ["3", "Hermione Jean Granger", "19 September, 1979", True, "Gryffindor", "10¾' vine wood dragon heartstring", "Otter", "Muggle-born"], - ["4", "Albus Percival Wulfric Brian Dumbledore", "Late August 1881", True, "Gryffindor", "15' Elder Thestral tail hair core", "Phoenix", "Half-blood"], - ["5", "Rubeus Hagrid", "6 December 1928", False, "Gryffindor", "16' Oak unknown core", "None", "Part-Human (Half-giant)"], - ["6", "Fred Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"], - ["7", "George Weasley", "1 April, 1978", True, "Gryffindor", "Unknown", "Unknown", "Pure-blood"], -]""" - - -darkTheme = { - "accent_color": "#8c96ff", - "accent_light": "rgba(202, 206, 255, 0.253)", - "text_dark": "#ffffff", - "text_medium": "#b8b8b8", - "text_light": "#a0a0a0", - "text_bubble": "#ffffff", - "bg_icon_header": "#b8b8b8", - "fg_icon_header": "#000000", - "text_header": "#a1a1a1", - "text_header_selected": "#000000", - "bg_cell": "#16161b", - "bg_cell_medium": "#202027", - "bg_header": "#212121", - "bg_header_has_focus": "#474747", - "bg_header_hovered": "#404040", - "bg_bubble": "#212121", - "bg_bubble_selected": "#000000", - "bg_search_result": "#423c24", - "border_color": "rgba(225,225,225,0.2)", - "drilldown_border": "rgba(225,225,225,0.4)", - "link_color": "#4F5DFF", - "header_font_style": "bold 14px", - "base_font_style": "13px", - "font_family": "Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif", -} - -darkTheme_show = """darkTheme={ - "accent_color": "#8c96ff", - "accent_light": "rgba(202, 206, 255, 0.253)", - "text_dark": "#ffffff", - "text_medium": "#b8b8b8", - "text_light": "#a0a0a0", - "text_bubble": "#ffffff", - "bg_icon_header": "#b8b8b8", - "fg_icon_header": "#000000", - "text_header": "#a1a1a1", - "text_header_selected": "#000000", - "bg_cell": "#16161b", - "bg_cell_medium": "#202027", - "bg_header": "#212121", - "bg_header_has_focus": "#474747", - "bg_header_hovered": "#404040", - "bg_bubble": "#212121", - "bg_bubble_selected": "#000000", - "bg_search_result": "#423c24", - "border_color": "rgba(225,225,225,0.2)", - "drilldown_border": "rgba(225,225,225,0.4)", - "link_color": "#4F5DFF", - "header_font_style": "bold 14px", - "base_font_style": "13px", - "font_family": "Inter, Roboto, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, noto, arial, sans-serif", -}""" - - -def datatable_page() -> rx.Component: - """The UI for the settings page. - - Returns: - rx.Component: The UI for the settings page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Data Table Demo", - font_size="3em", - ), - rx.chakra.hstack( - rx.chakra.vstack( - rx.chakra.box( - rx.data_editor( - columns=DataTableState.cols, - data=DataTableState.data, - draw_focus_ring=True, - row_height=50, - smooth_scroll_x=True, - smooth_scroll_y=True, - column_select="single", - # style - theme=DataEditorTheme(**darkTheme), - width="80vw", - ), - ), - rx.chakra.spacer(), - spacing="25", - ), - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("Data", style=tab_style), - rx.chakra.tab("State", style=tab_style), - rx.chakra.tab("Styling", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - code_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - data_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - state_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - darkTheme_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/pages/forms.py b/reflex/.templates/apps/demo/code/pages/forms.py deleted file mode 100644 index 6e3150067..000000000 --- a/reflex/.templates/apps/demo/code/pages/forms.py +++ /dev/null @@ -1,257 +0,0 @@ -"""The settings page for the template.""" - -import reflex as rx - -from ..states.form_state import FormState, UploadState -from ..styles import * - -forms_1_code = """rx.chakra.vstack( - rx.chakra.form( - rx.chakra.vstack( - rx.chakra.input( - placeholder="First Name", - id="first_name", - ), - rx.chakra.input( - placeholder="Last Name", id="last_name" - ), - rx.chakra.hstack( - rx.chakra.checkbox("Checked", id="check"), - rx.chakra.switch("Switched", id="switch"), - ), - rx.chakra.button("Submit", - type_="submit", - bg="#ecfdf5", - color="#047857", - border_radius="lg", - ), - ), - on_submit=FormState.handle_submit, - ), - rx.chakra.divider(), - rx.chakra.heading("Results"), - rx.chakra.text(FormState.form_data.to_string()), - width="100%", -)""" - -color = "rgb(107,99,246)" - -forms_1_state = """class FormState(rx.State): - - form_data: dict = {} - - def handle_submit(self, form_data: dict): - "Handle the form submit." - self.form_data = form_data""" - - -forms_2_code = """rx.chakra.vstack( - rx.upload( - rx.chakra.vstack( - rx.chakra.button( - "Select File", - color=color, - bg="white", - border=f"1px solid {color}", - ), - rx.chakra.text( - "Drag and drop files here or click to select files" - ), - ), - border=f"1px dotted {color}", - padding="5em", - ), - rx.chakra.hstack(rx.foreach(rx.selected_files, rx.chakra.text)), - rx.chakra.button( - "Upload", - on_click=lambda: UploadState.handle_upload( - rx.upload_files() - ), - ), - rx.chakra.button( - "Clear", - on_click=rx.clear_selected_files, - ), - rx.foreach( - UploadState.img, lambda img: rx.chakra.image(src=img, width="20%", height="auto",) - ), - padding="5em", - width="100%", -)""" - -forms_2_state = """class UploadState(State): - "The app state." - - # The images to show. - img: list[str] - - async def handle_upload( - self, files: list[rx.UploadFile] - ): - "Handle the upload of file(s). - - Args: - files: The uploaded files. - " - for file in files: - upload_data = await file.read() - outfile = rx.get_asset_path(file.filename) - # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) - - # Update the img var. - self.img.append(f"/{file.filename}")""" - - -def forms_page() -> rx.Component: - """The UI for the settings page. - - Returns: - rx.Component: The UI for the settings page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Forms Demo", - font_size="3em", - ), - rx.chakra.vstack( - rx.chakra.form( - rx.chakra.vstack( - rx.chakra.input( - placeholder="First Name", - id="first_name", - ), - rx.chakra.input(placeholder="Last Name", id="last_name"), - rx.chakra.hstack( - rx.chakra.checkbox("Checked", id="check"), - rx.chakra.switch("Switched", id="switch"), - ), - rx.chakra.button( - "Submit", - type_="submit", - bg="#ecfdf5", - color="#047857", - border_radius="lg", - ), - ), - on_submit=FormState.handle_submit, - ), - rx.chakra.divider(), - rx.chakra.heading("Results"), - rx.chakra.text(FormState.form_data.to_string()), - width="100%", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("State", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - forms_1_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - forms_1_state, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - rx.chakra.heading("Upload Example", font_size="3em"), - rx.chakra.text("Try uploading some images and see how they look."), - rx.chakra.vstack( - rx.upload( - rx.chakra.vstack( - rx.chakra.button( - "Select File", - color=color, - bg="white", - border=f"1px solid {color}", - ), - rx.chakra.text( - "Drag and drop files here or click to select files" - ), - ), - border=f"1px dotted {color}", - padding="5em", - ), - rx.chakra.hstack(rx.foreach(rx.selected_files, rx.chakra.text)), - rx.chakra.button( - "Upload", - on_click=lambda: UploadState.handle_upload(rx.upload_files()), - ), - rx.chakra.button( - "Clear", - on_click=rx.clear_selected_files, - ), - rx.foreach( - UploadState.img, - lambda img: rx.chakra.image( - src=img, - width="20%", - height="auto", - ), - ), - padding="5em", - width="100%", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("State", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - forms_2_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - forms_2_state, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/pages/graphing.py b/reflex/.templates/apps/demo/code/pages/graphing.py deleted file mode 100644 index e56af96c1..000000000 --- a/reflex/.templates/apps/demo/code/pages/graphing.py +++ /dev/null @@ -1,253 +0,0 @@ -"""The dashboard page for the template.""" - -import reflex as rx - -from ..states.pie_state import PieChartState -from ..styles import * - -data_1 = [ - {"name": "Page A", "uv": 4000, "pv": 2400, "amt": 2400}, - {"name": "Page B", "uv": 3000, "pv": 1398, "amt": 2210}, - {"name": "Page C", "uv": 2000, "pv": 9800, "amt": 2290}, - {"name": "Page D", "uv": 2780, "pv": 3908, "amt": 2000}, - {"name": "Page E", "uv": 1890, "pv": 4800, "amt": 2181}, - {"name": "Page F", "uv": 2390, "pv": 3800, "amt": 2500}, - {"name": "Page G", "uv": 3490, "pv": 4300, "amt": 2100}, -] -data_1_show = """[ - {"name": "Page A", "uv": 4000, "pv": 2400, "amt": 2400}, - {"name": "Page B", "uv": 3000, "pv": 1398, "amt": 2210}, - {"name": "Page C", "uv": 2000, "pv": 9800, "amt": 2290}, - {"name": "Page D", "uv": 2780, "pv": 3908, "amt": 2000}, - {"name": "Page E", "uv": 1890, "pv": 4800, "amt": 2181}, - {"name": "Page F", "uv": 2390, "pv": 3800, "amt": 2500}, - {"name": "Page G", "uv": 3490, "pv": 4300, "amt": 2100}, -]""" - - -graph_1_code = """rx.recharts.composed_chart( - rx.recharts.area( - data_key="uv", stroke="#8884d8", fill="#8884d8" - ), - rx.recharts.bar( - data_key="amt", bar_size=20, fill="#413ea0" - ), - rx.recharts.line( - data_key="pv", type_="monotone", stroke="#ff7300" - ), - rx.recharts.x_axis(data_key="name"), - rx.recharts.y_axis(), - rx.recharts.cartesian_grid(stroke_dasharray="3 3"), - rx.recharts.graphing_tooltip(), - data=data, -)""" - - -graph_2_code = """rx.recharts.pie_chart( - rx.recharts.pie( - data=PieChartState.resources, - data_key="count", - name_key="type_", - cx="50%", - cy="50%", - start_angle=180, - end_angle=0, - fill="#8884d8", - label=True, - ), - rx.recharts.graphing_tooltip(), -), -rx.chakra.vstack( - rx.foreach( - PieChartState.resource_types, - lambda type_, i: rx.chakra.hstack( - rx.chakra.button( - "-", - on_click=PieChartState.decrement(type_), - ), - rx.chakra.text( - type_, - PieChartState.resources[i]["count"], - ), - rx.chakra.button( - "+", - on_click=PieChartState.increment(type_), - ), - ), - ), -)""" - -graph_2_state = """class PieChartState(rx.State): - resources: list[dict[str, Any]] = [ - dict(type_="🏆", count=1), - dict(type_="🪵", count=1), - dict(type_="🥑", count=1), - dict(type_="🧱", count=1), - ] - - @rx.cached_var - def resource_types(self) -> list[str]: - return [r["type_"] for r in self.resources] - - def increment(self, type_: str): - for resource in self.resources: - if resource["type_"] == type_: - resource["count"] += 1 - break - - def decrement(self, type_: str): - for resource in self.resources: - if ( - resource["type_"] == type_ - and resource["count"] > 0 - ): - resource["count"] -= 1 - break -""" - - -def graphing_page() -> rx.Component: - """The UI for the dashboard page. - - Returns: - rx.Component: The UI for the dashboard page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Graphing Demo", - font_size="3em", - ), - rx.chakra.heading( - "Composed Chart", - font_size="2em", - ), - rx.chakra.stack( - rx.recharts.composed_chart( - rx.recharts.area(data_key="uv", stroke="#8884d8", fill="#8884d8"), - rx.recharts.bar(data_key="amt", bar_size=20, fill="#413ea0"), - rx.recharts.line(data_key="pv", type_="monotone", stroke="#ff7300"), - rx.recharts.x_axis(data_key="name"), - rx.recharts.y_axis(), - rx.recharts.cartesian_grid(stroke_dasharray="3 3"), - rx.recharts.graphing_tooltip(), - data=data_1, - # height="15em", - ), - width="100%", - height="20em", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("Data", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - graph_1_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - data_1_show, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - rx.chakra.heading("Interactive Example", font_size="2em"), - rx.chakra.hstack( - rx.recharts.pie_chart( - rx.recharts.pie( - data=PieChartState.resources, - data_key="count", - name_key="type_", - cx="50%", - cy="50%", - start_angle=180, - end_angle=0, - fill="#8884d8", - label=True, - ), - rx.recharts.graphing_tooltip(), - ), - rx.chakra.vstack( - rx.foreach( - PieChartState.resource_types, - lambda type_, i: rx.chakra.hstack( - rx.chakra.button( - "-", - on_click=PieChartState.decrement(type_), - ), - rx.chakra.text( - type_, - PieChartState.resources[i]["count"], - ), - rx.chakra.button( - "+", - on_click=PieChartState.increment(type_), - ), - ), - ), - ), - width="100%", - height="15em", - ), - rx.chakra.tabs( - rx.chakra.tab_list( - rx.chakra.tab("Code", style=tab_style), - rx.chakra.tab("State", style=tab_style), - padding_x=0, - ), - rx.chakra.tab_panels( - rx.chakra.tab_panel( - rx.code_block( - graph_2_code, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - rx.chakra.tab_panel( - rx.code_block( - graph_2_state, - language="python", - show_line_numbers=True, - ), - width="100%", - padding_x=0, - padding_y=".25em", - ), - width="100%", - ), - variant="unstyled", - color_scheme="purple", - align="end", - width="100%", - padding_top=".5em", - ), - style=template_content_style, - min_h="100vh", - ), - style=template_page_style, - min_h="100vh", - ) diff --git a/reflex/.templates/apps/demo/code/pages/home.py b/reflex/.templates/apps/demo/code/pages/home.py deleted file mode 100644 index 8d85e015b..000000000 --- a/reflex/.templates/apps/demo/code/pages/home.py +++ /dev/null @@ -1,56 +0,0 @@ -"""The home page of the app.""" - -import reflex as rx - -from ..styles import * - - -def home_page() -> rx.Component: - """The UI for the home page. - - Returns: - rx.Component: The UI for the home page. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.heading( - "Welcome to Reflex! 👋", - font_size="3em", - ), - rx.chakra.text( - "Reflex is an open-source app framework built specifically to allow you to build web apps in pure python. 👈 Select a demo from the sidebar to see some examples of what Reflex can do!", - ), - rx.chakra.heading( - "Things to check out:", - font_size="2em", - ), - rx.chakra.unordered_list( - rx.chakra.list_item( - "Take a look at ", - rx.chakra.link( - "reflex.dev", - href="https://reflex.dev", - color="rgb(107,99,246)", - ), - ), - rx.chakra.list_item( - "Check out our ", - rx.chakra.link( - "docs", - href="https://reflex.dev/docs/getting-started/introduction/", - color="rgb(107,99,246)", - ), - ), - rx.chakra.list_item( - "Ask a question in our ", - rx.chakra.link( - "community", - href="https://discord.gg/T5WSbC2YtQ", - color="rgb(107,99,246)", - ), - ), - ), - style=template_content_style, - ), - style=template_page_style, - ) diff --git a/reflex/.templates/apps/demo/code/sidebar.py b/reflex/.templates/apps/demo/code/sidebar.py deleted file mode 100644 index 5f634402f..000000000 --- a/reflex/.templates/apps/demo/code/sidebar.py +++ /dev/null @@ -1,178 +0,0 @@ -"""Sidebar component for the app.""" - -import reflex as rx - -from .state import State -from .styles import * - - -def sidebar_header() -> rx.Component: - """Sidebar header. - - Returns: - rx.Component: The sidebar header component. - """ - return rx.chakra.hstack( - rx.chakra.image( - src="/icon.svg", - height="2em", - ), - rx.chakra.spacer(), - rx.chakra.link( - rx.chakra.center( - rx.chakra.image( - src="/github.svg", - height="3em", - padding="0.5em", - ), - box_shadow=box_shadow, - bg="transparent", - border_radius=border_radius, - _hover={ - "bg": accent_color, - }, - ), - href="https://github.com/reflex-dev/reflex", - ), - width="100%", - border_bottom=border, - padding="1em", - ) - - -def sidebar_footer() -> rx.Component: - """Sidebar footer. - - Returns: - rx.Component: The sidebar footer component. - """ - return rx.chakra.hstack( - rx.chakra.link( - rx.chakra.center( - rx.chakra.image( - src="/paneleft.svg", - height="2em", - padding="0.5em", - ), - bg="transparent", - border_radius=border_radius, - **hover_accent_bg, - ), - on_click=State.toggle_sidebar_displayed, - transform=rx.cond(~State.sidebar_displayed, "rotate(180deg)", ""), - transition="transform 0.5s, left 0.5s", - position="relative", - left=rx.cond(State.sidebar_displayed, "0px", "20.5em"), - **overlapping_button_style, - ), - rx.chakra.spacer(), - rx.chakra.link( - rx.chakra.text( - "Docs", - ), - href="https://reflex.dev/docs/getting-started/introduction/", - ), - rx.chakra.link( - rx.chakra.text( - "Blog", - ), - href="https://reflex.dev/blog/", - ), - width="100%", - border_top=border, - padding="1em", - ) - - -def sidebar_item(text: str, icon: str, url: str) -> rx.Component: - """Sidebar item. - - Args: - text (str): The text of the item. - icon (str): The icon of the item. - url (str): The URL of the item. - - Returns: - rx.Component: The sidebar item component. - """ - return rx.chakra.link( - rx.chakra.hstack( - rx.chakra.image( - src=icon, - height="2.5em", - padding="0.5em", - ), - rx.chakra.text( - text, - ), - bg=rx.cond( - State.origin_url == f"/{text.lower()}/", - accent_color, - "transparent", - ), - color=rx.cond( - State.origin_url == f"/{text.lower()}/", - accent_text_color, - text_color, - ), - border_radius=border_radius, - box_shadow=box_shadow, - width="100%", - padding_x="1em", - ), - href=url, - width="100%", - ) - - -def sidebar() -> rx.Component: - """Sidebar. - - Returns: - rx.Component: The sidebar component. - """ - return rx.chakra.box( - rx.chakra.vstack( - sidebar_header(), - rx.chakra.vstack( - sidebar_item( - "Welcome", - "/github.svg", - "/", - ), - sidebar_item( - "Graphing Demo", - "/github.svg", - "/graphing", - ), - sidebar_item( - "Data Table Demo", - "/github.svg", - "/datatable", - ), - sidebar_item( - "Forms Demo", - "/github.svg", - "/forms", - ), - sidebar_item( - "Chat App Demo", - "/github.svg", - "/chatapp", - ), - width="100%", - overflow_y="auto", - align_items="flex-start", - padding="1em", - ), - rx.chakra.spacer(), - sidebar_footer(), - height="100dvh", - ), - display=["none", "none", "block"], - min_width=sidebar_width, - height="100%", - position="sticky", - top="0px", - border_right=border, - ) diff --git a/reflex/.templates/apps/demo/code/state.py b/reflex/.templates/apps/demo/code/state.py deleted file mode 100644 index a5c6f57bd..000000000 --- a/reflex/.templates/apps/demo/code/state.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Base state for the app.""" - -import reflex as rx - - -class State(rx.State): - """State for the app.""" - - sidebar_displayed: bool = True - - @rx.var - def origin_url(self) -> str: - """Get the url of the current page. - - Returns: - str: The url of the current page. - """ - return self.router_data.get("asPath", "") - - def toggle_sidebar_displayed(self) -> None: - """Toggle the sidebar displayed.""" - self.sidebar_displayed = not self.sidebar_displayed diff --git a/reflex/.templates/apps/demo/code/states/form_state.py b/reflex/.templates/apps/demo/code/states/form_state.py deleted file mode 100644 index 2b30e859e..000000000 --- a/reflex/.templates/apps/demo/code/states/form_state.py +++ /dev/null @@ -1,40 +0,0 @@ -import reflex as rx - -from ..state import State - - -class FormState(State): - """Form state.""" - - form_data: dict = {} - - def handle_submit(self, form_data: dict): - """Handle the form submit. - - Args: - form_data: The form data. - """ - self.form_data = form_data - - -class UploadState(State): - """The app state.""" - - # The images to show. - img: list[str] - - async def handle_upload(self, files: list[rx.UploadFile]): - """Handle the upload of file(s). - - Args: - files: The uploaded files. - """ - for file in files: - upload_data = await file.read() - outfile = rx.get_asset_path(file.filename) - # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) - - # Update the img var. - self.img.append(f"/{file.filename}") diff --git a/reflex/.templates/apps/demo/code/states/pie_state.py b/reflex/.templates/apps/demo/code/states/pie_state.py deleted file mode 100644 index 1c380c3af..000000000 --- a/reflex/.templates/apps/demo/code/states/pie_state.py +++ /dev/null @@ -1,47 +0,0 @@ -from typing import Any - -import reflex as rx - -from ..state import State - - -class PieChartState(State): - """Pie Chart State.""" - - resources: list[dict[str, Any]] = [ - dict(type_="🏆", count=1), - dict(type_="🪵", count=1), - dict(type_="🥑", count=1), - dict(type_="🧱", count=1), - ] - - @rx.cached_var - def resource_types(self) -> list[str]: - """Get the resource types. - - Returns: - The resource types. - """ - return [r["type_"] for r in self.resources] - - def increment(self, type_: str): - """Increment the count of a resource type. - - Args: - type_: The type of resource to increment. - """ - for resource in self.resources: - if resource["type_"] == type_: - resource["count"] += 1 - break - - def decrement(self, type_: str): - """Decrement the count of a resource type. - - Args: - type_: The type of resource to decrement. - """ - for resource in self.resources: - if resource["type_"] == type_ and resource["count"] > 0: - resource["count"] -= 1 - break diff --git a/reflex/.templates/apps/demo/code/styles.py b/reflex/.templates/apps/demo/code/styles.py deleted file mode 100644 index 5ca236ece..000000000 --- a/reflex/.templates/apps/demo/code/styles.py +++ /dev/null @@ -1,68 +0,0 @@ -"""Styles for the app.""" - -import reflex as rx - -from .state import State - -border_radius = "0.375rem" -box_shadow = "0px 0px 0px 1px rgba(84, 82, 95, 0.14)" -border = "1px solid #F4F3F6" -text_color = "black" -accent_text_color = "#1A1060" -accent_color = "#F5EFFE" -hover_accent_color = {"_hover": {"color": accent_color}} -hover_accent_bg = {"_hover": {"bg": accent_color}} -content_width_vw = "90vw" -sidebar_width = "20em" - -template_page_style = { - "padding_top": "5em", - "padding_x": "2em", -} - -template_content_style = { - "width": rx.cond( - State.sidebar_displayed, - f"calc({content_width_vw} - {sidebar_width})", - content_width_vw, - ), - "min-width": sidebar_width, - "align_items": "flex-start", - "box_shadow": box_shadow, - "border_radius": border_radius, - "padding": "1em", - "margin_bottom": "2em", -} - -link_style = { - "color": text_color, - "text_decoration": "none", - **hover_accent_color, -} - -overlapping_button_style = { - "background_color": "white", - "border": border, - "border_radius": border_radius, -} - -base_style = { - rx.chakra.MenuButton: { - "width": "3em", - "height": "3em", - **overlapping_button_style, - }, - rx.chakra.MenuItem: hover_accent_bg, -} - -tab_style = { - "color": "#494369", - "font_weight": 600, - "_selected": { - "color": "#5646ED", - "bg": "#F5EFFE", - "padding_x": "0.5em", - "padding_y": "0.25em", - "border_radius": "8px", - }, -} diff --git a/reflex/.templates/apps/demo/code/webui/components/__init__.py b/reflex/.templates/apps/demo/code/webui/components/__init__.py deleted file mode 100644 index e29eb0ab2..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .loading_icon import loading_icon -from .modal import modal -from .navbar import navbar -from .sidebar import sidebar diff --git a/reflex/.templates/apps/demo/code/webui/components/chat.py b/reflex/.templates/apps/demo/code/webui/components/chat.py deleted file mode 100644 index fd9b6ba98..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/chat.py +++ /dev/null @@ -1,118 +0,0 @@ -import reflex as rx - -from ...webui import styles -from ...webui.components import loading_icon -from ...webui.state import QA, State - - -def message(qa: QA) -> rx.Component: - """A single question/answer message. - - Args: - qa: The question/answer pair. - - Returns: - A component displaying the question/answer pair. - """ - return rx.chakra.box( - rx.chakra.box( - rx.chakra.text( - qa.question, - bg=styles.border_color, - shadow=styles.shadow_light, - **styles.message_style, - ), - text_align="right", - margin_top="1em", - ), - rx.chakra.box( - rx.chakra.text( - qa.answer, - bg=styles.accent_color, - shadow=styles.shadow_light, - **styles.message_style, - ), - text_align="left", - padding_top="1em", - ), - width="100%", - ) - - -def chat() -> rx.Component: - """List all the messages in a single conversation. - - Returns: - A component displaying all the messages in a single conversation. - """ - return rx.chakra.vstack( - rx.chakra.box(rx.foreach(State.chats[State.current_chat], message)), - py="8", - flex="1", - width="100%", - max_w="3xl", - padding_x="4", - align_self="center", - overflow="hidden", - padding_bottom="5em", - **styles.base_style[rx.chakra.Vstack], - ) - - -def action_bar() -> rx.Component: - """The action bar to send a new message. - - Returns: - The action bar to send a new message. - """ - return rx.chakra.box( - rx.chakra.vstack( - rx.chakra.form( - rx.chakra.form_control( - rx.chakra.hstack( - rx.chakra.input( - placeholder="Type something...", - value=State.question, - on_change=State.set_question, - _placeholder={"color": "#fffa"}, - _hover={"border_color": styles.accent_color}, - style=styles.input_style, - ), - rx.chakra.button( - rx.cond( - State.processing, - loading_icon(height="1em"), - rx.chakra.text("Send"), - ), - type_="submit", - _hover={"bg": styles.accent_color}, - style=styles.input_style, - ), - **styles.base_style[rx.chakra.Hstack], - ), - is_disabled=State.processing, - ), - on_submit=State.process_question, - width="100%", - ), - rx.chakra.text( - "ReflexGPT may return factually incorrect or misleading responses. Use discretion.", - font_size="xs", - color="#fff6", - text_align="center", - ), - width="100%", - max_w="3xl", - mx="auto", - **styles.base_style[rx.chakra.Vstack], - ), - position="sticky", - bottom="0", - left="0", - py="4", - backdrop_filter="auto", - backdrop_blur="lg", - border_top=f"1px solid {styles.border_color}", - align_items="stretch", - width="100%", - ) diff --git a/reflex/.templates/apps/demo/code/webui/components/loading_icon.py b/reflex/.templates/apps/demo/code/webui/components/loading_icon.py deleted file mode 100644 index 46cedb8ef..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/loading_icon.py +++ /dev/null @@ -1,19 +0,0 @@ -import reflex as rx - - -class LoadingIcon(rx.Component): - """A custom loading icon component.""" - - library = "react-loading-icons" - tag = "SpinningCircles" - stroke: rx.Var[str] - stroke_opacity: rx.Var[str] - fill: rx.Var[str] - fill_opacity: rx.Var[str] - stroke_width: rx.Var[str] - speed: rx.Var[str] - height: rx.Var[str] - on_change: rx.EventHandler[lambda status: [status]] - - -loading_icon = LoadingIcon.create diff --git a/reflex/.templates/apps/demo/code/webui/components/modal.py b/reflex/.templates/apps/demo/code/webui/components/modal.py deleted file mode 100644 index c76b8dffd..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/modal.py +++ /dev/null @@ -1,56 +0,0 @@ -import reflex as rx - -from ...webui.state import State - - -def modal() -> rx.Component: - """A modal to create a new chat. - - Returns: - The modal component. - """ - return rx.chakra.modal( - rx.chakra.modal_overlay( - rx.chakra.modal_content( - rx.chakra.modal_header( - rx.chakra.hstack( - rx.chakra.text("Create new chat"), - rx.chakra.icon( - tag="close", - font_size="sm", - on_click=State.toggle_modal, - color="#fff8", - _hover={"color": "#fff"}, - cursor="pointer", - ), - align_items="center", - justify_content="space-between", - ) - ), - rx.chakra.modal_body( - rx.chakra.input( - placeholder="Type something...", - on_blur=State.set_new_chat_name, - bg="#222", - border_color="#fff3", - _placeholder={"color": "#fffa"}, - ), - ), - rx.chakra.modal_footer( - rx.chakra.button( - "Create", - bg="#5535d4", - box_shadow="md", - px="4", - py="2", - h="auto", - _hover={"bg": "#4c2db3"}, - on_click=State.create_chat, - ), - ), - bg="#222", - color="#fff", - ), - ), - is_open=State.modal_open, - ) diff --git a/reflex/.templates/apps/demo/code/webui/components/navbar.py b/reflex/.templates/apps/demo/code/webui/components/navbar.py deleted file mode 100644 index e836f29ec..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/navbar.py +++ /dev/null @@ -1,70 +0,0 @@ -import reflex as rx - -from ...webui import styles -from ...webui.state import State - - -def navbar(): - return rx.chakra.box( - rx.chakra.hstack( - rx.chakra.hstack( - rx.chakra.icon( - tag="hamburger", - mr=4, - on_click=State.toggle_drawer, - cursor="pointer", - ), - rx.chakra.link( - rx.chakra.box( - rx.chakra.image(src="favicon.ico", width=30, height="auto"), - p="1", - border_radius="6", - bg="#F0F0F0", - mr="2", - ), - href="/", - ), - rx.chakra.breadcrumb( - rx.chakra.breadcrumb_item( - rx.chakra.heading("ReflexGPT", size="sm"), - ), - rx.chakra.breadcrumb_item( - rx.chakra.text( - State.current_chat, size="sm", font_weight="normal" - ), - ), - ), - ), - rx.chakra.hstack( - rx.chakra.button( - "+ New chat", - bg=styles.accent_color, - px="4", - py="2", - h="auto", - on_click=State.toggle_modal, - ), - rx.chakra.menu( - rx.chakra.menu_button( - rx.chakra.avatar(name="User", size="md"), - rx.chakra.box(), - ), - rx.chakra.menu_list( - rx.chakra.menu_item("Help"), - rx.chakra.menu_divider(), - rx.chakra.menu_item("Settings"), - ), - ), - spacing="8", - ), - justify="space-between", - ), - bg=styles.bg_dark_color, - backdrop_filter="auto", - backdrop_blur="lg", - p="4", - border_bottom=f"1px solid {styles.border_color}", - position="sticky", - top="0", - z_index="100", - ) diff --git a/reflex/.templates/apps/demo/code/webui/components/sidebar.py b/reflex/.templates/apps/demo/code/webui/components/sidebar.py deleted file mode 100644 index b4ffdd41f..000000000 --- a/reflex/.templates/apps/demo/code/webui/components/sidebar.py +++ /dev/null @@ -1,66 +0,0 @@ -import reflex as rx - -from ...webui import styles -from ...webui.state import State - - -def sidebar_chat(chat: str) -> rx.Component: - """A sidebar chat item. - - Args: - chat: The chat item. - - Returns: - The sidebar chat item. - """ - return rx.chakra.hstack( - rx.chakra.box( - chat, - on_click=lambda: State.set_chat(chat), - style=styles.sidebar_style, - color=styles.icon_color, - flex="1", - ), - rx.chakra.box( - rx.chakra.icon( - tag="delete", - style=styles.icon_style, - on_click=State.delete_chat, - ), - style=styles.sidebar_style, - ), - color=styles.text_light_color, - cursor="pointer", - ) - - -def sidebar() -> rx.Component: - """The sidebar component. - - Returns: - The sidebar component. - """ - return rx.chakra.drawer( - rx.chakra.drawer_overlay( - rx.chakra.drawer_content( - rx.chakra.drawer_header( - rx.chakra.hstack( - rx.chakra.text("Chats"), - rx.chakra.icon( - tag="close", - on_click=State.toggle_drawer, - style=styles.icon_style, - ), - ) - ), - rx.chakra.drawer_body( - rx.chakra.vstack( - rx.foreach(State.chat_titles, lambda chat: sidebar_chat(chat)), - align_items="stretch", - ) - ), - ), - ), - placement="left", - is_open=State.drawer_open, - ) diff --git a/reflex/.templates/apps/demo/code/webui/state.py b/reflex/.templates/apps/demo/code/webui/state.py deleted file mode 100644 index 51739222d..000000000 --- a/reflex/.templates/apps/demo/code/webui/state.py +++ /dev/null @@ -1,146 +0,0 @@ -import asyncio - -import reflex as rx - -from ..state import State - -# openai.api_key = os.environ["OPENAI_API_KEY"] -# openai.api_base = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1") - - -class QA(rx.Base): - """A question and answer pair.""" - - question: str - answer: str - - -DEFAULT_CHATS = { - "Intros": [], -} - - -class State(State): - """The app state.""" - - # A dict from the chat name to the list of questions and answers. - chats: dict[str, list[QA]] = DEFAULT_CHATS - - # The current chat name. - current_chat = "Intros" - - # The current question. - question: str - - # Whether we are processing the question. - processing: bool = False - - # The name of the new chat. - new_chat_name: str = "" - - # Whether the drawer is open. - drawer_open: bool = False - - # Whether the modal is open. - modal_open: bool = False - - def create_chat(self): - """Create a new chat.""" - # Add the new chat to the list of chats. - self.current_chat = self.new_chat_name - self.chats[self.new_chat_name] = [] - - # Toggle the modal. - self.modal_open = False - - def toggle_modal(self): - """Toggle the new chat modal.""" - self.modal_open = not self.modal_open - - def toggle_drawer(self): - """Toggle the drawer.""" - self.drawer_open = not self.drawer_open - - def delete_chat(self): - """Delete the current chat.""" - del self.chats[self.current_chat] - if len(self.chats) == 0: - self.chats = DEFAULT_CHATS - # set self.current_chat to the first chat. - self.current_chat = next(iter(self.chats)) - self.toggle_drawer() - - def set_chat(self, chat_name: str): - """Set the name of the current chat. - - Args: - chat_name: The name of the chat. - """ - self.current_chat = chat_name - self.toggle_drawer() - - @rx.var - def chat_titles(self) -> list[str]: - """Get the list of chat titles. - - Returns: - The list of chat names. - """ - return [*self.chats] - - async def process_question(self, form_data: dict[str, str]): - """Get the response from the API. - - Args: - form_data: A dict with the current question. - - Yields: - The current question and the response. - """ - # Check if the question is empty - if self.question == "": - return - - # Add the question to the list of questions. - qa = QA(question=self.question, answer="") - self.chats[self.current_chat].append(qa) - - # Clear the input and start the processing. - self.processing = True - self.question = "" - yield - - # # Build the messages. - # messages = [ - # {"role": "system", "content": "You are a friendly chatbot named Reflex."} - # ] - # for qa in self.chats[self.current_chat]: - # messages.append({"role": "user", "content": qa.question}) - # messages.append({"role": "assistant", "content": qa.answer}) - - # # Remove the last mock answer. - # messages = messages[:-1] - - # Start a new session to answer the question. - # session = openai.ChatCompletion.create( - # model=os.getenv("OPENAI_MODEL", "gpt-3.5-turbo"), - # messages=messages, - # stream=True, - # ) - - # Stream the results, yielding after every word. - # for item in session: - answer = "I don't know! This Chatbot still needs to add in AI API keys!" - for i in range(len(answer)): - # Pause to show the streaming effect. - await asyncio.sleep(0.1) - # Add one letter at a time to the output. - - # if hasattr(item.choices[0].delta, "content"): - # answer_text = item.choices[0].delta.content - self.chats[self.current_chat][-1].answer += answer[i] - self.chats = self.chats - yield - - # Toggle the processing flag. - self.processing = False diff --git a/reflex/.templates/apps/demo/code/webui/styles.py b/reflex/.templates/apps/demo/code/webui/styles.py deleted file mode 100644 index 62212ac1a..000000000 --- a/reflex/.templates/apps/demo/code/webui/styles.py +++ /dev/null @@ -1,88 +0,0 @@ -import reflex as rx - -bg_dark_color = "#111" -bg_medium_color = "#222" - -border_color = "#fff3" - -accennt_light = "#6649D8" -accent_color = "#5535d4" -accent_dark = "#4c2db3" - -icon_color = "#fff8" - -text_light_color = "#fff" -shadow_light = "rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;" -shadow = "rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;" - -message_style = dict(display="inline-block", p="4", border_radius="xl", max_w="30em") - -input_style = dict( - bg=bg_medium_color, - border_color=border_color, - border_width="1px", - p="4", -) - -icon_style = dict( - font_size="md", - color=icon_color, - _hover=dict(color=text_light_color), - cursor="pointer", - w="8", -) - -sidebar_style = dict( - border="double 1px transparent;", - border_radius="10px;", - background_image=f"linear-gradient({bg_dark_color}, {bg_dark_color}), radial-gradient(circle at top left, {accent_color},{accent_dark});", - background_origin="border-box;", - background_clip="padding-box, border-box;", - p="2", - _hover=dict( - background_image=f"linear-gradient({bg_dark_color}, {bg_dark_color}), radial-gradient(circle at top left, {accent_color},{accennt_light});", - ), -) - -base_style = { - rx.chakra.Avatar: { - "shadow": shadow, - "color": text_light_color, - # "bg": border_color, - }, - rx.chakra.Button: { - "shadow": shadow, - "color": text_light_color, - "_hover": { - "bg": accent_dark, - }, - }, - rx.chakra.Menu: { - "bg": bg_dark_color, - "border": f"red", - }, - rx.chakra.MenuList: { - "bg": bg_dark_color, - "border": f"1.5px solid {bg_medium_color}", - }, - rx.chakra.MenuDivider: { - "border": f"1px solid {bg_medium_color}", - }, - rx.chakra.MenuItem: { - "bg": bg_dark_color, - "color": text_light_color, - }, - rx.chakra.DrawerContent: { - "bg": bg_dark_color, - "color": text_light_color, - "opacity": "0.9", - }, - rx.chakra.Hstack: { - "align_items": "center", - "justify_content": "space-between", - }, - rx.chakra.Vstack: { - "align_items": "stretch", - "justify_content": "space-between", - }, -} diff --git a/reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 b/reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 index e70a835a5..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 d4322b171..21cfd921a 100644 --- a/reflex/.templates/jinja/web/pages/_app.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/_app.js.jinja2 @@ -1,12 +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}} @@ -26,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/custom_component.js.jinja2 b/reflex/.templates/jinja/web/pages/custom_component.js.jinja2 index 210246992..222524d2d 100644 --- a/reflex/.templates/jinja/web/pages/custom_component.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/custom_component.js.jinja2 @@ -8,20 +8,6 @@ {% endfor %} export const {{component.name}} = memo(({ {{-component.props|join(", ")-}} }) => { -{% if component.name == "CodeBlock" and "language" in component.props %} - if (language) { - (async () => { - try { - const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${language}`); - SyntaxHighlighter.registerLanguage(language, module.default); - } catch (error) { - console.error(`Error importing language module for ${language}:`, error); - } - })(); - - - } -{% endif %} {% for hook in component.hooks %} {{ hook }} {% endfor %} diff --git a/reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 b/reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 index 4a40ef545..b04a78781 100644 --- a/reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 +++ b/reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 @@ -5,11 +5,15 @@ export function {{tag_name}} () { {{ hook }} {% endfor %} + {% for hook, data in component._get_all_hooks().items() if not data.position or data.position == const.hook_position.PRE_TRIGGER %} + {{ hook }} + {% endfor %} + {% for hook in memo_trigger_hooks %} {{ hook }} {% endfor %} - {% for hook in component._get_all_hooks() %} + {% for hook, data in component._get_all_hooks().items() if data.position and data.position == const.hook_position.POST_TRIGGER %} {{ hook }} {% endfor %} 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 5f734a0c3..32be61ebb 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); @@ -28,7 +28,7 @@ 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. +// These events are triggered on initial load and each page navigation. export const onLoadInternalEvent = () => { const internal_events = []; @@ -59,6 +59,8 @@ export const initialEvents = () => [ {% else %} export const state_name = undefined +export const exception_state_name = undefined + export const onLoadInternalEvent = () => [] export const initialEvents = () => [] diff --git a/reflex/.templates/jinja/web/utils/theme.js.jinja2 b/reflex/.templates/jinja/web/utils/theme.js.jinja2 index a647a35b3..819abd232 100644 --- a/reflex/.templates/jinja/web/utils/theme.js.jinja2 +++ b/reflex/.templates/jinja/web/utils/theme.js.jinja2 @@ -1 +1 @@ -export default {{ theme|json_dumps }} \ No newline at end of file +export default {{ theme }} \ No newline at end of file diff --git a/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js b/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js deleted file mode 100644 index ad41d5134..000000000 --- a/reflex/.templates/web/components/reflex/chakra_color_mode_provider.js +++ /dev/null @@ -1,36 +0,0 @@ -import { useColorMode as chakraUseColorMode } from "@chakra-ui/react"; -import { useTheme } from "next-themes"; -import { useEffect, useState } from "react"; -import { ColorModeContext, defaultColorMode } from "/utils/context.js"; - -export default function ChakraColorModeProvider({ children }) { - const { theme, resolvedTheme, setTheme } = useTheme(); - const { colorMode, toggleColorMode } = chakraUseColorMode(); - const [resolvedColorMode, setResolvedColorMode] = useState(colorMode); - - useEffect(() => { - if (colorMode != resolvedTheme) { - toggleColorMode(); - } - setResolvedColorMode(resolvedTheme); - }, [theme, resolvedTheme]); - - const rawColorMode = colorMode; - const setColorMode = (mode) => { - const allowedModes = ["light", "dark", "system"]; - if (!allowedModes.includes(mode)) { - console.error( - `Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".` - ); - mode = defaultColorMode; - } - setTheme(mode); - }; - return ( - - {children} - - ); -} diff --git a/reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js b/reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js index 04df06059..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 @@ -4,8 +4,8 @@ import { ColorModeContext, defaultColorMode, isDevMode, - lastCompiledTimeStamp -} from "/utils/context.js"; + lastCompiledTimeStamp, +} from "$/utils/context.js"; export default function RadixThemesColorModeProvider({ children }) { const { theme, resolvedTheme, setTheme } = useTheme(); @@ -37,7 +37,7 @@ export default function RadixThemesColorModeProvider({ children }) { const allowedModes = ["light", "dark", "system"]; if (!allowedModes.includes(mode)) { console.error( - `Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".`, + `Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".` ); mode = defaultColorMode; } 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/utils/state.js b/reflex/.templates/web/utils/state.js index 26b2d0d0c..608df084a 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -2,7 +2,7 @@ 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, useRef, useState } from "react"; import Router, { useRouter } from "next/router"; @@ -12,9 +12,9 @@ import { onLoadInternalEvent, state_name, exception_state_name, -} from "utils/context.js"; -import debounce from "/utils/helpers/debounce"; -import throttle from "/utils/helpers/throttle"; +} from "$/utils/context.js"; +import debounce from "$/utils/helpers/debounce"; +import throttle from "$/utils/helpers/throttle"; // Endpoint URLs. const EVENTURL = env.EVENT; @@ -40,9 +40,6 @@ let event_processing = false; // Array holding pending events to be processed. const event_queue = []; -// Pending upload promises, by id -const upload_controllers = {}; - /** * Generate a UUID (Used for session tokens). * Taken from: https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid @@ -117,8 +114,8 @@ export const isStateful = () => { if (event_queue.length === 0) { return false; } - return event_queue.some(event => event.name.startsWith("reflex___state")); -} + return event_queue.some((event) => event.name.startsWith("reflex___state")); +}; /** * Apply a delta to the state. @@ -129,6 +126,21 @@ 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. @@ -141,7 +153,7 @@ export const queueEventIfSocketExists = async (events, socket) => { return; } await queueEvents(events, socket); -} +}; /** * Handle frontend event or send the event to the backend via Websocket. @@ -163,11 +175,6 @@ export const applyEvent = async (event, socket) => { return false; } - if (event.name == "_console") { - console.log(event.payload.message); - return false; - } - if (event.name == "_remove_cookie") { cookies.remove(event.payload.key, { ...event.payload.options }); queueEventIfSocketExists(initialEvents(), socket); @@ -198,28 +205,20 @@ export const applyEvent = async (event, socket) => { return false; } - if (event.name == "_set_clipboard") { - const content = event.payload.content; - navigator.clipboard.writeText(content); - return false; - } - if (event.name == "_download") { 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(); return false; } - if (event.name == "_alert") { - alert(event.payload.message); - return false; - } - if (event.name == "_set_focus") { const ref = event.payload.ref in refs ? refs[event.payload.ref] : event.payload.ref; @@ -236,9 +235,35 @@ export const applyEvent = async (event, socket) => { return false; } - if (event.name == "_call_script") { + if ( + event.name == "_call_function" && + typeof event.payload.function !== "string" + ) { try { - const eval_result = eval(event.payload.javascript_code); + const eval_result = event.payload.function(); + if (event.payload.callback) { + if (!!eval_result && typeof eval_result.then === "function") { + event.payload.callback(await eval_result); + } else { + event.payload.callback(eval_result); + } + } + } catch (e) { + console.log("_call_function", e); + if (window && window?.onerror) { + window.onerror(e.message, null, null, null, e); + } + } + return false; + } + + if (event.name == "_call_script" || event.name == "_call_function") { + try { + const eval_result = + event.name == "_call_script" + ? eval(event.payload.javascript_code) + : eval(event.payload.function)(); + if (event.payload.callback) { if (!!eval_result && typeof eval_result.then === "function") { eval(event.payload.callback)(await eval_result); @@ -249,7 +274,7 @@ export const applyEvent = async (event, socket) => { } catch (e) { console.log("_call_script", e); if (window && window?.onerror) { - window.onerror(e.message, null, null, null, e) + window.onerror(e.message, null, null, null, e); } } return false; @@ -272,7 +297,7 @@ export const applyEvent = async (event, socket) => { if (socket) { socket.emit( "event", - JSON.stringify(event, (k, v) => (v === undefined ? null : v)) + event, ); return true; } @@ -290,10 +315,9 @@ export const applyEvent = async (event, socket) => { export const applyRestEvent = async (event, socket) => { let eventSent = false; if (event.handler === "uploadFiles") { - if (event.payload.files === undefined || event.payload.files.length === 0) { // Submit the event over the websocket to trigger the event handler. - return await applyEvent(Event(event.name), socket) + return await applyEvent(Event(event.name), socket); } // Start upload, but do not wait for it, which would block other events. @@ -380,6 +404,8 @@ export const connect = async ( transports: transports, autoUnref: false, }); + // Ensure undefined fields in events are sent as null instead of removed + socket.current.io.encoder.replacer = (k, v) => (v === undefined ? null : v) function checkVisibility() { if (document.visibilityState === "visible") { @@ -397,7 +423,7 @@ export const connect = async ( console.log("Disconnect backend before bfcache on navigation"); socket.current.disconnect(); } - } + }; // Once the socket is open, hydrate the page. socket.current.on("connect", () => { @@ -416,8 +442,7 @@ export const connect = async ( }); // On each received message, queue the updates and events. - socket.current.on("event", (message) => { - const update = JSON5.parse(message); + socket.current.on("event", async (update) => { for (const substate in update.delta) { dispatch[substate](update.delta[substate]); } @@ -427,6 +452,10 @@ export const connect = async ( queueEvents(update.events, socket); } }); + socket.current.on("reload", async (event) => { + event_processing = false; + queueEvents([...initialEvents(), event], socket); + }); document.addEventListener("visibilitychange", checkVisibility); }; @@ -454,25 +483,42 @@ export const uploadFiles = async ( return false; } - if (upload_controllers[upload_id]) { + const upload_ref_name = `__upload_controllers_${upload_id}` + + if (refs[upload_ref_name]) { console.log("Upload already in progress for ", upload_id); return false; } + // Track how many partial updates have been processed for this upload. let resp_idx = 0; const eventHandler = (progressEvent) => { - // handle any delta / event streamed from the upload event handler + const event_callbacks = socket._callbacks.$event; + // Whenever called, responseText will contain the entire response so far. const chunks = progressEvent.event.target.responseText.trim().split("\n"); - chunks.slice(resp_idx).map((chunk) => { + // So only process _new_ chunks beyond resp_idx. + chunks.slice(resp_idx).map((chunk_json) => { try { - socket._callbacks.$event.map((f) => { - f(chunk); + const chunk = JSON5.parse(chunk_json); + event_callbacks.map((f, ix) => { + f(chunk) + .then(() => { + if (ix === event_callbacks.length - 1) { + // Mark this chunk as processed. + resp_idx += 1; + } + }) + .catch((e) => { + if (progressEvent.progress === 1) { + // Chunk may be incomplete, so only report errors when full response is available. + console.log("Error processing chunk", chunk, e); + } + return; + }); }); - resp_idx += 1; } catch (e) { if (progressEvent.progress === 1) { - // Chunk may be incomplete, so only report errors when full response is available. - console.log("Error parsing chunk", chunk, e); + console.log("Error parsing chunk", chunk_json, e); } return; } @@ -499,7 +545,7 @@ export const uploadFiles = async ( }); // Send the file to the server. - upload_controllers[upload_id] = controller; + refs[upload_ref_name] = controller; try { return await axios.post(getBackendURL(UPLOADURL), formdata, config); @@ -519,19 +565,25 @@ export const uploadFiles = async ( } return false; } finally { - delete upload_controllers[upload_id]; + delete refs[upload_ref_name]; } }; /** * 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 }; }; /** @@ -574,7 +626,11 @@ export const hydrateClientStorage = (client_storage) => { } } } - if (client_storage.cookies || client_storage.local_storage || client_storage.session_storage) { + if ( + client_storage.cookies || + client_storage.local_storage || + client_storage.session_storage + ) { return client_storage_values; } return {}; @@ -614,15 +670,17 @@ const applyClientStorageDelta = (client_storage, delta) => { ) { const options = client_storage.local_storage[state_key]; localStorage.setItem(options.name || state_key, delta[substate][key]); - } else if( + } else if ( client_storage.session_storage && state_key in client_storage.session_storage && typeof window !== "undefined" ) { const session_options = client_storage.session_storage[state_key]; - sessionStorage.setItem(session_options.name || state_key, delta[substate][key]); + sessionStorage.setItem( + session_options.name || state_key, + delta[substate][key] + ); } - } } }; @@ -651,7 +709,13 @@ export const useEventLoop = ( if (!(args instanceof Array)) { args = [args]; } - const _e = args.filter((o) => o?.preventDefault !== undefined)[0] + + 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(); @@ -660,6 +724,11 @@ export const useEventLoop = ( _e.stopPropagation(); } const combined_name = events.map((e) => e.name).join("+++"); + if (event_actions?.temporal) { + if (!socket.current || !socket.current.connected) { + return; // don't queue when the backend is not connected + } + } if (event_actions?.throttle) { // If throttle returns false, the events are not added to the queue. if (!throttle(combined_name, event_actions.throttle)) { @@ -671,7 +740,7 @@ export const useEventLoop = ( debounce( combined_name, () => queueEvents(events, socket), - event_actions.debounce, + event_actions.debounce ); } else { queueEvents(events, socket); @@ -696,30 +765,34 @@ export const useEventLoop = ( } }, [router.isReady]); - // Handle frontend errors and send them to the backend via websocket. - useEffect(() => { - - if (typeof window === 'undefined') { - return; - } - - window.onerror = function (msg, url, lineNo, columnNo, error) { - addEvents([Event(`${exception_state_name}.handle_frontend_exception`, { - stack: error.stack, - })]) - return false; - } + // Handle frontend errors and send them to the backend via websocket. + useEffect(() => { + if (typeof window === "undefined") { + return; + } - //NOTE: Only works in Chrome v49+ - //https://github.com/mknichel/javascript-errors?tab=readme-ov-file#promise-rejection-events - window.onunhandledrejection = function (event) { - addEvents([Event(`${exception_state_name}.handle_frontend_exception`, { - stack: event.reason.stack, - })]) - return false; - } - - },[]) + window.onerror = function (msg, url, lineNo, columnNo, error) { + addEvents([ + Event(`${exception_state_name}.handle_frontend_exception`, { + stack: error.stack, + 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(() => { @@ -734,7 +807,7 @@ export const useEventLoop = ( connect( socket, dispatch, - ["websocket", "polling"], + ["websocket"], setConnectErrors, client_storage ); @@ -782,17 +855,26 @@ export const useEventLoop = ( // Route after the initial page hydration. useEffect(() => { const change_start = () => { - const main_state_dispatch = dispatch["reflex___state____state"] + const main_state_dispatch = dispatch["reflex___state____state"]; if (main_state_dispatch !== undefined) { - main_state_dispatch({ is_hydrated: false }) + main_state_dispatch({ is_hydrated: false }); } - } + }; const change_complete = () => addEvents(onLoadInternalEvent()); + const change_error = () => { + // Remove cached error state from router for this page, otherwise the + // page will never send on_load events again. + if (router.components[router.pathname].error) { + delete router.components[router.pathname].error; + } + }; router.events.on("routeChangeStart", change_start); router.events.on("routeChangeComplete", change_complete); + router.events.on("routeChangeError", change_error); return () => { router.events.off("routeChangeStart", change_start); router.events.off("routeChangeComplete", change_complete); + router.events.off("routeChangeError", change_error); }; }, [router]); @@ -805,7 +887,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 faf3e087e..0be568b1a 100644 --- a/reflex/__init__.py +++ b/reflex/__init__.py @@ -89,6 +89,8 @@ from reflex.utils import ( lazy_loader, ) +from .event import event as event + # 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 @@ -140,6 +142,7 @@ RADIX_THEMES_COMPONENTS_MAPPING: dict = { "components.radix.themes.components.radio_group": ["radio", "radio_group"], "components.radix.themes.components.dropdown_menu": ["menu", "dropdown_menu"], "components.radix.themes.components.separator": ["divider", "separator"], + "components.radix.themes.components.progress": ["progress"], } RADIX_THEMES_LAYOUT_MAPPING: dict = { @@ -205,7 +208,13 @@ RADIX_PRIMITIVES_MAPPING: dict = { "components.radix.primitives.form": [ "form", ], - "components.radix.primitives.progress": ["progress"], + "components.radix.primitives.progress": [ + "progress", + ], +} + +RADIX_PRIMITIVES_SHORTCUT_MAPPING: dict = { + k: v for k, v in RADIX_PRIMITIVES_MAPPING.items() if "progress" not in k } COMPONENTS_CORE_MAPPING: dict = { @@ -248,13 +257,14 @@ RADIX_MAPPING: dict = { **RADIX_THEMES_COMPONENTS_MAPPING, **RADIX_THEMES_TYPOGRAPHY_MAPPING, **RADIX_THEMES_LAYOUT_MAPPING, - **RADIX_PRIMITIVES_MAPPING, + **RADIX_PRIMITIVES_SHORTCUT_MAPPING, } _MAPPING: dict = { "experimental": ["_x"], "admin": ["AdminDash"], "app": ["App", "UploadFile"], + "assets": ["asset"], "base": ["Base"], "components.component": [ "Component", @@ -270,7 +280,7 @@ _MAPPING: dict = { "EditorButtonList", "EditorOptions", ], - "components": ["el", "chakra", "radix", "lucide", "recharts", "next"], + "components": ["el", "radix", "lucide", "recharts", "next"], "components.markdown": ["markdown"], **RADIX_MAPPING, "components.plotly": ["plotly"], @@ -289,15 +299,19 @@ _MAPPING: dict = { "components.moment": ["MomentDelta", "moment"], "config": ["Config", "DBConfig"], "constants": ["Env"], + "constants.colors": ["Color"], "event": [ "EventChain", "EventHandler", "background", "call_script", + "call_function", + "run_script", "clear_local_storage", "clear_session_storage", "console_log", "download", + "noop", "prevent_default", "redirect", "remove_cookie", @@ -311,25 +325,28 @@ _MAPPING: dict = { "upload_files", "window_alert", ], - "middleware": ["middleware", "Middleware"], - "model": ["session", "Model"], - "state": [ - "var", + "istate.storage": [ "Cookie", "LocalStorage", "SessionStorage", + ], + "middleware": ["middleware", "Middleware"], + "model": ["asession", "session", "Model"], + "state": [ + "var", "ComponentState", "State", + "dynamic", ], + "istate.wrappers": ["get_state"], "style": ["Style", "toggle_color_mode"], - "utils.imports": ["ImportVar"], + "utils.imports": ["ImportDict", "ImportVar"], "utils.serializers": ["serializer"], - "vars": ["cached_var", "Var"], + "vars": ["Var", "field", "Field"], } _SUBMODULES: set[str] = { "components", - "event", "app", "style", "admin", @@ -342,8 +359,27 @@ _SUBMODULES: set[str] = { "compiler", } _SUBMOD_ATTRS: dict = _MAPPING -__getattr__, __dir__, __all__ = lazy_loader.attach( +getattr, __dir__, __all__ = lazy_loader.attach( __name__, submodules=_SUBMODULES, submod_attrs=_SUBMOD_ATTRS, ) + + +def __getattr__(name): + if name == "chakra": + from reflex.utils import console + + 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, + ) + import reflex_chakra as rc + + return rc + return getattr(name) diff --git a/reflex/__init__.pyi b/reflex/__init__.pyi index 8fe42cfb3..6bdfa11a0 100644 --- a/reflex/__init__.pyi +++ b/reflex/__init__.pyi @@ -11,7 +11,6 @@ from . import base as base from . import compiler as compiler from . import components as components from . import config as config -from . import event as event from . import model as model from . import style as style from . import testing as testing @@ -20,8 +19,8 @@ from . import vars as vars from .admin import AdminDash as AdminDash from .app import App as App from .app import UploadFile as UploadFile +from .assets import asset as asset from .base import Base as Base -from .components import chakra as chakra from .components import el as el from .components import lucide as lucide from .components import next as next @@ -71,7 +70,6 @@ from .components.plotly import plotly as plotly from .components.radix.primitives.accordion import accordion as accordion from .components.radix.primitives.drawer import drawer as drawer from .components.radix.primitives.form import form as form -from .components.radix.primitives.progress import progress as progress from .components.radix.themes.base import theme as theme from .components.radix.themes.base import theme_panel as theme_panel from .components.radix.themes.color_mode import color_mode as color_mode @@ -106,6 +104,7 @@ from .components.radix.themes.components.hover_card import hover_card as hover_c from .components.radix.themes.components.icon_button import icon_button as icon_button from .components.radix.themes.components.inset import inset as inset from .components.radix.themes.components.popover import popover as popover +from .components.radix.themes.components.progress import progress as progress from .components.radix.themes.components.radio_cards import radio_cards as radio_cards from .components.radix.themes.components.radio_group import radio as radio from .components.radix.themes.components.radio_group import radio_group as radio_group @@ -132,6 +131,7 @@ from .components.radix.themes.layout.container import container as container from .components.radix.themes.layout.flex import flex as flex from .components.radix.themes.layout.grid import grid as grid from .components.radix.themes.layout.list import list_item as list_item +from .components.radix.themes.layout.list import list_ns as list # noqa from .components.radix.themes.layout.list import ordered_list as ordered_list from .components.radix.themes.layout.list import unordered_list as unordered_list from .components.radix.themes.layout.section import section as section @@ -153,19 +153,24 @@ 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 .constants.colors import Color as Color from .event import EventChain as EventChain from .event import EventHandler as EventHandler from .event import background as background +from .event import call_function as call_function 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 noop as noop 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 run_script as run_script from .event import scroll_to as scroll_to from .event import set_clipboard as set_clipboard from .event import set_focus as set_focus @@ -174,23 +179,28 @@ 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 .istate.wrappers import get_state as get_state from .middleware import Middleware as Middleware from .middleware import middleware as middleware from .model import Model as Model +from .model import asession as asession from .model import session as session from .page import page as page from .state import ComponentState as ComponentState -from .state import Cookie as Cookie -from .state import LocalStorage as LocalStorage -from .state import SessionStorage as SessionStorage 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 ImportDict as ImportDict 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 cached_var as cached_var +from .vars import field as field del compat RADIX_THEMES_MAPPING: dict @@ -198,6 +208,7 @@ RADIX_THEMES_COMPONENTS_MAPPING: dict RADIX_THEMES_LAYOUT_MAPPING: dict RADIX_THEMES_TYPOGRAPHY_MAPPING: dict RADIX_PRIMITIVES_MAPPING: dict +RADIX_PRIMITIVES_SHORTCUT_MAPPING: dict COMPONENTS_CORE_MAPPING: dict COMPONENTS_BASE_MAPPING: dict RADIX_MAPPING: dict diff --git a/reflex/app.py b/reflex/app.py index 92ad3d149..9bef006b4 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -6,22 +6,26 @@ 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 types import SimpleNamespace from typing import ( + TYPE_CHECKING, Any, AsyncIterator, Callable, Coroutine, Dict, + Generic, List, Optional, Set, @@ -33,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 @@ -43,10 +47,9 @@ from starlette_admin.contrib.sqla.view import ModelView from reflex import constants from reflex.admin import AdminDash from reflex.app_mixins import AppMixin, LifespanMixin, MiddlewareMixin -from reflex.base import Base from reflex.compiler import compiler from reflex.compiler import utils as compiler_utils -from reflex.compiler.compiler import ExecutorSafeFunctions +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 @@ -63,12 +66,19 @@ from reflex.components.core.client_side_routing import ( ) from reflex.components.core.upload import Upload, get_upload_dir from reflex.components.radix import themes -from reflex.config import get_config -from reflex.event import Event, EventHandler, EventSpec, window_alert -from reflex.model import Model -from reflex.page import ( - DECORATED_PAGES, +from reflex.config import environment, get_config +from reflex.event import ( + BASE_STATE, + Event, + EventHandler, + EventSpec, + EventType, + IndividualEventType, + get_hydrate_event, + window_alert, ) +from reflex.model import Model, get_db_status +from reflex.page import DECORATED_PAGES from reflex.route import ( get_route_args, replace_brackets_with_keywords, @@ -84,9 +94,12 @@ from reflex.state import ( code_uses_state_contexts, ) from reflex.utils import codespaces, console, exceptions, format, prerequisites, types -from reflex.utils.exec import is_prod_mode, is_testing_env, should_skip_compile +from reflex.utils.exec import is_prod_mode, is_testing_env 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]] @@ -169,7 +182,23 @@ class OverlayFragment(Fragment): pass -class App(MiddlewareMixin, LifespanMixin, Base): +@dataclasses.dataclass( + frozen=True, +) +class UnevaluatedPage(Generic[BASE_STATE]): + """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[[], BASE_STATE], 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. @@ -191,24 +220,26 @@ class App(MiddlewareMixin, LifespanMixin, 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() + 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 @@ -219,8 +250,13 @@ class App(MiddlewareMixin, LifespanMixin, 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 @@ -232,7 +268,9 @@ class App(MiddlewareMixin, LifespanMixin, Base): _state_manager: Optional[StateManager] = None # 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[[], Any]]] = dataclasses.field( + default_factory=dict + ) # Admin dashboard to view and manage the database. PRIVATE. admin_dash: Optional[AdminDash] = None @@ -241,7 +279,7 @@ class App(MiddlewareMixin, LifespanMixin, 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) # Frontend Error Handler Function frontend_exception_handler: Callable[[Exception], None] = ( @@ -253,29 +291,19 @@ class App(MiddlewareMixin, LifespanMixin, Base): [Exception], Union[EventSpec, List[EventSpec], None] ] = default_backend_exception_handler - def __init__(self, **kwargs): + 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" ) if "breakpoints" in self.style: @@ -336,6 +364,11 @@ class App(MiddlewareMixin, LifespanMixin, Base): max_http_buffer_size=constants.POLLING_MAX_HTTP_BUFFER_SIZE, ping_interval=constants.Ping.INTERVAL, ping_timeout=constants.Ping.TIMEOUT, + json=SimpleNamespace( + dumps=staticmethod(format.json_dumps), + loads=staticmethod(json.loads), + ), + transports=["websocket"], ) elif getattr(self.sio, "async_mode", "") != "asgi": raise RuntimeError( @@ -377,11 +410,12 @@ class App(MiddlewareMixin, LifespanMixin, Base): """Add default api endpoints (ping).""" # To test the server. self.api.get(str(constants.Endpoint.PING))(ping) + self.api.get(str(constants.Endpoint.HEALTH))(health) def _add_optional_endpoints(self): """Add optional api endpoints (_upload).""" - # To upload files. if Upload.is_used: + # To upload files. self.api.post(str(constants.Endpoint.UPLOAD))(upload(self)) # To access uploaded files. @@ -402,7 +436,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): allow_credentials=True, allow_methods=["*"], allow_headers=["*"], - allow_origins=["*"], + allow_origins=get_config().cors_allowed_origins, ) @property @@ -430,36 +464,21 @@ class App(MiddlewareMixin, LifespanMixin, 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, + component: Component | ComponentCallable | None = None, 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[[], BASE_STATE] | None = None, meta: list[dict[str, str]] = constants.DefaultPage.META_LIST, ): """Add a page to the app. @@ -477,34 +496,49 @@ class App(MiddlewareMixin, LifespanMixin, Base): meta: The metadata of the page. Raises: - ValueError: When the specified route name already exists. + PageValueError: When the component is not set for a non-404 page. + RouteValueError: When the specified route name already exists. """ # 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 exceptions.RouteValueError( + "Route must be set if component is not a callable." + ) # Format the route. route = format.format_route(component.__name__) else: route = format.format_route(route, format_case=False) + if route == constants.Page404.SLUG: + if component is None: + component = Default404Page.create() + component = wait_for_client_redirect(self._generate_component(component)) + title = title or constants.Page404.TITLE + description = description or constants.Page404.DESCRIPTION + image = image or constants.Page404.IMAGE + else: + if component is None: + raise exceptions.PageValueError( + "Component must be set for a non-404 page." + ) + # 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 environment.RELOAD_CONFIG.is_set(): # 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 else f"`{route}`" ) - raise ValueError( + raise exceptions.RouteValueError( f"Duplicate page route {route_name} already exists. Make sure you do not have two" f" pages with the same route" ) @@ -514,58 +548,39 @@ class App(MiddlewareMixin, LifespanMixin, 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_stateful_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[[], Any]]: """Get the load events for a route. Args: @@ -624,9 +639,7 @@ class App(MiddlewareMixin, LifespanMixin, 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[[], BASE_STATE] | None = None, meta: list[dict[str, str]] = constants.DefaultPage.META_LIST, ): """Define a custom 404 page for any url having no match. @@ -642,10 +655,14 @@ class App(MiddlewareMixin, LifespanMixin, Base): on_load: The event handler(s) that will be called each time the page load. meta: The metadata of the page. """ - if component is None: - component = Default404Page.create() + console.deprecate( + feature_name="App.add_custom_404_page", + reason=f"Use app.add_page(component, route='/{constants.Page404.SLUG}') instead.", + deprecation_version="0.6.7", + removal_version="0.8.0", + ) self.add_page( - component=wait_for_client_redirect(self._generate_component(component)), + component=component, route=constants.Page404.SLUG, title=title or constants.Page404.TITLE, image=image or constants.Page404.IMAGE, @@ -691,7 +708,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): for i, tags in imports.items() 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 not any(i.startswith(prefix) for prefix in ["/", "$/", ".", "next/"]) and i != "" and any(tag.install for tag in tags) } @@ -730,7 +747,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): Whether the app should be compiled. """ # Check the environment variable. - if should_skip_compile(): + if environment.REFLEX_SKIP_COMPILE.get(): return False nocompile = prerequisites.get_web_dir() / constants.NOCOMPILE_FILE @@ -822,7 +839,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): for dep in deps: if dep not in state.vars and dep not in state.backend_vars: raise exceptions.VarDependencyError( - f"ComputedVar {var._var_name} on state {state.__name__} has an invalid dependency {dep}" + f"ComputedVar {var._js_expr} on state {state.__name__} has an invalid dependency {dep}" ) for substate in state.class_subclasses: @@ -839,12 +856,31 @@ class App(MiddlewareMixin, LifespanMixin, 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: - self.add_custom_404_page() + if constants.Page404.SLUG not in self.unevaluated_pages: + self.add_page(route=constants.Page404.SLUG) + + # 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 + + for route in self.unevaluated_pages: + console.debug(f"Evaluating page: {route}") + self._compile_page(route) # Add the optional endpoints (_upload) self._add_optional_endpoints() @@ -880,28 +916,15 @@ class App(MiddlewareMixin, LifespanMixin, 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()) @@ -911,8 +934,6 @@ class App(MiddlewareMixin, LifespanMixin, 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, @@ -930,6 +951,8 @@ class App(MiddlewareMixin, LifespanMixin, 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( @@ -939,77 +962,49 @@ class App(MiddlewareMixin, LifespanMixin, 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.get()) + is not None ): executor = concurrent.futures.ProcessPoolExecutor( - max_workers=int(os.environ.get("REFLEX_COMPILE_PROCESSES", 0)) or None, + max_workers=number_of_processes or None, 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.get() or None ) + 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) 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: @@ -1023,21 +1018,37 @@ class App(MiddlewareMixin, LifespanMixin, 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) + # Compile the contexts. + compile_results.append( + compiler.compile_contexts(self.state, self.theme), + ) + if self.theme is not None: + # Fix #2992 by removing the top-level appearance prop + self.theme.appearance = None + 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() @@ -1115,6 +1126,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): Task if the event was backgroundable, otherwise None """ substate, handler = state._get_event_handler(event) + if not handler.is_background: return None @@ -1172,7 +1184,7 @@ class App(MiddlewareMixin, LifespanMixin, Base): if hasattr(handler_fn, "__name__"): _fn_name = handler_fn.__name__ else: - _fn_name = handler_fn.__class__.__name__ + _fn_name = type(handler_fn).__name__ if isinstance(handler_fn, functools.partial): raise ValueError( @@ -1282,6 +1294,21 @@ async def process( ) # Get the state for the session exclusively. async with app.state_manager.modify_state(event.substate_token) as state: + # When this is a brand new instance of the state, signal the + # frontend to reload before processing it. + if ( + not state.router_data + and event.name != get_hydrate_event(state) + and app.event_namespace is not None + ): + await asyncio.create_task( + app.event_namespace.emit( + "reload", + data=event, + to=sid, + ) + ) + return # re-assign only when the value is different if state.router_data != router_data: # assignment will recurse into substates and force recalculation of @@ -1326,6 +1353,40 @@ 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 + + tasks = [] + + if prerequisites.check_db_used(): + tasks.append(get_db_status()) + if prerequisites.check_redis_used(): + tasks.append(prerequisites.get_redis_status()) + + results = await asyncio.gather(*tasks) + + for result in results: + health_status |= result + + if "redis" in health_status and health_status["redis"] is None: + health_status["redis"] = False + + if not all(health_status.values()): + health_status["status"] = False + status_code = 503 + + return JSONResponse(content=health_status, status_code=status_code) + + def upload(app: App): """Upload a file. @@ -1380,7 +1441,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): @@ -1453,10 +1514,10 @@ class EventNamespace(AsyncNamespace): app: App # Keep a mapping between socket ID and client token. - token_to_sid: dict[str, str] = {} + token_to_sid: dict[str, str] # Keep a mapping between client token and socket ID. - sid_to_token: dict[str, str] = {} + sid_to_token: dict[str, str] def __init__(self, namespace: str, app: App): """Initialize the event namespace. @@ -1466,6 +1527,8 @@ class EventNamespace(AsyncNamespace): app: The application object. """ super().__init__(namespace) + self.token_to_sid = {} + self.sid_to_token = {} self.app = app def on_connect(self, sid, environ): @@ -1556,24 +1619,35 @@ class EventNamespace(AsyncNamespace): update.scopes = [] # Creating a task prevents the update from being blocked behind other coroutines. + await asyncio.create_task( + self.emit(str(constants.SocketEvent.EVENT), update, to=sid) + ) 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 = 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/lifespan.py b/reflex/app_mixins/lifespan.py index 2b5ed8b58..52bf0be1d 100644 --- a/reflex/app_mixins/lifespan.py +++ b/reflex/app_mixins/lifespan.py @@ -4,21 +4,27 @@ from __future__ import annotations import asyncio import contextlib +import dataclasses import functools import inspect -import sys 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]] = set() + lifespan_tasks: Set[Union[asyncio.Task, Callable]] = dataclasses.field( + default_factory=set + ) @contextlib.asynccontextmanager async def _run_lifespan_tasks(self, app: FastAPI): @@ -26,6 +32,7 @@ class LifespanMixin(AppMixin): 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: @@ -35,15 +42,19 @@ class LifespanMixin(AppMixin): _t = task() if isinstance(_t, contextlib._AsyncGeneratorContextManager): await stack.enter_async_context(_t) + console.debug(run_msg.format(type="asynccontextmanager")) elif isinstance(_t, Coroutine): - running_tasks.append(asyncio.create_task(_t)) + 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: - cancel_kwargs = ( - {"msg": "lifespan_cleanup"} if sys.version_info >= (3, 9) else {} - ) for task in running_tasks: - task.cancel(**cancel_kwargs) + 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. @@ -51,7 +62,18 @@ class LifespanMixin(AppMixin): 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 index 1e42faf18..30593d9ae 100644 --- a/reflex/app_mixins/middleware.py +++ b/reflex/app_mixins/middleware.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio +import dataclasses from typing import List from reflex.event import Event @@ -12,11 +13,12 @@ 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] = [] + middleware: List[Middleware] = dataclasses.field(default_factory=list) def _init_mixin(self): self.middleware.append(HydrateMiddleware()) diff --git a/reflex/app_mixins/mixin.py b/reflex/app_mixins/mixin.py index ed301c495..23207a462 100644 --- a/reflex/app_mixins/mixin.py +++ b/reflex/app_mixins/mixin.py @@ -1,9 +1,10 @@ """Default mixin for all app mixins.""" -from reflex.base import Base +import dataclasses -class AppMixin(Base): +@dataclasses.dataclass +class AppMixin: """Define the base class for all app mixins.""" def _init_mixin(self): diff --git a/reflex/app_module_for_backend.py b/reflex/app_module_for_backend.py index cae136354..8109fc3d6 100644 --- a/reflex/app_module_for_backend.py +++ b/reflex/app_module_for_backend.py @@ -15,7 +15,7 @@ if constants.CompileVars.APP != "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) diff --git a/reflex/assets.py b/reflex/assets.py new file mode 100644 index 000000000..a9aa7a6a9 --- /dev/null +++ b/reflex/assets.py @@ -0,0 +1,95 @@ +"""Helper functions for adding assets to the app.""" + +import inspect +from pathlib import Path +from typing import Optional + +from reflex import constants +from reflex.config import EnvironmentVariables + + +def asset( + path: str, + shared: bool = False, + subfolder: Optional[str] = None, + _stack_level: int = 1, +) -> str: + """Add an asset to the app, either shared as a symlink or local. + + Shared/External/Library assets: + Place the file next to your including python file. + Links the file to the app's external assets directory. + + Example: + ```python + # my_custom_javascript.js is a shared asset located next to the including python file. + rx.script(src=rx.asset(path="my_custom_javascript.js", shared=True)) + rx.image(src=rx.asset(path="test_image.png", shared=True, subfolder="subfolder")) + ``` + + Local/Internal assets: + Place the file in the app's assets/ directory. + + Example: + ```python + # local_image.png is an asset located in the app's assets/ directory. It cannot be shared when developing a library. + rx.image(src=rx.asset(path="local_image.png")) + ``` + + Args: + path: The relative path of the asset. + subfolder: The directory to place the shared asset in. + shared: Whether to expose the asset to other apps. + _stack_level: The stack level to determine the calling file, defaults to + the immediate caller 1. When using rx.asset via a helper function, + increase this number for each helper function in the stack. + + Raises: + FileNotFoundError: If the file does not exist. + ValueError: If subfolder is provided for local assets. + + Returns: + The relative URL to the asset. + """ + assets = constants.Dirs.APP_ASSETS + backend_only = EnvironmentVariables.REFLEX_BACKEND_ONLY.get() + + # Local asset handling + if not shared: + cwd = Path.cwd() + src_file_local = cwd / assets / path + if subfolder is not None: + raise ValueError("Subfolder is not supported for local assets.") + if not backend_only and not src_file_local.exists(): + raise FileNotFoundError(f"File not found: {src_file_local}") + return f"/{path}" + + # Shared asset handling + # Determine the file by which the asset is exposed. + frame = inspect.stack()[_stack_level] + calling_file = frame.filename + module = inspect.getmodule(frame[0]) + assert module is not None + + external = constants.Dirs.EXTERNAL_APP_ASSETS + src_file_shared = Path(calling_file).parent / path + if not src_file_shared.exists(): + raise FileNotFoundError(f"File not found: {src_file_shared}") + + caller_module_path = module.__name__.replace(".", "/") + subfolder = f"{caller_module_path}/{subfolder}" if subfolder else caller_module_path + + # Symlink the asset to the app's external assets directory if running frontend. + if not backend_only: + # 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 / path + + if not dst_file.exists() and ( + not dst_file.is_symlink() or dst_file.resolve() != src_file_shared.resolve() + ): + dst_file.symlink_to(src_file_shared) + + return f"/{external}/{subfolder}/{path}" diff --git a/reflex/base.py b/reflex/base.py index 2eca63600..a88e557ef 100644 --- a/reflex/base.py +++ b/reflex/base.py @@ -16,9 +16,6 @@ except ModuleNotFoundError: from pydantic.fields import ModelField # type: ignore -from reflex import constants - - def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None: """Ensure that the field's name does not shadow an existing attribute of the model. @@ -31,22 +28,27 @@ def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None """ from reflex.utils.exceptions import VarNameError - reload = os.getenv(constants.RELOAD_CONFIG) == "True" - for base in bases: - try: + # can't use reflex.config.environment here cause of circular import + reload = os.getenv("__RELOAD_CONFIG", "").lower() == "true" + base = None + try: + for base in bases: if not reload and getattr(base, field_name, None): pass - except TypeError as te: - raise VarNameError( - f'State var "{field_name}" in {base} has been shadowed by a substate var; ' - f'use a different field name instead".' - ) from te + except TypeError as te: + raise VarNameError( + f'State var "{field_name}" in {base} has been shadowed by a substate var; ' + f'use a different field name instead".' + ) from te # 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 +if TYPE_CHECKING: + from reflex.vars import Var + class Base(BaseModel): # pyright: ignore [reportUnboundVariable] """The base class subclassed by all Reflex classes. @@ -92,7 +94,7 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] return self @classmethod - def get_fields(cls) -> dict[str, Any]: + def get_fields(cls) -> dict[str, ModelField]: """Get the fields of the object. Returns: @@ -101,7 +103,7 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] return cls.__fields__ @classmethod - def add_field(cls, var: Any, default_value: Any): + def add_field(cls, var: Var, default_value: Any): """Add a pydantic field after class definition. Used by State.add_var() to correctly handle the new variable. @@ -110,14 +112,15 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] var: The variable to add a pydantic field for. default_value: The default value of the field """ + var_name = var._var_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. @@ -128,17 +131,8 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable] Returns: The value of the field. """ - if isinstance(key, str) and key in self.__fields__: + if isinstance(key, str): # 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 getattr(self, key, key) + return key diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index 4345e244f..9f81f319d 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -2,13 +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, @@ -16,13 +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 SYSTEM_COLOR_MODE from reflex.utils.exec import is_prod_mode from reflex.utils.imports import ImportVar from reflex.utils.prerequisites import get_web_dir -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var def _compile_document_root(root: Component) -> str: @@ -40,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. @@ -49,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: @@ -80,8 +104,8 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component | None) The compiled context file. """ appearance = getattr(theme, "appearance", None) - if appearance is None or Var.create_safe(appearance)._var_name == "inherit": - appearance = SYSTEM_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 ( @@ -103,8 +127,8 @@ def _compile_contexts(state: Optional[Type[BaseState]], theme: Component | None) def _compile_page( - component: Component, - state: Type[BaseState], + component: BaseComponent, + state: Type[BaseState] | None, ) -> str: """Compile the component given the app state. @@ -119,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, @@ -171,7 +195,7 @@ 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." ) @@ -205,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 = [] @@ -292,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( @@ -377,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 @@ -401,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. @@ -503,7 +527,7 @@ 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.get(): # Skip purging the web directory in dev mode if REFLEX_PERSIST_WEB_DIR is set. return @@ -511,6 +535,81 @@ def purge_web_pages_dir(): 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: """Helper class to allow parallelisation of parts of the compilation process. @@ -536,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: @@ -551,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 c868a0cbb..631aa4ee2 100644 --- a/reflex/compiler/templates.py +++ b/reflex/compiler/templates.py @@ -45,6 +45,7 @@ class ReflexJinjaEnvironment(Environment): "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, + "hook_position": constants.Hooks.HookPosition, } diff --git a/reflex/compiler/utils.py b/reflex/compiler/utils.py index 1b69539ac..1d698431c 100644 --- a/reflex/compiler/utils.py +++ b/reflex/compiler/utils.py @@ -2,12 +2,12 @@ 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 @@ -28,11 +28,11 @@ from reflex.components.base import ( Title, ) from reflex.components.component import Component, ComponentStyle, CustomComponent -from reflex.state import BaseState, Cookie, LocalStorage, SessionStorage +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.utils.imports import ImportVar, ParsedImportDict -from reflex.vars import Var # To re-export this function. merge_imports = imports.merge_imports @@ -44,6 +44,9 @@ def compile_import_statement(fields: list[ImportVar]) -> tuple[str, list[str]]: 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". @@ -54,7 +57,8 @@ def compile_import_statement(fields: list[ImportVar]) -> tuple[str, list[str]]: # 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}), "") @@ -79,6 +83,12 @@ def validate_imports(import_dict: ParsedImportDict): 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]}" ) @@ -92,6 +102,9 @@ def compile_imports(import_dict: ParsedImportDict) -> list[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. """ @@ -102,14 +115,15 @@ def compile_imports(import_dict: ParsedImportDict) -> list[dict]: default, rest = compile_import_statement(fields) # prevent lib from being rendered on the page if all imports are non rendered kind - if not any({f.render for f in fields}): # type: ignore + if not any(f.render for f in fields): # type: ignore 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." - for module in sorted(rest): - import_dicts.append(get_import_dict(module)) + 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.") + import_dicts.extend(get_import_dict(module) for module in sorted(rest)) continue # remove the version before rendering the package imports @@ -152,8 +166,10 @@ 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( @@ -266,7 +282,7 @@ def compile_custom_component( } # Concatenate the props. - props = [prop._var_name for prop in component.get_prop_vars()] + props = [prop._js_expr for prop in component.get_prop_vars()] # Compile the component. return ( @@ -427,11 +443,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)) @@ -446,16 +462,16 @@ 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 | Path, keep_files: list[str] | None = None): diff --git a/reflex/components/__init__.py b/reflex/components/__init__.py index a1fd95f45..250df4e71 100644 --- a/reflex/components/__init__.py +++ b/reflex/components/__init__.py @@ -16,7 +16,6 @@ _SUBMODULES: set[str] = { "react_player", "sonner", "suneditor", - "chakra", "el", "base", "recharts", diff --git a/reflex/components/__init__.pyi b/reflex/components/__init__.pyi index eb858f512..781e75eb0 100644 --- a/reflex/components/__init__.pyi +++ b/reflex/components/__init__.pyi @@ -4,7 +4,6 @@ # ------------------------------------------------------ from . import base as base -from . import chakra as chakra from . import core as core from . import datadisplay as datadisplay from . import el as el diff --git a/reflex/components/base/app_wrap.py b/reflex/components/base/app_wrap.py index 76bf2d99b..c7cfe6505 100644 --- a/reflex/components/base/app_wrap.py +++ b/reflex/components/base/app_wrap.py @@ -2,7 +2,7 @@ from reflex.components.base.fragment import Fragment from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var class AppWrap(Fragment): @@ -15,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 f57f46b02..962e70c76 100644 --- a/reflex/components/base/app_wrap.pyi +++ b/reflex/components/base/app_wrap.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.base.fragment import Fragment -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class AppWrap(Fragment): @overload @@ -21,52 +21,22 @@ class AppWrap(Fragment): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AppWrap": """Create a new AppWrap component. diff --git a/reflex/components/base/bare.py b/reflex/components/base/bare.py index 0de7307db..e1b5d9237 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"{{{self.contents.to_string()!s}}}") + return Tagless(contents=f"{{{self.contents!s}}}") 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 443712ac9..8a20a6c06 100644 --- a/reflex/components/base/body.pyi +++ b/reflex/components/base/body.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Body(Component): @overload @@ -21,52 +21,22 @@ class Body(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Body": """Create the component. diff --git a/reflex/components/base/document.pyi b/reflex/components/base/document.pyi index 428decc8e..5b5e1a7f4 100644 --- a/reflex/components/base/document.pyi +++ b/reflex/components/base/document.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class NextDocumentLib(Component): @overload @@ -21,52 +21,22 @@ class NextDocumentLib(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "NextDocumentLib": """Create the component. @@ -98,52 +68,22 @@ class Html(NextDocumentLib): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Html": """Create the component. @@ -174,52 +114,22 @@ class DocumentHead(NextDocumentLib): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DocumentHead": """Create the component. @@ -250,52 +160,22 @@ class Main(NextDocumentLib): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Main": """Create the component. @@ -326,52 +206,22 @@ class NextScript(NextDocumentLib): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "NextScript": """Create the component. diff --git a/reflex/components/base/error_boundary.py b/reflex/components/base/error_boundary.py index e90f0ed63..f328773c2 100644 --- a/reflex/components/base/error_boundary.py +++ b/reflex/components/base/error_boundary.py @@ -2,15 +2,33 @@ from __future__ import annotations -from typing import List +from typing import Dict, Tuple -from reflex.compiler.compiler import _compile_component from reflex.components.component import Component -from reflex.components.el import div, p -from reflex.constants import Hooks, Imports -from reflex.event import EventChain, EventHandler -from reflex.utils.imports import ImportVar -from reflex.vars import Var +from reflex.components.datadisplay.logo import svg_logo +from reflex.components.el import a, button, details, div, h2, hr, p, pre, summary +from reflex.event import EventHandler, set_clipboard +from reflex.state import FrontendEventExceptionState +from reflex.vars.base import Var +from reflex.vars.function import ArgsFunctionOperation + + +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): @@ -20,59 +38,118 @@ class ErrorBoundary(Component): tag = "ErrorBoundary" # Fired when the boundary catches an error. - on_error: EventHandler[lambda error, info: [error, info]] = Var.create_safe( # type: ignore - "logFrontendError", _var_is_string=False, _var_is_local=False - ).to(EventChain) + on_error: EventHandler[on_error_spec] # Rendered instead of the children when an error is caught. - Fallback_component: Var[Component] = Var.create_safe( - "Fallback", _var_is_string=False, _var_is_local=False - ).to(Component) + fallback_render: Var[Component] - def add_imports(self) -> dict[str, list[ImportVar]]: - """Add imports for the component. + @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 imports to add. + The ErrorBoundary component. """ - return Imports.EVENTS - - def add_hooks(self) -> List[str | Var]: - """Add hooks for the component. - - Returns: - The hooks to add. - """ - return [Hooks.EVENTS, Hooks.FRONTEND_ERRORS] - - 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.create("error.message", _var_is_local=False, _var_is_string=False), - color="red", - ), - p("Please contact the support."), - ) - - compiled_fallback = _compile_component(fallback_container) - - return [ - f""" - function Fallback({{ error, resetErrorBoundary }}) {{ - return ( - {compiled_fallback} - ); - }} - """ - ] + if "on_error" not in props: + props["on_error"] = FrontendEventExceptionState.handle_frontend_exception + if "fallback_render" not in props: + props["fallback_render"] = ArgsFunctionOperation.create( + ("event_args",), + Var.create( + div( + div( + div( + h2( + "An error occurred while rendering this page.", + font_size="1.25rem", + font_weight="bold", + ), + p( + "This is an error with the application itself.", + opacity="0.75", + ), + details( + summary("Error message", padding="0.5rem"), + div( + div( + pre( + Var( + _js_expr="event_args.error.stack", + ), + ), + padding="0.5rem", + width="fit-content", + ), + width="100%", + max_height="50vh", + overflow="auto", + background="#000", + color="#fff", + border_radius="0.25rem", + ), + button( + "Copy", + on_click=set_clipboard( + Var(_js_expr="event_args.error.stack"), + ), + padding="0.35rem 0.75rem", + margin="0.5rem", + background="#fff", + color="#000", + border="1px solid #000", + border_radius="0.25rem", + font_weight="bold", + ), + ), + display="flex", + flex_direction="column", + gap="1rem", + max_width="50ch", + border="1px solid #888888", + border_radius="0.25rem", + padding="1rem", + ), + hr( + border_color="currentColor", + opacity="0.25", + ), + a( + div( + "Built with ", + svg_logo("currentColor"), + display="flex", + align_items="baseline", + justify_content="center", + font_family="monospace", + gap="0.5rem", + ), + href="https://reflex.dev", + ), + display="flex", + flex_direction="column", + gap="1rem", + ), + height="100%", + width="100%", + position="absolute", + display="flex", + align_items="center", + justify_content="center", + ) + ), + _var_type=Component, + ) + else: + props["fallback_render"] = ArgsFunctionOperation.create( + ("event_args",), + props["fallback_render"], + _var_type=Component, + ) + 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 index 5bc260b3c..2e01c7da0 100644 --- a/reflex/components/base/error_boundary.pyi +++ b/reflex/components/base/error_boundary.pyi @@ -3,85 +3,60 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Optional, Union, overload +from typing import Any, Dict, Optional, Tuple, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.utils.imports import ImportVar -from reflex.vars import BaseVar, Var +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_imports(self) -> dict[str, list[ImportVar]]: ... - def add_hooks(self) -> List[str | Var]: ... - def add_custom_code(self) -> List[str]: ... @overload @classmethod def create( # type: ignore cls, *children, - Fallback_component: Optional[Union[Var[Component], Component]] = None, + fallback_render: 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[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, str], BASE_STATE], + ] ] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ErrorBoundary": - """Create the component. + """Create an ErrorBoundary component. Args: *children: The children of the component. - Fallback_component: Rendered instead of the children when an error is caught. + on_error: Fired when the boundary catches an error. + fallback_render: 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. @@ -91,7 +66,7 @@ class ErrorBoundary(Component): **props: The props of the component. Returns: - The component. + The ErrorBoundary component. """ ... diff --git a/reflex/components/base/fragment.pyi b/reflex/components/base/fragment.pyi index 8c6f4c891..33030bc01 100644 --- a/reflex/components/base/fragment.pyi +++ b/reflex/components/base/fragment.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Fragment(Component): @overload @@ -21,52 +21,22 @@ class Fragment(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Fragment": """Create the component. diff --git a/reflex/components/base/head.pyi b/reflex/components/base/head.pyi index b5477259d..b01778094 100644 --- a/reflex/components/base/head.pyi +++ b/reflex/components/base/head.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component, MemoizationLeaf -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class NextHeadLib(Component): @overload @@ -21,52 +21,22 @@ class NextHeadLib(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "NextHeadLib": """Create the component. @@ -97,52 +67,22 @@ class Head(NextHeadLib, MemoizationLeaf): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Head": """Create a new memoization leaf component. diff --git a/reflex/components/base/link.py b/reflex/components/base/link.py index 1c11ab262..3ea34f212 100644 --- a/reflex/components/base/link.py +++ b/reflex/components/base/link.py @@ -1,7 +1,7 @@ """Display the title of the current page.""" from reflex.components.component import Component -from reflex.vars import Var +from reflex.vars.base import Var class RawLink(Component): diff --git a/reflex/components/base/link.pyi b/reflex/components/base/link.pyi index ecee03ef2..b48fae3a5 100644 --- a/reflex/components/base/link.pyi +++ b/reflex/components/base/link.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class RawLink(Component): @overload @@ -23,52 +23,22 @@ class RawLink(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RawLink": """Create the component. @@ -108,52 +78,22 @@ class ScriptTag(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 10e357a2e..b388b4794 100644 --- a/reflex/components/base/meta.pyi +++ b/reflex/components/base/meta.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Title(Component): def render(self) -> dict: ... @@ -22,52 +22,22 @@ class Title(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Title": """Create the component. @@ -103,52 +73,22 @@ class Meta(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Meta": """Create the component. @@ -189,52 +129,22 @@ class Description(Meta): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Description": """Create the component. @@ -275,52 +185,22 @@ class Image(Meta): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Image": """Create the component. diff --git a/reflex/components/base/script.py b/reflex/components/base/script.py index bef2f036b..15145ecbf 100644 --- a/reflex/components/base/script.py +++ b/reflex/components/base/script.py @@ -8,8 +8,8 @@ from __future__ import annotations from typing import Literal from reflex.components.component import Component -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec +from reflex.vars.base import LiteralVar, Var class Script(Component): @@ -31,17 +31,17 @@ class Script(Component): # When the script will execute: afterInteractive (defer-like behavior) | beforeInteractive | lazyOnload (async-like behavior) strategy: Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]] = ( - Var.create_safe("afterInteractive", _var_is_string=True) + LiteralVar.create("afterInteractive") ) # Triggered when the script is loading - on_load: EventHandler[lambda: []] + on_load: EventHandler[no_args_event_spec] # Triggered when the script has loaded - on_ready: EventHandler[lambda: []] + on_ready: EventHandler[no_args_event_spec] # Triggered when the script has errored - on_error: EventHandler[lambda: []] + on_error: EventHandler[no_args_event_spec] @classmethod def create(cls, *children, **props) -> Component: diff --git a/reflex/components/base/script.pyi b/reflex/components/base/script.pyi index 5165f5fd4..1633fdb70 100644 --- a/reflex/components/base/script.pyi +++ b/reflex/components/base/script.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Script(Component): @overload @@ -19,8 +19,8 @@ class Script(Component): src: Optional[Union[Var[str], str]] = None, strategy: Optional[ Union[ - Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]], Literal["afterInteractive", "beforeInteractive", "lazyOnload"], + Var[Literal["afterInteractive", "beforeInteractive", "lazyOnload"]], ] ] = None, style: Optional[Style] = None, @@ -28,61 +28,25 @@ class Script(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ready: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_error: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_load: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_ready: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Script": """Create an inline or user-defined script. @@ -101,6 +65,9 @@ class Script(Component): *children: The children of the component. src: Required unless inline script is used 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. 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 0b6b97b61..000000000 --- a/reflex/components/chakra/base.py +++ /dev/null @@ -1,210 +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.imports import ImportDict, ImportVar -from reflex.vars import Var - - -class ChakraComponent(Component): - """A component that wraps a Chakra component.""" - - library: str = "@chakra-ui/react@2.6.1" # type: ignore - 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) -> ImportDict: - """Get the imports from lib_dependencies for installing. - - Returns: - The dependencies imports of the component. - """ - return { - dep: [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, _var_is_string=False - ), - ) - - def add_imports(self) -> ImportDict: - """Add imports for the ChakraProvider component. - - Returns: - The import dict for the component. - """ - return { - self.library: ImportVar(tag="extendTheme", is_default=False), - "/utils/theme.js": ImportVar(tag="theme", is_default=True), - } - - @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 46ab1a0db..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - **props, - ) -> "ChakraProvider": - """Create a new ChakraProvider component. - - Returns: - A new ChakraProvider component. - """ - ... - - def add_imports(self) -> ImportDict: ... - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 d3d821a30..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 ad85327bf..000000000 --- a/reflex/components/chakra/datadisplay/code.py +++ /dev/null @@ -1,11 +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 7866e92d7..000000000 --- a/reflex/components/chakra/datadisplay/code.pyi +++ /dev/null @@ -1,87 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 9333be49a..000000000 --- a/reflex/components/chakra/datadisplay/divider.py +++ /dev/null @@ -1,20 +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 0b0439833..000000000 --- a/reflex/components/chakra/datadisplay/divider.pyi +++ /dev/null @@ -1,100 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 000fb8fb8..000000000 --- a/reflex/components/chakra/datadisplay/keyboard_key.pyi +++ /dev/null @@ -1,87 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 e266791fa..000000000 --- a/reflex/components/chakra/datadisplay/list.pyi +++ /dev/null @@ -1,339 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 bbade38bf..000000000 --- a/reflex/components/chakra/datadisplay/stat.pyi +++ /dev/null @@ -1,477 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 c49d909ad..000000000 --- a/reflex/components/chakra/datadisplay/table.py +++ /dev/null @@ -1,305 +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 48b0d6db7..000000000 --- a/reflex/components/chakra/datadisplay/table.pyi +++ /dev/null @@ -1,737 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 c5b448ab4..000000000 --- a/reflex/components/chakra/datadisplay/tag.py +++ /dev/null @@ -1,85 +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 bd4e76bc5..000000000 --- a/reflex/components/chakra/datadisplay/tag.pyi +++ /dev/null @@ -1,433 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 cf6e6b4cb..000000000 --- a/reflex/components/chakra/disclosure/accordion.pyi +++ /dev/null @@ -1,411 +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, Callable, Dict, List, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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]]], List[int]]] = None, - index: Optional[Union[Var[Union[List[int], int]], 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 c76f4125e..000000000 --- a/reflex/components/chakra/disclosure/tabs.pyi +++ /dev/null @@ -1,496 +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, Callable, Dict, List, Literal, Optional, Tuple, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 f0d01f3a0..000000000 --- a/reflex/components/chakra/disclosure/transition.py +++ /dev/null @@ -1,73 +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 a7598e359..000000000 --- a/reflex/components/chakra/disclosure/transition.pyi +++ /dev/null @@ -1,509 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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[int, str]], str, int]] = None, - offsetY: Optional[Union[Var[Union[int, str]], 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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[int, str]], 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 d5fa8e983..000000000 --- a/reflex/components/chakra/disclosure/visuallyhidden.pyi +++ /dev/null @@ -1,87 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 da1a7e2d9..000000000 --- a/reflex/components/chakra/feedback/alert.pyi +++ /dev/null @@ -1,335 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 25bb3c348..000000000 --- a/reflex/components/chakra/feedback/circularprogress.py +++ /dev/null @@ -1,68 +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 5a788d7d3..000000000 --- a/reflex/components/chakra/feedback/circularprogress.pyi +++ /dev/null @@ -1,185 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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[int, str]], 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 bcd3f5631..000000000 --- a/reflex/components/chakra/feedback/progress.pyi +++ /dev/null @@ -1,101 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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[float, int]], 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 b121a86c8..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 d2c45ca1d..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 e7109a5fe..000000000 --- a/reflex/components/chakra/forms/button.py +++ /dev/null @@ -1,83 +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 71c632178..000000000 --- a/reflex/components/chakra/forms/button.pyi +++ /dev/null @@ -1,262 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 7b5ed7b50..000000000 --- a/reflex/components/chakra/forms/checkbox.py +++ /dev/null @@ -1,77 +0,0 @@ -"""A checkbox component.""" - -from __future__ import annotations - -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralTagSize, -) -from reflex.event import EventHandler -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", _var_is_string=True) # type: ignore - - # The spacing between the checkbox and its label text (0.5rem) - spacing: Var[str] - - # Fired when the checkbox is checked or unchecked - on_change: EventHandler[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 7a2195411..000000000 --- a/reflex/components/chakra/forms/checkbox.pyi +++ /dev/null @@ -1,247 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Checkbox(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 667e07b7b..000000000 --- a/reflex/components/chakra/forms/colormodeswitch.py +++ /dev/null @@ -1,104 +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 05e354bbc..000000000 --- a/reflex/components/chakra/forms/colormodeswitch.pyi +++ /dev/null @@ -1,473 +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, Callable, Dict, Literal, Optional, Union, overload - -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 -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 4e2a42b5c..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra.forms.input import Input -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 9562c5de3..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra.forms.input import Input -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 f9932bb65..000000000 --- a/reflex/components/chakra/forms/editable.py +++ /dev/null @@ -1,67 +0,0 @@ -"""An editable component.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler -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] - - # Fired when the Editable is changed. - on_change: EventHandler[lambda e0: [e0]] - - # Fired when the Editable is in edit mode. - on_edit: EventHandler[lambda e0: [e0]] - - # Fired when the Editable is submitted. - on_submit: EventHandler[lambda e0: [e0]] - - # Fired when the Editable is canceled. - on_cancel: EventHandler[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 c8cbe20e1..000000000 --- a/reflex/components/chakra/forms/editable.pyi +++ /dev/null @@ -1,343 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Editable(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_cancel: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_edit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_submit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 e8ec4876f..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra.forms.input import Input -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 d59faad6e..000000000 --- a/reflex/components/chakra/forms/form.py +++ /dev/null @@ -1,103 +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 cae6952c2..000000000 --- a/reflex/components/chakra/forms/form.pyi +++ /dev/null @@ -1,484 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.el.elements.forms import Form as HTMLForm -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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[bool, int, str]], str, int, bool]] = None, - accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] - ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] - ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - reset_on_submit: Optional[Union[Var[bool], bool]] = None, - handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] - ] = None, - content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] - ] = None, - context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] - ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] - ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - style: Optional[Style] = None, - key: Optional[Any] = None, - id: Optional[Any] = None, - class_name: Optional[Any] = None, - autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_submit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 a98d4d23d..000000000 --- a/reflex/components/chakra/forms/iconbutton.pyi +++ /dev/null @@ -1,108 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra.typography.text import Text -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 c162a776f..000000000 --- a/reflex/components/chakra/forms/input.py +++ /dev/null @@ -1,130 +0,0 @@ -"""An input component.""" - -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 MemoizationMode -from reflex.event import EventHandler -from reflex.utils.imports import ImportDict -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] - - # Fired when the input value changes. - on_change: EventHandler[lambda e0: [e0.target.value]] - - # Fired when the input is focused. - on_focus: EventHandler[lambda e0: [e0.target.value]] - - # Fired when the input lose focus. - on_blur: EventHandler[lambda e0: [e0.target.value]] - - # Fired when a key is pressed down. - on_key_down: EventHandler[lambda e0: [e0.key]] - - # Fired when a key is released. - on_key_up: EventHandler[lambda e0: [e0.key]] - - def add_imports(self) -> ImportDict: - """Add imports for the Input component. - - Returns: - The import dict. - """ - return {"/utils/state": "set_val"} - - @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") 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) - - -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 fcf61c888..000000000 --- a/reflex/components/chakra/forms/input.pyi +++ /dev/null @@ -1,566 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var - -class Input(ChakraComponent): - def add_imports(self) -> ImportDict: ... - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 3d52d4bbe..000000000 --- a/reflex/components/chakra/forms/multiselect.py +++ /dev/null @@ -1,355 +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 39956840d..000000000 --- a/reflex/components/chakra/forms/numberinput.py +++ /dev/null @@ -1,128 +0,0 @@ -"""A number input component.""" - -from numbers import Number - -from reflex.components.chakra import ( - ChakraComponent, - LiteralButtonSize, - LiteralInputVariant, -) -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the input value changes. - on_change: EventHandler[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 521fcdd74..000000000 --- a/reflex/components/chakra/forms/numberinput.pyi +++ /dev/null @@ -1,442 +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 numbers import Number -from typing import Any, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class NumberInput(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 8d2a02109..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra.forms.input import Input -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 7e075887e..000000000 --- a/reflex/components/chakra/forms/pininput.py +++ /dev/null @@ -1,201 +0,0 @@ -"""A pin input component.""" - -from __future__ import annotations - -from typing import Optional - -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.component import Component -from reflex.components.tags.tag import Tag -from reflex.event import EventHandler -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] - - # Fired when the pin input is changed. - on_change: EventHandler[lambda e0: [e0]] - - # Fired when the pin input is completed. - on_complete: EventHandler[lambda e0: [e0]] - - 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_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, _var_is_string=False).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 c8f5cc878..000000000 --- a/reflex/components/chakra/forms/pininput.pyi +++ /dev/null @@ -1,215 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class PinInput(ChakraComponent): - 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_complete: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 d43327935..000000000 --- a/reflex/components/chakra/forms/radio.py +++ /dev/null @@ -1,101 +0,0 @@ -"""A radio component.""" - -from typing import Any, List - -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.event import EventHandler -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] - - # Fired when the radio group value changes. - on_change: EventHandler[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 9d9eb06a8..000000000 --- a/reflex/components/chakra/forms/radio.pyi +++ /dev/null @@ -1,197 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.typography.text import Text -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class RadioGroup(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 9e0c179b8..000000000 --- a/reflex/components/chakra/forms/rangeslider.py +++ /dev/null @@ -1,149 +0,0 @@ -"""A range slider component.""" - -from __future__ import annotations - -from typing import List, Optional - -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the value changes. - on_change: EventHandler[lambda e0: [e0]] - - # Fired when the value starts changing. - on_change_start: EventHandler[lambda e0: [e0]] - - # Fired when the value stops changing. - on_change_end: EventHandler[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, _var_is_string=False).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 38ca43f73..000000000 --- a/reflex/components/chakra/forms/rangeslider.pyi +++ /dev/null @@ -1,354 +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, Callable, Dict, List, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class RangeSlider(ChakraComponent): - 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_change_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_change_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 3c25ea8b9..000000000 --- a/reflex/components/chakra/forms/select.py +++ /dev/null @@ -1,103 +0,0 @@ -"""A select component.""" - -from typing import Any, List - -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.event import EventHandler -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] - - # Fired when the value changes. - on_change: EventHandler[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 8835cd588..000000000 --- a/reflex/components/chakra/forms/select.pyi +++ /dev/null @@ -1,204 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.typography.text import Text -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Select(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 e773a93e1..000000000 --- a/reflex/components/chakra/forms/slider.py +++ /dev/null @@ -1,130 +0,0 @@ -"""A slider component.""" - -from __future__ import annotations - -from typing import Literal - -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the value changes. - on_change: EventHandler[lambda e0: [e0]] - - # Fired when the value starts changing. - on_change_start: EventHandler[lambda e0: [e0]] - - # Fired when the value stops changing. - on_change_end: EventHandler[lambda e0: [e0]] - - @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 40eec470b..000000000 --- a/reflex/components/chakra/forms/slider.pyi +++ /dev/null @@ -1,449 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -LiteralLayout = Literal["horizontal", "vertical"] - -class Slider(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_change_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_change_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 a52c7c9a5..000000000 --- a/reflex/components/chakra/forms/switch.py +++ /dev/null @@ -1,49 +0,0 @@ -"""A switch component.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent, LiteralColorScheme -from reflex.event import EventHandler -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] - - # Fired when the switch value changes - on_change: EventHandler[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 be132e858..000000000 --- a/reflex/components/chakra/forms/switch.pyi +++ /dev/null @@ -1,159 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Switch(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 a88158feb..000000000 --- a/reflex/components/chakra/forms/textarea.py +++ /dev/null @@ -1,79 +0,0 @@ -"""A textarea component.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent, LiteralInputVariant -from reflex.components.component import Component -from reflex.components.core.debounce import DebounceInput -from reflex.event import EventHandler -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] - - # Fired when the value changes. - on_change: EventHandler[lambda e0: [e0.target.value]] - - # Fired when the textarea gets focus. - on_focus: EventHandler[lambda e0: [e0.target.value]] - - # Fired when the textarea loses focus. - on_blur: EventHandler[lambda e0: [e0.target.value]] - - # Fired when a key is pressed down. - on_key_down: EventHandler[lambda e0: [e0.key]] - - # Fired when a key is released. - on_key_up: EventHandler[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") 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) diff --git a/reflex/components/chakra/forms/textarea.pyi b/reflex/components/chakra/forms/textarea.pyi deleted file mode 100644 index b73c6d907..000000000 --- a/reflex/components/chakra/forms/textarea.pyi +++ /dev/null @@ -1,123 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class TextArea(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 1f9e641e8..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra.forms.input import Input -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 da798076f..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 995cddfb3..000000000 --- a/reflex/components/chakra/layout/box.pyi +++ /dev/null @@ -1,93 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 19aa6c57a..000000000 --- a/reflex/components/chakra/layout/card.pyi +++ /dev/null @@ -1,379 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 a78e662f7..000000000 --- a/reflex/components/chakra/layout/center.pyi +++ /dev/null @@ -1,239 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 856dc5fec..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 da08f05a6..000000000 --- a/reflex/components/chakra/layout/flex.pyi +++ /dev/null @@ -1,101 +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, Callable, Dict, List, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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[List[str], str]], str, List[str]]] = None, - grow: Optional[Union[Var[str], str]] = None, - justify: Optional[Union[Var[str], str]] = None, - wrap: Optional[Union[Var[Union[List[str], str]], 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 b70ee344a..000000000 --- a/reflex/components/chakra/layout/grid.pyi +++ /dev/null @@ -1,293 +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, Callable, Dict, List, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 3cfeabc57..000000000 --- a/reflex/components/chakra/layout/spacer.pyi +++ /dev/null @@ -1,87 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 715624a7b..000000000 --- a/reflex/components/chakra/layout/stack.pyi +++ /dev/null @@ -1,305 +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, Callable, Dict, List, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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[List[str], Literal["row", "column"]]], - 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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[List[str], Literal["row", "column"]]], - 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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[List[str], Literal["row", "column"]]], - 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 51654ad61..000000000 --- a/reflex/components/chakra/layout/wrap.pyi +++ /dev/null @@ -1,179 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 6152da730..000000000 --- a/reflex/components/chakra/media/avatar.py +++ /dev/null @@ -1,58 +0,0 @@ -"""Avatar components.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent, LiteralAvatarSize -from reflex.event import EventHandler -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] - - # Fired when the image fails to load. - on_error: EventHandler[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 c93ad72b7..000000000 --- a/reflex/components/chakra/media/avatar.pyi +++ /dev/null @@ -1,267 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Avatar(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 989ddd111..000000000 --- a/reflex/components/chakra/media/icon.py +++ /dev/null @@ -1,111 +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 bbd20f673..000000000 --- a/reflex/components/chakra/media/icon.pyi +++ /dev/null @@ -1,171 +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, Callable, Dict, List, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 b68fe8e6a..000000000 --- a/reflex/components/chakra/media/image.py +++ /dev/null @@ -1,74 +0,0 @@ -"""An image component.""" - -from __future__ import annotations - -from typing import Any, Optional - -from reflex.components.chakra import ChakraComponent, LiteralImageLoading -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the image fails to load. - on_error: EventHandler[lambda: []] - - # Fired when the image is loaded. - on_load: EventHandler[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 9e659e856..000000000 --- a/reflex/components/chakra/media/image.pyi +++ /dev/null @@ -1,118 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Image(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 3593f4128..000000000 --- a/reflex/components/chakra/navigation/breadcrumb.pyi +++ /dev/null @@ -1,351 +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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.navigation.link import Link -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 e30644acd..000000000 --- a/reflex/components/chakra/navigation/link.py +++ /dev/null @@ -1,62 +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.imports import ImportDict -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, _var_is_string=False - ) # type: ignore - - # If true, the link will open in new tab. - is_external: Var[bool] - - 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: - """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 be8f53fec..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.next.link import NextLink -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var - -next_link = NextLink.create() - -class Link(ChakraComponent): - def add_imports(self) -> ImportDict: ... - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 bac747c2b..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 ce365f994..000000000 --- a/reflex/components/chakra/navigation/stepper.pyi +++ /dev/null @@ -1,762 +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, Callable, Dict, List, Literal, Optional, Tuple, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 72f3ad642..000000000 --- a/reflex/components/chakra/overlay/alertdialog.py +++ /dev/null @@ -1,153 +0,0 @@ -"""Alert dialog components.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent, LiteralAlertDialogSize -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the modal is closing. - on_close: EventHandler[lambda: []] - - # Fired when the modal is closed and the exit animation is complete. - on_close_complete: EventHandler[lambda: []] - - # Fired when the Esc key is pressed. - on_esc: EventHandler[lambda: []] - - # Fired when the overlay is clicked. - on_overlay_click: EventHandler[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 490684ce4..000000000 --- a/reflex/components/chakra/overlay/alertdialog.pyi +++ /dev/null @@ -1,612 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class AlertDialog(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_complete: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_esc: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_overlay_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 b8f286855..000000000 --- a/reflex/components/chakra/overlay/drawer.py +++ /dev/null @@ -1,168 +0,0 @@ -"""Container to stack elements with spacing.""" - -from __future__ import annotations - -from reflex.components.chakra import ( - ChakraComponent, - LiteralColorScheme, - LiteralDrawerSize, -) -from reflex.components.chakra.media.icon import Icon -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the modal is closing. - on_close: EventHandler[lambda: []] - - # Fired when the modal is closed and the exit animation is complete. - on_close_complete: EventHandler[lambda: []] - - # Fired when the Esc key is pressed. - on_esc: EventHandler[lambda: []] - - # Fired when the overlay is clicked. - on_overlay_click: EventHandler[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 1adc43f3e..000000000 --- a/reflex/components/chakra/overlay/drawer.pyi +++ /dev/null @@ -1,652 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Drawer(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_complete: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_esc: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_overlay_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 88ccf8a35..000000000 --- a/reflex/components/chakra/overlay/menu.py +++ /dev/null @@ -1,225 +0,0 @@ -"""Menu components.""" - -from __future__ import annotations - -from typing import List, Optional - -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.event import EventHandler -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] - - # Fired when the menu is closed. - on_close: EventHandler[lambda: []] - - # Fired when the menu is opened. - on_open: EventHandler[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 5288251e0..000000000 --- a/reflex/components/chakra/overlay/menu.pyi +++ /dev/null @@ -1,708 +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, Callable, Dict, List, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Menu(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 522327058..000000000 --- a/reflex/components/chakra/overlay/modal.py +++ /dev/null @@ -1,166 +0,0 @@ -"""Modal components.""" - -from __future__ import annotations - -from typing import Literal, Optional, Union - -from reflex.components.chakra import ChakraComponent -from reflex.components.chakra.media import Icon -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the modal is closing. - on_close: EventHandler[lambda: []] - - # Fired when the modal is closed and the exit animation is complete. - on_close_complete: EventHandler[lambda: []] - - # Fired when the Esc key is pressed. - on_esc: EventHandler[lambda: []] - - # Fired when the overlay is clicked. - on_overlay_click: EventHandler[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 396c4a7a7..000000000 --- a/reflex/components/chakra/overlay/modal.pyi +++ /dev/null @@ -1,600 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -ModalSizes = Literal["xs", "sm", "md", "lg", "xl", "full"] - -class Modal(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_complete: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_esc: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_overlay_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 76b74600c..000000000 --- a/reflex/components/chakra/overlay/popover.py +++ /dev/null @@ -1,183 +0,0 @@ -"""Popover components.""" - -from __future__ import annotations - -from reflex.components.chakra import ( - ChakraComponent, - LiteralChakraDirection, - LiteralMenuStrategy, - LiteralPopOverTrigger, -) -from reflex.components.component import Component -from reflex.event import EventHandler -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] - - # Fired when the popover is closed. - on_close: EventHandler[lambda: []] - - # Fired when the popover is opened. - on_open: EventHandler[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 eacf54197..000000000 --- a/reflex/components/chakra/overlay/popover.pyi +++ /dev/null @@ -1,757 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ( - ChakraComponent, -) -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Popover(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 e0734251f..000000000 --- a/reflex/components/chakra/overlay/tooltip.py +++ /dev/null @@ -1,70 +0,0 @@ -"""Tooltip components.""" - -from __future__ import annotations - -from reflex.components.chakra import ChakraComponent, LiteralChakraDirection -from reflex.event import EventHandler -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] - - # Fired when the tooltip is closing. - on_close: EventHandler[lambda: []] - - # Fired when the tooltip is opened. - on_open: EventHandler[lambda: []] diff --git a/reflex/components/chakra/overlay/tooltip.pyi b/reflex/components/chakra/overlay/tooltip.pyi deleted file mode 100644 index 76e144d3f..000000000 --- a/reflex/components/chakra/overlay/tooltip.pyi +++ /dev/null @@ -1,129 +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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, Var - -class Tooltip(ChakraComponent): - @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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 29ddd7de2..000000000 --- a/reflex/components/chakra/typography/heading.py +++ /dev/null @@ -1,16 +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 5f4300d9a..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, Callable, Dict, Literal, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 8d768cb5e..000000000 --- a/reflex/components/chakra/typography/highlight.pyi +++ /dev/null @@ -1,91 +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, Callable, Dict, List, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 247be1447..000000000 --- a/reflex/components/chakra/typography/span.py +++ /dev/null @@ -1,15 +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 1e9d065ad..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 b2cd2356f..000000000 --- a/reflex/components/chakra/typography/text.py +++ /dev/null @@ -1,18 +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 f707bae36..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, Callable, Dict, Optional, Union, overload - -from reflex.components.chakra import ChakraComponent -from reflex.event import EventHandler, EventSpec -from reflex.style import Style -from reflex.vars import BaseVar, 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, 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 bb3e9053f..34800ab6e 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 @@ -16,6 +17,7 @@ from typing import ( Iterator, List, Optional, + Sequence, Set, Type, Union, @@ -25,6 +27,7 @@ import reflex.state from reflex.base import Base from reflex.compiler.templates import STATEFUL_COMPONENT from reflex.components.core.breakpoints import Breakpoints +from reflex.components.dynamic import load_dynamic_serializer from reflex.components.tags import Tag from reflex.constants import ( Dirs, @@ -35,19 +38,40 @@ from reflex.constants import ( MemoizationMode, PageNames, ) +from reflex.constants.compiler import SpecialAttributes +from reflex.constants.state import FRONTEND_EVENT_STATE from reflex.event import ( + EventCallback, EventChain, + EventChainVar, EventHandler, EventSpec, + EventVar, call_event_fn, call_event_handler, get_handler_args, + no_args_event_spec, ) from reflex.style import Style, format_as_emotion -from reflex.utils import console, format, imports, types -from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports -from reflex.utils.serializers import serializer -from reflex.vars import BaseVar, 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): @@ -134,11 +158,10 @@ class ComponentNamespace(SimpleNamespace): def __hash__(self) -> int: """Get the hash of the namespace. - Returns: The hash of the namespace. """ - return hash(self.__class__.__name__) + return hash(type(self).__name__) def evaluate_style_namespaces(style: ComponentStyle) -> dict: @@ -163,6 +186,23 @@ ComponentStyle = Dict[ ComponentChild = Union[types.PrimitiveType, Var, BaseComponent] +def satisfies_type_hint(obj: Any, type_hint: Any) -> bool: + """Check if an object satisfies a type hint. + + Args: + obj: The object to check. + type_hint: The type hint to check against. + + Returns: + Whether the object satisfies the type hint. + """ + if isinstance(obj, LiteralVar): + return types._isinstance(obj._var_value, type_hint) + if isinstance(obj, Var): + return types._issubclass(obj._var_type, type_hint) + return types._isinstance(obj, type_hint) + + class Component(BaseComponent, ABC): """A component with style, event trigger and other props.""" @@ -188,7 +228,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 @@ -206,7 +246,7 @@ class Component(BaseComponent, ABC): _rename_props: Dict[str, str] = {} # custom attribute - custom_attrs: Dict[str, Union[Var, str]] = {} + custom_attrs: Dict[str, Union[Var, Any]] = {} # When to memoize this component and its children. _memoization_mode: MemoizationMode = MemoizationMode() @@ -320,9 +360,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, _var_is_string=isinstance(field.default, str) - ) + if field.default is not None: + field.default = LiteralVar.create(field.default) elif types._issubclass(field.type_, EventHandler): field.required = False @@ -351,10 +390,7 @@ class Component(BaseComponent, ABC): "id": kwargs.get("id"), "children": children, **{ - prop: Var.create( - kwargs[prop], - _var_is_string=False if isinstance(kwargs[prop], str) else None, - ) + prop: LiteralVar.create(kwargs[prop]) for prop in self.get_initial_props() if prop in kwargs }, @@ -401,10 +437,10 @@ class Component(BaseComponent, ABC): passed_types = None try: # Try to create a var from the value. - kwargs[key] = Var.create( - value, - _var_is_string=False if isinstance(value, str) else None, - ) + 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: @@ -441,33 +477,51 @@ 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, value) + not passed_types and not satisfies_type_hint(value, expected_type) ): - 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 component_specific_triggers: # Temporarily disable full control for event triggers. kwargs["event_triggers"][key] = self._create_event_chain( 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): + if isinstance(style, (Breakpoints, Var)): style = { # Assign the Breakpoints to the self-referential selector to avoid squashing down to a regular dict. "&": style, @@ -480,29 +534,38 @@ 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) def _create_event_chain( self, - args_spec: Any, + args_spec: types.ArgsSpec | Sequence[types.ArgsSpec], 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. @@ -512,9 +575,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: {value!s} of type {value._var_type}" + ) elif isinstance(value, EventChain): # Trust that the caller knows what they're doing passing an EventChain directly return value @@ -525,99 +595,92 @@ 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. - result = 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): - result = call_event_fn(value, args_spec) + result = call_event_fn(value, args_spec, key=key) if isinstance(result, Var): # Recursively call this function if the lambda returned an EventChain Var. - return self._create_event_chain(args_spec, result) - events = result + 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]: + def get_event_triggers( + self, + ) -> Dict[str, types.ArgsSpec | Sequence[types.ArgsSpec]]: """Get the event triggers for the component. 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: [], + default_triggers: Dict[str, types.ArgsSpec | Sequence[types.ArgsSpec]] = { + EventTriggers.ON_FOCUS: no_args_event_spec, + EventTriggers.ON_BLUR: no_args_event_spec, + EventTriggers.ON_CLICK: no_args_event_spec, + EventTriggers.ON_CONTEXT_MENU: no_args_event_spec, + EventTriggers.ON_DOUBLE_CLICK: no_args_event_spec, + EventTriggers.ON_MOUSE_DOWN: no_args_event_spec, + EventTriggers.ON_MOUSE_ENTER: no_args_event_spec, + EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec, + EventTriggers.ON_MOUSE_MOVE: no_args_event_spec, + EventTriggers.ON_MOUSE_OUT: no_args_event_spec, + EventTriggers.ON_MOUSE_OVER: no_args_event_spec, + EventTriggers.ON_MOUSE_UP: no_args_event_spec, + EventTriggers.ON_SCROLL: no_args_event_spec, + EventTriggers.ON_MOUNT: no_args_event_spec, + EventTriggers.ON_UNMOUNT: no_args_event_spec, } # 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 (no_args_event_spec) # type: ignore return default_triggers def __repr__(self) -> str: @@ -638,27 +701,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. @@ -678,7 +720,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, ) @@ -692,9 +734,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, _var_is_string=False - ) + props["ref"] = Var(_js_expr=ref) else: props = props.copy() @@ -768,22 +808,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} @@ -809,7 +833,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 @@ -900,17 +924,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) @@ -936,7 +949,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. @@ -1061,8 +1079,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]: @@ -1089,12 +1110,12 @@ class Component(BaseComponent, ABC): vars.append(prop_var) # 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): + 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), ) ) @@ -1113,10 +1134,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, _var_is_string=isinstance(comp_prop, str) - ) - 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. @@ -1124,7 +1143,8 @@ 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 @@ -1137,8 +1157,17 @@ class Component(BaseComponent, ABC): for trigger in self.event_triggers.values(): if isinstance(trigger, EventChain): for event in trigger.events: - if event.handler.state_full_name: - return True + if isinstance(event, EventCallback): + continue + if isinstance(event, EventSpec): + if ( + event.handler.state_full_name + and event.handler.state_full_name != FRONTEND_EVENT_STATE + ): + return True + else: + if event._var_state: + return True elif isinstance(trigger, Var) and trigger._var_state: return True return False @@ -1179,7 +1208,7 @@ class Component(BaseComponent, ABC): Yields: The parent classes that define the method (differently than the base). """ - seen_methods = set([getattr(Component, method)]) + seen_methods = {getattr(Component, method)} for clz in cls.mro(): if clz is Component: break @@ -1312,7 +1341,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`. @@ -1329,15 +1360,17 @@ class Component(BaseComponent, ABC): other_imports = [] user_hooks = self._get_hooks() - if ( - user_hooks is not None - and isinstance(user_hooks, Var) - and user_hooks._var_data is not None - and user_hooks._var_data.imports - ): - other_imports.append(user_hooks._var_data.imports) + 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() + hook_vardata.imports + for hook_vardata in self._get_added_hooks().values() + if hook_vardata is not None ) return imports.merge_imports(_imports, *other_imports) @@ -1358,8 +1391,9 @@ 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 + var_datas = [var._get_all_var_data() for var in self._get_vars()] + var_imports: List[ImmutableParsedImportDict] = [ + var_data.imports for var_data in var_datas if var_data is not None ] added_import_dicts: list[ParsedImportDict] = [] @@ -1369,8 +1403,9 @@ class Component(BaseComponent, ABC): 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)) + added_import_dicts.extend( + [parse_imports(import_dict) for import_dict in list_of_import_dict] + ) return imports.merge_imports( *self._get_props_imports(), @@ -1407,9 +1442,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(() => {{ @@ -1427,7 +1462,9 @@ class Component(BaseComponent, ABC): """ ref = self.get_ref() if ref is not None: - return f"const {ref} = useRef(null); {str(Var.create_safe(ref, _var_is_string=False).as_ref())} = {ref};" + return ( + f"const {ref} = useRef(null); {Var(_js_expr=ref)._as_ref()!s} = {ref};" + ) def _get_vars_hooks(self) -> dict[str, None]: """Get the hooks required by vars referenced in this component. @@ -1437,8 +1474,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]: @@ -1477,7 +1519,7 @@ class Component(BaseComponent, ABC): **self._get_special_hooks(), } - def _get_added_hooks(self) -> dict[str, ImportDict]: + def _get_added_hooks(self) -> dict[str, VarData | None]: """Get the hooks added via `add_hooks` method. Returns: @@ -1486,16 +1528,15 @@ class Component(BaseComponent, ABC): code = {} def extract_var_hooks(hook: Var): - _imports = {} - if hook._var_data is not None: - for sub_hook in hook._var_data.hooks: - code[sub_hook] = {} - if hook._var_data.imports: - _imports = hook._var_data.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] = None + if str(hook) in code: - code[str(hook)] = imports.merge_imports(code[str(hook)], _imports) + code[str(hook)] = VarData.merge(var_data, code[str(hook)]) else: - code[str(hook)] = _imports + code[str(hook)] = var_data # 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) @@ -1504,7 +1545,8 @@ class Component(BaseComponent, ABC): if isinstance(hook, Var): extract_var_hooks(hook) else: - code[hook] = {} + code[hook] = None + return code def _get_hooks(self) -> str | None: @@ -1545,8 +1587,7 @@ class Component(BaseComponent, ABC): if hooks is not None: code[hooks] = None - for hook in self._get_added_hooks(): - code[hook] = None + code.update(self._get_added_hooks()) # Add the hook code for the children. for child in self.children: @@ -1561,7 +1602,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) @@ -1655,7 +1696,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 @@ -1699,15 +1740,16 @@ class CustomComponent(Component): value = self._create_event_chain( value=value, args_spec=event_triggers_in_component_declaration.get( - key, lambda: [] + key, no_args_event_spec ), + 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): @@ -1721,7 +1763,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 @@ -1762,10 +1804,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: @@ -1800,19 +1846,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() ] @@ -1825,9 +1871,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: @@ -1867,6 +1915,11 @@ memo = custom_component class NoSSRComponent(Component): """A dynamic component that is not rendered on the server.""" + def _get_import_name(self) -> None | str: + if not self.library: + return None + return f"${self.library}" if self.library.startswith("/") else self.library + def _get_imports(self) -> ParsedImportDict: """Get the imports for the component. @@ -1880,8 +1933,9 @@ class NoSSRComponent(Component): _imports = super()._get_imports() # Do NOT import the main library/tag statically. - if self.library is not None: - _imports[self.library] = [ + import_name = self._get_import_name() + if import_name is not None: + _imports[import_name] = [ imports.ImportVar( tag=None, render=False, @@ -1899,10 +1953,10 @@ class NoSSRComponent(Component): opts_fragment = ", { ssr: false });" # extract the correct import name from library name - if self.library is None: + base_import_name = self._get_import_name() + if base_import_name is None: raise ValueError("Undefined library for NoSSRComponent") - - import_name = format.format_library_name(self.library) + import_name = format.format_library_name(base_import_name) library_import = f"const {self.alias if self.alias else self.tag} = dynamic(() => import('{import_name}')" mod_import = ( @@ -1912,19 +1966,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. @@ -1981,7 +2022,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 @@ -1996,7 +2037,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 @@ -2148,6 +2189,31 @@ class StatefulComponent(BaseComponent): ] return [var_name] + @staticmethod + def _get_deps_from_event_trigger(event: EventChain | EventSpec | Var) -> set[str]: + """Get the dependencies accessed by event triggers. + + Args: + event: The event trigger to extract deps from. + + Returns: + The dependencies accessed by the event triggers. + """ + events: list = [event] + deps = set() + + if isinstance(event, EventChain): + events.extend(event.events) + + for ev in events: + if isinstance(ev, EventSpec): + for arg in ev.args: + for a in arg: + var_datas = VarData.merge(a._get_all_var_data()) + if var_datas and var_datas.deps is not None: + deps |= {str(dep) for dep in var_datas.deps} + return deps + @classmethod def _get_memoized_event_triggers( cls, @@ -2176,9 +2242,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() @@ -2186,13 +2250,19 @@ class StatefulComponent(BaseComponent): # Calculate Var dependencies accessed by the handler for useCallback dep array. var_deps = ["addEvents", "Event"] + + # Get deps from event trigger var data. + var_deps.extend(cls._get_deps_from_event_trigger(event)) + + # Get deps from hooks. 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], + *[var._get_all_var_data() for var in event_args], VarData( imports={"react": [ImportVar(tag="useCallback")]}, ), @@ -2200,7 +2270,7 @@ class StatefulComponent(BaseComponent): # Store the memoized function name and hook code for this event trigger. trigger_memo[event_trigger] = ( - Var.create_safe(memo_name, _var_is_string=False)._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)}])", @@ -2231,7 +2301,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) ] } @@ -2273,7 +2343,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. @@ -2338,3 +2408,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((type(self).__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/banner.py b/reflex/components/core/banner.py index c6b46696c..b7b6fae6c 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 @@ -19,71 +18,60 @@ from reflex.components.radix.themes.typography.text import Text from reflex.components.sonner.toast import Toaster, ToastProps from reflex.constants import Dirs, Hooks, Imports from reflex.constants.compiler import CompileVars -from reflex.utils.imports import ImportDict, ImportVar -from reflex.utils.serializers import serialize -from reflex.vars import Var, VarData +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}, ) -connect_errors: Var = Var.create_safe( - value=CompileVars.CONNECT_ERROR, - _var_is_local=True, - _var_is_string=False, +connect_errors = Var( + _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data +) + +connection_error = Var( + _js_expr="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')", _var_data=connect_error_var_data, ) -connection_error: Var = Var.create_safe( - value="(connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : ''", - _var_is_local=False, - _var_is_string=False, - _var_data=connect_error_var_data, +connection_errors_count = Var( + _js_expr="connectErrors.length", _var_data=connect_error_var_data ) -connection_errors_count: Var = Var.create_safe( - value="connectErrors.length", - _var_is_string=False, - _var_is_local=False, - _var_data=connect_error_var_data, -) +has_connection_errors = Var( + _js_expr="(connectErrors.length > 0)", _var_data=connect_error_var_data +).to(BooleanVar) -has_connection_errors: Var = Var.create_safe( - value="connectErrors.length > 0", - _var_is_string=False, - _var_data=connect_error_var_data, -).to(bool) - -has_too_many_connection_errors: Var = Var.create_safe( - value="connectErrors.length >= 2", - _var_is_string=False, - _var_data=connect_error_var_data, -).to(bool) +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 add_imports(self) -> ImportDict: - """Add imports for the websocket target URL component. - - Returns: - The import dict. - """ - return { - f"/{Dirs.STATE_PATH}": [ImportVar(tag="getBackendURL")], - "/env.json": [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]: @@ -112,24 +100,34 @@ class ConnectionToaster(Toaster): toast_id = "websocket-error" target_url = WebsocketTargetURL.create() props = ToastProps( # type: ignore - description=Var.create( - f"`Check if server is reachable at ${target_url}`", - _var_is_string=False, - _var_is_local=False, + description=LiteralVar.create( + f"Check if server is reachable at {target_url}", ), close_button=True, duration=120000, id=toast_id, ) - hook = Var.create_safe( - f""" -const toast_props = {serialize(props)}; -const [userDismissed, setUserDismissed] = useState(false); -useEffect(() => {{ - if ({has_too_many_connection_errors}) {{ + + individual_hooks = [ + f"const toast_props = {LiteralVar.create(props)!s};", + "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 ({has_too_many_connection_errors!s}) {{ if (!userDismissed) {{ toast.error( - `Cannot connect to server: {connection_error}.`, + `Cannot connect to server: ${{{connection_error}}}.`, {{...toast_props, onDismiss: () => setUserDismissed(true)}}, ) }} @@ -137,20 +135,16 @@ useEffect(() => {{ toast.dismiss("{toast_id}"); setUserDismissed(false); // after reconnection reset dismissed state }} -}}, [{connect_errors}]);""", - _var_is_string=False, - ) - imports: ImportDict = { - "react": ["useEffect", "useState"], - **target_url._get_imports(), # type: ignore - } - hook._var_data = VarData.merge( - connect_errors._var_data, - VarData(imports=imports), - ) +}} +""" + ), + LiteralArrayVar.create([connect_errors]), + ), + ] + return [ Hooks.EVENTS, - hook, + *individual_hooks, ] @classmethod @@ -240,15 +234,16 @@ class WifiOffPulse(Icon): 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", "33px"), + bottom=props.pop("bottom", "33px"), right=props.pop("right", "33px"), - animation=Var.create(f"${{pulse}} 1s infinite", _var_is_string=True), + animation=LiteralVar.create(f"{pulse_var} 1s infinite"), **props, ) diff --git a/reflex/components/core/banner.pyi b/reflex/components/core/banner.pyi index b9b6d506f..f44ee7992 100644 --- a/reflex/components/core/banner.pyi +++ b/reflex/components/core/banner.pyi @@ -3,92 +3,41 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.components.base.bare import Bare from reflex.components.component import Component from reflex.components.el.elements.typography import Div from reflex.components.lucide.icon import Icon from reflex.components.sonner.toast import Toaster, ToastProps -from reflex.event import EventHandler, EventSpec +from reflex.constants.compiler import CompileVars +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import BaseVar, Var, VarData +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 -connect_errors: Var -connection_error: Var -connection_errors_count: Var -has_connection_errors: Var -has_too_many_connection_errors: Var +connect_errors = Var( + _js_expr=CompileVars.CONNECT_ERROR, _var_data=connect_error_var_data +) +connection_error = Var( + _js_expr="((connectErrors.length > 0) ? connectErrors[connectErrors.length - 1].message : '')", + _var_data=connect_error_var_data, +) +connection_errors_count = Var( + _js_expr="connectErrors.length", _var_data=connect_error_var_data +) +has_connection_errors = Var( + _js_expr="(connectErrors.length > 0)", _var_data=connect_error_var_data +).to(BooleanVar) +has_too_many_connection_errors = Var( + _js_expr="(connectErrors.length >= 2)", _var_data=connect_error_var_data +).to(BooleanVar) -class WebsocketTargetURL(Bare): - def add_imports(self) -> ImportDict: ... - @overload +class WebsocketTargetURL(Var): @classmethod - def create( # type: ignore - cls, - *children, - contents: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - **props, - ) -> "WebsocketTargetURL": - """Create a websocket target URL component. - - Returns: - The websocket target URL component. - """ - ... + def create(cls) -> Var: ... # type: ignore def default_connection_error() -> list[str | Var | Component]: ... @@ -105,24 +54,24 @@ class ConnectionToaster(Toaster): visible_toasts: Optional[Union[Var[int], int]] = None, position: Optional[ Union[ + Literal[ + "bottom-center", + "bottom-left", + "bottom-right", + "top-center", + "top-left", + "top-right", + ], Var[ Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", "bottom-center", + "bottom-left", "bottom-right", + "top-center", + "top-left", + "top-right", ] ], - Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", - "bottom-center", - "bottom-right", - ], ] ] = None, close_button: Optional[Union[Var[bool], bool]] = None, @@ -130,61 +79,31 @@ class ConnectionToaster(Toaster): dir: Optional[Union[Var[str], str]] = None, hotkey: Optional[Union[Var[str], str]] = None, invert: Optional[Union[Var[bool], bool]] = None, - toast_options: Optional[Union[Var[ToastProps], ToastProps]] = None, + toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None, gap: Optional[Union[Var[int], int]] = None, - loading_icon: Optional[Union[Var[Icon], Icon]] = None, + loading_icon: Optional[Union[Icon, Var[Icon]]] = None, pause_when_page_is_hidden: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ConnectionToaster": """Create a connection toaster component. @@ -229,52 +148,22 @@ class ConnectionBanner(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ConnectionBanner": """Create a connection banner component. @@ -298,52 +187,22 @@ class ConnectionModal(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ConnectionModal": """Create a connection banner component. @@ -368,52 +227,22 @@ class WifiOffPulse(Icon): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "WifiOffPulse": """Create a wifi_off icon with an animated opacity pulse. @@ -442,87 +271,57 @@ class ConnectionPulser(Div): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ConnectionPulser": """Create a connection pulser component. Args: - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/core/breakpoints.py b/reflex/components/core/breakpoints.py index 4b2372a70..25396ecd9 100644 --- a/reflex/components/core/breakpoints.py +++ b/reflex/components/core/breakpoints.py @@ -58,7 +58,7 @@ class Breakpoints(Dict[K, V]): Args: custom: Custom mapping using CSS values or variables. - initial: Styling when in the inital width + initial: Styling when in the initial width xs: Styling when in the extra-small width sm: Styling when in the small width md: Styling when in the medium width diff --git a/reflex/components/core/client_side_routing.py b/reflex/components/core/client_side_routing.py index 618467f39..a10b90de8 100644 --- a/reflex/components/core/client_side_routing.py +++ b/reflex/components/core/client_side_routing.py @@ -13,18 +13,18 @@ from __future__ import annotations from reflex import constants from reflex.components.component import Component from reflex.components.core.cond import cond -from reflex.vars import Var +from reflex.vars.base import Var -route_not_found: Var = Var.create_safe(constants.ROUTE_NOT_FOUND, _var_is_string=False) +route_not_found: Var = Var(_js_expr=constants.ROUTE_NOT_FOUND) class ClientSideRouting(Component): """The client-side routing component.""" - library = "/utils/client_side_routing" + library = "$/utils/client_side_routing" tag = "useClientSideRouting" - def add_hooks(self) -> list[str]: + def add_hooks(self) -> list[str | Var]: """Get the hooks to render. Returns: @@ -66,4 +66,4 @@ class Default404Page(Component): tag = "Error" is_default = True - status_code: Var[int] = 404 # type: ignore + status_code: Var[int] = Var.create(404) diff --git a/reflex/components/core/client_side_routing.pyi b/reflex/components/core/client_side_routing.pyi index 7562f6f5c..581b0e120 100644 --- a/reflex/components/core/client_side_routing.pyi +++ b/reflex/components/core/client_side_routing.pyi @@ -3,17 +3,17 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var route_not_found: Var class ClientSideRouting(Component): - def add_hooks(self) -> list[str]: ... + def add_hooks(self) -> list[str | Var]: ... def render(self) -> str: ... @overload @classmethod @@ -25,52 +25,22 @@ class ClientSideRouting(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ClientSideRouting": """Create the component. @@ -104,52 +74,22 @@ class Default404Page(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Default404Page": """Create the component. diff --git a/reflex/components/core/clipboard.py b/reflex/components/core/clipboard.py index 9b0edcc29..644de80d0 100644 --- a/reflex/components/core/clipboard.py +++ b/reflex/components/core/clipboard.py @@ -2,14 +2,16 @@ from __future__ import annotations -from typing import Dict, List, Union +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 +from reflex.constants.compiler import Hooks +from reflex.event import EventChain, EventHandler, passthrough_event_spec from reflex.utils.format import format_prop, wrap from reflex.utils.imports import ImportVar -from reflex.vars import Var, get_unique_variable_name +from reflex.vars import get_unique_variable_name +from reflex.vars.base import Var, VarData class Clipboard(Fragment): @@ -19,7 +21,7 @@ class Clipboard(Fragment): 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[lambda data: [data]] + on_paste: EventHandler[passthrough_event_spec(List[Tuple[str, str]])] # Save the original event actions for the on_paste event. on_paste_event_actions: Var[Dict[str, Union[bool, int]]] @@ -50,7 +52,7 @@ class Clipboard(Fragment): return super().create(*children, **props) def _exclude_props(self) -> list[str]: - return super()._exclude_props() + ["on_paste", "on_paste_event_actions"] + return [*super()._exclude_props(), "on_paste", "on_paste_event_actions"] def _render(self) -> Tag: tag = super()._render() @@ -66,12 +68,12 @@ class Clipboard(Fragment): The import dict for the component. """ return { - "/utils/helpers/paste.js": ImportVar( + "$/utils/helpers/paste.js": ImportVar( tag="usePasteHandler", is_default=True ), } - def add_hooks(self) -> list[str]: + def add_hooks(self) -> list[str | Var[str]]: """Add hook to register paste event listener. Returns: @@ -82,13 +84,14 @@ class Clipboard(Fragment): return [] if isinstance(on_paste, EventChain): on_paste = wrap(str(format_prop(on_paste)).strip("{}"), "(") + hook_expr = f"usePasteHandler({self.targets!s}, {self.on_paste_event_actions!s}, {on_paste!s})" + return [ - "usePasteHandler(%s, %s, %s)" - % ( - self.targets._var_name_unwrapped, - self.on_paste_event_actions._var_name_unwrapped, - on_paste, - ) + Var( + hook_expr, + _var_type="str", + _var_data=VarData(position=Hooks.HookPosition.POST_TRIGGER), + ), ] diff --git a/reflex/components/core/clipboard.pyi b/reflex/components/core/clipboard.pyi index 29ad80c2f..328554f2a 100644 --- a/reflex/components/core/clipboard.pyi +++ b/reflex/components/core/clipboard.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Optional, Union, overload +from typing import Any, Dict, List, Optional, Union, overload from reflex.components.base.fragment import Fragment -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportVar -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Clipboard(Fragment): @overload @@ -17,64 +17,37 @@ class Clipboard(Fragment): def create( # type: ignore cls, *children, - targets: Optional[Union[Var[List[str]], List[str]]] = None, + targets: Optional[Union[List[str], Var[List[str]]]] = None, on_paste_event_actions: Optional[ - Union[Var[Dict[str, Union[bool, int]]], Dict[str, Union[bool, int]]] + Union[Dict[str, Union[bool, int]], Var[Dict[str, Union[bool, int]]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_paste: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[list[tuple[str, str]]], BASE_STATE], + ] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Clipboard": """Create a Clipboard component. @@ -82,6 +55,7 @@ class Clipboard(Fragment): 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. @@ -97,6 +71,6 @@ class Clipboard(Fragment): ... def add_imports(self) -> dict[str, ImportVar]: ... - def add_hooks(self) -> list[str]: ... + def add_hooks(self) -> list[str | Var[str]]: ... clipboard = Clipboard.create diff --git a/reflex/components/core/cond.py b/reflex/components/core/cond.py index 5d9ab7544..488990f54 100644 --- a/reflex/components/core/cond.py +++ b/reflex/components/core/cond.py @@ -2,20 +2,20 @@ from __future__ import annotations -from typing import Any, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, overload 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, resolved_color_mode -from reflex.utils import format from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import BaseVar, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var +from reflex.vars.number import ternary_operation _IS_TRUE_IMPORT: ImportDict = { - f"/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")], + f"$/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")], } @@ -49,9 +49,9 @@ class Cond(MemoizationLeaf): The conditional component. """ # Wrap everything in fragments. - if comp1.__class__.__name__ != "Fragment": + if type(comp1).__name__ != "Fragment": comp1 = Fragment.create(comp1) - if comp2 is None or comp2.__class__.__name__ != "Fragment": + if comp2 is None or type(comp2).__name__ != "Fragment": comp2 = Fragment.create(comp2) if comp2 else Fragment.create() return Fragment.create( cls( @@ -94,7 +94,7 @@ class Cond(MemoizationLeaf): ).set( props=tag.format_props(), ), - cond_state=f"isTrue({self.cond._var_full_name})", + cond_state=f"isTrue({self.cond!s})", ) def add_imports(self) -> ImportDict: @@ -103,10 +103,11 @@ class Cond(MemoizationLeaf): Returns: The import dict for the component. """ - cond_imports: dict[str, str | ImportVar | list[str | ImportVar]] = getattr( - self.cond._var_data, "imports", {} - ) - return {**cond_imports, **_IS_TRUE_IMPORT} + var_data = VarData.merge(self.cond._get_all_var_data()) + + imports = var_data.old_school_imports() if var_data else {} + + return {**imports, **_IS_TRUE_IMPORT} @overload @@ -118,10 +119,10 @@ def cond(condition: Any, c1: Component) -> Component: ... @overload -def cond(condition: Any, c1: Any, c2: Any) -> BaseVar: ... +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: @@ -135,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. @@ -160,40 +153,32 @@ 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]) - - c1_type = c1._var_type if isinstance(c1, Var) else type(c1) - c2_type = c2._var_type if isinstance(c2, Var) else type(c2) - - var_type = c1_type if c1_type == c2_type else Union[c1_type, c2_type] # 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=var_type, - _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, ) +@overload +def color_mode_cond(light: Component, dark: Component | None = None) -> Component: ... # type: ignore + + +@overload +def color_mode_cond(light: Any, dark: Any = None) -> Var: ... + + def color_mode_cond(light: Any, dark: Any = None) -> Var | Component: """Create a component or Prop based on color_mode. @@ -205,7 +190,7 @@ def color_mode_cond(light: Any, dark: Any = None) -> Var | Component: The conditional component or prop. """ return cond( - resolved_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 4dc7c14a1..12cc94426 100644 --- a/reflex/components/core/debounce.py +++ b/reflex/components/core/debounce.py @@ -6,8 +6,9 @@ from typing import Any, Type, Union from reflex.components.component import Component from reflex.constants import EventTriggers -from reflex.event import EventHandler -from reflex.vars import Var, VarData +from reflex.event import EventHandler, no_args_event_spec +from reflex.vars import VarData +from reflex.vars.base import Var DEFAULT_DEBOUNCE_TIMEOUT = 300 @@ -45,7 +46,7 @@ class DebounceInput(Component): element: Var[Type[Component]] # Fired when the input value changes - on_change: EventHandler[lambda e0: [e0.value]] + on_change: EventHandler[no_args_event_spec] @classmethod def create(cls, *children: Component, **props: Any) -> Component: @@ -106,23 +107,20 @@ class DebounceInput(Component): props[field] = getattr(child, field) child_ref = child.get_ref() if props.get("input_ref") is None and child_ref: - props["input_ref"] = Var.create_safe( - child_ref, _var_is_local=False, _var_is_string=False - ) + props["input_ref"] = Var(_js_expr=child_ref, _var_type=str) props["id"] = child.id # Set the child element to wrap, including any imports/hooks from the child. props.setdefault( "element", - Var.create_safe( - "{%s}" % (child.alias or child.tag), - _var_is_local=False, - _var_is_string=False, + Var( + _js_expr=str(child.alias or child.tag), + _var_type=Type[Component], _var_data=VarData( imports=child._get_imports(), - hooks=child._get_hooks_internal(), + hooks=child._get_all_hooks(), ), - ).to(Type[Component]), + ), ) component = super().create(**props) @@ -130,6 +128,10 @@ 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 _render(self): diff --git a/reflex/components/core/debounce.pyi b/reflex/components/core/debounce.pyi index 59e87f366..9e61af6e3 100644 --- a/reflex/components/core/debounce.pyi +++ b/reflex/components/core/debounce.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Type, Union, overload +from typing import Any, Dict, Optional, Type, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var DEFAULT_DEBOUNCE_TIMEOUT = 300 @@ -22,63 +22,31 @@ class DebounceInput(Component): debounce_timeout: Optional[Union[Var[int], int]] = None, force_notify_by_enter: Optional[Union[Var[bool], bool]] = None, force_notify_on_blur: Optional[Union[Var[bool], bool]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, input_ref: Optional[Union[Var[str], str]] = None, - element: Optional[Union[Var[Type[Component]], Type[Component]]] = None, + element: Optional[Union[Type[Component], Var[Type[Component]]]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_change: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DebounceInput": """Create a DebounceInput component. diff --git a/reflex/components/core/foreach.py b/reflex/components/core/foreach.py index 44e0685dd..c9fbe5bc5 100644 --- a/reflex/components/core/foreach.py +++ b/reflex/components/core/foreach.py @@ -10,8 +10,7 @@ from reflex.components.component import Component from reflex.components.tags import IterTag from reflex.constants import MemoizationMode from reflex.state import ComponentState -from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var class ForeachVarError(TypeError): @@ -38,14 +37,12 @@ class Foreach(Component): cls, iterable: Var[Iterable] | Iterable, render_fn: Callable, - **props, ) -> Foreach: """Create a foreach component. Args: iterable: The iterable to create components from. render_fn: A function from the render args to the component. - **props: The attributes to pass to each child component (deprecated). Returns: The foreach component. @@ -54,17 +51,10 @@ class Foreach(Component): ForeachVarError: If the iterable is of type Any. TypeError: If the render function is a ComponentState. """ - if props: - console.deprecate( - feature_name="Passing props to rx.foreach", - reason="it does not have the intended effect and may be confusing", - deprecation_version="0.5.0", - removal_version="0.6.0", - ) - iterable = Var.create_safe(iterable, _var_is_string=False) + 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 `{iterable!s}` of type Any. " "(If you are trying to foreach over a state var, add a type annotation to the var). " "See https://reflex.dev/docs/library/dynamic-rendering/foreach/" ) @@ -136,7 +126,7 @@ class Foreach(Component): return dict( tag, - iterable_state=tag.iterable._var_full_name, + iterable_state=str(tag.iterable), arg_name=tag.arg_var_name, arg_index=tag.get_index_var_arg(), iterable_type=tag.iterable._var_type.mro()[0].__name__, diff --git a/reflex/components/core/html.py b/reflex/components/core/html.py index 812bf64be..cfe46e591 100644 --- a/reflex/components/core/html.py +++ b/reflex/components/core/html.py @@ -3,7 +3,7 @@ from typing import Dict from reflex.components.el.elements.typography import Div -from reflex.vars import Var +from reflex.vars.base import Var class Html(Div): diff --git a/reflex/components/core/html.pyi b/reflex/components/core/html.pyi index 62bec0063..e65549d0f 100644 --- a/reflex/components/core/html.pyi +++ b/reflex/components/core/html.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.el.elements.typography import Div -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Html(Div): @overload @@ -17,83 +17,53 @@ class Html(Div): cls, *children, dangerouslySetInnerHTML: Optional[ - Union[Var[Dict[str, str]], Dict[str, str]] + Union[Dict[str, str], Var[Dict[str, str]]] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Html": """Create a html component. @@ -101,7 +71,7 @@ class Html(Div): Args: *children: The children of the component. dangerouslySetInnerHTML: The HTML to render. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/core/match.py b/reflex/components/core/match.py index e85739605..8b9382c89 100644 --- a/reflex/components/core/match.py +++ b/reflex/components/core/match.py @@ -5,13 +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, types from reflex.utils.exceptions import MatchTypeError from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var class Match(MemoizationLeaf): @@ -27,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: @@ -46,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" ) @@ -56,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: @@ -68,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: @@ -94,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() @@ -103,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): @@ -117,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: @@ -159,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) @@ -168,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: @@ -182,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}" ) @@ -197,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: @@ -230,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: @@ -275,7 +267,8 @@ class Match(MemoizationLeaf): Returns: The import dict. """ - return getattr(self.cond._var_data, "imports", {}) + var_data = VarData.merge(self.cond._get_all_var_data()) + return var_data.old_school_imports() if var_data else {} match = Match.create diff --git a/reflex/components/core/upload.py b/reflex/components/core/upload.py index 3c2113253..14205cc6b 100644 --- a/reflex/components/core/upload.py +++ b/reflex/components/core/upload.py @@ -2,32 +2,42 @@ from __future__ import annotations -import os from pathlib import Path -from typing import Callable, ClassVar, Dict, List, Optional +from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple -from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf +from reflex.components.base.fragment import Fragment +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 Hooks, Imports from reflex.event import ( CallableEventSpec, EventChain, EventHandler, EventSpec, call_event_fn, - call_script, parse_args_spec, + run_script, ) +from reflex.utils import format from reflex.utils.imports import ImportVar -from reflex.vars import BaseVar, CallableVar, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import CallableVar, Var, get_unique_variable_name +from reflex.vars.sequence import LiteralStringVar DEFAULT_UPLOAD_ID: str = "default" upload_files_context_var_data: VarData = VarData( imports={ "react": "useContext", - f"/{Dirs.CONTEXTS_PATH}": "UploadFilesContext", + f"$/{Dirs.CONTEXTS_PATH}": "UploadFilesContext", }, hooks={ "const [filesById, setFilesById] = useContext(UploadFilesContext);": None, @@ -36,7 +46,7 @@ upload_files_context_var_data: VarData = VarData( @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 @@ -48,23 +58,25 @@ def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: Returns: A var referencing the file upload drop trigger. """ - id_var = Var.create_safe(id_, _var_is_string=True) + id_var = LiteralStringVar.create(id_) var_name = f"""e => setFilesById(filesById => {{ const updatedFilesById = Object.assign({{}}, filesById); - updatedFilesById[{id_var._var_name_unwrapped}] = e; + updatedFilesById[{id_var!s}] = e; return updatedFilesById; }}) """ - return BaseVar( - _var_name=var_name, + return Var( + _js_expr=var_name, _var_type=EventChain, - _var_data=VarData.merge(upload_files_context_var_data, id_var._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: @@ -73,12 +85,14 @@ def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> BaseVar: Returns: A var referencing the list of selected file paths. """ - id_var = Var.create_safe(id_, _var_is_string=True) - return BaseVar( - _var_name=f"(filesById[{id_var._var_name_unwrapped}] ? filesById[{id_var._var_name_unwrapped}].map((f) => (f.path || f.name)) : [])", + id_var = LiteralStringVar.create(id_) + return Var( + _js_expr=f"(filesById[{id_var!s}] ? filesById[{id_var!s}].map((f) => (f.path || f.name)) : [])", _var_type=List[str], - _var_data=VarData.merge(upload_files_context_var_data, id_var._var_data), - ) + _var_data=VarData.merge( + upload_files_context_var_data, id_var._get_all_var_data() + ), + ).guess_type() @CallableEventSpec @@ -93,8 +107,9 @@ def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: """ # UploadFilesProvider assigns a special function to clear selected files # into the shared global refs object to make it accessible outside a React - # component via `call_script` (otherwise backend could never clear files). - return call_script(f"refs['__clear_selected_files']({id_!r})") + # component via `run_script` (otherwise backend could never clear files). + func = Var("__clear_selected_files")._as_ref() + return run_script(f"{func}({id_!r})") def cancel_upload(upload_id: str) -> EventSpec: @@ -106,9 +121,8 @@ def cancel_upload(upload_id: str) -> EventSpec: Returns: An event spec that cancels the upload when triggered. """ - return call_script( - f"upload_controllers[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]?.abort()" - ) + controller = Var(f"__upload_controllers_{upload_id}")._as_ref() + return run_script(f"{controller}?.abort()") def get_upload_dir() -> Path: @@ -119,23 +133,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.get() uploaded_files_dir.mkdir(parents=True, exist_ok=True) return uploaded_files_dir -uploaded_files_url_prefix: Var = Var.create_safe( - "${getBackendURL(env.UPLOAD)}", - _var_is_string=False, +uploaded_files_url_prefix = Var( + _js_expr="getBackendURL(env.UPLOAD)", _var_data=VarData( imports={ - f"/{Dirs.STATE_PATH}": "getBackendURL", - "/env.json": ImportVar(tag="env", is_default=True), + f"$/{Dirs.STATE_PATH}": "getBackendURL", + "$/env.json": ImportVar(tag="env", is_default=True), } ), -) +).to(str) def get_upload_url(file_path: str) -> Var[str]: @@ -149,12 +160,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: @@ -163,24 +172,29 @@ 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 GhostUpload(Fragment): + """A ghost upload component.""" + + # Fired when files are dropped. + on_drop: EventHandler[_on_drop_spec] + + 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. @@ -200,7 +214,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] @@ -231,6 +245,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): @@ -242,19 +258,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) @@ -276,9 +279,75 @@ class Upload(MemoizationLeaf): ), ) upload_props["on_drop"] = on_drop + + 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( + GhostUpload.create(on_drop=upload_props["on_drop"]) + )["on_drop"] + + upload_props["on_drop"] = event_var + + upload_props = { + format.to_camel_case(key): value for key, value in upload_props.items() + } + + use_dropzone_arguments = Var.create( + { + "onDrop": event_var, + **upload_props, + } + ) + + left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} " + right_side = f"useDropzone({use_dropzone_arguments!s})" + + var_data = VarData.merge( + VarData( + imports=Imports.EVENTS, + hooks={Hooks.EVENTS: None}, + ), + event_var._get_all_var_data(), + use_dropzone_arguments._get_all_var_data(), + VarData( + hooks={ + callback_str: None, + f"{left_side} = {right_side};": None, + }, + imports={ + "react-dropzone": "useDropzone", + **Imports.EVENTS, + }, + ), + ) + + # 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, + ) + ] + + # 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, - **upload_props, ) @classmethod @@ -291,16 +360,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 { diff --git a/reflex/components/core/upload.pyi b/reflex/components/core/upload.pyi index 54bb351de..6238ff9cb 100644 --- a/reflex/components/core/upload.pyi +++ b/reflex/components/core/upload.pyi @@ -4,30 +4,38 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from pathlib import Path -from typing import Any, Callable, ClassVar, Dict, List, Optional, Union, overload +from typing import Any, ClassVar, Dict, List, Optional, Union, overload +from reflex.components.base.fragment import Fragment from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf -from reflex.event import ( - CallableEventSpec, - EventHandler, - EventSpec, -) +from reflex.constants import Dirs +from reflex.event import BASE_STATE, CallableEventSpec, EventSpec, EventType from reflex.style import Style -from reflex.vars import BaseVar, CallableVar, Var, VarData +from reflex.utils.imports import ImportVar +from reflex.vars import VarData +from reflex.vars.base import CallableVar, Var DEFAULT_UPLOAD_ID: str upload_files_context_var_data: VarData @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]: ... @@ -42,52 +50,22 @@ class UploadFilesProvider(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "UploadFilesProvider": """Create the component. @@ -107,6 +85,56 @@ class UploadFilesProvider(Component): """ ... +class GhostUpload(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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_drop: Optional[ + Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]] + ] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "GhostUpload": + """Create the component. + + Args: + *children: The children of the component. + 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. + 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 Upload(MemoizationLeaf): is_used: ClassVar[bool] = False @@ -115,7 +143,7 @@ class Upload(MemoizationLeaf): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None, + accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None, disabled: Optional[Union[Var[bool], bool]] = None, max_files: Optional[Union[Var[int], int]] = None, max_size: Optional[Union[Var[int], int]] = None, @@ -129,55 +157,25 @@ class Upload(MemoizationLeaf): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_drop: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]] ] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Upload": """Create an upload component. @@ -193,6 +191,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. @@ -212,7 +211,7 @@ class StyledUpload(Upload): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None, + accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None, disabled: Optional[Union[Var[bool], bool]] = None, max_files: Optional[Union[Var[int], int]] = None, max_size: Optional[Union[Var[int], int]] = None, @@ -226,55 +225,25 @@ class StyledUpload(Upload): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_drop: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]] ] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "StyledUpload": """Create the styled upload component. @@ -290,6 +259,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. @@ -309,7 +279,7 @@ class UploadNamespace(ComponentNamespace): @staticmethod def __call__( *children, - accept: Optional[Union[Var[Optional[Dict[str, List]]], Dict[str, List]]] = None, + accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None, disabled: Optional[Union[Var[bool], bool]] = None, max_files: Optional[Union[Var[int], int]] = None, max_size: Optional[Union[Var[int], int]] = None, @@ -323,55 +293,25 @@ class UploadNamespace(ComponentNamespace): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_drop: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]] ] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "StyledUpload": """Create the styled upload component. @@ -387,6 +327,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. diff --git a/reflex/components/datadisplay/__init__.py b/reflex/components/datadisplay/__init__.py index fe613ee52..1aff69676 100644 --- a/reflex/components/datadisplay/__init__.py +++ b/reflex/components/datadisplay/__init__.py @@ -8,7 +8,6 @@ _SUBMOD_ATTRS: dict[str, list[str]] = { "code": [ "CodeBlock", "code_block", - "LiteralCodeBlockTheme", "LiteralCodeLanguage", ], "dataeditor": ["data_editor", "data_editor_theme", "DataEditorTheme"], diff --git a/reflex/components/datadisplay/__init__.pyi b/reflex/components/datadisplay/__init__.pyi index 4882c83df..32b29d106 100644 --- a/reflex/components/datadisplay/__init__.pyi +++ b/reflex/components/datadisplay/__init__.pyi @@ -4,7 +4,6 @@ # ------------------------------------------------------ from .code import CodeBlock as CodeBlock -from .code import LiteralCodeBlockTheme as LiteralCodeBlockTheme from .code import LiteralCodeLanguage as LiteralCodeLanguage from .code import code_block as code_block from .dataeditor import DataEditorTheme as DataEditorTheme diff --git a/reflex/components/datadisplay/code.py b/reflex/components/datadisplay/code.py index 47cba3736..2d5dfc625 100644 --- a/reflex/components/datadisplay/code.py +++ b/reflex/components/datadisplay/code.py @@ -2,69 +2,21 @@ 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.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.markdown.markdown import _LANGUAGE, MarkdownComponentMap 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 -from reflex.utils.imports import ImportDict, 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 ImportVar +from reflex.vars.base import LiteralVar, Var, VarData LiteralCodeLanguage = Literal[ "abap", @@ -349,20 +301,98 @@ LiteralCodeLanguage = Literal[ ] -class CodeBlock(Component): +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, MarkdownComponentMap): """A code block.""" - library = "react-syntax-highlighter@15.5.0" + library = "react-syntax-highlighter@15.6.0" 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] @@ -382,67 +412,22 @@ class CodeBlock(Component): # Props passed down to the code tag. code_tag_props: Var[Dict[str, str]] - def add_imports(self) -> ImportDict: - """Add imports for the CodeBlock component. + # Whether a copy button should appear. + can_copy: Optional[bool] = False - Returns: - The import dict. - """ - imports_: ImportDict = {} - themes = re.findall(r"`(.*?)`", self.theme._var_name) - if not themes: - themes = [self.theme._var_name] - - imports_.update( - { - 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 - } - ) - - if ( - self.language is not None - and self.language._var_name in LiteralCodeLanguage.__args__ # type: ignore - ): - 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 imports_ - - def _get_custom_code(self) -> Optional[str]: - if ( - self.language is not None - and self.language._var_name in LiteralCodeLanguage.__args__ # type: ignore - ): - return f"{self.alias}.registerLanguage('{self.language._var_name}', {format.to_camel_case(self.language._var_name)})" + # A custom copy button to override the default one. + copy_button: Optional[Union[bool, Component]] = None @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: @@ -450,15 +435,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 + # react-syntax-highlighter doesn't 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] @@ -484,7 +480,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( @@ -503,33 +499,65 @@ class CodeBlock(Component): 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, - _var_is_string=False, - ) - ).remove_props("theme", "code") - if self.code is not None: - out.special_props.add( - Var.create_safe(f"children={str(self.code)}", _var_is_string=False) - ) + + theme = self.theme + + out.add_props(style=theme).remove_props("theme", "code", "language").add_props( + children=self.code, language=_LANGUAGE + ) + 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. + @classmethod + def _get_language_registration_hook(cls) -> str: + """Get the hook to register the language. Returns: - The right theme name. + The hook to register the language. """ - if theme in ["light", "dark"]: - return f"one-{theme}" - return theme + return f""" + if ({_LANGUAGE!s}) {{ + (async () => {{ + try {{ + const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{{_LANGUAGE!s}}}`); + SyntaxHighlighter.registerLanguage({_LANGUAGE!s}, module.default); + }} catch (error) {{ + console.error(`Error importing language module for ${{{_LANGUAGE!s}}}:`, error); + }} + }})(); + }} +""" + + @classmethod + def get_component_map_custom_code(cls) -> str: + """Get the custom code for the component. + + Returns: + The custom code for the component. + """ + return cls._get_language_registration_hook() + + def add_hooks(self) -> list[str | Var]: + """Add hooks for the component. + + Returns: + The hooks for the component. + """ + return [ + f"const {_LANGUAGE!s} = {self.language!s}", + self._get_language_registration_hook(), + ] -code_block = CodeBlock.create +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 a60838b8e..da89195ce 100644 --- a/reflex/components/datadisplay/code.pyi +++ b/reflex/components/datadisplay/code.pyi @@ -3,62 +3,16 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +import dataclasses +from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload -from reflex.components.component import Component +from reflex.components.component import Component, ComponentNamespace +from reflex.components.markdown.markdown import MarkdownComponentMap from reflex.constants.colors import Color -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +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", @@ -341,117 +295,350 @@ LiteralCodeLanguage = Literal[ "zig", ] -class CodeBlock(Component): - def add_imports(self) -> ImportDict: ... +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, MarkdownComponentMap): @overload @classmethod def create( # type: ignore cls, *children, - can_copy: Optional[bool] = False, - copy_button: Optional[Union[Component, bool]] = None, - theme: Optional[ - Union[ - Var[ - Literal[ - "a11y-dark", - "atom-dark", - "cb", - "coldark-cold", - "coldark-dark", - "coy", - "coy-without-shadows", - "darcula", - "dark", - "dracula", - "duotone-dark", - "duotone-earth", - "duotone-forest", - "duotone-light", - "duotone-sea", - "duotone-space", - "funky", - "ghcolors", - "gruvbox-dark", - "gruvbox-light", - "holi-theme", - "hopscotch", - "light", - "lucario", - "material-dark", - "material-light", - "material-oceanic", - "night-owl", - "nord", - "okaidia", - "one-dark", - "one-light", - "pojoaque", - "prism", - "shades-of-purple", - "solarized-dark-atom", - "solarizedlight", - "synthwave84", - "tomorrow", - "twilight", - "vs", - "vs-dark", - "vsc-dark-plus", - "xonokai", - "z-touch", - ] - ], - Literal[ - "a11y-dark", - "atom-dark", - "cb", - "coldark-cold", - "coldark-dark", - "coy", - "coy-without-shadows", - "darcula", - "dark", - "dracula", - "duotone-dark", - "duotone-earth", - "duotone-forest", - "duotone-light", - "duotone-sea", - "duotone-space", - "funky", - "ghcolors", - "gruvbox-dark", - "gruvbox-light", - "holi-theme", - "hopscotch", - "light", - "lucario", - "material-dark", - "material-light", - "material-oceanic", - "night-owl", - "nord", - "okaidia", - "one-dark", - "one-light", - "pojoaque", - "prism", - "shades-of-purple", - "solarized-dark-atom", - "solarizedlight", - "synthwave84", - "tomorrow", - "twilight", - "vs", - "vs-dark", - "vsc-dark-plus", - "xonokai", - "z-touch", - ], - ] - ] = None, + theme: Optional[Union[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", @@ -735,6 +922,80 @@ 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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): ... + @classmethod + def get_component_map_custom_code(cls) -> str: ... + def add_hooks(self) -> list[str | Var]: ... + +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", @@ -1016,6 +1277,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, @@ -1023,66 +1567,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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -1091,6 +1605,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. @@ -1104,8 +1620,4 @@ class CodeBlock(Component): """ ... - def add_style(self): ... - @staticmethod - def convert_theme_name(theme) -> str: ... - -code_block = CodeBlock.create +code_block = CodeblockNamespace() diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py index c6d9c1981..f71f97713 100644 --- a/reflex/components/datadisplay/dataeditor.py +++ b/reflex/components/datadisplay/dataeditor.py @@ -3,16 +3,20 @@ from __future__ import annotations from enum import Enum -from typing import Any, 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.event import EventHandler +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec 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. @@ -47,27 +51,6 @@ class GridColumnIcons(Enum): VideoUri = "video_uri" -# @serializer -# def serialize_gridcolumn_icon(icon: GridColumnIcons) -> str: -# """Serialize grid column icon. - -# Args: -# icon: the Icon to serialize. - -# Returns: -# The serialized value. -# """ -# return "prefix" + str(icon) - - -# class DataEditorColumn(Base): -# """Column.""" - -# title: str -# id: Optional[str] = None -# type_: str = "str" - - class DataEditorTheme(Base): """The theme for the DataEditor component.""" @@ -105,17 +88,76 @@ class DataEditorTheme(Base): text_medium: Optional[str] = None -def on_edit_spec(pos, data: dict[str, Any]): - """The on edit spec function. +class Bounds(TypedDict): + """The bounds of the group header.""" - Args: - pos: The position of the edit event. - data: The data of the edit event. + x: int + y: int + width: int + height: int - Returns: - The position and data. - """ - return [pos, data] + +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): @@ -123,10 +165,9 @@ class DataEditor(NoSSRComponent): 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", "react-responsive-carousel@^3.2.7", ] @@ -143,7 +184,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] @@ -167,7 +208,7 @@ class DataEditor(NoSSRComponent): header_height: Var[int] # Additional header icons: - # header_icons: Var[Any] # (TODO: must be a map of name: svg) + # header_icons: Var[Any] # (TODO: must be a map of name: svg) #noqa: ERA001 # The maximum width a column can be automatically sized to. max_column_auto_width: Var[int] @@ -178,7 +219,7 @@ class DataEditor(NoSSRComponent): # The minimum width a column can be resized to. min_column_width: Var[int] - # Determins the height of each row. + # Determines the height of each row. row_height: Var[int] # Kind of row markers. @@ -221,52 +262,58 @@ class DataEditor(NoSSRComponent): theme: Var[Union[DataEditorTheme, Dict]] # Fired when a cell is activated. - on_cell_activated: EventHandler[lambda pos: [pos]] + on_cell_activated: EventHandler[passthrough_event_spec(Tuple[int, int])] # Fired when a cell is clicked. - on_cell_clicked: EventHandler[lambda pos: [pos]] + on_cell_clicked: EventHandler[passthrough_event_spec(Tuple[int, int])] # Fired when a cell is right-clicked. - on_cell_context_menu: EventHandler[lambda pos: [pos]] + on_cell_context_menu: EventHandler[passthrough_event_spec(Tuple[int, int])] # Fired when a cell is edited. - on_cell_edited: EventHandler[on_edit_spec] + on_cell_edited: EventHandler[passthrough_event_spec(Tuple[int, int], GridCell)] # Fired when a group header is clicked. - on_group_header_clicked: EventHandler[on_edit_spec] + on_group_header_clicked: EventHandler[ + passthrough_event_spec(Tuple[int, int], GridCell) + ] # Fired when a group header is right-clicked. - on_group_header_context_menu: EventHandler[lambda grp_idx, data: [grp_idx, data]] + on_group_header_context_menu: EventHandler[ + passthrough_event_spec(int, GroupHeaderClickedEventArgs) + ] # Fired when a group header is renamed. - on_group_header_renamed: EventHandler[lambda idx, val: [idx, val]] + on_group_header_renamed: EventHandler[passthrough_event_spec(str, str)] # Fired when a header is clicked. - on_header_clicked: EventHandler[lambda pos: [pos]] + on_header_clicked: EventHandler[passthrough_event_spec(Tuple[int, int])] # Fired when a header is right-clicked. - on_header_context_menu: EventHandler[lambda pos: [pos]] + on_header_context_menu: EventHandler[passthrough_event_spec(Tuple[int, int])] # Fired when a header menu item is clicked. - on_header_menu_click: EventHandler[lambda col, pos: [col, pos]] + on_header_menu_click: EventHandler[passthrough_event_spec(int, Rectangle)] # Fired when an item is hovered. - on_item_hovered: EventHandler[lambda pos: [pos]] + on_item_hovered: EventHandler[passthrough_event_spec(Tuple[int, int])] # Fired when a selection is deleted. - on_delete: EventHandler[lambda selection: [selection]] + on_delete: EventHandler[passthrough_event_spec(GridSelection)] # Fired when editing is finished. - on_finished_editing: EventHandler[lambda new_value, movement: [new_value, movement]] + on_finished_editing: EventHandler[ + passthrough_event_spec(Union[GridCell, None], tuple[int, int]) + ] # Fired when a row is appended. - on_row_appended: EventHandler[lambda: []] + on_row_appended: EventHandler[no_args_event_spec] # Fired when the selection is cleared. - on_selection_cleared: EventHandler[lambda: []] + on_selection_cleared: EventHandler[no_args_event_spec] # Fired when a column is resized. - on_column_resize: EventHandler[lambda col, width: [col, width]] + on_column_resize: EventHandler[passthrough_event_spec(GridColumn, int)] def add_imports(self) -> ImportDict: """Add imports for the component. @@ -277,7 +324,7 @@ class DataEditor(NoSSRComponent): return { "": f"{format.format_library_name(self.library)}/dist/index.css", self.library: "GridCellKind", - "/utils/helpers/dataeditor.js": ImportVar( + "$/utils/helpers/dataeditor.js": ImportVar( tag="formatDataEditorCells", is_default=False, install=False ), } @@ -292,15 +339,16 @@ class DataEditor(NoSSRComponent): 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, _var_is_string=False - ) # type: ignore + if self.get_cell_content is not None: + data_callback = self.get_cell_content._js_expr + else: + data_callback = f"getData_{editor_id}" + 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( [ @@ -329,17 +377,19 @@ 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: + 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 ( - types.is_dataframe(type(data)) - or isinstance(data, Var) - and types.is_dataframe(data._var_type) + if types.is_dataframe(type(data)) or ( + isinstance(data, Var) and types.is_dataframe(data._var_type) ): raise ValueError( "Cannot pass in both a pandas dataframe and columns to the data_editor component." @@ -355,7 +405,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) @@ -403,9 +453,9 @@ def serialize_dataeditortheme(theme: DataEditorTheme): Returns: The serialized theme. """ - return format.json_dumps( - {format.to_camel_case(k): v for k, v in theme.__dict__.items() if v is not None} - ) + return { + format.to_camel_case(k): v for k, v in theme.__dict__.items() if v is not None + } data_editor = DataEditor.create diff --git a/reflex/components/datadisplay/dataeditor.pyi b/reflex/components/datadisplay/dataeditor.pyi index 21ee461c3..d930fe256 100644 --- a/reflex/components/datadisplay/dataeditor.pyi +++ b/reflex/components/datadisplay/dataeditor.pyi @@ -4,15 +4,17 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from enum import Enum -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +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 NoSSRComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict from reflex.utils.serializers import serializer -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class GridColumnIcons(Enum): Array = "array" @@ -76,7 +78,53 @@ class DataEditorTheme(Base): text_light: Optional[str] text_medium: Optional[str] -def on_edit_spec(pos, data: dict[str, Any]): ... +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 add_imports(self) -> ImportDict: ... @@ -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,107 +175,101 @@ class DataEditor(NoSSRComponent): scroll_offset_x: Optional[Union[Var[int], int]] = None, scroll_offset_y: Optional[Union[Var[int], int]] = None, theme: Optional[ - Union[Var[Union[DataEditorTheme, Dict]], DataEditorTheme, Dict] + Union[DataEditorTheme, Dict, Var[Union[DataEditorTheme, Dict]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_cell_activated: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]] ] = None, on_cell_clicked: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]] ] = None, on_cell_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]] ] = None, on_cell_edited: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[tuple[int, int]], BASE_STATE], + EventType[[tuple[int, int], GridCell], BASE_STATE], + ] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, on_column_resize: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[GridColumn], BASE_STATE], + EventType[[GridColumn, int], BASE_STATE], + ] ] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, on_delete: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[GridSelection], BASE_STATE]] ] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_finished_editing: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[Union[GridCell, None]], BASE_STATE], + EventType[[Union[GridCell, None], tuple[int, int]], BASE_STATE], + ] ] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, on_group_header_clicked: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[tuple[int, int]], BASE_STATE], + EventType[[tuple[int, int], GridCell], BASE_STATE], + ] ] = None, on_group_header_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[int], BASE_STATE], + EventType[[int, GroupHeaderClickedEventArgs], BASE_STATE], + ] ] = None, on_group_header_renamed: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, str], BASE_STATE], + ] ] = None, on_header_clicked: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]] ] = None, on_header_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]] ] = None, on_header_menu_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[int], BASE_STATE], + EventType[[int, Rectangle], BASE_STATE], + ] ] = None, on_item_hovered: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_row_appended: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_selection_cleared: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[tuple[int, int]], BASE_STATE]] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_row_appended: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_selection_cleared: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DataEditor": """Create the DataEditor component. @@ -238,7 +280,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. @@ -246,10 +288,10 @@ class DataEditor(NoSSRComponent): freeze_columns: The number of columns which should remain in place when scrolling horizontally. Doesn't include rowMarkers. group_header_height: Controls the header of the group header row. header_height: Controls the height of the header row. - max_column_auto_width: Additional header icons: header_icons: Var[Any] # (TODO: must be a map of name: svg) The maximum width a column can be automatically sized to. + max_column_auto_width: The maximum width a column can be automatically sized to. max_column_width: The maximum width a column can be resized to. min_column_width: The minimum width a column can be resized to. - row_height: Determins the height of each row. + row_height: Determines the height of each row. row_markers: Kind of row markers. row_marker_start_index: Changes the starting index for row markers. row_marker_width: Sets the width of row markers in pixels, if unset row markers will automatically size. @@ -263,6 +305,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. diff --git a/reflex/components/datadisplay/logo.py b/reflex/components/datadisplay/logo.py index c00c8ebae..d960b8cee 100644 --- a/reflex/components/datadisplay/logo.py +++ b/reflex/components/datadisplay/logo.py @@ -1,8 +1,44 @@ """A Reflex logo component.""" +from typing import Union + import reflex as rx +def svg_logo(color: Union[str, rx.Var[str]] = rx.color_mode_cond("#110F1F", "white")): + """A Reflex logo SVG. + + Args: + color: The color of the logo. + + Returns: + The Reflex logo SVG. + """ + + def logo_path(d): + return rx.el.svg.path( + d=d, + ) + + 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.el.svg( + *[logo_path(d) for d in paths], + width="56", + height="12", + viewBox="0 0 56 12", + fill=color, + xmlns="http://www.w3.org/2000/svg", + ) + + def logo(**props): """A Reflex logo. @@ -12,32 +48,11 @@ def logo(**props): Returns: The logo component. """ - light_mode_logo = """ - - - - - - -""" - - dark_mode_logo = """ - - - - - - -""" - return rx.center( rx.link( rx.hstack( "Built with ", - rx.color_mode_cond( - rx.html(light_mode_logo), - rx.html(dark_mode_logo), - ), + svg_logo(), text_align="center", align="center", padding="1em", diff --git a/reflex/components/datadisplay/shiki_code_block.py b/reflex/components/datadisplay/shiki_code_block.py new file mode 100644 index 000000000..3b6bce8a1 --- /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.markdown.markdown import MarkdownComponentMap +from reflex.components.props import NoExtrasAllowedProps +from reflex.components.radix.themes.layout.box import Box +from reflex.event import run_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 run_script( + """ +// 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", # noqa: ERA001 + # }, + # ".tab::before": { + # "content": "'⇥'", # noqa: ERA001 + # "position": "absolute", # noqa: ERA001 + # "opacity": "0.3",# noqa: ERA001 + # }, + # ".space::before": { + # "content": "'·'", # noqa: ERA001 + # "position": "absolute", # noqa: ERA001 + # "opacity": "0.3", # noqa: ERA001 + # }, + } + ) + + 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, MarkdownComponentMap): + """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..92546ee4f --- /dev/null +++ b/reflex/components/datadisplay/shiki_code_block.pyi @@ -0,0 +1,2232 @@ +"""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.markdown.markdown import MarkdownComponentMap +from reflex.components.props import NoExtrasAllowedProps +from reflex.event import BASE_STATE, 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, MarkdownComponentMap): + @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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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..fbfc55f97 --- /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(" as ", ": ") + .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({js_string!s})" + ".then((component) => {" + "if (isMounted) {" + f"set_{unique_var_name}(component);" + "}" + "});" + "return () => {" + "isMounted = false;" + "};" + "}" + f", [{js_string!s}]);": None, + }, + ), + ), + ) diff --git a/reflex/components/el/__init__.py b/reflex/components/el/__init__.py index 9fe1d89cd..750e65dba 100644 --- a/reflex/components/el/__init__.py +++ b/reflex/components/el/__init__.py @@ -10,7 +10,6 @@ _SUBMODULES: set[str] = {"elements"} _SUBMOD_ATTRS: dict[str, list[str]] = { f"elements.{k}": v for k, v in elements._MAPPING.items() } -_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS __getattr__, __dir__, __all__ = lazy_loader.attach( __name__, diff --git a/reflex/components/el/__init__.pyi b/reflex/components/el/__init__.pyi index d312db84e..cbfb65f58 100644 --- a/reflex/components/el/__init__.pyi +++ b/reflex/components/el/__init__.pyi @@ -3,8 +3,9 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from . import elements +from . import elements as elements from .elements.forms import Button as Button +from .elements.forms import Datalist as Datalist from .elements.forms import Fieldset as Fieldset from .elements.forms import Form as Form from .elements.forms import Input as Input @@ -18,6 +19,7 @@ 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 datalist as datalist from .elements.forms import fieldset as fieldset from .elements.forms import form as form from .elements.forms import input as input @@ -88,36 +90,28 @@ from .elements.inline import u as u from .elements.inline import wbr as wbr from .elements.media import Area as Area from .elements.media import Audio as Audio -from .elements.media import Defs as Defs from .elements.media import Embed as Embed from .elements.media import Iframe as Iframe from .elements.media import Img as Img -from .elements.media import LinearGradient as LinearGradient from .elements.media import Map as Map from .elements.media import Object as Object -from .elements.media import Path as Path from .elements.media import Picture as Picture from .elements.media import Portal as Portal from .elements.media import Source as Source -from .elements.media import Stop as Stop from .elements.media import Svg as Svg from .elements.media import Track as Track from .elements.media import Video as Video from .elements.media import area as area from .elements.media import audio as audio -from .elements.media import defs as defs # type: ignore from .elements.media import embed as embed from .elements.media import iframe as iframe from .elements.media import image as image from .elements.media import img as img -from .elements.media import lineargradient as lineargradient # type: ignore from .elements.media import map as map from .elements.media import object as object -from .elements.media import path as path # type: ignore from .elements.media import picture as picture from .elements.media import portal as portal from .elements.media import source as source -from .elements.media import stop as stop # type: ignore from .elements.media import svg as svg from .elements.media import track as track from .elements.media import video as video @@ -231,5 +225,3 @@ from .elements.typography import ol as ol from .elements.typography import p as p from .elements.typography import pre as pre from .elements.typography import ul as ul - -_PYRIGHT_IGNORE_IMPORTS = elements._PYRIGHT_IGNORE_IMPORTS diff --git a/reflex/components/el/element.pyi b/reflex/components/el/element.pyi index ce87335c3..de5dee956 100644 --- a/reflex/components/el/element.pyi +++ b/reflex/components/el/element.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Element(Component): @overload @@ -21,52 +21,22 @@ class Element(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Element": """Create the component. diff --git a/reflex/components/el/elements/__init__.py b/reflex/components/el/elements/__init__.py index 024ae8c3d..f0d4fd200 100644 --- a/reflex/components/el/elements/__init__.py +++ b/reflex/components/el/elements/__init__.py @@ -7,6 +7,7 @@ from reflex.utils import lazy_loader _MAPPING = { "forms": [ "button", + "datalist", "fieldset", "form", "input", @@ -65,11 +66,6 @@ _MAPPING = { "portal", "source", "svg", - "defs", - "lineargradient", - "LinearGradient", - "stop", - "path", ], "metadata": [ "base", @@ -130,13 +126,12 @@ _MAPPING = { } -EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"] -for _, v in _MAPPING.items(): +EXCLUDE = ["del_", "Del", "image"] +for v in _MAPPING.values(): v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE]) _SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING -_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"] __getattr__, __dir__, __all__ = lazy_loader.attach( __name__, submod_attrs=_SUBMOD_ATTRS, diff --git a/reflex/components/el/elements/__init__.pyi b/reflex/components/el/elements/__init__.pyi index 4f218f361..defaa5848 100644 --- a/reflex/components/el/elements/__init__.pyi +++ b/reflex/components/el/elements/__init__.pyi @@ -4,6 +4,7 @@ # ------------------------------------------------------ from .forms import Button as Button +from .forms import Datalist as Datalist from .forms import Fieldset as Fieldset from .forms import Form as Form from .forms import Input as Input @@ -17,6 +18,7 @@ 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 datalist as datalist from .forms import fieldset as fieldset from .forms import form as form from .forms import input as input @@ -87,36 +89,28 @@ from .inline import u as u from .inline import wbr as wbr from .media import Area as Area from .media import Audio as Audio -from .media import Defs as Defs from .media import Embed as Embed from .media import Iframe as Iframe from .media import Img as Img -from .media import LinearGradient as LinearGradient from .media import Map as Map from .media import Object as Object -from .media import Path as Path from .media import Picture as Picture from .media import Portal as Portal from .media import Source as Source -from .media import Stop as Stop from .media import Svg as Svg from .media import Track as Track from .media import Video as Video from .media import area as area from .media import audio as audio -from .media import defs as defs # type: ignore from .media import embed as embed from .media import iframe as iframe from .media import image as image from .media import img as img -from .media import lineargradient as lineargradient # type: ignore from .media import map as map from .media import object as object -from .media import path as path # type: ignore from .media import picture as picture from .media import portal as portal from .media import source as source -from .media import stop as stop # type: ignore from .media import svg as svg from .media import track as track from .media import video as video @@ -234,6 +228,7 @@ from .typography import ul as ul _MAPPING = { "forms": [ "button", + "datalist", "fieldset", "form", "input", @@ -292,11 +287,6 @@ _MAPPING = { "portal", "source", "svg", - "defs", - "lineargradient", - "LinearGradient", - "stop", - "path", ], "metadata": ["base", "head", "link", "meta", "title", "style"], "other": ["details", "dialog", "summary", "slot", "template", "math", "html"], @@ -348,7 +338,6 @@ _MAPPING = { "Del", ], } -EXCLUDE = ["del_", "Del", "image", "lineargradient", "LinearGradient"] -for _, v in _MAPPING.items(): +EXCLUDE = ["del_", "Del", "image"] +for v in _MAPPING.values(): v.extend([mod.capitalize() for mod in v if mod not in EXCLUDE]) -_PYRIGHT_IGNORE_IMPORTS = ["stop", "lineargradient", "path", "defs"] diff --git a/reflex/components/el/elements/base.py b/reflex/components/el/elements/base.py index 5eb8aa70c..f6e191f68 100644 --- a/reflex/components/el/elements/base.py +++ b/reflex/components/el/elements/base.py @@ -1,15 +1,15 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Base classes.""" 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): """Base class for common attributes.""" - # Provides a hint for generating a keyboard shortcut for the current element. + # Provides a hint for generating a keyboard shortcut for the current element. access_key: Var[Union[str, int, bool]] # Controls whether and how text input is automatically capitalized as it is entered/edited by the user. diff --git a/reflex/components/el/elements/base.pyi b/reflex/components/el/elements/base.pyi index 14ee5b62c..b60dabe87 100644 --- a/reflex/components/el/elements/base.pyi +++ b/reflex/components/el/elements/base.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.el.element import Element -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class BaseHTML(Element): @overload @@ -16,88 +16,58 @@ class BaseHTML(Element): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "BaseHTML": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/el/elements/forms.py b/reflex/components/el/elements/forms.py index cdad212aa..61ded4fd3 100644 --- a/reflex/components/el/elements/forms.py +++ b/reflex/components/el/elements/forms.py @@ -1,31 +1,38 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Forms classes.""" 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, EventHandler -from reflex.utils.format import format_event_chain +from reflex.event import ( + EventChain, + EventHandler, + input_event, + key_event, + prevent_default, +) from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.utils.types import is_optional +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var from .base import BaseHTML -FORM_DATA = Var.create("form_data", _var_is_string=False) +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() @@ -78,7 +85,6 @@ class Datalist(BaseHTML): """Display the datalist element.""" tag = "datalist" - # No unique attributes, only common ones are inherited class Fieldset(Element): @@ -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.""" @@ -135,7 +159,7 @@ class Form(BaseHTML): handle_submit_unique_name: Var[str] # Fired when the form is submitted - on_submit: EventHandler[lambda e0: [FORM_DATA]] + on_submit: EventHandler[on_submit_event_spec, on_submit_string_event_spec] @classmethod def create(cls, *children, **props): @@ -148,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,7 +196,7 @@ class Form(BaseHTML): """ return { "react": "useCallback", - f"/{Dirs.STATE_PATH}": ["getRefValue", "getRefValues"], + f"$/{Dirs.STATE_PATH}": ["getRefValue", "getRefValues"], } def add_hooks(self) -> list[str]: @@ -184,9 +211,9 @@ class Form(BaseHTML): 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] + 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, ) @@ -197,8 +224,8 @@ class Form(BaseHTML): 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, ) } @@ -212,20 +239,16 @@ 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], _var_is_string=False).as_ref() - form_refs[ref[5:-3]] = Var.create_safe( - f"getRefValues({str(ref_var)})", - _var_is_local=False, - _var_is_string=False, - _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({ref_var!s})", + _var_data=VarData.merge(ref_var._get_all_var_data()), ) else: - ref_var = Var.create_safe(ref, _var_is_string=False).as_ref() - form_refs[ref[4:]] = Var.create_safe( - f"getRefValue({str(ref_var)})", - _var_is_local=False, - _var_is_string=False, - _var_data=ref_var._var_data, + ref_var = Var(_js_expr=ref)._as_ref() + form_refs[ref[4:]] = Var( + _js_expr=f"getRefValue({ref_var!s})", + _var_data=VarData.merge(ref_var._get_all_var_data()), ) return form_refs @@ -234,7 +257,8 @@ class Form(BaseHTML): yield from self._get_form_refs().values() def _exclude_props(self) -> list[str]: - return super()._exclude_props() + [ + return [ + *super()._exclude_props(), "reset_on_submit", "handle_submit_unique_name", ] @@ -345,19 +369,46 @@ class Input(BaseHTML): value: Var[Union[str, int, float]] # Fired when the input value changes - on_change: EventHandler[lambda e0: [e0.target.value]] + on_change: EventHandler[input_event] # Fired when the input gains focus - on_focus: EventHandler[lambda e0: [e0.target.value]] + on_focus: EventHandler[input_event] # Fired when the input loses focus - on_blur: EventHandler[lambda e0: [e0.target.value]] + on_blur: EventHandler[input_event] # Fired when a key is pressed down - on_key_down: EventHandler[lambda e0: [e0.key]] + on_key_down: EventHandler[key_event] # Fired when a key is released - on_key_up: EventHandler[lambda e0: [e0.key]] + on_key_up: EventHandler[key_event] + + @classmethod + def create(cls, *children, **props): + """Create an Input component. + + Args: + *children: The children of the component. + **props: The properties of the component. + + Returns: + The component. + """ + from reflex.vars.number import ternary_operation + + value = props.get("value") + + # React expects an empty string(instead of null) for controlled inputs. + if value is not None and is_optional( + (value_var := Var.create(value))._var_type + ): + props["value"] = ternary_operation( + (value_var != Var.create(None)) # pyright: ignore [reportGeneralTypeIssues] + & (value_var != Var(_js_expr="undefined")), + value, + Var.create(""), + ) + return super().create(*children, **props) class Label(BaseHTML): @@ -376,7 +427,6 @@ class Legend(BaseHTML): """Display the legend element.""" tag = "legend" - # No unique attributes, only common ones are inherited class Meter(BaseHTML): @@ -496,14 +546,14 @@ class Select(BaseHTML): size: Var[Union[str, int, bool]] # Fired when the select value changes - on_change: EventHandler[lambda e0: [e0.target.value]] + 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) { @@ -546,6 +596,9 @@ class Textarea(BaseHTML): # Visible width of the text control, in average character widths cols: Var[Union[str, int, bool]] + # The default value of the textarea when initially rendered + default_value: Var[str] + # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted dirname: Var[Union[str, int, bool]] @@ -586,22 +639,59 @@ class Textarea(BaseHTML): wrap: Var[Union[str, int, bool]] # Fired when the input value changes - on_change: EventHandler[lambda e0: [e0.target.value]] + on_change: EventHandler[input_event] # Fired when the input gains focus - on_focus: EventHandler[lambda e0: [e0.target.value]] + on_focus: EventHandler[input_event] # Fired when the input loses focus - on_blur: EventHandler[lambda e0: [e0.target.value]] + on_blur: EventHandler[input_event] # Fired when a key is pressed down - on_key_down: EventHandler[lambda e0: [e0.key]] + on_key_down: EventHandler[key_event] # Fired when a key is released - on_key_up: EventHandler[lambda e0: [e0.key]] + 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, {enter_key_submit!s})", + _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, {auto_height!s})", + _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() + [ + return [ + *super()._exclude_props(), "auto_height", "enter_key_submit", ] @@ -619,34 +709,9 @@ 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, - _var_is_string=False, - _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, - _var_is_string=False, - _var_data=self.auto_height._var_data, - ) - ) - return tag - button = Button.create +datalist = Datalist.create fieldset = Fieldset.create form = Form.create input = Input.create diff --git a/reflex/components/el/elements/forms.pyi b/reflex/components/el/elements/forms.pyi index 31a56e9be..dfab40b21 100644 --- a/reflex/components/el/elements/forms.pyi +++ b/reflex/components/el/elements/forms.pyi @@ -3,21 +3,21 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Tuple, Union, overload from jinja2 import Environment from reflex.components.el.element import Element -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType, KeyInputInfo from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML -FORM_DATA = Var.create("form_data", _var_is_string=False) +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): @@ -26,96 +26,66 @@ class Button(BaseHTML): def create( # type: ignore cls, *children, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Button": """Create the component. @@ -133,7 +103,7 @@ class Button(BaseHTML): name: Name of the button, used when sending form data type: Type of the button (submit, reset, or button) value: Value of the button, used when sending form data - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -168,88 +138,58 @@ class Datalist(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Datalist": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -284,60 +224,30 @@ class Fieldset(Element): def create( # type: ignore cls, *children, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Fieldset": """Create the component. @@ -360,105 +270,85 @@ 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): @overload @classmethod def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE] + ], + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE] + ], + ] ] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Form": """Create a form component. @@ -476,7 +366,8 @@ 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. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -514,132 +405,114 @@ class Input(BaseHTML): def create( # type: ignore cls, *children, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - capture: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - checked: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + capture: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + checked: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, default_checked: Optional[Union[Var[bool], bool]] = None, default_value: Optional[Union[Var[str], str]] = None, - dirname: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - list: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - multiple: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - pattern: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - placeholder: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - read_only: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - size: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - step: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + pattern: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + placeholder: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + read_only: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + size: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + step: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Input": - """Create the component. + """Create an Input component. Args: *children: The children of the component. @@ -676,7 +549,12 @@ 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 - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -698,7 +576,7 @@ class Input(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 component. Returns: The component. @@ -711,83 +589,53 @@ class Label(BaseHTML): def create( # type: ignore cls, *children, - html_for: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + html_for: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Label": """Create the component. @@ -796,7 +644,7 @@ class Label(BaseHTML): *children: The children of the component. html_for: ID of a form control with which the label is associated form: Associates the label with a form (by id) - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -831,88 +679,58 @@ class Legend(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Legend": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -947,88 +765,58 @@ class Meter(BaseHTML): def create( # type: ignore cls, *children, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - high: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - low: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - optimum: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + high: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + low: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + optimum: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Meter": """Create the component. @@ -1042,7 +830,7 @@ class Meter(BaseHTML): min: Minimum value of the range optimum: Optimum value in the range value: Current value of the meter - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1077,83 +865,53 @@ class Optgroup(BaseHTML): def create( # type: ignore cls, *children, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Optgroup": """Create the component. @@ -1162,7 +920,7 @@ class Optgroup(BaseHTML): *children: The children of the component. disabled: Disables the optgroup label: Label for the optgroup - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1197,85 +955,55 @@ class Option(BaseHTML): def create( # type: ignore cls, *children, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - selected: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + selected: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Option": """Create the component. @@ -1286,7 +1014,7 @@ class Option(BaseHTML): label: Label for the option, if the text is not the label selected: Indicates that the option is initially selected value: Value to be sent as form data - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1321,84 +1049,54 @@ class Output(BaseHTML): def create( # type: ignore cls, *children, - html_for: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + html_for: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Output": """Create the component. @@ -1408,7 +1106,7 @@ class Output(BaseHTML): html_for: Associates the output with one or more elements (by their IDs) form: Associates the output with a form (by id) name: Name of the output element for form submission - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1443,84 +1141,54 @@ class Progress(BaseHTML): def create( # type: ignore cls, *children, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Progress": """Create the component. @@ -1530,7 +1198,7 @@ class Progress(BaseHTML): form: Associates the progress element with a form (by id) max: Maximum value of the progress indicator value: Current value of the progress indicator - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1566,93 +1234,63 @@ class Select(BaseHTML): cls, *children, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - multiple: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - size: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + size: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Select": """Create the component. @@ -1667,7 +1305,8 @@ 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 - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -1696,7 +1335,7 @@ class Select(BaseHTML): """ ... -AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_enabled) {\n const el = e.target;\n el.style.overflowY = "hidden";\n el.style.height = "auto";\n el.style.height = (e.target.scrollHeight) + "px";\n if (el.form && !el.form.data_resize_on_reset) {\n el.form.addEventListener("reset", () => window.setTimeout(() => autoHeightOnInput(e, is_enabled), 0))\n el.form.data_resize_on_reset = true;\n }\n }\n}\n' +AUTO_HEIGHT_JS = '\nconst autoHeightOnInput = (e, is_enabled) => {\n if (is_enabled) {\n const el = e.target;\n el.style.overflowY = "scroll";\n el.style.height = "auto";\n el.style.height = (e.target.scrollHeight) + "px";\n if (el.form && !el.form.data_resize_on_reset) {\n el.form.addEventListener("reset", () => window.setTimeout(() => autoHeightOnInput(e, is_enabled), 0))\n el.form.data_resize_on_reset = true;\n }\n }\n}\n' ENTER_KEY_SUBMIT_JS = "\nconst enterKeySubmitOnKeyDown = (e, is_enabled) => {\n if (is_enabled && e.which === 13 && !e.shiftKey) {\n e.preventDefault();\n if (!e.repeat) {\n if (e.target.form) {\n e.target.form.requestSubmit();\n }\n }\n }\n}\n" class Textarea(BaseHTML): @@ -1706,118 +1345,102 @@ class Textarea(BaseHTML): cls, *children, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_height: Optional[Union[Var[bool], bool]] = None, - cols: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - dirname: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - disabled: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + default_value: Optional[Union[Var[str], str]] = None, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + disabled: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_submit: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - max_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - min_length: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - placeholder: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - read_only: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - required: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - rows: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - wrap: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + max_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + min_length: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + placeholder: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + read_only: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + required: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + rows: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + wrap: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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) cols: Visible width of the text control, in average character widths + default_value: The default value of the textarea when initially rendered dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted disabled: Disables the textarea enter_key_submit: Enter key submits form (shift-enter adds new line) @@ -1831,7 +1454,12 @@ 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 - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -1853,14 +1481,18 @@ 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 +datalist = Datalist.create fieldset = Fieldset.create form = Form.create input = Input.create diff --git a/reflex/components/el/elements/inline.py b/reflex/components/el/elements/inline.py index 4364c1ead..270eca28e 100644 --- a/reflex/components/el/elements/inline.py +++ b/reflex/components/el/elements/inline.py @@ -1,8 +1,8 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Inline classes.""" from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/inline.pyi b/reflex/components/el/elements/inline.pyi index c4cd4286f..06aeeca76 100644 --- a/reflex/components/el/elements/inline.pyi +++ b/reflex/components/el/elements/inline.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,92 +17,62 @@ class A(BaseHTML): def create( # type: ignore cls, *children, - download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "A": """Create the component. @@ -118,7 +88,7 @@ class A(BaseHTML): rel: Specifies the relationship between the linked document and the current document shape: Specifies the shape of the area target: Specifies where to open the linked document - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -153,88 +123,58 @@ class Abbr(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Abbr": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -269,88 +209,58 @@ class B(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "B": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -385,88 +295,58 @@ class Bdi(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Bdi": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -501,88 +381,58 @@ class Bdo(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Bdo": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -617,88 +467,58 @@ class Br(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Br": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -733,88 +553,58 @@ class Cite(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Cite": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -849,88 +639,58 @@ class Code(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Code": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -965,82 +725,52 @@ class Data(BaseHTML): def create( # type: ignore cls, *children, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Data": """Create the component. @@ -1048,7 +778,7 @@ class Data(BaseHTML): Args: *children: The children of the component. value: Specifies the machine-readable translation of the data element. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1083,88 +813,58 @@ class Dfn(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Dfn": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1199,88 +899,58 @@ class Em(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Em": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1315,88 +985,58 @@ class I(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "I": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1431,88 +1071,58 @@ class Kbd(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Kbd": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1547,88 +1157,58 @@ class Mark(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Mark": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1663,82 +1243,52 @@ class Q(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Q": """Create the component. @@ -1746,7 +1296,7 @@ class Q(BaseHTML): Args: *children: The children of the component. cite: Specifies the source URL of the quote. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1781,88 +1331,58 @@ class Rp(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Rp": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1897,88 +1417,58 @@ class Rt(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Rt": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2013,88 +1503,58 @@ class Ruby(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Ruby": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2129,88 +1589,58 @@ class S(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "S": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2245,88 +1675,58 @@ class Samp(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Samp": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2361,88 +1761,58 @@ class Small(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Small": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2477,88 +1847,58 @@ class Span(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Span": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2593,88 +1933,58 @@ class Strong(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Strong": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2709,88 +2019,58 @@ class Sub(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Sub": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2825,88 +2105,58 @@ class Sup(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Sup": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2941,82 +2191,52 @@ class Time(BaseHTML): def create( # type: ignore cls, *children, - date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Time": """Create the component. @@ -3024,7 +2244,7 @@ class Time(BaseHTML): Args: *children: The children of the component. date_time: Specifies the date and/or time of the element. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -3059,88 +2279,58 @@ class U(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "U": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -3175,88 +2365,58 @@ class Wbr(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Wbr": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/el/elements/media.py b/reflex/components/el/elements/media.py index b2bdc9e6f..7d2f0e3e9 100644 --- a/reflex/components/el/elements/media.py +++ b/reflex/components/el/elements/media.py @@ -1,11 +1,10 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Media classes.""" from typing import Any, Union from reflex import Component, ComponentNamespace from reflex.constants.colors import Color -from reflex.utils import console -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -130,7 +129,6 @@ class Img(BaseHTML): Returns: The component. - """ return ( super().create(src=children[0], **props) @@ -275,14 +273,12 @@ class Picture(BaseHTML): """Display the picture element.""" tag = "picture" - # No unique attributes, only common ones are inherited class Portal(BaseHTML): """Display the portal element.""" tag = "portal" - # No unique attributes, only common ones are inherited class Source(BaseHTML): @@ -318,6 +314,42 @@ class Svg(BaseHTML): 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.""" @@ -332,6 +364,22 @@ class Circle(BaseHTML): 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.""" @@ -395,6 +443,39 @@ class LinearGradient(BaseHTML): 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.""" @@ -422,12 +503,16 @@ class Path(BaseHTML): 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) @@ -445,23 +530,3 @@ picture = Picture.create portal = Portal.create source = Source.create svg = SVG() - - -def __getattr__(name: str): - if name in ("defs", "lineargradient", "stop", "path"): - console.deprecate( - f"`rx.el.{name}`", - reason=f"use `rx.el.svg.{'linear_gradient' if name =='lineargradient' else name}`", - deprecation_version="0.5.8", - removal_version="0.6.0", - ) - return ( - LinearGradient.create - if name == "lineargradient" - else globals()[name.capitalize()].create - ) - - try: - return globals()[name] - except KeyError: - raise AttributeError(f"module '{__name__} has no attribute '{name}'") from None diff --git a/reflex/components/el/elements/media.pyi b/reflex/components/el/elements/media.pyi index ba5f14137..b172d0c07 100644 --- a/reflex/components/el/elements/media.pyi +++ b/reflex/components/el/elements/media.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex import ComponentNamespace from reflex.constants.colors import Color -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -19,94 +19,64 @@ class Area(BaseHTML): def create( # type: ignore cls, *children, - alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - coords: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + coords: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Area": """Create the component. @@ -124,7 +94,7 @@ class Area(BaseHTML): rel: Specifies the relationship of the target object to the link object shape: Defines the shape of the area (rectangle, circle, polygon) target: Specifies where to open the linked document - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -159,91 +129,61 @@ class Audio(BaseHTML): def create( # type: ignore cls, *children, - auto_play: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - buffered: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - controls: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_play: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + buffered: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + controls: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - loop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - muted: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - preload: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + loop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + muted: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + preload: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Audio": """Create the component. @@ -258,7 +198,7 @@ class Audio(BaseHTML): muted: Indicates whether the audio is muted by default preload: Specifies how the audio file should be preloaded src: URL of the audio to play - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -293,99 +233,69 @@ class Img(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - alt: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + alt: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - decoding: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + decoding: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, intrinsicsize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - ismap: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - loading: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + ismap: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + loading: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Any], Any]] = None, - src_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Any, Var[Any]]] = None, + src_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Img": """Override create method to apply source attribute to value if user fails to pass in attribute. @@ -404,7 +314,7 @@ class Img(BaseHTML): src: URL of the image to display src_set: A set of source sizes and URLs for responsive images use_map: The name of the map to use with the image - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -430,7 +340,6 @@ class Img(BaseHTML): Returns: The component. - """ ... @@ -440,82 +349,52 @@ class Map(BaseHTML): def create( # type: ignore cls, *children, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Map": """Create the component. @@ -523,7 +402,7 @@ class Map(BaseHTML): Args: *children: The children of the component. name: Name of the map, referenced by the 'usemap' attribute in 'img' and 'object' elements - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -558,86 +437,56 @@ class Track(BaseHTML): def create( # type: ignore cls, *children, - default: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - kind: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - label: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + default: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + kind: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + label: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Track": """Create the component. @@ -649,7 +498,7 @@ class Track(BaseHTML): label: Title of the text track, used by the browser when listing available text tracks src: URL of the track file src_lang: Language of the track text data - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -684,95 +533,65 @@ class Video(BaseHTML): def create( # type: ignore cls, *children, - auto_play: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - buffered: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - controls: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_play: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + buffered: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + controls: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - loop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - muted: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + loop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + muted: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, plays_inline: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - poster: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - preload: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + poster: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + preload: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Video": """Create the component. @@ -789,7 +608,7 @@ class Video(BaseHTML): poster: URL of an image to show while the video is downloading, or until the user hits the play button preload: Specifies how the video file should be preloaded src: URL of the video to play - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -824,83 +643,53 @@ class Embed(BaseHTML): def create( # type: ignore cls, *children, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Embed": """Create the component. @@ -909,7 +698,7 @@ class Embed(BaseHTML): *children: The children of the component. src: URL of the embedded content type: Media type of the embedded content - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -944,92 +733,62 @@ class Iframe(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - allow: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - csp: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - loading: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + allow: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + csp: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + loading: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - sandbox: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src_doc: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + sandbox: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src_doc: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Iframe": """Create the component. @@ -1045,7 +804,7 @@ class Iframe(BaseHTML): sandbox: Security restrictions for the content in the iframe src: URL of the document to display in the iframe src_doc: HTML content to embed directly within the iframe - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1080,86 +839,56 @@ class Object(BaseHTML): def create( # type: ignore cls, *children, - data: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - use_map: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + data: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Object": """Create the component. @@ -1171,7 +900,7 @@ class Object(BaseHTML): name: Name of the object, used for scripting or as a target for forms and links type: Media type of the data specified in the data attribute use_map: Name of an image map to use with the object - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1206,88 +935,58 @@ class Picture(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Picture": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1322,88 +1021,58 @@ class Portal(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Portal": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1438,86 +1107,56 @@ class Source(BaseHTML): def create( # type: ignore cls, *children, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - src_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + src_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Source": """Create the component. @@ -1529,7 +1168,7 @@ class Source(BaseHTML): src: URL of the media file or an image for the element to use src_set: A set of source sizes and URLs for responsive images type: Media type of the source - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1564,84 +1203,54 @@ class Svg(BaseHTML): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, xmlns: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Svg": """Create the component. @@ -1651,7 +1260,203 @@ class Svg(BaseHTML): 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. + 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -1686,85 +1491,55 @@ class Circle(BaseHTML): def create( # type: ignore cls, *children, - cx: Optional[Union[Var[Union[int, str]], str, int]] = None, - cy: Optional[Union[Var[Union[int, str]], str, int]] = None, - r: Optional[Union[Var[Union[int, str]], str, int]] = None, + cx: Optional[Union[Var[Union[int, str]], int, str]] = None, + cy: Optional[Union[Var[Union[int, str]], int, str]] = None, + r: Optional[Union[Var[Union[int, str]], int, str]] = None, path_length: Optional[Union[Var[int], int]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Circle": """Create the component. @@ -1775,7 +1550,103 @@ class Circle(BaseHTML): 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. + 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -1810,88 +1681,58 @@ class Rect(BaseHTML): def create( # type: ignore cls, *children, - x: Optional[Union[Var[Union[int, str]], str, int]] = None, - y: Optional[Union[Var[Union[int, str]], str, int]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, - rx: Optional[Union[Var[Union[int, str]], str, int]] = None, - ry: Optional[Union[Var[Union[int, str]], str, int]] = None, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, + rx: Optional[Union[Var[Union[int, str]], int, str]] = None, + ry: Optional[Union[Var[Union[int, str]], int, str]] = None, path_length: Optional[Union[Var[int], int]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Rect": """Create the component. @@ -1905,7 +1746,7 @@ class Rect(BaseHTML): 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. + 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. @@ -1942,81 +1783,51 @@ class Polygon(BaseHTML): *children, points: Optional[Union[Var[str], str]] = None, path_length: Optional[Union[Var[int], int]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Polygon": """Create the component. @@ -2025,7 +1836,7 @@ class Polygon(BaseHTML): *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. + 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. @@ -2060,88 +1871,58 @@ class Defs(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. + 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. @@ -2176,88 +1957,58 @@ class LinearGradient(BaseHTML): def create( # type: ignore cls, *children, - gradient_units: Optional[Union[Var[Union[bool, str]], str, bool]] = None, - gradient_transform: Optional[Union[Var[Union[bool, str]], str, bool]] = None, - spread_method: Optional[Union[Var[Union[bool, str]], str, bool]] = None, - x1: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - x2: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - y1: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - y2: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + gradient_units: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + gradient_transform: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + spread_method: Optional[Union[Var[Union[bool, str]], bool, str]] = None, + x1: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + x2: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + y1: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + y2: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "LinearGradient": """Create the component. @@ -2271,7 +2022,111 @@ class LinearGradient(BaseHTML): 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. + 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -2306,88 +2161,58 @@ class Stop(BaseHTML): def create( # type: ignore cls, *children, - offset: Optional[Union[Var[Union[float, int, str]], str, float, int]] = None, + offset: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, stop_color: Optional[ - Union[Var[Union[Color, bool, str]], str, Color, bool] + Union[Color, Var[Union[Color, bool, str]], bool, str] ] = None, stop_opacity: Optional[ - Union[Var[Union[bool, float, int, str]], str, float, int, bool] + Union[Var[Union[bool, float, int, str]], bool, float, int, str] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Stop": """Create the component. @@ -2397,7 +2222,7 @@ class Stop(BaseHTML): 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. + 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. @@ -2432,82 +2257,52 @@ class Path(BaseHTML): def create( # type: ignore cls, *children, - d: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + d: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Path": """Create the component. @@ -2515,7 +2310,7 @@ class Path(BaseHTML): Args: *children: The children of the component. d: Defines the shape of the path. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -2545,95 +2340,69 @@ class Path(BaseHTML): ... 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]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, xmlns: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Svg": """Create the component. @@ -2643,7 +2412,7 @@ class SVG(ComponentNamespace): 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. + 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. diff --git a/reflex/components/el/elements/metadata.py b/reflex/components/el/elements/metadata.py index 9a4d18b73..8e0fbcd4d 100644 --- a/reflex/components/el/elements/metadata.py +++ b/reflex/components/el/elements/metadata.py @@ -1,14 +1,14 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Metadata classes.""" -from typing import Set, Union +from typing import List, Union from reflex.components.el.element import Element -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML -class Base(BaseHTML): # noqa: E742 +class Base(BaseHTML): """Display the base element.""" tag = "base" @@ -18,13 +18,13 @@ class Base(BaseHTML): # noqa: E742 target: Var[Union[str, int, bool]] -class Head(BaseHTML): # noqa: E742 +class Head(BaseHTML): """Display the head element.""" tag = "head" -class Link(BaseHTML): # noqa: E742 +class Link(BaseHTML): """Display the link element.""" tag = "link" @@ -75,23 +75,21 @@ class Meta(BaseHTML): # Inherits common attributes from BaseHTML name: Var[Union[str, int, bool]] -class Title(Element): # noqa: E742 +class Title(Element): """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 +# Had to be named with an underscore so it doesn't conflict with reflex.style Style in pyi +class StyleEl(Element): """Display the style element.""" tag = "style" media: Var[Union[str, int, bool]] - special_props: Set[Var] = { - Var.create_safe("suppressHydrationWarning", _var_is_string=False) - } + special_props: List[Var] = [Var(_js_expr="suppressHydrationWarning")] base = Base.create diff --git a/reflex/components/el/elements/metadata.pyi b/reflex/components/el/elements/metadata.pyi index e08c1d723..08cd2fd76 100644 --- a/reflex/components/el/elements/metadata.pyi +++ b/reflex/components/el/elements/metadata.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.el.element import Element -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -18,90 +18,60 @@ class Base(BaseHTML): def create( # type: ignore cls, *children, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Base": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -136,88 +106,58 @@ class Head(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Head": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -253,93 +193,63 @@ class Link(BaseHTML): cls, *children, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - integrity: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + integrity: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - sizes: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + sizes: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Link": """Create the component. @@ -355,7 +265,7 @@ class Link(BaseHTML): 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. + 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. @@ -390,85 +300,55 @@ class Meta(BaseHTML): def create( # type: ignore cls, *children, - char_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - content: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - http_equiv: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + char_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + content: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + http_equiv: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Meta": """Create the component. @@ -479,7 +359,7 @@ class Meta(BaseHTML): 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. + 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. @@ -519,52 +399,22 @@ class Title(Element): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Title": """Create the component. @@ -590,58 +440,28 @@ class StyleEl(Element): def create( # type: ignore cls, *children, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "StyleEl": """Create the component. diff --git a/reflex/components/el/elements/other.py b/reflex/components/el/elements/other.py index 560ed5138..4e7f0f227 100644 --- a/reflex/components/el/elements/other.py +++ b/reflex/components/el/elements/other.py @@ -1,8 +1,8 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Other classes.""" from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -26,31 +26,39 @@ class Dialog(BaseHTML): class Summary(BaseHTML): - """Display the summary element.""" + """Display the summary element. + + Used as a summary or caption for a
element. + """ tag = "summary" - # No unique attributes, only common ones are inherited; used as a summary or caption for a
element class Slot(BaseHTML): - """Display the slot element.""" + """Display the slot element. + + Used as a placeholder inside a web component. + """ tag = "slot" - # No unique attributes, only common ones are inherited; used as a placeholder inside a web component class Template(BaseHTML): - """Display the template element.""" + """Display the template element. + + Used for declaring fragments of HTML that can be cloned and inserted in the document. + """ tag = "template" - # No unique attributes, only common ones are inherited; used for declaring fragments of HTML that can be cloned and inserted in the document class Math(BaseHTML): - """Display the math element.""" + """Display the math element. + + Represents a mathematical expression. + """ tag = "math" - # No unique attributes, only common ones are inherited; used for displaying mathematical expressions class Html(BaseHTML): diff --git a/reflex/components/el/elements/other.pyi b/reflex/components/el/elements/other.pyi index 6dc5d0aa1..57e4ab24b 100644 --- a/reflex/components/el/elements/other.pyi +++ b/reflex/components/el/elements/other.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,82 +17,52 @@ class Details(BaseHTML): def create( # type: ignore cls, *children, - open: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + open: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Details": """Create the component. @@ -100,7 +70,7 @@ class Details(BaseHTML): Args: *children: The children of the component. open: Indicates whether the details will be visible (expanded) to the user - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -135,82 +105,52 @@ class Dialog(BaseHTML): def create( # type: ignore cls, *children, - open: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + open: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Dialog": """Create the component. @@ -218,7 +158,7 @@ class Dialog(BaseHTML): Args: *children: The children of the component. open: Indicates whether the dialog is active and can be interacted with - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -253,88 +193,58 @@ class Summary(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Summary": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited; used as a summary or caption for a
element Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -369,88 +279,58 @@ class Slot(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Slot": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited; used as a placeholder inside a web component Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -485,88 +365,58 @@ class Template(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Template": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited; used for declaring fragments of HTML that can be cloned and inserted in the document Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -601,88 +451,58 @@ class Math(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Math": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited; used for displaying mathematical expressions Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -717,82 +537,52 @@ class Html(BaseHTML): def create( # type: ignore cls, *children, - manifest: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + manifest: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Html": """Create the component. @@ -800,7 +590,7 @@ class Html(BaseHTML): Args: *children: The children of the component. manifest: Specifies the URL of the document's cache manifest (obsolete in HTML5) - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/el/elements/scripts.py b/reflex/components/el/elements/scripts.py index 09a9fd17a..c30931e99 100644 --- a/reflex/components/el/elements/scripts.py +++ b/reflex/components/el/elements/scripts.py @@ -1,8 +1,8 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Scripts classes.""" from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,7 +17,6 @@ class Noscript(BaseHTML): """Display the noscript element.""" tag = "noscript" - # No unique attributes, only common ones are inherited class Script(BaseHTML): diff --git a/reflex/components/el/elements/scripts.pyi b/reflex/components/el/elements/scripts.pyi index d7858dde8..c66e150af 100644 --- a/reflex/components/el/elements/scripts.pyi +++ b/reflex/components/el/elements/scripts.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,88 +17,58 @@ class Canvas(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Canvas": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -133,88 +103,58 @@ class Noscript(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Noscript": """Create the component. Args: *children: The children of the component. - access_key: No unique attributes, only common ones are inherited Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -249,94 +189,64 @@ class Script(BaseHTML): def create( # type: ignore cls, *children, - async_: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - char_set: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + async_: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + char_set: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, cross_origin: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - defer: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - integrity: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - language: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + defer: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + integrity: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + language: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - src: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + src: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Script": """Create the component. @@ -352,7 +262,7 @@ class Script(BaseHTML): referrer_policy: Specifies which referrer information to send when fetching the script src: URL of an external script type: Specifies the MIME type of the script - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/el/elements/sectioning.py b/reflex/components/el/elements/sectioning.py index e1544bd15..cfe82b6d5 100644 --- a/reflex/components/el/elements/sectioning.py +++ b/reflex/components/el/elements/sectioning.py @@ -1,95 +1,93 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" - -from reflex.vars import Var as Var +"""Sectioning classes.""" from .base import BaseHTML -class Body(BaseHTML): # noqa: E742 +class Body(BaseHTML): """Display the body element.""" tag = "body" -class Address(BaseHTML): # noqa: E742 +class Address(BaseHTML): """Display the address element.""" tag = "address" -class Article(BaseHTML): # noqa: E742 +class Article(BaseHTML): """Display the article element.""" tag = "article" -class Aside(BaseHTML): # noqa: E742 +class Aside(BaseHTML): """Display the aside element.""" tag = "aside" -class Footer(BaseHTML): # noqa: E742 +class Footer(BaseHTML): """Display the footer element.""" tag = "footer" -class Header(BaseHTML): # noqa: E742 +class Header(BaseHTML): """Display the header element.""" tag = "header" -class H1(BaseHTML): # noqa: E742 +class H1(BaseHTML): """Display the h1 element.""" tag = "h1" -class H2(BaseHTML): # noqa: E742 +class H2(BaseHTML): """Display the h1 element.""" tag = "h2" -class H3(BaseHTML): # noqa: E742 +class H3(BaseHTML): """Display the h1 element.""" tag = "h3" -class H4(BaseHTML): # noqa: E742 +class H4(BaseHTML): """Display the h1 element.""" tag = "h4" -class H5(BaseHTML): # noqa: E742 +class H5(BaseHTML): """Display the h1 element.""" tag = "h5" -class H6(BaseHTML): # noqa: E742 +class H6(BaseHTML): """Display the h1 element.""" tag = "h6" -class Main(BaseHTML): # noqa: E742 +class Main(BaseHTML): """Display the main element.""" tag = "main" -class Nav(BaseHTML): # noqa: E742 +class Nav(BaseHTML): """Display the nav element.""" tag = "nav" -class Section(BaseHTML): # noqa: E742 +class Section(BaseHTML): """Display the section element.""" tag = "section" diff --git a/reflex/components/el/elements/sectioning.pyi b/reflex/components/el/elements/sectioning.pyi index a6ea47d9c..ecbabe516 100644 --- a/reflex/components/el/elements/sectioning.pyi +++ b/reflex/components/el/elements/sectioning.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,88 +17,58 @@ class Body(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Body": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -133,88 +103,58 @@ class Address(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Address": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -249,88 +189,58 @@ class Article(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Article": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -365,88 +275,58 @@ class Aside(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Aside": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -481,88 +361,58 @@ class Footer(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Footer": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -597,88 +447,58 @@ class Header(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Header": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -713,88 +533,58 @@ class H1(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "H1": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -829,88 +619,58 @@ class H2(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "H2": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -945,88 +705,58 @@ class H3(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "H3": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1061,88 +791,58 @@ class H4(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "H4": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1177,88 +877,58 @@ class H5(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "H5": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1293,88 +963,58 @@ class H6(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "H6": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1409,88 +1049,58 @@ class Main(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Main": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1525,88 +1135,58 @@ class Nav(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Nav": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1641,88 +1221,58 @@ class Section(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Section": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/el/elements/tables.py b/reflex/components/el/elements/tables.py index 007879358..a0c10d829 100644 --- a/reflex/components/el/elements/tables.py +++ b/reflex/components/el/elements/tables.py @@ -1,8 +1,8 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Tables classes.""" from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/tables.pyi b/reflex/components/el/elements/tables.pyi index d06d0cf6d..420bad585 100644 --- a/reflex/components/el/elements/tables.pyi +++ b/reflex/components/el/elements/tables.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,82 +17,52 @@ class Caption(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Caption": """Create the component. @@ -100,7 +70,7 @@ class Caption(BaseHTML): Args: *children: The children of the component. align: Alignment of the caption - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -135,83 +105,53 @@ class Col(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Col": """Create the component. @@ -220,7 +160,7 @@ class Col(BaseHTML): *children: The children of the component. align: Alignment of the content within the column span: Number of columns the col element spans - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -255,83 +195,53 @@ class Colgroup(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Colgroup": """Create the component. @@ -340,7 +250,7 @@ class Colgroup(BaseHTML): *children: The children of the component. align: Alignment of the content within the column group span: Number of columns the colgroup element spans - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -375,83 +285,53 @@ class Table(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - summary: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + summary: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Table": """Create the component. @@ -460,7 +340,7 @@ class Table(BaseHTML): *children: The children of the component. align: Alignment of the table summary: Provides a summary of the table's purpose and structure - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -495,82 +375,52 @@ class Tbody(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Tbody": """Create the component. @@ -578,7 +428,7 @@ class Tbody(BaseHTML): Args: *children: The children of the component. align: Alignment of the content within the table body - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -613,85 +463,55 @@ class Td(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Td": """Create the component. @@ -702,7 +522,7 @@ class Td(BaseHTML): col_span: Number of columns a cell should span headers: IDs of the headers associated with this cell row_span: Number of rows a cell should span - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -737,82 +557,52 @@ class Tfoot(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Tfoot": """Create the component. @@ -820,7 +610,7 @@ class Tfoot(BaseHTML): Args: *children: The children of the component. align: Alignment of the content within the table footer - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -855,86 +645,56 @@ class Th(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Th": """Create the component. @@ -946,7 +706,7 @@ class Th(BaseHTML): headers: IDs of the headers associated with this header cell row_span: Number of rows a header cell should span scope: Scope of the header cell (row, col, rowgroup, colgroup) - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -981,82 +741,52 @@ class Thead(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Thead": """Create the component. @@ -1064,7 +794,7 @@ class Thead(BaseHTML): Args: *children: The children of the component. align: Alignment of the content within the table header - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1099,82 +829,52 @@ class Tr(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Tr": """Create the component. @@ -1182,7 +882,7 @@ class Tr(BaseHTML): Args: *children: The children of the component. align: Alignment of the content within the table row - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/el/elements/typography.py b/reflex/components/el/elements/typography.py index dccad7a6d..9fa5c3a02 100644 --- a/reflex/components/el/elements/typography.py +++ b/reflex/components/el/elements/typography.py @@ -1,8 +1,8 @@ -"""Element classes. This is an auto-generated file. Do not edit. See ../generate.py.""" +"""Typography classes.""" from typing import Union -from reflex.vars import Var as Var +from reflex.vars.base import Var from .base import BaseHTML diff --git a/reflex/components/el/elements/typography.pyi b/reflex/components/el/elements/typography.pyi index a6deb12e4..8332b3306 100644 --- a/reflex/components/el/elements/typography.pyi +++ b/reflex/components/el/elements/typography.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import BaseHTML @@ -17,82 +17,52 @@ class Blockquote(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Blockquote": """Create the component. @@ -100,7 +70,7 @@ class Blockquote(BaseHTML): Args: *children: The children of the component. cite: Define the title of a work. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -135,88 +105,58 @@ class Dd(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Dd": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -251,88 +191,58 @@ class Div(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Div": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -367,88 +277,58 @@ class Dl(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Dl": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -483,88 +363,58 @@ class Dt(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Dt": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -599,88 +449,58 @@ class Figcaption(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Figcaption": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -715,82 +535,52 @@ class Hr(BaseHTML): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Hr": """Create the component. @@ -798,7 +588,7 @@ class Hr(BaseHTML): Args: *children: The children of the component. align: Used to specify the alignment of text content of The Element. this attribute is used in all elements. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -833,88 +623,58 @@ class Li(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Li": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -949,82 +709,52 @@ class Menu(BaseHTML): def create( # type: ignore cls, *children, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Menu": """Create the component. @@ -1032,7 +762,7 @@ class Menu(BaseHTML): Args: *children: The children of the component. type: Specifies that the menu element is a context menu. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1067,84 +797,54 @@ class Ol(BaseHTML): def create( # type: ignore cls, *children, - reversed: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - start: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + reversed: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + start: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Ol": """Create the component. @@ -1154,7 +854,7 @@ class Ol(BaseHTML): 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). - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1189,88 +889,58 @@ class P(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "P": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1305,88 +975,58 @@ class Pre(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Pre": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1421,88 +1061,58 @@ class Ul(BaseHTML): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Ul": """Create the component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1537,83 +1147,53 @@ class Ins(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Ins": """Create the component. @@ -1622,7 +1202,7 @@ class Ins(BaseHTML): *children: The children of the component. cite: Specifies the URL of the document that explains the reason why the text was inserted/changed. date_time: Specifies the date and time of when the text was inserted/changed. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1657,83 +1237,53 @@ class Del(BaseHTML): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - date_time: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + date_time: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Del": """Create the component. @@ -1742,7 +1292,7 @@ class Del(BaseHTML): *children: The children of the component. cite: Specifies the URL of the document that explains the reason why the text was deleted. date_time: Specifies the date and time of when the text was deleted. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/gridjs/datatable.py b/reflex/components/gridjs/datatable.py index 6d856cf45..bd568d84a 100644 --- a/reflex/components/gridjs/datatable.py +++ b/reflex/components/gridjs/datatable.py @@ -9,15 +9,15 @@ from reflex.components.tags import Tag 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): @@ -65,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( @@ -113,24 +113,21 @@ class DataTable(Gridjs): 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, - _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, - _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 ee8bf6f3a..f3f732db3 100644 --- a/reflex/components/gridjs/datatable.pyi +++ b/reflex/components/gridjs/datatable.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Optional, Union, overload +from typing import Any, Dict, List, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Gridjs(Component): @overload @@ -22,52 +22,22 @@ class Gridjs(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Gridjs": """Create the component. @@ -94,62 +64,32 @@ class DataTable(Gridjs): cls, *children, data: Optional[Any] = None, - columns: Optional[Union[Var[List], List]] = None, + columns: Optional[Union[List, Var[List]]] = None, search: Optional[Union[Var[bool], bool]] = None, sort: Optional[Union[Var[bool], bool]] = None, resizable: Optional[Union[Var[bool], bool]] = None, - pagination: Optional[Union[Var[Union[Dict, bool]], bool, Dict]] = None, + pagination: Optional[Union[Dict, Var[Union[Dict, bool]], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DataTable": """Create a datatable component. diff --git a/reflex/components/lucide/icon.py b/reflex/components/lucide/icon.py index e9cf9ab82..b32fb8de3 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])}, ..." @@ -72,120 +58,10 @@ class Icon(LucideIconComponent): props["tag"] = format.to_title_case(format.to_snake_case(props["tag"])) + "Icon" props["alias"] = f"Lucide{props['tag']}" - props.setdefault("color", f"var(--current-color)") + props.setdefault("color", "var(--current-color)") 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 7fc7ee38d..7f59edec5 100644 --- a/reflex/components/lucide/icon.pyi +++ b/reflex/components/lucide/icon.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class LucideIconComponent(Component): @overload @@ -21,52 +21,22 @@ class LucideIconComponent(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "LucideIconComponent": """Create the component. @@ -98,52 +68,22 @@ class Icon(LucideIconComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Icon": """Initialize the Icon component. @@ -170,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 e62c85af3..cd82d5903 100644 --- a/reflex/components/markdown/markdown.py +++ b/reflex/components/markdown/markdown.py @@ -2,44 +2,37 @@ from __future__ import annotations +import dataclasses import textwrap from functools import lru_cache from hashlib import md5 -from typing import Any, Callable, Dict, Union +from typing import Any, Callable, Dict, Sequence, Union 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 types from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import ARRAY_ISARRAY, ArgsFunctionOperation, DestructuredArg +from reflex.vars.number import ternary_operation # Special vars used in the component map. -_CHILDREN = Var.create_safe("children", _var_is_local=False, _var_is_string=False) -_PROPS = Var.create_safe("...props", _var_is_local=False, _var_is_string=False) -_MOCK_ARG = Var.create_safe("", _var_is_string=False) +_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) +_LANGUAGE = Var(_js_expr="_language", _var_type=str) # Special remark plugins. -_REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False, _var_is_string=False) -_REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False, _var_is_string=False) -_REMARK_UNWRAP_IMAGES = Var.create_safe( - "remarkUnwrapImages", _var_is_local=False, _var_is_string=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, _var_is_string=False -) -_REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False, _var_is_string=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") @@ -54,7 +47,15 @@ def get_base_component_map() -> dict[str, Callable]: The base component map. """ from reflex.components.datadisplay.code import CodeBlock + from reflex.components.radix.themes.layout.list import ( + ListItem, + OrderedList, + UnorderedList, + ) from reflex.components.radix.themes.typography.code import Code + 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 return { "h1": lambda value: Heading.create(value, as_="h1", size="6", margin_y="0.5em"), @@ -70,11 +71,72 @@ 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 ), } +@dataclasses.dataclass() +class MarkdownComponentMap: + """Mixin class for handling custom component maps in Markdown components.""" + + _explicit_return: bool = dataclasses.field(default=False) + + @classmethod + def get_component_map_custom_code(cls) -> str: + """Get the custom code for the component map. + + Returns: + The custom code for the component map. + """ + return "" + + @classmethod + def create_map_fn_var( + cls, + fn_body: Var | None = None, + fn_args: Sequence[str] | None = None, + explicit_return: bool | None = None, + ) -> Var: + """Create a function Var for the component map. + + Args: + fn_body: The formatted component as a string. + fn_args: The function arguments. + explicit_return: Whether to use explicit return syntax. + + Returns: + The function Var for the component map. + """ + fn_args = fn_args or cls.get_fn_args() + fn_body = fn_body if fn_body is not None else cls.get_fn_body() + explicit_return = explicit_return or cls._explicit_return + + return ArgsFunctionOperation.create( + args_names=(DestructuredArg(fields=tuple(fn_args)),), + return_expr=fn_body, + explicit_return=explicit_return, + ) + + @classmethod + def get_fn_args(cls) -> Sequence[str]: + """Get the function arguments for the component map. + + Returns: + The function arguments as a list of strings. + """ + return ["node", _CHILDREN._js_expr, _PROPS._js_expr] + + @classmethod + def get_fn_body(cls) -> Var: + """Get the function body for the component map. + + Returns: + The function body as a string. + """ + return Var(_js_expr="undefined", _var_type=None) + + class Markdown(Component): """A markdown component.""" @@ -98,12 +160,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", {})} @@ -150,36 +216,94 @@ class Markdown(Component): Returns: The imports for the markdown component. """ - from reflex.components.datadisplay.code import CodeBlock - from reflex.components.radix.themes.typography.code import Code - return [ { "": "katex/dist/katex.min.css", "remark-math@5.1.1": ImportVar( - tag=_REMARK_MATH._var_name, is_default=True + tag=_REMARK_MATH._js_expr, is_default=True ), "remark-gfm@3.0.1": ImportVar( - tag=_REMARK_GFM._var_name, is_default=True + tag=_REMARK_GFM._js_expr, is_default=True ), "remark-unwrap-images@4.0.0": ImportVar( - tag=_REMARK_UNWRAP_IMAGES._var_name, is_default=True + tag=_REMARK_UNWRAP_IMAGES._js_expr, is_default=True ), "rehype-katex@6.0.3": ImportVar( - tag=_REHYPE_KATEX._var_name, is_default=True + tag=_REHYPE_KATEX._js_expr, is_default=True ), "rehype-raw@6.1.1": ImportVar( - tag=_REHYPE_RAW._var_name, is_default=True + tag=_REHYPE_RAW._js_expr, is_default=True ), }, *[ - component(_MOCK_ARG)._get_imports() # type: ignore + component(_MOCK_ARG)._get_all_imports() # type: ignore for component in self.component_map.values() ], - CodeBlock.create(theme="light")._get_imports(), # type: ignore, - Code.create()._get_imports(), # type: ignore, ] + def _get_tag_map_fn_var(self, tag: str) -> Var: + return self._get_map_fn_var_from_children(self.get_component(tag), tag) + + def format_component_map(self) -> dict[str, Var]: + """Format the component map for rendering. + + Returns: + The formatted component map. + """ + components = { + tag: self._get_tag_map_fn_var(tag) + for tag in self.component_map + if tag not in ("code", "codeblock") + } + + # Separate out inline code and code blocks. + components["code"] = self._get_inline_code_fn_var() + + return components + + def _get_inline_code_fn_var(self) -> Var: + """Get the function variable for inline code. + + This function creates a Var that represents a function to handle + both inline code and code blocks in markdown. + + Returns: + The Var for inline code. + """ + # Get any custom code from the codeblock and code components. + custom_code_list = self._get_map_fn_custom_code_from_children( + self.get_component("codeblock") + ) + custom_code_list.extend( + self._get_map_fn_custom_code_from_children(self.get_component("code")) + ) + + codeblock_custom_code = "\n".join(custom_code_list) + + # Format the code to handle inline and block code. + formatted_code = f""" +const match = (className || '').match(/language-(?.*)/); +const {_LANGUAGE!s} = match ? match[1] : ''; +{codeblock_custom_code}; + return inline ? ( + {self.format_component("code")} + ) : ( + {self.format_component("codeblock", language=_LANGUAGE)} + ); + """.replace("\n", " ") + + return MarkdownComponentMap.create_map_fn_var( + fn_args=( + "node", + "inline", + "className", + _CHILDREN._js_expr, + _PROPS._js_expr, + ), + fn_body=Var(_js_expr=formatted_code), + explicit_return=True, + ) + def get_component(self, tag: str, **props) -> Component: """Get the component for a tag and props. @@ -197,21 +321,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)}", _var_is_string=False) - ) + special_props.append(Var(_js_expr=f"children={{{children_prop!s}}}")) children = [] - # Get the component. component = self.component_map[tag](*children, **props).set( special_props=special_props @@ -230,41 +360,53 @@ class Markdown(Component): """ return str(self.get_component(tag, **props)).replace("\n", "") - def format_component_map(self) -> dict[str, str]: - """Format the component map for rendering. + def _get_map_fn_var_from_children(self, component: Component, tag: str) -> Var: + """Create a function Var for the component map for the specified tag. + + Args: + component: The component to check for custom code. + tag: The tag of the component. Returns: - The formatted component map. + The function Var for the component map. """ - components = { - tag: f"{{({{node, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {self.format_component(tag)}}}" - for tag in self.component_map - } + formatted_component = Var( + _js_expr=f"({self.format_component(tag)})", _var_type=str + ) + if isinstance(component, MarkdownComponentMap): + return component.create_map_fn_var(fn_body=formatted_component) - # Separate out inline code and code blocks. - components[ - "code" - ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{ - const match = (className || '').match(/language-(?.*)/); - const language = match ? match[1] : ''; - if (language) {{ - (async () => {{ - try {{ - const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${{language}}`); - SyntaxHighlighter.registerLanguage(language, module.default); - }} catch (error) {{ - console.error(`Error importing language module for ${{language}}:`, error); - }} - }})(); - }} - return inline ? ( - {self.format_component("code")} - ) : ( - {self.format_component("codeblock", language=Var.create_safe("language", _var_is_local=False, _var_is_string=False))} - ); - }}}}""".replace("\n", " ") + # fallback to the default fn Var creation if the component is not a MarkdownComponentMap. + return MarkdownComponentMap.create_map_fn_var(fn_body=formatted_component) - return components + def _get_map_fn_custom_code_from_children(self, component) -> list[str]: + """Recursively get markdown custom code from children components. + + Args: + component: The component to check for custom code. + + Returns: + A list of markdown custom code strings. + """ + custom_code_list = [] + if isinstance(component, MarkdownComponentMap): + custom_code_list.append(component.get_component_map_custom_code()) + + # If the component is a custom component(rx.memo), obtain the underlining + # component and get the custom code from the children. + if isinstance(component, CustomComponent): + custom_code_list.extend( + self._get_map_fn_custom_code_from_children( + component.component_fn(*component.get_prop_vars()) + ) + ) + elif isinstance(component, Component): + for child in component.children: + custom_code_list.extend( + self._get_map_fn_custom_code_from_children(child) + ) + + return custom_code_list @staticmethod def _component_map_hash(component_map) -> str: @@ -277,17 +419,17 @@ class Markdown(Component): return f"ComponentMap_{self.component_map_hash}" def _get_custom_code(self) -> str | None: - hooks = set() + hooks = {} for _component in self.component_map.values(): comp = _component(_MOCK_ARG) hooks.update(comp._get_all_hooks_internal()) hooks.update(comp._get_all_hooks()) - formatted_hooks = "\n".join(hooks) + formatted_hooks = "\n".join(hooks.keys()) return f""" function {self._get_component_map_name()} () {{ {formatted_hooks} return ( - {str(Var.create(self.format_component_map()))} + {LiteralVar.create(self.format_component_map())!s} ) }} """ @@ -299,14 +441,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 e0eb43454..1c329fb8c 100644 --- a/reflex/components/markdown/markdown.pyi +++ b/reflex/components/markdown/markdown.pyi @@ -3,33 +3,47 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ +import dataclasses from functools import lru_cache -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Callable, Dict, Optional, Sequence, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.vars.base import LiteralVar, Var -_CHILDREN = Var.create_safe("children", _var_is_local=False, _var_is_string=False) -_PROPS = Var.create_safe("...props", _var_is_local=False, _var_is_string=False) -_MOCK_ARG = Var.create_safe("", _var_is_string=False) -_REMARK_MATH = Var.create_safe("remarkMath", _var_is_local=False, _var_is_string=False) -_REMARK_GFM = Var.create_safe("remarkGfm", _var_is_local=False, _var_is_string=False) -_REMARK_UNWRAP_IMAGES = Var.create_safe( - "remarkUnwrapImages", _var_is_local=False, _var_is_string=False -) -_REMARK_PLUGINS = Var.create_safe([_REMARK_MATH, _REMARK_GFM, _REMARK_UNWRAP_IMAGES]) -_REHYPE_KATEX = Var.create_safe( - "rehypeKatex", _var_is_local=False, _var_is_string=False -) -_REHYPE_RAW = Var.create_safe("rehypeRaw", _var_is_local=False, _var_is_string=False) -_REHYPE_PLUGINS = Var.create_safe([_REHYPE_KATEX, _REHYPE_RAW]) +_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) +_LANGUAGE = Var(_js_expr="_language", _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 def get_base_component_map() -> dict[str, Callable]: ... +@dataclasses.dataclass() +class MarkdownComponentMap: + @classmethod + def get_component_map_custom_code(cls) -> str: ... + @classmethod + def create_map_fn_var( + cls, + fn_body: Var | None = None, + fn_args: Sequence[str] | None = None, + explicit_return: bool | None = None, + ) -> Var: ... + @classmethod + def get_fn_args(cls) -> Sequence[str]: ... + @classmethod + def get_fn_body(cls) -> Var: ... class Markdown(Component): @overload @@ -44,52 +58,22 @@ class Markdown(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Markdown": """Create a markdown component. @@ -106,12 +90,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 format_component_map(self) -> dict[str, Var]: ... def get_component(self, tag: str, **props) -> Component: ... def format_component(self, tag: str, **props) -> str: ... - def format_component_map(self) -> dict[str, str]: ... 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 eaca071e7..000000000 --- a/reflex/components/media/icon.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Shim for reflex.components.chakra.media.icon.""" - -from reflex.components.chakra.media.icon import * diff --git a/reflex/components/moment/moment.py b/reflex/components/moment/moment.py index 958ba6c57..80940d228 100644 --- a/reflex/components/moment/moment.py +++ b/reflex/components/moment/moment.py @@ -1,26 +1,28 @@ """Moment component for humanized date rendering.""" -from typing import List, Optional +import dataclasses +from datetime import date, datetime, time, timedelta +from typing import List, Optional, Union -from reflex.base import Base -from reflex.components.component import Component, NoSSRComponent -from reflex.event import EventHandler +from reflex.components.component import NoSSRComponent +from reflex.event import EventHandler, passthrough_event_spec from reflex.utils.imports import ImportDict -from reflex.vars import Var +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) + minutes: Optional[int] = dataclasses.field(default=None) + seconds: Optional[int] = dataclasses.field(default=None) + milliseconds: Optional[int] = dataclasses.field(default=None) class Moment(NoSSRComponent): @@ -77,7 +79,7 @@ class Moment(NoSSRComponent): duration: Var[str] # The date to display (also work if passed as children). - date: Var[str] + date: Var[Union[str, datetime, date, time, timedelta]] # Shows the duration (elapsed time) between now and the provided datetime. duration_from_now: Var[bool] @@ -91,8 +93,11 @@ class Moment(NoSSRComponent): # Display the date in the given timezone. tz: Var[str] + # The locale to use when rendering. + locale: Var[str] + # Fires when the date changes. - on_change: EventHandler[lambda date: [date]] + on_change: EventHandler[passthrough_event_spec(str)] def add_imports(self) -> ImportDict: """Add the imports for the Moment component. @@ -100,22 +105,15 @@ class Moment(NoSSRComponent): 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: - return {"moment-timezone": ""} - return {} + imports["moment-timezone"] = "" - @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 5497a5336..83ab670b0 100644 --- a/reflex/components/moment/moment.pyi +++ b/reflex/components/moment/moment.pyi @@ -3,23 +3,25 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +import dataclasses +from datetime import date, datetime, time, timedelta +from typing import Any, Dict, Optional, Union, overload -from reflex.base import Base from reflex.components.component import NoSSRComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -class MomentDelta(Base): +@dataclasses.dataclass(frozen=True) +class MomentDelta: years: Optional[int] quarters: Optional[int] months: Optional[int] weeks: Optional[int] days: Optional[int] hours: Optional[int] - minutess: Optional[int] + minutes: Optional[int] seconds: Optional[int] milliseconds: Optional[int] @@ -34,8 +36,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, @@ -45,68 +47,48 @@ class Moment(NoSSRComponent): decimal: Optional[Union[Var[bool], bool]] = None, unit: Optional[Union[Var[str], str]] = None, duration: Optional[Union[Var[str], str]] = None, - date: Optional[Union[Var[str], str]] = None, + date: Optional[ + Union[ + Var[Union[date, datetime, str, time, timedelta]], + date, + datetime, + str, + time, + timedelta, + ] + ] = None, duration_from_now: Optional[Union[Var[bool], bool]] = None, 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, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Moment": - """Create a Moment component. + """Create the component. Args: *children: The children of the component. @@ -130,15 +112,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.pyi b/reflex/components/next/base.pyi index fd561fbec..4a82d7bef 100644 --- a/reflex/components/next/base.pyi +++ b/reflex/components/next/base.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class NextComponent(Component): ... @@ -23,52 +23,22 @@ class NextComponent(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "NextComponent": """Create the component. diff --git a/reflex/components/next/image.py b/reflex/components/next/image.py index 108d17452..2011505d8 100644 --- a/reflex/components/next/image.py +++ b/reflex/components/next/image.py @@ -2,9 +2,9 @@ from typing import Any, Literal, Optional, Union -from reflex.event import EventHandler +from reflex.event import EventHandler, no_args_event_spec from reflex.utils import types -from reflex.vars import Var +from reflex.vars.base import Var from .base import NextComponent @@ -47,7 +47,7 @@ class Image(NextComponent): placeholder: Var[str] # Allows passing CSS styles to the underlying image element. - # style: Var[Any] + # style: Var[Any] #noqa: ERA001 # The loading behavior of the image. Defaults to lazy. Can hurt performance, recommended to use `priority` instead. loading: Var[Literal["lazy", "eager"]] @@ -56,10 +56,10 @@ class Image(NextComponent): blurDataURL: Var[str] # Fires when the image has loaded. - on_load: EventHandler[lambda: []] + on_load: EventHandler[no_args_event_spec] # Fires when the image has an error. - on_error: EventHandler[lambda: []] + on_error: EventHandler[no_args_event_spec] @classmethod def create( @@ -102,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 a27a3420c..dd9dd38c3 100644 --- a/reflex/components/next/image.pyi +++ b/reflex/components/next/image.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import NextComponent @@ -19,16 +19,16 @@ class Image(NextComponent): *children, width: Optional[Union[int, str]] = None, height: Optional[Union[int, str]] = None, - src: Optional[Union[Var[Any], Any]] = None, + src: Optional[Union[Any, Var[Any]]] = None, alt: Optional[Union[Var[str], str]] = None, - loader: Optional[Union[Var[Any], Any]] = None, + loader: Optional[Union[Any, Var[Any]]] = None, fill: Optional[Union[Var[bool], bool]] = None, sizes: Optional[Union[Var[str], str]] = None, quality: Optional[Union[Var[int], int]] = None, priority: Optional[Union[Var[bool], bool]] = None, placeholder: Optional[Union[Var[str], str]] = None, loading: Optional[ - Union[Var[Literal["lazy", "eager"]], Literal["lazy", "eager"]] + Union[Literal["eager", "lazy"], Var[Literal["eager", "lazy"]]] ] = None, blurDataURL: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, @@ -36,58 +36,24 @@ class Image(NextComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_load: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_error: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_load: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Image": """Create an Image component from next/image. @@ -104,8 +70,10 @@ class Image(NextComponent): quality: The quality of the optimized image, an integer between 1 and 100, where 100 is the best quality and therefore largest file size. Defaults to 75. priority: When true, the image will be considered high priority and preload. Lazy loading is automatically disabled for images using priority. 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. + loading: 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 06d138176..fdccc9ee6 100644 --- a/reflex/components/next/link.pyi +++ b/reflex/components/next/link.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class NextLink(Component): @overload @@ -23,52 +23,22 @@ class NextLink(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 eb28fab46..8f31748f7 100644 --- a/reflex/components/next/video.pyi +++ b/reflex/components/next/video.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import NextComponent @@ -25,52 +25,22 @@ class Video(NextComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Video": """Create a Video component. diff --git a/reflex/components/plotly/plotly.py b/reflex/components/plotly/plotly.py index a2393fdca..3bdef7875 100644 --- a/reflex/components/plotly/plotly.py +++ b/reflex/components/plotly/plotly.py @@ -2,14 +2,15 @@ from __future__ import annotations -from typing import Any, Dict, List +from typing import Any, Dict, List, Tuple, Union + +from typing_extensions import TypedDict, TypeVar -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.event import EventHandler, no_args_event_spec from reflex.utils import console -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var try: from plotly.graph_objects import Figure, layout @@ -21,19 +22,7 @@ except ImportError: Template = Any # type: ignore -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.create_safe(f"{e0}?.event", _var_is_string=False)] - - -def _event_points_data_signature(e0: Var) -> List[Any]: +def _event_points_data_signature(e0: Var) -> Tuple[Var[List[Point]]]: """For plotly events with event data containing a point array. Args: @@ -42,54 +31,63 @@ def _event_points_data_signature(e0: Var) -> List[Any]: Returns: The event data and the extracted points. """ - return [ - Var.create_safe(f"{e0}?.event", _var_is_string=False), - Var.create_safe( - f"extractPoints({e0}?.points)", - _var_is_string=False, - ), + return (Var(_js_expr=f"extractPoints({e0}?.points)"),) + + +T = TypeVar("T") + +ItemOrList = Union[T, List[T]] + + +class BBox(TypedDict): + """Bounding box for a point in a plotly graph.""" + + x0: Union[float, int, None] + x1: Union[float, int, None] + y0: Union[float, int, None] + y1: Union[float, int, None] + z0: Union[float, int, None] + z1: Union[float, int, None] + + +class Point(TypedDict): + """A point in a plotly graph.""" + + x: Union[float, int, None] + y: Union[float, int, None] + z: Union[float, int, None] + lat: Union[float, int, None] + lon: Union[float, int, None] + curveNumber: Union[int, None] + pointNumber: Union[int, None] + pointNumbers: Union[List[int], None] + pointIndex: Union[int, None] + markerColor: Union[ + ItemOrList[ + ItemOrList[ + Union[ + float, + int, + str, + None, + ] + ] + ], + None, ] - - -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 [] + markerSize: Union[ + ItemOrList[ + ItemOrList[ + Union[ + float, + int, + None, + ] + ] + ], + None, + ] + bbox: Union[BBox, None] class Plotly(NoSSRComponent): @@ -97,71 +95,71 @@ class Plotly(NoSSRComponent): library = "react-plotly.js@2.6.0" - lib_dependencies: List[str] = ["plotly.js@2.22.0"] + 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] + template: Var[Template] # type: ignore # The config of the graph. config: Var[Dict] # If true, the graph will resize when the window is resized. - use_resize_handler: Var[bool] = Var.create_safe(True) + use_resize_handler: Var[bool] = LiteralVar.create(True) # Fired after the plot is redrawn. - on_after_plot: EventHandler[_passthrough_signature] + on_after_plot: EventHandler[no_args_event_spec] # Fired after the plot was animated. - on_animated: EventHandler[_null_signature] + on_animated: EventHandler[no_args_event_spec] # Fired while animating a single frame (does not currently pass data through). - on_animating_frame: EventHandler[_null_signature] + on_animating_frame: EventHandler[no_args_event_spec] # Fired when an animation is interrupted (to start a new animation for example). - on_animation_interrupted: EventHandler[_null_signature] + on_animation_interrupted: EventHandler[no_args_event_spec] # Fired when the plot is responsively sized. - on_autosize: EventHandler[_event_data_signature] + on_autosize: EventHandler[no_args_event_spec] # Fired whenever mouse moves over a plot. - on_before_hover: EventHandler[_event_data_signature] + on_before_hover: EventHandler[no_args_event_spec] # Fired when a plotly UI button is clicked. - on_button_clicked: EventHandler[_button_click_signature] + on_button_clicked: EventHandler[no_args_event_spec] # 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] + on_deselect: EventHandler[no_args_event_spec] # Fired when the plot is double clicked. - on_double_click: EventHandler[_passthrough_signature] + on_double_click: EventHandler[no_args_event_spec] # 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 after the plot is laid out (zoom, pan, etc). + on_relayout: EventHandler[no_args_event_spec] - # Fired while the plot is being layed out. - on_relayouting: EventHandler[_passthrough_signature] + # Fired while the plot is being laid out. + on_relayouting: EventHandler[no_args_event_spec] # Fired after the plot style is changed. - on_restyle: EventHandler[_passthrough_signature] + on_restyle: EventHandler[no_args_event_spec] # Fired after the plot is redrawn. - on_redraw: EventHandler[_event_data_signature] + on_redraw: EventHandler[no_args_event_spec] # Fired after selecting plot elements. on_selected: EventHandler[_event_points_data_signature] @@ -169,11 +167,11 @@ class Plotly(NoSSRComponent): # 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 while an animation is occurring. + on_transitioning: EventHandler[no_args_event_spec] # Fired when a transition is stopped early. - on_transition_interrupted: EventHandler[_event_data_signature] + on_transition_interrupted: EventHandler[no_args_event_spec] # Fired when a hovered element is no longer hovered. on_unhover: EventHandler[_event_points_data_signature] @@ -219,8 +217,8 @@ const extractPoints = (points) => { pointNumber: point.pointNumber, pointNumbers: point.pointNumbers, pointIndex: point.pointIndex, - 'marker.color': point['marker.color'], - 'marker.size': point['marker.size'], + markerColor: point['marker.color'], + markerSize: point['marker.size'], bbox: bbox, }) }) @@ -242,8 +240,8 @@ const extractPoints = (points) => { from plotly.io import templates responsive_template = color_mode_cond( - light=Var.create_safe(templates["plotly"]).to(dict), - dark=Var.create_safe(templates["plotly_dark"]).to(dict), + light=LiteralVar.create(templates["plotly"]), + dark=LiteralVar.create(templates["plotly_dark"]), ) if isinstance(responsive_template, Var): # Mark the conditional Var as a Template to avoid type mismatch @@ -257,36 +255,26 @@ const extractPoints = (points) => { def _render(self): tag = super()._render() - figure = self.data.to(dict) + figure = self.data.to(dict) if self.data is not None else Var.create({}) 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 = Var.create_safe( - f"{{'layout': {self.layout.to(dict)._var_name_unwrapped}}}" - ).to(dict) + layout_dict = LiteralVar.create({"layout": self.layout}) merge_dicts.append(layout_dict) if self.template is not None: - template_dict = Var.create_safe( - {"layout": {"template": self.template.to(dict)}} - ) - template_dict._var_data = None # To avoid stripping outer curly brackets - merge_dicts.append(template_dict) + template_dict = LiteralVar.create({"layout": {"template": self.template}}) + merge_dicts.append(template_dict._without_data()) if merge_dicts: - tag.special_props.add( + tag.special_props.append( # Merge all dictionaries and spread the result over props. - Var.create_safe( - f"{{...mergician({figure._var_name_unwrapped}," - f"{','.join(md._var_name_unwrapped for md in merge_dicts)})}}", - _var_is_string=False, + Var( + _js_expr=f"{{...mergician({figure!s}," + f"{','.join(str(md) for md in merge_dicts)})}}", ), ) else: # Spread the figure dict over props, nothing to merge. - tag.special_props.add( - Var.create_safe( - f"{{...{figure._var_name_unwrapped}}}", _var_is_string=False - ) - ) + tag.special_props.append(Var(_js_expr=f"{{...{figure!s}}}")) return tag diff --git a/reflex/components/plotly/plotly.pyi b/reflex/components/plotly/plotly.pyi index 219f113bc..ca1ddef39 100644 --- a/reflex/components/plotly/plotly.pyi +++ b/reflex/components/plotly/plotly.pyi @@ -3,14 +3,15 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, List, Optional, Union, overload + +from typing_extensions import TypedDict, TypeVar -from reflex.base import Base from reflex.components.component import NoSSRComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils import console -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var try: from plotly.graph_objects import Figure, layout @@ -20,11 +21,30 @@ except ImportError: console.warn("Plotly is not installed. Please run `pip install plotly`.") Figure = Any Template = Any +T = TypeVar("T") +ItemOrList = Union[T, List[T]] -class _ButtonClickData(Base): - menu: Any - button: Any - active: Any +class BBox(TypedDict): + x0: Union[float, int, None] + x1: Union[float, int, None] + y0: Union[float, int, None] + y1: Union[float, int, None] + z0: Union[float, int, None] + z1: Union[float, int, None] + +class Point(TypedDict): + x: Union[float, int, None] + y: Union[float, int, None] + z: Union[float, int, None] + lat: Union[float, int, None] + lon: Union[float, int, None] + curveNumber: Union[int, None] + pointNumber: Union[int, None] + pointNumbers: Union[List[int], None] + pointIndex: Union[int, None] + markerColor: Union[ItemOrList[ItemOrList[Union[float, int, str, None]]], None] + markerSize: Union[ItemOrList[ItemOrList[Union[float, int, None]]], None] + bbox: Union[BBox, None] class Plotly(NoSSRComponent): def add_imports(self) -> dict[str, str]: ... @@ -34,116 +54,60 @@ class Plotly(NoSSRComponent): def create( # type: ignore cls, *children, - data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore - layout: Optional[Union[Var[Dict], Dict]] = None, - template: Optional[Union[Var[Template], Template]] = None, # type: ignore - config: Optional[Union[Var[Dict], Dict]] = None, + data: Optional[Union[Figure, Var[Figure]]] = None, # type: ignore + layout: Optional[Union[Dict, Var[Dict]]] = None, + template: Optional[Union[Template, Var[Template]]] = None, # type: ignore + config: Optional[Union[Dict, Var[Dict]]] = None, use_resize_handler: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_after_plot: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animated: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animating_frame: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animation_interrupted: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_autosize: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_before_hover: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_button_clicked: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_after_plot: Optional[EventType[[], BASE_STATE]] = None, + on_animated: Optional[EventType[[], BASE_STATE]] = None, + on_animating_frame: Optional[EventType[[], BASE_STATE]] = None, + on_animation_interrupted: Optional[EventType[[], BASE_STATE]] = None, + on_autosize: Optional[EventType[[], BASE_STATE]] = None, + on_before_hover: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_button_clicked: Optional[EventType[[], BASE_STATE]] = None, on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_deselect: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]] ] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_deselect: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, on_hover: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_redraw: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_relayout: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_relayouting: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_restyle: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_redraw: Optional[EventType[[], BASE_STATE]] = None, + on_relayout: Optional[EventType[[], BASE_STATE]] = None, + on_relayouting: Optional[EventType[[], BASE_STATE]] = None, + on_restyle: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_selected: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]] ] = None, on_selecting: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_transition_interrupted: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_transitioning: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]] ] = None, + on_transition_interrupted: Optional[EventType[[], BASE_STATE]] = None, + on_transitioning: Optional[EventType[[], BASE_STATE]] = None, on_unhover: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[Point]], BASE_STATE]] ] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Plotly": """Create the Plotly component. @@ -155,6 +119,26 @@ class Plotly(NoSSRComponent): template: The template for visual appearance of the graph. config: The config 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 laid out (zoom, pan, etc). + on_relayouting: Fired while the plot is being laid 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 occurring. + 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. diff --git a/reflex/components/props.py b/reflex/components/props.py index a66ba7f2f..adce134fc 100644 --- a/reflex/components/props.py +++ b/reflex/components/props.py @@ -2,9 +2,12 @@ from __future__ import annotations +from pydantic import ValidationError + from reflex.base import Base from reflex.utils import format -from reflex.utils.serializers import serialize +from reflex.utils.exceptions import InvalidPropValueError +from reflex.vars.object import LiteralObjectVar class PropsBase(Base): @@ -20,12 +23,54 @@ class PropsBase(Base): Returns: The object as a Javascript Object literal. """ - return format.unwrap_vars( - self.__config__.json_dumps( - { - format.to_camel_case(key): value - for key, value in self.dict().items() - }, - default=serialize, - ) - ) + return LiteralObjectVar.create( + {format.to_camel_case(key): value for key, value in self.dict().items()} + ).json() + + def dict(self, *args, **kwargs): + """Convert the object to a dictionary. + + Keys will be converted to camelCase. + + Args: + *args: Arguments to pass to the parent class. + **kwargs: Keyword arguments to pass to the parent class. + + Returns: + The object as a dictionary. + """ + return { + format.to_camel_case(key): value + for key, value in super().dict(*args, **kwargs).items() + } + + +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__.pyi b/reflex/components/radix/__init__.pyi index b61659320..f4e81666a 100644 --- a/reflex/components/radix/__init__.pyi +++ b/reflex/components/radix/__init__.pyi @@ -8,7 +8,6 @@ from . import themes as themes from .primitives.accordion import accordion as accordion from .primitives.drawer import drawer as drawer from .primitives.form import form as form -from .primitives.progress import progress as progress from .themes.base import theme as theme from .themes.base import theme_panel as theme_panel from .themes.color_mode import color_mode as color_mode @@ -31,6 +30,7 @@ from .themes.components.hover_card import hover_card as hover_card from .themes.components.icon_button import icon_button as icon_button from .themes.components.inset import inset as inset from .themes.components.popover import popover as popover +from .themes.components.progress import progress as progress from .themes.components.radio_cards import radio_cards as radio_cards from .themes.components.radio_group import radio as radio from .themes.components.radio_group import radio_group as radio_group @@ -55,6 +55,7 @@ from .themes.layout.container import container as container from .themes.layout.flex import flex as flex from .themes.layout.grid import grid as grid from .themes.layout.list import list_item as list_item +from .themes.layout.list import list_ns as list # noqa from .themes.layout.list import ordered_list as ordered_list from .themes.layout.list import unordered_list as unordered_list from .themes.layout.section import section as section diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index b93bbf284..0ba618e21 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, 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 @@ -12,7 +12,8 @@ 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.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"] @@ -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,10 +115,10 @@ 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, _var_is_string=True) + easing: Var[str] = LiteralVar.create(DEFAULT_ANIMATION_EASING) # Whether to show divider lines between items. show_dividers: Var[bool] @@ -113,10 +126,11 @@ class AccordionRoot(AccordionComponent): _valid_children: List[str] = ["AccordionItem"] # Fired when the opened the accordions changes. - on_value_change: EventHandler[lambda e0: [e0]] + on_value_change: EventHandler[on_value_change] def _exclude_props(self) -> list[str]: - return super()._exclude_props() + [ + return [ + *super()._exclude_props(), "radius", "duration", "easing", @@ -180,6 +194,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", @@ -192,21 +211,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()) @@ -278,6 +296,9 @@ class AccordionItem(AccordionComponent): }, } + def _exclude_props(self) -> list[str]: + return ["header", "content"] + class AccordionHeader(AccordionComponent): """An accordion component.""" @@ -362,7 +383,7 @@ class AccordionTrigger(AccordionComponent): "background_color": color("accent", 4), }, "& > .AccordionChevron": { - "transition": f"transform var(--animation-duration) var(--animation-easing)", + "transition": "transform var(--animation-duration) var(--animation-easing)", }, _inherited_variant_selector("classic"): { "color": "var(--accent-contrast)", @@ -464,14 +485,12 @@ to { Returns: The style of the component. """ - slideDown = Var.create( - f"${{slideDown}} var(--animation-duration) var(--animation-easing)", - _var_is_string=True, + slideDown = LiteralVar.create( + "${slideDown} var(--animation-duration) var(--animation-easing)", ) - slideUp = Var.create( - f"${{slideUp}} var(--animation-duration) var(--animation-easing)", - _var_is_string=True, + slideUp = LiteralVar.create( + "${slideUp} var(--animation-duration) var(--animation-easing)", ) return { diff --git a/reflex/components/radix/primitives/accordion.pyi b/reflex/components/radix/primitives/accordion.pyi index 7cc1059ab..03208f496 100644 --- a/reflex/components/radix/primitives/accordion.pyi +++ b/reflex/components/radix/primitives/accordion.pyi @@ -3,14 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload from reflex.components.component import Component, ComponentNamespace from reflex.components.lucide.icon import Icon from reflex.components.radix.primitives.base import RadixPrimitiveComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var LiteralAccordionType = Literal["single", "multiple"] LiteralAccordionDir = Literal["ltr", "rtl"] @@ -28,70 +28,70 @@ class AccordionComponent(RadixPrimitiveComponent): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "soft", "surface", "outline", "ghost"]], - Literal["classic", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "surface"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -100,52 +100,22 @@ class AccordionComponent(RadixPrimitiveComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AccordionComponent": """Create the component. @@ -168,6 +138,8 @@ class AccordionComponent(RadixPrimitiveComponent): """ ... +def on_value_change(value: Var[str | List[str]]) -> Tuple[Var[str | List[str]]]: ... + class AccordionRoot(AccordionComponent): def add_style(self): ... @overload @@ -176,25 +148,25 @@ class AccordionRoot(AccordionComponent): cls, *children, type: Optional[ - Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]] + Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]] ] = None, - value: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None, + value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, default_value: Optional[ - Union[Var[Union[List[str], str]], str, List[str]] + Union[List[str], Var[Union[List[str], str]], str] ] = None, collapsible: Optional[Union[Var[bool], bool]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, orientation: Optional[ Union[ - Var[Literal["vertical", "horizontal"]], - Literal["vertical", "horizontal"], + Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, duration: Optional[Union[Var[int], int]] = None, @@ -202,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, @@ -274,54 +246,24 @@ class AccordionRoot(AccordionComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, on_value_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str | List[str]], BASE_STATE]] ] = None, **props, ) -> "AccordionRoot": @@ -340,6 +282,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. @@ -362,76 +305,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, @@ -440,62 +383,32 @@ class AccordionItem(AccordionComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -522,70 +435,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, @@ -594,52 +507,22 @@ class AccordionHeader(AccordionComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AccordionHeader": """Create the Accordion header component. @@ -672,70 +555,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, @@ -744,52 +627,22 @@ class AccordionTrigger(AccordionComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AccordionTrigger": """Create the Accordion trigger component. @@ -826,52 +679,22 @@ class AccordionIcon(Icon): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AccordionIcon": """Create the Accordion icon component. @@ -901,70 +724,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, @@ -973,52 +796,22 @@ class AccordionContent(AccordionComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AccordionContent": """Create the Accordion content component. diff --git a/reflex/components/radix/primitives/base.py b/reflex/components/radix/primitives/base.py index 857e80b5a..479cd2912 100644 --- a/reflex/components/radix/primitives/base.py +++ b/reflex/components/radix/primitives/base.py @@ -5,7 +5,7 @@ from typing import List from reflex.components.component import Component from reflex.components.tags.tag import Tag from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Var class RadixPrimitiveComponent(Component): diff --git a/reflex/components/radix/primitives/base.pyi b/reflex/components/radix/primitives/base.pyi index 0ddea6cb5..42847f160 100644 --- a/reflex/components/radix/primitives/base.pyi +++ b/reflex/components/radix/primitives/base.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.component import Component -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class RadixPrimitiveComponent(Component): @overload @@ -22,52 +22,22 @@ class RadixPrimitiveComponent(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadixPrimitiveComponent": """Create the component. @@ -100,52 +70,22 @@ class RadixPrimitiveComponentWithClassName(RadixPrimitiveComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadixPrimitiveComponentWithClassName": """Create the component. diff --git a/reflex/components/radix/primitives/drawer.py b/reflex/components/radix/primitives/drawer.py index 1c8a91837..ed57dcbd8 100644 --- a/reflex/components/radix/primitives/drawer.py +++ b/reflex/components/radix/primitives/drawer.py @@ -10,8 +10,8 @@ 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.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var class DrawerComponent(RadixPrimitiveComponent): @@ -32,14 +32,29 @@ class DrawerRoot(DrawerComponent): alias = "Vaul" + tag + # The open state of the drawer when it is initially rendered. Use when you do not need to control its open state. + default_open: Var[bool] + # Whether the drawer is open or not. open: Var[bool] - # Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. - should_scale_background: Var[bool] + # Fires when the drawer is opened or closed. + on_open_change: EventHandler[passthrough_event_spec(bool)] - # Number between 0 and 1 that determines when the drawer should be closed. - close_threshold: Var[float] + # When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`. + modal: Var[bool] + + # Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"` + direction: Var[LiteralDirectionType] + + # Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered. + on_animation_end: EventHandler[passthrough_event_spec(bool)] + + # When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer. + dismissible: Var[bool] + + # When `True`, dragging will only be possible by the handle. + handle_only: Var[bool] # Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account. snap_points: Optional[List[Union[str, float]]] @@ -50,17 +65,14 @@ class DrawerRoot(DrawerComponent): # Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms scroll_lock_timeout: Var[int] - # When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`. - modal: Var[bool] - - # Direction of the drawer. Defaults to `"bottom"` - direction: Var[LiteralDirectionType] - # When `True`, it prevents scroll restoration. Defaults to `True`. preventScrollRestoration: Var[bool] - # Fires when the drawer is opened. - on_open_change: EventHandler[lambda e0: [e0]] + # Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background. + should_scale_background: Var[bool] + + # Number between 0 and 1 that determines when the drawer should be closed. + close_threshold: Var[float] class DrawerTrigger(DrawerComponent): @@ -78,8 +90,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. @@ -128,19 +140,19 @@ class DrawerContent(DrawerComponent): return {"css": base_style} # Fired when the drawer content is opened. - on_open_auto_focus: EventHandler[lambda e0: [e0.target.value]] + on_open_auto_focus: EventHandler[no_args_event_spec] # Fired when the drawer content is closed. - on_close_auto_focus: EventHandler[lambda e0: [e0.target.value]] + on_close_auto_focus: EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0.target.value]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when the pointer is down outside the drawer content. - on_pointer_down_outside: EventHandler[lambda e0: [e0.target.value]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when interacting outside the drawer content. - on_interact_outside: EventHandler[lambda e0: [e0.target.value]] + on_interact_outside: EventHandler[no_args_event_spec] @classmethod def create(cls, *children, **props): @@ -245,6 +257,14 @@ class DrawerDescription(DrawerComponent): return {"css": base_style} +class DrawerHandle(DrawerComponent): + """A description for the drawer.""" + + tag = "Drawer.Handle" + + alias = "Vaul" + tag + + class Drawer(ComponentNamespace): """A namespace for Drawer components.""" @@ -256,6 +276,7 @@ class Drawer(ComponentNamespace): close = staticmethod(DrawerClose.create) title = staticmethod(DrawerTitle.create) description = staticmethod(DrawerDescription.create) + handle = staticmethod(DrawerHandle.create) drawer = Drawer() diff --git a/reflex/components/radix/primitives/drawer.pyi b/reflex/components/radix/primitives/drawer.pyi index dcbebfa15..1ca1e4325 100644 --- a/reflex/components/radix/primitives/drawer.pyi +++ b/reflex/components/radix/primitives/drawer.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class DrawerComponent(RadixPrimitiveComponent): @overload @@ -23,52 +23,22 @@ class DrawerComponent(RadixPrimitiveComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerComponent": """Create the component. @@ -97,90 +67,71 @@ class DrawerRoot(DrawerComponent): def create( # type: ignore cls, *children, + default_open: Optional[Union[Var[bool], bool]] = None, 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[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, + dismissible: Optional[Union[Var[bool], bool]] = None, + handle_only: Optional[Union[Var[bool], bool]] = 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, preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, + should_scale_background: Optional[Union[Var[bool], bool]] = None, + close_threshold: Optional[Union[Var[float], float]] = 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[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[ + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerRoot": """Create the component. Args: *children: The children of the component. + default_open: The open state of the drawer when it is initially rendered. Use when you do not need to control its open state. open: Whether the drawer is open or not. - should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. - close_threshold: Number between 0 and 1 that determines when the drawer should be closed. + on_open_change: Fires when the drawer is opened or closed. + modal: When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`. + direction: Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"` + on_animation_end: Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered. + dismissible: When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer. + handle_only: When `True`, dragging will only be possible by the handle. snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account. fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point. scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms - 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`. + should_scale_background: Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background. + close_threshold: Number between 0 and 1 that determines when the drawer should be 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. @@ -207,59 +158,36 @@ class DrawerTrigger(DrawerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -278,52 +206,22 @@ class DrawerPortal(DrawerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerPortal": """Create the component. @@ -356,67 +254,27 @@ class DrawerContent(DrawerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerContent": """Create a Drawer Content. @@ -453,52 +311,22 @@ class DrawerOverlay(DrawerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerOverlay": """Create the component. @@ -531,59 +359,36 @@ class DrawerClose(DrawerTrigger): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -602,52 +407,22 @@ class DrawerTitle(DrawerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerTitle": """Create the component. @@ -680,52 +455,22 @@ class DrawerDescription(DrawerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerDescription": """Create the component. @@ -746,6 +491,54 @@ class DrawerDescription(DrawerComponent): """ ... +class DrawerHandle(DrawerComponent): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "DrawerHandle": + """Create the component. + + Args: + *children: The children of the component. + 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 props of the component. + + Returns: + The component. + """ + ... + class Drawer(ComponentNamespace): root = staticmethod(DrawerRoot.create) trigger = staticmethod(DrawerTrigger.create) @@ -755,94 +548,76 @@ class Drawer(ComponentNamespace): close = staticmethod(DrawerClose.create) title = staticmethod(DrawerTitle.create) description = staticmethod(DrawerDescription.create) + handle = staticmethod(DrawerHandle.create) @staticmethod def __call__( *children, + default_open: Optional[Union[Var[bool], bool]] = None, 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[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, + dismissible: Optional[Union[Var[bool], bool]] = None, + handle_only: Optional[Union[Var[bool], bool]] = 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, preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, + should_scale_background: Optional[Union[Var[bool], bool]] = None, + close_threshold: Optional[Union[Var[float], float]] = 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[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[ + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerRoot": """Create the component. Args: *children: The children of the component. + default_open: The open state of the drawer when it is initially rendered. Use when you do not need to control its open state. open: Whether the drawer is open or not. - should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background. - close_threshold: Number between 0 and 1 that determines when the drawer should be closed. + on_open_change: Fires when the drawer is opened or closed. + modal: When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`. + direction: Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"` + on_animation_end: Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered. + dismissible: When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer. + handle_only: When `True`, dragging will only be possible by the handle. snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account. fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point. scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms - 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`. + should_scale_background: Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background. + close_threshold: Number between 0 and 1 that determines when the drawer should be 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 3b871d0af..f2b8201ad 100644 --- a/reflex/components/radix/primitives/form.py +++ b/reflex/components/radix/primitives/form.py @@ -8,8 +8,8 @@ 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.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec +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): @@ -28,7 +28,7 @@ class FormRoot(FormComponent, HTMLForm): alias = "RadixFormRoot" # Fired when the errors are cleared. - on_clear_server_errors: EventHandler[lambda: []] + on_clear_server_errors: EventHandler[no_args_event_spec] def add_style(self) -> dict[str, Any] | None: """Add style to the component. diff --git a/reflex/components/radix/primitives/form.pyi b/reflex/components/radix/primitives/form.pyi index 43bd0bbd2..83e65a54d 100644 --- a/reflex/components/radix/primitives/form.pyi +++ b/reflex/components/radix/primitives/form.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.el.elements.forms import Form as HTMLForm -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .base import RadixPrimitiveComponentWithClassName @@ -25,52 +25,22 @@ class FormComponent(RadixPrimitiveComponentWithClassName): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormComponent": """Create the component. @@ -99,108 +69,84 @@ class FormRoot(FormComponent, HTMLForm): cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_clear_server_errors: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_clear_server_errors: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE] + ], + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE] + ], + ] ] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 @@ -213,7 +159,8 @@ 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. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -257,52 +204,22 @@ class FormField(FormComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormField": """Create the component. @@ -338,52 +255,22 @@ class FormLabel(FormComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormLabel": """Create the component. @@ -416,52 +303,22 @@ class FormControl(FormComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormControl": """Create a Form Control component. @@ -509,6 +366,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", @@ -523,18 +392,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, @@ -544,52 +401,22 @@ class FormMessage(FormComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormMessage": """Create the component. @@ -625,52 +452,22 @@ class FormValidityState(FormComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormValidityState": """Create the component. @@ -703,52 +500,22 @@ class FormSubmit(FormComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FormSubmit": """Create the component. @@ -778,108 +545,84 @@ class Form(FormRoot): cls, *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_clear_server_errors: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_clear_server_errors: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE] + ], + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE] + ], + ] ] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 @@ -892,7 +635,8 @@ 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. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -934,108 +678,84 @@ class FormNamespace(ComponentNamespace): def __call__( *children, as_child: Optional[Union[Var[bool], bool]] = None, - accept: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + accept: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, accept_charset: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_complete: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - enc_type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - no_validate: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + enc_type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + no_validate: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, reset_on_submit: Optional[Union[Var[bool], bool]] = None, handle_submit_unique_name: Optional[Union[Var[str], str]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_clear_server_errors: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_clear_server_errors: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_submit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, Any]], BASE_STATE] + ], + Union[ + EventType[[], BASE_STATE], EventType[[Dict[str, str]], BASE_STATE] + ], + ] ] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 @@ -1048,7 +768,8 @@ 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. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. diff --git a/reflex/components/radix/primitives/progress.py b/reflex/components/radix/primitives/progress.py index 976daf505..72aee1038 100644 --- a/reflex/components/radix/primitives/progress.py +++ b/reflex/components/radix/primitives/progress.py @@ -9,7 +9,7 @@ from reflex.components.core.colors import color from reflex.components.radix.primitives.accordion import DEFAULT_ANIMATION_DURATION from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName from reflex.components.radix.themes.base import LiteralAccentColor, LiteralRadius -from reflex.vars import Var +from reflex.vars.base import Var class ProgressComponent(RadixPrimitiveComponentWithClassName): diff --git a/reflex/components/radix/primitives/progress.pyi b/reflex/components/radix/primitives/progress.pyi index 99609c0fc..32e4bb155 100644 --- a/reflex/components/radix/primitives/progress.pyi +++ b/reflex/components/radix/primitives/progress.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class ProgressComponent(RadixPrimitiveComponentWithClassName): @overload @@ -23,52 +23,22 @@ class ProgressComponent(RadixPrimitiveComponentWithClassName): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ProgressComponent": """Create the component. @@ -98,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, @@ -108,52 +78,22 @@ class ProgressRoot(ProgressComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ProgressRoot": """Create the component. @@ -186,63 +126,63 @@ class ProgressIndicator(ProgressComponent): max: Optional[Union[Var[Optional[int]], int]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -252,52 +192,22 @@ class ProgressIndicator(ProgressComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ProgressIndicator": """Create the component. @@ -329,63 +239,63 @@ class Progress(ProgressRoot): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -393,8 +303,8 @@ class Progress(ProgressRoot): max: Optional[Union[Var[Optional[int]], int]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -403,52 +313,22 @@ class Progress(ProgressRoot): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Progress": """High-level API for progress bar. @@ -481,63 +361,63 @@ class ProgressNamespace(ComponentNamespace): *children, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -545,8 +425,8 @@ class ProgressNamespace(ComponentNamespace): max: Optional[Union[Var[Optional[int]], int]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, @@ -555,52 +435,22 @@ class ProgressNamespace(ComponentNamespace): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 b8abd23b5..68f39e32c 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, 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.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var LiteralSliderOrientation = Literal["horizontal", "vertical"] LiteralSliderDir = Literal["ltr", "rtl"] @@ -19,8 +19,22 @@ 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.""" + """The Slider component containing all slider parts.""" tag = "Root" alias = "RadixSliderRoot" @@ -48,10 +62,10 @@ class SliderRoot(SliderComponent): min_steps_between_thumbs: Var[int] # Fired when the value of a thumb changes. - on_value_change: EventHandler[lambda e0: [e0]] + on_value_change: EventHandler[on_value_event_spec] # Fired when a thumb is released. - on_value_commit: EventHandler[lambda e0: [e0]] + on_value_commit: EventHandler[on_value_event_spec] def add_style(self) -> dict[str, Any] | None: """Add style to the component. @@ -174,7 +188,7 @@ class Slider(ComponentNamespace): else: children = [ track, - # Foreach.create(props.get("value"), lambda e: SliderThumb.create()), # foreach doesn't render Thumbs properly + # Foreach.create(props.get("value"), lambda e: SliderThumb.create()), # foreach doesn't render Thumbs properly # noqa: ERA001 ] return SliderRoot.create(*children, **props) diff --git a/reflex/components/radix/primitives/slider.pyi b/reflex/components/radix/primitives/slider.pyi index 0094bc3bb..2a14ba518 100644 --- a/reflex/components/radix/primitives/slider.pyi +++ b/reflex/components/radix/primitives/slider.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload from reflex.components.component import Component, ComponentNamespace from reflex.components.radix.primitives.base import RadixPrimitiveComponentWithClassName -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var LiteralSliderOrientation = Literal["horizontal", "vertical"] LiteralSliderDir = Literal["ltr", "rtl"] @@ -26,52 +26,22 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SliderComponent": """Create the component. @@ -92,6 +62,8 @@ class SliderComponent(RadixPrimitiveComponentWithClassName): """ ... +def on_value_event_spec(value: Var[List[int]]) -> Tuple[Var[List[int]]]: ... + class SliderRoot(SliderComponent): def add_style(self) -> dict[str, Any] | None: ... @overload @@ -99,17 +71,17 @@ class SliderRoot(SliderComponent): def create( # type: ignore cls, *children, - default_value: Optional[Union[Var[List[int]], List[int]]] = None, - value: Optional[Union[Var[List[int]], List[int]]] = None, + default_value: Optional[Union[List[int], Var[List[int]]]] = None, + value: Optional[Union[List[int], Var[List[int]]]] = None, name: Optional[Union[Var[str], str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, inverted: Optional[Union[Var[bool], bool]] = None, min: Optional[Union[Var[int], int]] = None, max: Optional[Union[Var[int], int]] = None, @@ -121,57 +93,27 @@ class SliderRoot(SliderComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, on_value_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[int]], BASE_STATE]] ] = None, on_value_commit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[List[int]], BASE_STATE]] ] = None, **props, ) -> "SliderRoot": @@ -179,6 +121,8 @@ class SliderRoot(SliderComponent): 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. @@ -206,52 +150,22 @@ class SliderTrack(SliderComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SliderTrack": """Create the component. @@ -285,52 +199,22 @@ class SliderRange(SliderComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SliderRange": """Create the component. @@ -364,52 +248,22 @@ class SliderThumb(SliderComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SliderThumb": """Create the component. diff --git a/reflex/components/radix/themes/base.py b/reflex/components/radix/themes/base.py index e0e05cc81..19e805f7a 100644 --- a/reflex/components/radix/themes/base.py +++ b/reflex/components/radix/themes/base.py @@ -5,10 +5,11 @@ from __future__ import annotations from typing import Any, Dict, Literal from reflex.components import Component +from reflex.components.core.breakpoints import Responsive from reflex.components.tags import Tag from reflex.config import get_config from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import Var LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"] LiteralJustify = Literal["start", "center", "end", "between"] @@ -52,7 +53,7 @@ LiteralAccentColor = Literal[ class CommonMarginProps(Component): """Many radix-themes elements accept shorthand margin props.""" - # Margin: "0" - "9" + # Margin: "0" - "9" # noqa: ERA001 m: Var[LiteralSpacing] # Margin horizontal: "0" - "9" @@ -74,6 +75,31 @@ class CommonMarginProps(Component): ml: Var[LiteralSpacing] +class CommonPaddingProps(Component): + """Many radix-themes elements accept shorthand padding props.""" + + # Padding: "0" - "9" # noqa: ERA001 + p: Var[Responsive[LiteralSpacing]] + + # Padding horizontal: "0" - "9" + px: Var[Responsive[LiteralSpacing]] + + # Padding vertical: "0" - "9" + py: Var[Responsive[LiteralSpacing]] + + # Padding top: "0" - "9" + pt: Var[Responsive[LiteralSpacing]] + + # Padding right: "0" - "9" + pr: Var[Responsive[LiteralSpacing]] + + # Padding bottom: "0" - "9" + pb: Var[Responsive[LiteralSpacing]] + + # Padding left: "0" - "9" + pl: Var[Responsive[LiteralSpacing]] + + class RadixLoadingProp(Component): """Base class for components that can be in a loading state.""" @@ -86,6 +112,9 @@ class RadixThemesComponent(Component): library = "@radix-ui/themes@^3.0.0" + # Temporary pin < 3.1.5 until radix-ui/themes#627 is resolved. + library = library + " && <3.1.5" + # "Fake" prop color_scheme is used to avoid shadowing CSS prop "color". _rename_props: Dict[str, str] = {"colorScheme": "color"} @@ -110,9 +139,7 @@ class RadixThemesComponent(Component): component = super().create(*children, **props) if component.library is None: component.library = RadixThemesComponent.__fields__["library"].default - component.alias = "RadixThemes" + ( - component.tag or component.__class__.__name__ - ) + component.alias = "RadixThemes" + (component.tag or type(component).__name__) return component @staticmethod @@ -216,7 +243,7 @@ class Theme(RadixThemesComponent): The import dict. """ _imports: ImportDict = { - "/utils/theme.js": [ImportVar(tag="theme", is_default=True)], + "$/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 @@ -230,12 +257,11 @@ class Theme(RadixThemesComponent): 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, - _var_is_string=False, + css=Var( + _js_expr="{...theme.styles.global[':root'], ...theme.styles.global.body}" ), ) + tag.remove_props("appearance") return tag @@ -258,31 +284,11 @@ class ThemePanel(RadixThemesComponent): """ return {"react": "useEffect"} - def add_hooks(self) -> list[str]: - """Add a hook on the ThemePanel to clear chakra-ui-color-mode. - - Returns: - The hooks to render. - """ - # The panel freezes the tab if the user color preference differs from the - # theme "appearance", so clear it out when theme panel is used. - return [ - """ - useEffect(() => { - if (typeof window !== 'undefined') { - window.onbeforeunload = () => { - localStorage.removeItem('chakra-ui-color-mode'); - } - window.onbeforeunload(); - } - }, [])""" - ] - class RadixThemesColorModeProvider(Component): """Next-themes integration for radix themes components.""" - 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 3014b5013..b0a8e2fcb 100644 --- a/reflex/components/radix/themes/base.pyi +++ b/reflex/components/radix/themes/base.pyi @@ -3,13 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components import Component -from reflex.event import EventHandler, EventSpec +from reflex.components.core.breakpoints import Breakpoints +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var LiteralAlign = Literal["start", "center", "end", "baseline", "stretch"] LiteralJustify = Literal["start", "center", "end", "between"] @@ -57,44 +58,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, @@ -102,52 +103,22 @@ class CommonMarginProps(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CommonMarginProps": """Create the component. @@ -174,6 +145,178 @@ class CommonMarginProps(Component): """ ... +class CommonPaddingProps(Component): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + p: Optional[ + Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + Union[ + Breakpoints[ + 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[ + 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[ + 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[ + 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[ + 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[ + 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[ + 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, + style: Optional[Style] = None, + key: Optional[Any] = None, + id: Optional[Any] = None, + class_name: Optional[Any] = None, + autofocus: Optional[bool] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "CommonPaddingProps": + """Create the component. + + Args: + *children: The children of the component. + p: Padding: "0" - "9" + px: Padding horizontal: "0" - "9" + py: Padding vertical: "0" - "9" + pt: Padding top: "0" - "9" + pr: Padding right: "0" - "9" + pb: Padding bottom: "0" - "9" + pl: Padding left: "0" - "9" + 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 RadixLoadingProp(Component): @overload @classmethod @@ -186,52 +329,22 @@ class RadixLoadingProp(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadixLoadingProp": """Create the component. @@ -263,52 +376,22 @@ class RadixThemesComponent(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadixThemesComponent": """Create a new component instance. @@ -342,52 +425,22 @@ class RadixThemesTriggerComponent(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadixThemesTriggerComponent": """Create a new RadixThemesTriggerComponent instance. @@ -407,96 +460,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, @@ -504,52 +557,22 @@ class Theme(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Theme": """Create a new Radix Theme specification. @@ -582,7 +605,6 @@ class Theme(RadixThemesComponent): class ThemePanel(RadixThemesComponent): def add_imports(self) -> dict[str, str]: ... - def add_hooks(self) -> list[str]: ... @overload @classmethod def create( # type: ignore @@ -594,52 +616,22 @@ class ThemePanel(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ThemePanel": """Create a new component instance. @@ -674,52 +666,22 @@ class RadixThemesColorModeProvider(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 8243a822a..2dd0f5e83 100644 --- a/reflex/components/radix/themes/color_mode.py +++ b/reflex/components/radix/themes/color_mode.py @@ -17,8 +17,7 @@ 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 @@ -32,8 +31,8 @@ from reflex.style import ( set_color_mode, toggle_color_mode, ) -from reflex.utils import console -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var +from reflex.vars.sequence import LiteralArrayVar from .components.icon_button import IconButton @@ -67,9 +66,9 @@ class ColorModeIcon(Cond): LiteralPosition = Literal["top-left", "top-right", "bottom-left", "bottom-right"] -position_values = get_args(LiteralPosition) +position_values: List[str] = list(get_args(LiteralPosition)) -position_map = { +position_map: Dict[str, List[str]] = { "position": position_values, "left": ["top-left", "bottom-left"], "right": ["top-right", "bottom-right"], @@ -79,8 +78,8 @@ position_map = { # needed to inverse contains for find -def _find(const, var): - return Var.create_safe(const, _var_is_string=False).contains(var) +def _find(const: List[str], var): + return LiteralArrayVar.create(const).contains(var) def _set_var_default(props, position, prop, default1, default2=""): @@ -97,36 +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, - allow_system: bool = False, **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. - allow_system: Allow picking the "system" value for the color mode. **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") @@ -166,12 +160,15 @@ class ColorModeIconButton(IconButton): color_mode_item("system"), ), ) - return super().create( + 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.""" @@ -195,7 +192,7 @@ class ColorModeSwitch(Switch): ) -class ColorModeNamespace(BaseVar): +class ColorModeNamespace(Var): """Namespace for color mode components.""" icon = staticmethod(ColorModeIcon.create) @@ -204,5 +201,7 @@ class ColorModeNamespace(BaseVar): color_mode = color_mode_var_and_namespace = ColorModeNamespace( - **dataclasses.asdict(color_mode) + _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 474c4cf36..3a9347017 100644 --- a/reflex/components/radix/themes/color_mode.pyi +++ b/reflex/components/radix/themes/color_mode.pyi @@ -3,20 +3,16 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -import dataclasses -from typing import Any, Callable, Dict, Literal, Optional, Union, get_args, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.component import BaseComponent 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.event import EventHandler, EventSpec -from reflex.style import ( - Style, - color_mode, -) -from reflex.vars import BaseVar, Var +from reflex.event import BASE_STATE, EventType +from reflex.style import Style, color_mode +from reflex.vars.base import Var from .components.icon_button import IconButton @@ -29,7 +25,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, @@ -37,52 +33,22 @@ class ColorModeIcon(Cond): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ColorModeIcon": """Create an icon component based on color_mode. @@ -97,14 +63,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 @@ -113,194 +73,171 @@ 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] = False, + allow_system: Optional[bool] = None, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -320,7 +257,7 @@ class ColorModeIconButton(IconButton): name: Name of the button, used when sending form data type: Type of the button (submit, reset, or button) value: Value of the button, used when sending form data - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -365,87 +302,87 @@ class ColorModeSwitch(Switch): value: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "full"]], Literal["none", "small", "full"] + Literal["full", "none", "small"], Var[Literal["full", "none", "small"]] ] ] = None, style: Optional[Style] = None, @@ -453,55 +390,25 @@ class ColorModeSwitch(Switch): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ColorModeSwitch": """Create a switch component bound to color_mode. @@ -520,6 +427,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: 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. @@ -533,11 +441,13 @@ class ColorModeSwitch(Switch): """ ... -class ColorModeNamespace(BaseVar): +class ColorModeNamespace(Var): icon = staticmethod(ColorModeIcon.create) button = staticmethod(ColorModeIconButton.create) switch = staticmethod(ColorModeSwitch.create) color_mode = color_mode_var_and_namespace = ColorModeNamespace( - **dataclasses.asdict(color_mode) + _js_expr=color_mode._js_expr, + _var_type=color_mode._var_type, + _var_data=color_mode._get_default_value(), ) diff --git a/reflex/components/radix/themes/components/__init__.pyi b/reflex/components/radix/themes/components/__init__.pyi index 6f6df88fa..29f15e311 100644 --- a/reflex/components/radix/themes/components/__init__.pyi +++ b/reflex/components/radix/themes/components/__init__.pyi @@ -22,6 +22,7 @@ from .hover_card import hover_card as hover_card from .icon_button import icon_button as icon_button from .inset import inset as inset from .popover import popover as popover +from .progress import progress as progress from .radio_cards import radio_cards as radio_cards from .radio_group import radio as radio from .radio_group import radio_group as radio_group diff --git a/reflex/components/radix/themes/components/alert_dialog.py b/reflex/components/radix/themes/components/alert_dialog.py index e8dfb57b2..36d38532c 100644 --- a/reflex/components/radix/themes/components/alert_dialog.py +++ b/reflex/components/radix/themes/components/alert_dialog.py @@ -5,8 +5,8 @@ from typing import Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -22,7 +22,10 @@ class AlertDialogRoot(RadixThemesComponent): open: Var[bool] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0]] + on_open_change: EventHandler[passthrough_event_spec(bool)] + + # The open state of the dialog when it is initially rendered. Use when you do not need to control its open state. + default_open: Var[bool] class AlertDialogTrigger(RadixThemesTriggerComponent): @@ -43,13 +46,13 @@ class AlertDialogContent(elements.Div, RadixThemesComponent): force_mount: Var[bool] # Fired when the dialog is opened. - on_open_auto_focus: EventHandler[lambda e0: [e0]] + on_open_auto_focus: EventHandler[no_args_event_spec] # Fired when the dialog is closed. - on_close_auto_focus: EventHandler[lambda e0: [e0]] + on_close_auto_focus: EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] class AlertDialogTitle(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/alert_dialog.pyi b/reflex/components/radix/themes/components/alert_dialog.pyi index 406d5eb2d..6188fdd45 100644 --- a/reflex/components/radix/themes/components/alert_dialog.pyi +++ b/reflex/components/radix/themes/components/alert_dialog.pyi @@ -3,14 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -23,60 +23,31 @@ class AlertDialogRoot(RadixThemesComponent): cls, *children, open: Optional[Union[Var[bool], bool]] = None, + default_open: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AlertDialogRoot": """Create a new component instance. @@ -87,6 +58,8 @@ class AlertDialogRoot(RadixThemesComponent): Args: *children: Child components. open: The controlled open state of the dialog. + on_open_change: Fired when the open state changes. + default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -111,52 +84,22 @@ class AlertDialogTrigger(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AlertDialogTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -178,101 +121,65 @@ class AlertDialogContent(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, force_mount: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AlertDialogContent": """Create a new component instance. @@ -284,7 +191,10 @@ class AlertDialogContent(elements.Div, RadixThemesComponent): *children: Child components. size: The size of the content. force_mount: Whether to force mount the content on open. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -324,52 +234,22 @@ class AlertDialogTitle(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AlertDialogTitle": """Create a new component instance. @@ -403,52 +283,22 @@ class AlertDialogDescription(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AlertDialogDescription": """Create a new component instance. @@ -482,52 +332,22 @@ class AlertDialogAction(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "AlertDialogAction": """Create a new RadixThemesTriggerComponent instance. @@ -552,52 +372,22 @@ class AlertDialogCancel(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 b06b2d564..fc8052c85 100644 --- a/reflex/components/radix/themes/components/aspect_ratio.py +++ b/reflex/components/radix/themes/components/aspect_ratio.py @@ -2,7 +2,7 @@ from typing import Union -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixThemesComponent diff --git a/reflex/components/radix/themes/components/aspect_ratio.pyi b/reflex/components/radix/themes/components/aspect_ratio.pyi index 08109b740..882014073 100644 --- a/reflex/components/radix/themes/components/aspect_ratio.pyi +++ b/reflex/components/radix/themes/components/aspect_ratio.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,52 +23,22 @@ class AspectRatio(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 22482f0c9..77a305e29 100644 --- a/reflex/components/radix/themes/components/avatar.py +++ b/reflex/components/radix/themes/components/avatar.py @@ -3,13 +3,9 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - LiteralRadius, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent LiteralSize = Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"] diff --git a/reflex/components/radix/themes/components/avatar.pyi b/reflex/components/radix/themes/components/avatar.pyi index 894ee6f67..e0ff0d913 100644 --- a/reflex/components/radix/themes/components/avatar.pyi +++ b/reflex/components/radix/themes/components/avatar.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,10 +21,12 @@ class Avatar(RadixThemesComponent): cls, *children, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -33,77 +35,75 @@ class Avatar(RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, src: Optional[Union[Var[str], str]] = None, @@ -113,52 +113,22 @@ class Avatar(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 fd26b17ab..389012bf0 100644 --- a/reflex/components/radix/themes/components/badge.py +++ b/reflex/components/radix/themes/components/badge.py @@ -4,13 +4,9 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - LiteralRadius, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent class Badge(elements.Span, RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/badge.pyi b/reflex/components/radix/themes/components/badge.pyi index 74d6dec24..38f20efeb 100644 --- a/reflex/components/radix/themes/components/badge.pyi +++ b/reflex/components/radix/themes/components/badge.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,165 +21,135 @@ class Badge(elements.Span, RadixThemesComponent): *children, variant: Optional[ Union[ - Var[Literal["solid", "soft", "surface", "outline"]], - Literal["solid", "soft", "surface", "outline"], + Literal["outline", "soft", "solid", "surface"], + Var[Literal["outline", "soft", "solid", "surface"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Badge": """Create a new component instance. @@ -194,7 +164,7 @@ class Badge(elements.Span, RadixThemesComponent): color_scheme: Color theme of the badge high_contrast: Whether to render the badge with higher contrast color against background radius: Override theme radius for badge: "none" | "small" | "medium" | "large" | "full" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/components/button.py b/reflex/components/radix/themes/components/button.py index 0c52e6ec6..cb44ee684 100644 --- a/reflex/components/radix/themes/components/button.py +++ b/reflex/components/radix/themes/components/button.py @@ -4,7 +4,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, diff --git a/reflex/components/radix/themes/components/button.pyi b/reflex/components/radix/themes/components/button.pyi index 877b7630b..cee24abc4 100644 --- a/reflex/components/radix/themes/components/button.pyi +++ b/reflex/components/radix/themes/components/button.pyi @@ -3,18 +3,15 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from ..base import ( - RadixLoadingProp, - RadixThemesComponent, -) +from ..base import RadixLoadingProp, RadixThemesComponent LiteralButtonSize = Literal["1", "2", "3", "4"] @@ -27,182 +24,152 @@ class Button(elements.Button, RadixLoadingProp, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Button": """Create a new component instance. @@ -229,7 +196,7 @@ class Button(elements.Button, RadixLoadingProp, RadixThemesComponent): name: Name of the button, used when sending form data type: Type of the button (submit, reset, or button) value: Value of the button, used when sending form data - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/components/callout.py b/reflex/components/radix/themes/components/callout.py index ea8be4623..6b0a1d399 100644 --- a/reflex/components/radix/themes/components/callout.py +++ b/reflex/components/radix/themes/components/callout.py @@ -7,12 +7,9 @@ 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, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, RadixThemesComponent CalloutVariant = Literal["soft", "surface", "outline"] diff --git a/reflex/components/radix/themes/components/callout.pyi b/reflex/components/radix/themes/components/callout.pyi index 2085fb4f5..2c469956f 100644 --- a/reflex/components/radix/themes/components/callout.pyi +++ b/reflex/components/radix/themes/components/callout.pyi @@ -3,14 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,159 +25,129 @@ class CalloutRoot(elements.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["soft", "surface", "outline"]], - Literal["soft", "surface", "outline"], + Literal["outline", "soft", "surface"], + Var[Literal["outline", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CalloutRoot": """Create a new component instance. @@ -192,7 +162,7 @@ class CalloutRoot(elements.Div, RadixThemesComponent): variant: Variant of button: "soft" | "surface" | "outline" color_scheme: Override theme color for button high_contrast: Whether to render the button with higher contrast color against background - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -227,81 +197,51 @@ class CalloutIcon(elements.Div, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CalloutIcon": """Create a new component instance. @@ -311,7 +251,7 @@ class CalloutIcon(elements.Div, RadixThemesComponent): Args: *children: Child components. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -346,81 +286,51 @@ class CalloutText(elements.P, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CalloutText": """Create a new component instance. @@ -430,7 +340,7 @@ class CalloutText(elements.P, RadixThemesComponent): Args: *children: Child components. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -470,159 +380,129 @@ class Callout(CalloutRoot): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["soft", "surface", "outline"]], - Literal["soft", "surface", "outline"], + Literal["outline", "soft", "surface"], + Var[Literal["outline", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Callout": """Create a callout component. @@ -636,7 +516,7 @@ class Callout(CalloutRoot): variant: Variant of button: "soft" | "surface" | "outline" color_scheme: Override theme color for button high_contrast: Whether to render the button with higher contrast color against background - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -678,159 +558,129 @@ class CalloutNamespace(ComponentNamespace): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["soft", "surface", "outline"]], - Literal["soft", "surface", "outline"], + Literal["outline", "soft", "surface"], + Var[Literal["outline", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Callout": """Create a callout component. @@ -844,7 +694,7 @@ class CalloutNamespace(ComponentNamespace): variant: Variant of button: "soft" | "surface" | "outline" color_scheme: Override theme color for button high_contrast: Whether to render the button with higher contrast color against background - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/components/card.py b/reflex/components/radix/themes/components/card.py index 574336b1b..30823de56 100644 --- a/reflex/components/radix/themes/components/card.py +++ b/reflex/components/radix/themes/components/card.py @@ -4,11 +4,9 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, -) +from ..base import RadixThemesComponent class Card(elements.Div, RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/card.pyi b/reflex/components/radix/themes/components/card.pyi index dc12b7d88..d8ab6c06b 100644 --- a/reflex/components/radix/themes/components/card.pyi +++ b/reflex/components/radix/themes/components/card.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,97 +22,67 @@ class Card(elements.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5"]], + Literal["1", "2", "3", "4", "5"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4", "5"]], Literal["1", "2", "3", "4", "5"], ] ], - Literal["1", "2", "3", "4", "5"], - Breakpoints[str, Literal["1", "2", "3", "4", "5"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["surface", "classic", "ghost"]], - Literal["surface", "classic", "ghost"], + Literal["classic", "ghost", "surface"], + Var[Literal["classic", "ghost", "surface"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Card": """Create a new component instance. @@ -125,7 +95,7 @@ class Card(elements.Div, RadixThemesComponent): as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. size: Card size: "1" - "5" variant: Variant of Card: "solid" | "soft" | "outline" | "ghost" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/components/checkbox.py b/reflex/components/radix/themes/components/checkbox.py index 4751c4995..42277bfea 100644 --- a/reflex/components/radix/themes/components/checkbox.py +++ b/reflex/components/radix/themes/components/checkbox.py @@ -6,14 +6,10 @@ 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.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.vars.base import LiteralVar, Var -from ..base import ( - LiteralAccentColor, - LiteralSpacing, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralSpacing, RadixThemesComponent LiteralCheckboxSize = Literal["1", "2", "3"] LiteralCheckboxVariant = Literal["classic", "surface", "soft"] @@ -61,7 +57,7 @@ class Checkbox(RadixThemesComponent): _rename_props = {"onChange": "onCheckedChange"} # Fired when the checkbox is checked or unchecked. - on_change: EventHandler[lambda e0: [e0]] + on_change: EventHandler[passthrough_event_spec(bool)] class HighLevelCheckbox(RadixThemesComponent): @@ -112,12 +108,10 @@ class HighLevelCheckbox(RadixThemesComponent): _rename_props = {"onChange": "onCheckedChange"} # Fired when the checkbox is checked or unchecked. - on_change: EventHandler[lambda e0: [e0]] + on_change: EventHandler[passthrough_event_spec(bool)] @classmethod - def create( - cls, text: Var[str] = Var.create_safe("", _var_is_string=True), **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 d21018e1d..fb6b51434 100644 --- a/reflex/components/radix/themes/components/checkbox.pyi +++ b/reflex/components/radix/themes/components/checkbox.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,80 +25,80 @@ class Checkbox(RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -114,55 +114,25 @@ class Checkbox(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Checkbox": """Create a new component instance. @@ -183,6 +153,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: 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. @@ -205,79 +176,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, @@ -293,55 +264,25 @@ class HighLevelCheckbox(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HighLevelCheckbox": """Create a checkbox with a label. @@ -361,6 +302,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: 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. @@ -381,79 +323,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, @@ -469,55 +411,25 @@ class CheckboxNamespace(ComponentNamespace): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HighLevelCheckbox": """Create a checkbox with a label. @@ -537,6 +449,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: 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 d5042c355..5f5fc3ae3 100644 --- a/reflex/components/radix/themes/components/checkbox_cards.py +++ b/reflex/components/radix/themes/components/checkbox_cards.py @@ -4,7 +4,7 @@ from types import SimpleNamespace from typing import Literal, Union from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/checkbox_cards.pyi b/reflex/components/radix/themes/components/checkbox_cards.pyi index c35754bde..64eb151b0 100644 --- a/reflex/components/radix/themes/components/checkbox_cards.pyi +++ b/reflex/components/radix/themes/components/checkbox_cards.pyi @@ -4,12 +4,12 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,83 +21,88 @@ class CheckboxCardsRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, columns: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -112,15 +117,15 @@ class CheckboxCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, gap: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -135,11 +140,6 @@ class CheckboxCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, style: Optional[Style] = None, @@ -147,52 +147,22 @@ class CheckboxCardsRoot(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CheckboxCardsRoot": """Create a new component instance. @@ -232,52 +202,22 @@ class CheckboxCardsItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 754f354b5..f6379e588 100644 --- a/reflex/components/radix/themes/components/checkbox_group.py +++ b/reflex/components/radix/themes/components/checkbox_group.py @@ -4,7 +4,7 @@ from types import SimpleNamespace from typing import List, Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/checkbox_group.pyi b/reflex/components/radix/themes/components/checkbox_group.pyi index 334ee3dd3..ffeeb75cf 100644 --- a/reflex/components/radix/themes/components/checkbox_group.pyi +++ b/reflex/components/radix/themes/components/checkbox_group.pyi @@ -4,12 +4,12 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,137 +21,107 @@ class CheckboxGroupRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - default_value: Optional[Union[Var[List[str]], List[str]]] = None, + default_value: Optional[Union[List[str], Var[List[str]]]] = None, name: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CheckboxGroupRoot": """Create a new component instance. @@ -193,52 +163,22 @@ class CheckboxGroupItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CheckboxGroupItem": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/context_menu.py b/reflex/components/radix/themes/components/context_menu.py index 95a0f2e74..f8512a902 100644 --- a/reflex/components/radix/themes/components/context_menu.py +++ b/reflex/components/radix/themes/components/context_menu.py @@ -1,16 +1,29 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import List, Literal +from typing import Dict, List, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, RadixThemesComponent +from .checkbox import Checkbox + +LiteralDirType = Literal["ltr", "rtl"] + +LiteralSizeType = Literal["1", "2"] + +LiteralVariantType = Literal["solid", "soft"] + +LiteralSideType = Literal["top", "right", "bottom", "left"] + +LiteralAlignType = Literal["start", "center", "end"] + +LiteralStickyType = Literal[ + "partial", + "always", +] class ContextMenuRoot(RadixThemesComponent): @@ -24,7 +37,10 @@ class ContextMenuRoot(RadixThemesComponent): _invalid_children: List[str] = ["ContextMenuItem"] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0]] + on_open_change: EventHandler[passthrough_event_spec(bool)] + + # The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. + dir: Var[LiteralDirType] class ContextMenuTrigger(RadixThemesComponent): @@ -45,38 +61,65 @@ class ContextMenuContent(RadixThemesComponent): tag = "ContextMenu.Content" - # Button size "1" - "4" - size: Var[Responsive[Literal["1", "2"]]] + # Dropdown Menu Content size "1" - "2" + size: Var[Responsive[LiteralSizeType]] - # Variant of button: "solid" | "soft" | "outline" | "ghost" - variant: Var[Literal["solid", "soft"]] + # Variant of Dropdown Menu Content: "solid" | "soft" + variant: Var[LiteralVariantType] - # Override theme color for button + # Override theme color for Dropdown Menu Content color_scheme: Var[LiteralAccentColor] - # Whether to render the button with higher contrast color against background + # Renders the Dropdown Menu Content in higher contrast high_contrast: Var[bool] - # The vertical distance in pixels from the anchor. - align_offset: Var[int] + # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. + as_child: Var[bool] - # When true, overrides the side and aligns preferences to prevent collisions with boundary edges. + # When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False. + loop: Var[bool] + + # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. + force_mount: Var[bool] + + # The preferred side of the trigger to render against when open. Will be reversed when collisions occur and `avoid_collisions` is enabled.The position of the tooltip. Defaults to "top". + side: Var[LiteralSideType] + + # The distance in pixels from the trigger. Defaults to 0. + side_offset: Var[Union[float, int]] + + # The preferred alignment against the trigger. May change when collisions occur. Defaults to "center". + align: Var[LiteralAlignType] + + # An offset in pixels from the "start" or "end" alignment options. + align_offset: Var[Union[float, int]] + + # When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True. avoid_collisions: Var[bool] - # Fired when the context menu is closed. - on_close_auto_focus: EventHandler[lambda e0: [e0]] + # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. + collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]] + + # 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". + sticky: Var[LiteralStickyType] + + # Whether to hide the content when the trigger becomes fully occluded. Defaults to False. + hide_when_detached: Var[bool] + + # Fired when focus moves back after closing. + on_close_auto_focus: EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when a pointer down event happens outside the context menu. - on_pointer_down_outside: EventHandler[lambda e0: [e0]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when focus moves outside the context menu. - on_focus_outside: EventHandler[lambda e0: [e0]] + on_focus_outside: EventHandler[no_args_event_spec] - # Fired when interacting outside the context menu. - on_interact_outside: EventHandler[lambda e0: [e0]] + # Fired when the pointer interacts outside the context menu. + on_interact_outside: EventHandler[no_args_event_spec] class ContextMenuSub(RadixThemesComponent): @@ -84,15 +127,30 @@ class ContextMenuSub(RadixThemesComponent): tag = "ContextMenu.Sub" + # The controlled open state of the submenu. Must be used in conjunction with `on_open_change`. + open: Var[bool] + + # 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] + + # Fired when the open state changes. + on_open_change: EventHandler[passthrough_event_spec(bool)] + class ContextMenuSubTrigger(RadixThemesComponent): """An item that opens a submenu.""" tag = "ContextMenu.SubTrigger" + # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. + as_child: Var[bool] + # Whether the trigger is disabled disabled: Var[bool] + # 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. + text_value: Var[str] + _valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSub"] @@ -101,22 +159,46 @@ class ContextMenuSubContent(RadixThemesComponent): tag = "ContextMenu.SubContent" - # When true, keyboard navigation will loop from last item to first, and vice versa. + # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. + as_child: Var[bool] + + # When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False. loop: Var[bool] + # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. + force_mount: Var[bool] + + # The distance in pixels from the trigger. Defaults to 0. + side_offset: Var[Union[float, int]] + + # An offset in pixels from the "start" or "end" alignment options. + align_offset: Var[Union[float, int]] + + # When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True. + avoid_collisions: Var[bool] + + # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. + collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]] + + # 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". + sticky: Var[LiteralStickyType] + + # Whether to hide the content when the trigger becomes fully occluded. Defaults to False. + hide_when_detached: Var[bool] + _valid_parents: List[str] = ["ContextMenuSub"] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when a pointer down event happens outside the context menu. - on_pointer_down_outside: EventHandler[lambda e0: [e0]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when focus moves outside the context menu. - on_focus_outside: EventHandler[lambda e0: [e0]] + on_focus_outside: EventHandler[no_args_event_spec] # Fired when interacting outside the context menu. - on_interact_outside: EventHandler[lambda e0: [e0]] + on_interact_outside: EventHandler[no_args_event_spec] class ContextMenuItem(RadixThemesComponent): @@ -130,8 +212,20 @@ class ContextMenuItem(RadixThemesComponent): # Shortcut to render a menu item as a link shortcut: Var[str] + # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. + as_child: Var[bool] + + # When true, prevents the user from interacting with the item. + disabled: Var[bool] + + # Optional text used for typeahead purposes. By default the typeahead behavior will use the content of the item. Use this when the content is complex, or you have non-textual content inside. + text_value: Var[str] + _valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSubContent"] + # Fired when the item is selected. + on_select: EventHandler[no_args_event_spec] + class ContextMenuSeparator(RadixThemesComponent): """Separates items in a context menu.""" @@ -139,6 +233,15 @@ class ContextMenuSeparator(RadixThemesComponent): tag = "ContextMenu.Separator" +class ContextMenuCheckbox(Checkbox): + """The component that contains the checkbox.""" + + tag = "ContextMenu.CheckboxItem" + + # Text to render as shortcut. + shortcut: Var[str] + + class ContextMenu(ComponentNamespace): """Menu representing a set of actions, displayed at the origin of a pointer right-click or long-press.""" @@ -150,6 +253,7 @@ class ContextMenu(ComponentNamespace): sub_content = staticmethod(ContextMenuSubContent.create) item = staticmethod(ContextMenuItem.create) separator = staticmethod(ContextMenuSeparator.create) + checkbox = staticmethod(ContextMenuCheckbox.create) context_menu = ContextMenu() diff --git a/reflex/components/radix/themes/components/context_menu.pyi b/reflex/components/radix/themes/components/context_menu.pyi index dbe23ee81..2d3ffbebc 100644 --- a/reflex/components/radix/themes/components/context_menu.pyi +++ b/reflex/components/radix/themes/components/context_menu.pyi @@ -3,15 +3,23 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent +from .checkbox import Checkbox + +LiteralDirType = Literal["ltr", "rtl"] +LiteralSizeType = Literal["1", "2"] +LiteralVariantType = Literal["solid", "soft"] +LiteralSideType = Literal["top", "right", "bottom", "left"] +LiteralAlignType = Literal["start", "center", "end"] +LiteralStickyType = Literal["partial", "always"] class ContextMenuRoot(RadixThemesComponent): @overload @@ -20,60 +28,31 @@ class ContextMenuRoot(RadixThemesComponent): cls, *children, modal: Optional[Union[Var[bool], bool]] = 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuRoot": """Create a new component instance. @@ -84,6 +63,8 @@ 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. + dir: The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -109,52 +90,22 @@ class ContextMenuTrigger(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuTrigger": """Create a new component instance. @@ -186,145 +137,133 @@ class ContextMenuContent(RadixThemesComponent): *children, size: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], - Literal["1", "2"], Breakpoints[str, Literal["1", "2"]], + Literal["1", "2"], + Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], ] ] = None, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - align_offset: Optional[Union[Var[int], int]] = None, + as_child: Optional[Union[Var[bool], bool]] = None, + loop: Optional[Union[Var[bool], bool]] = None, + force_mount: Optional[Union[Var[bool], bool]] = None, + side: Optional[ + Union[ + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], + ] + ] = None, + side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, + align: Optional[ + Union[ + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], + ] + ] = None, + align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, + collision_padding: Optional[ + Union[ + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, + ] + ] = None, + sticky: Optional[ + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] + ] = None, + hide_when_detached: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_focus_outside: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuContent": """Create a new component instance. @@ -334,12 +273,26 @@ class ContextMenuContent(RadixThemesComponent): Args: *children: Child components. - size: Button size "1" - "4" - variant: Variant of button: "solid" | "soft" | "outline" | "ghost" - color_scheme: Override theme color for button - 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. + size: Dropdown Menu Content size "1" - "2" + variant: Variant of Dropdown Menu Content: "solid" | "soft" + color_scheme: Override theme color for Dropdown Menu Content + high_contrast: Renders the Dropdown Menu Content in higher contrast + as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. + loop: When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False. + force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. + side: The preferred side of the trigger to render against when open. Will be reversed when collisions occur and `avoid_collisions` is enabled.The position of the tooltip. Defaults to "top". + side_offset: The distance in pixels from the trigger. Defaults to 0. + align: The preferred alignment against the trigger. May change when collisions occur. Defaults to "center". + align_offset: An offset in pixels from the "start" or "end" alignment options. + avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True. + collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. 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 focus moves back after closing. + 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 the pointer interacts outside the context menu. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -359,57 +312,32 @@ class ContextMenuSub(RadixThemesComponent): def create( # type: ignore cls, *children, + open: Optional[Union[Var[bool], bool]] = None, + default_open: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_open_change: Optional[ + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuSub": """Create a new component instance. @@ -419,6 +347,9 @@ class ContextMenuSub(RadixThemesComponent): Args: *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. @@ -438,58 +369,30 @@ class ContextMenuSubTrigger(RadixThemesComponent): def create( # type: ignore cls, *children, + as_child: Optional[Union[Var[bool], bool]] = None, disabled: Optional[Union[Var[bool], bool]] = None, + text_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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuSubTrigger": """Create a new component instance. @@ -499,7 +402,9 @@ class ContextMenuSubTrigger(RadixThemesComponent): Args: *children: Child components. + as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. disabled: Whether the trigger is disabled + 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. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -519,70 +424,49 @@ class ContextMenuSubContent(RadixThemesComponent): def create( # type: ignore cls, *children, + 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]], 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[ + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, + ] + ] = None, + sticky: Optional[ + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] + ] = None, + hide_when_detached: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_focus_outside: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuSubContent": """Create a new component instance. @@ -592,7 +476,19 @@ class ContextMenuSubContent(RadixThemesComponent): Args: *children: Child components. - loop: When true, keyboard navigation will loop from last item to first, and vice versa. + as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. + loop: When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False. + force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. + side_offset: The distance in pixels from the trigger. Defaults to 0. + align_offset: An offset in pixels from the "start" or "end" alignment options. + avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True. + collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. 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 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. @@ -614,118 +510,92 @@ 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, shortcut: Optional[Union[Var[str], str]] = None, + as_child: Optional[Union[Var[bool], bool]] = None, + disabled: Optional[Union[Var[bool], bool]] = None, + text_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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_select: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuItem": """Create a new component instance. @@ -737,6 +607,10 @@ class ContextMenuItem(RadixThemesComponent): *children: Child components. color_scheme: Override theme color for button shortcut: Shortcut to render a menu item as a link + 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 content 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. @@ -761,52 +635,22 @@ class ContextMenuSeparator(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ContextMenuSeparator": """Create a new component instance. @@ -829,6 +673,159 @@ class ContextMenuSeparator(RadixThemesComponent): """ ... +class ContextMenuCheckbox(Checkbox): + @overload + @classmethod + def create( # type: ignore + cls, + *children, + shortcut: Optional[Union[Var[str], str]] = None, + as_child: Optional[Union[Var[bool], bool]] = None, + size: Optional[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] + ] = None, + variant: Optional[ + Union[ + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], + ] + ] = None, + color_scheme: Optional[ + Union[ + 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", + ], + 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_checked: Optional[Union[Var[bool], bool]] = None, + checked: Optional[Union[Var[bool], bool]] = None, + disabled: Optional[Union[Var[bool], bool]] = None, + required: Optional[Union[Var[bool], bool]] = None, + name: Optional[Union[Var[str], str]] = 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, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_change: Optional[ + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] + ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, + **props, + ) -> "ContextMenuCheckbox": + """Create a new component instance. + + Will prepend "RadixThemes" to the component tag to avoid conflicts with + other UI libraries for common names, like Text and Button. + + Args: + *children: Child components. + shortcut: Text to render as shortcut. + as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. + size: Checkbox size "1" - "3" + variant: Variant of checkbox: "classic" | "surface" | "soft" + color_scheme: Override theme color for checkbox + high_contrast: Whether to render the checkbox with higher contrast color against background + default_checked: Whether the checkbox is checked by default + checked: Whether the checkbox is checked + disabled: Whether the checkbox is disabled + 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: 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. + 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: Component properties. + + Returns: + A new component instance. + """ + ... + class ContextMenu(ComponentNamespace): root = staticmethod(ContextMenuRoot.create) trigger = staticmethod(ContextMenuTrigger.create) @@ -838,5 +835,6 @@ class ContextMenu(ComponentNamespace): sub_content = staticmethod(ContextMenuSubContent.create) item = staticmethod(ContextMenuItem.create) separator = staticmethod(ContextMenuSeparator.create) + checkbox = staticmethod(ContextMenuCheckbox.create) context_menu = ContextMenu() diff --git a/reflex/components/radix/themes/components/data_list.py b/reflex/components/radix/themes/components/data_list.py index e5ce75464..05d4af074 100644 --- a/reflex/components/radix/themes/components/data_list.py +++ b/reflex/components/radix/themes/components/data_list.py @@ -4,7 +4,7 @@ from types import SimpleNamespace from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -29,6 +29,7 @@ class DataListItem(RadixThemesComponent): tag = "DataList.Item" + # The alignment of the data list item within its container. align: Var[Responsive[Literal["start", "center", "end", "baseline", "stretch"]]] @@ -37,12 +38,16 @@ class DataListLabel(RadixThemesComponent): tag = "DataList.Label" + # The width of the component width: Var[Responsive[str]] + # The minimum width of the component min_width: Var[Responsive[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 4fe0541a2..3b409363b 100644 --- a/reflex/components/radix/themes/components/data_list.pyi +++ b/reflex/components/radix/themes/components/data_list.pyi @@ -4,12 +4,12 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,37 +21,37 @@ class DataListRoot(RadixThemesComponent): *children, orientation: Optional[ Union[ + Breakpoints[str, Literal["horizontal", "vertical"]], + Literal["horizontal", "vertical"], Var[ Union[ Breakpoints[str, Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], ] ], - Literal["horizontal", "vertical"], - Breakpoints[str, Literal["horizontal", "vertical"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, style: Optional[Style] = None, @@ -59,52 +59,22 @@ class DataListRoot(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DataListRoot": """Create a new component instance. @@ -138,19 +108,19 @@ class DataListItem(RadixThemesComponent): *children, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, style: Optional[Style] = None, @@ -158,52 +128,22 @@ class DataListItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DataListItem": """Create a new component instance. @@ -213,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. @@ -233,73 +174,73 @@ class DataListLabel(RadixThemesComponent): cls, *children, width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, min_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, max_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -308,52 +249,22 @@ class DataListLabel(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DataListLabel": """Create a new component instance. @@ -363,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. @@ -387,52 +302,22 @@ class DataListValue(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 e0d7fae12..1b7c3b532 100644 --- a/reflex/components/radix/themes/components/dialog.py +++ b/reflex/components/radix/themes/components/dialog.py @@ -5,13 +5,10 @@ from typing import Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, - RadixThemesTriggerComponent, -) +from ..base import RadixThemesComponent, RadixThemesTriggerComponent class DialogRoot(RadixThemesComponent): @@ -23,7 +20,10 @@ class DialogRoot(RadixThemesComponent): open: Var[bool] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0]] + on_open_change: EventHandler[passthrough_event_spec(bool)] + + # The open state of the dialog when it is initially rendered. Use when you do not need to control its open state. + default_open: Var[bool] class DialogTrigger(RadixThemesTriggerComponent): @@ -47,19 +47,19 @@ class DialogContent(elements.Div, RadixThemesComponent): size: Var[Responsive[Literal["1", "2", "3", "4"]]] # Fired when the dialog is opened. - on_open_auto_focus: EventHandler[lambda e0: [e0]] + on_open_auto_focus: EventHandler[no_args_event_spec] # Fired when the dialog is closed. - on_close_auto_focus: EventHandler[lambda e0: [e0]] + on_close_auto_focus: EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when the pointer is down outside the dialog. - on_pointer_down_outside: EventHandler[lambda e0: [e0]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when the pointer interacts outside the dialog. - on_interact_outside: EventHandler[lambda e0: [e0]] + on_interact_outside: EventHandler[no_args_event_spec] class DialogDescription(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/dialog.pyi b/reflex/components/radix/themes/components/dialog.pyi index 0f05ca406..b1dfc1b54 100644 --- a/reflex/components/radix/themes/components/dialog.pyi +++ b/reflex/components/radix/themes/components/dialog.pyi @@ -3,14 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -21,60 +21,31 @@ class DialogRoot(RadixThemesComponent): cls, *children, open: Optional[Union[Var[bool], bool]] = None, + default_open: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogRoot": """Create a new component instance. @@ -85,6 +56,8 @@ class DialogRoot(RadixThemesComponent): Args: *children: Child components. open: The controlled open state of the dialog. + on_open_change: Fired when the open state changes. + default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -109,52 +82,22 @@ class DialogTrigger(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -179,52 +122,22 @@ class DialogTitle(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogTitle": """Create a new component instance. @@ -255,106 +168,66 @@ class DialogContent(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogContent": """Create a new component instance. @@ -365,7 +238,12 @@ class DialogContent(elements.Div, RadixThemesComponent): Args: *children: Child components. size: DialogContent size "1" - "4" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -405,52 +283,22 @@ class DialogDescription(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogDescription": """Create a new component instance. @@ -484,52 +332,22 @@ class DialogClose(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogClose": """Create a new RadixThemesTriggerComponent instance. @@ -555,60 +373,31 @@ class Dialog(ComponentNamespace): def __call__( *children, open: Optional[Union[Var[bool], bool]] = None, + default_open: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DialogRoot": """Create a new component instance. @@ -619,6 +408,8 @@ class Dialog(ComponentNamespace): Args: *children: Child components. open: The controlled open state of the dialog. + on_open_change: Fired when the open state changes. + default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state. 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 b425ef609..abce3e3bb 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.py +++ b/reflex/components/radix/themes/components/dropdown_menu.py @@ -4,14 +4,10 @@ from typing import Dict, List, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, - RadixThemesTriggerComponent, -) +from ..base import LiteralAccentColor, RadixThemesComponent, RadixThemesTriggerComponent LiteralDirType = Literal["ltr", "rtl"] @@ -23,7 +19,6 @@ LiteralSideType = Literal["top", "right", "bottom", "left"] LiteralAlignType = Literal["start", "center", "end"] - LiteralStickyType = Literal[ "partial", "always", @@ -50,7 +45,7 @@ class DropdownMenuRoot(RadixThemesComponent): _invalid_children: List[str] = ["DropdownMenuItem"] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0]] + on_open_change: EventHandler[passthrough_event_spec(bool)] class DropdownMenuTrigger(RadixThemesTriggerComponent): @@ -110,9 +105,6 @@ class DropdownMenuContent(RadixThemesComponent): # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]] - # 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. - arrow_padding: Var[Union[float, int]] - # 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". sticky: Var[LiteralStickyType] @@ -120,19 +112,19 @@ class DropdownMenuContent(RadixThemesComponent): hide_when_detached: Var[bool] # Fired when the dialog is closed. - on_close_auto_focus: EventHandler[lambda e0: [e0]] + on_close_auto_focus: EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when the pointer is down outside the dialog. - on_pointer_down_outside: EventHandler[lambda e0: [e0]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when focus moves outside the dialog. - on_focus_outside: EventHandler[lambda e0: [e0]] + on_focus_outside: EventHandler[no_args_event_spec] # Fired when the pointer interacts outside the dialog. - on_interact_outside: EventHandler[lambda e0: [e0]] + on_interact_outside: EventHandler[no_args_event_spec] class DropdownMenuSubTrigger(RadixThemesTriggerComponent): @@ -164,7 +156,7 @@ class DropdownMenuSub(RadixThemesComponent): default_open: Var[bool] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0.target.value]] + on_open_change: EventHandler[passthrough_event_spec(bool)] class DropdownMenuSubContent(RadixThemesComponent): @@ -193,9 +185,6 @@ class DropdownMenuSubContent(RadixThemesComponent): # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]] - # 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. - arrow_padding: Var[Union[float, int]] - # 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". sticky: Var[LiteralStickyType] @@ -205,16 +194,16 @@ class DropdownMenuSubContent(RadixThemesComponent): _valid_parents: List[str] = ["DropdownMenuSub"] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when the pointer is down outside the dialog. - on_pointer_down_outside: EventHandler[lambda e0: [e0]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when focus moves outside the dialog. - on_focus_outside: EventHandler[lambda e0: [e0]] + on_focus_outside: EventHandler[no_args_event_spec] # Fired when the pointer interacts outside the dialog. - on_interact_outside: EventHandler[lambda e0: [e0]] + on_interact_outside: EventHandler[no_args_event_spec] class DropdownMenuItem(RadixThemesComponent): @@ -240,7 +229,7 @@ class DropdownMenuItem(RadixThemesComponent): _valid_parents: List[str] = ["DropdownMenuContent", "DropdownMenuSubContent"] # Fired when the item is selected. - on_select: EventHandler[lambda e0: [e0.target.value]] + on_select: EventHandler[no_args_event_spec] class DropdownMenuSeparator(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/dropdown_menu.pyi b/reflex/components/radix/themes/components/dropdown_menu.pyi index d2b9216e1..96c624f89 100644 --- a/reflex/components/radix/themes/components/dropdown_menu.pyi +++ b/reflex/components/radix/themes/components/dropdown_menu.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -29,61 +29,31 @@ 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuRoot": """Create a new component instance. @@ -97,6 +67,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. @@ -122,52 +93,22 @@ class DropdownMenuTrigger(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -189,73 +130,73 @@ class DropdownMenuContent(RadixThemesComponent): *children, size: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], - Literal["1", "2"], Breakpoints[str, Literal["1", "2"]], + Literal["1", "2"], + Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], ] ] = None, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -265,30 +206,29 @@ class DropdownMenuContent(RadixThemesComponent): force_mount: Optional[Union[Var[bool], bool]] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ + Dict[str, Union[float, int]], Var[Union[Dict[str, Union[float, int]], float, int]], float, int, - Dict[str, Union[float, int]], ] ] = None, - arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None, sticky: Optional[ - Union[Var[Literal["partial", "always"]], Literal["partial", "always"]] + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] ] = None, hide_when_detached: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, @@ -296,67 +236,27 @@ class DropdownMenuContent(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_focus_outside: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuContent": """Create a new component instance. @@ -379,9 +279,13 @@ class DropdownMenuContent(RadixThemesComponent): align_offset: An offset in pixels from the "start" or "end" alignment options. avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True. collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. - 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. @@ -409,52 +313,22 @@ class DropdownMenuSubTrigger(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuSubTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -481,55 +355,25 @@ class DropdownMenuSub(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuSub": """Create a new component instance. @@ -541,6 +385,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. @@ -568,15 +413,14 @@ class DropdownMenuSubContent(RadixThemesComponent): avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ + Dict[str, Union[float, int]], Var[Union[Dict[str, Union[float, int]], float, int]], float, int, - Dict[str, Union[float, int]], ] ] = None, - arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None, sticky: Optional[ - Union[Var[Literal["partial", "always"]], Literal["partial", "always"]] + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] ] = None, hide_when_detached: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, @@ -584,64 +428,26 @@ class DropdownMenuSubContent(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_focus_outside: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuSubContent": """Create a new component instance. @@ -658,9 +464,12 @@ class DropdownMenuSubContent(RadixThemesComponent): align_offset: An offset in pixels from the "start" or "end" alignment options. avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True. collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. - 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. @@ -682,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 +560,23 @@ class DropdownMenuItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_select: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_select: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DropdownMenuItem": """Create a new component instance. @@ -814,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 +616,22 @@ class DropdownMenuSeparator(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 a1c5c82d4..bd5489ce6 100644 --- a/reflex/components/radix/themes/components/hover_card.py +++ b/reflex/components/radix/themes/components/hover_card.py @@ -1,17 +1,14 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Literal +from typing import Dict, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, - RadixThemesTriggerComponent, -) +from ..base import RadixThemesComponent, RadixThemesTriggerComponent class HoverCardRoot(RadixThemesComponent): @@ -32,7 +29,7 @@ class HoverCardRoot(RadixThemesComponent): close_delay: Var[int] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0]] + on_open_change: EventHandler[passthrough_event_spec(bool)] class HoverCardTrigger(RadixThemesTriggerComponent): @@ -55,9 +52,24 @@ class HoverCardContent(elements.Div, RadixThemesComponent): # The preferred alignment against the trigger. May change when collisions occur. align: Var[Literal["start", "center", "end"]] + # An offset in pixels from the "start" or "end" alignment options. + align_offset: Var[int] + # Whether or not the hover card should avoid collisions with its trigger. avoid_collisions: Var[bool] + # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }. + collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]] + + # 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 + sticky: Var[Literal["partial", "always"]] + + # Whether to hide the content when the trigger becomes fully occluded. + hide_when_detached: Var[bool] + + # Hovercard size "1" - "3" + size: Var[Responsive[Literal["1", "2", "3"]]] + class HoverCard(ComponentNamespace): """For sighted users to preview content available behind a link.""" diff --git a/reflex/components/radix/themes/components/hover_card.pyi b/reflex/components/radix/themes/components/hover_card.pyi index 0d43f387f..d43b583c2 100644 --- a/reflex/components/radix/themes/components/hover_card.pyi +++ b/reflex/components/radix/themes/components/hover_card.pyi @@ -3,14 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -29,55 +29,25 @@ class HoverCardRoot(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HoverCardRoot": """Create a new component instance. @@ -91,6 +61,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. @@ -115,52 +86,22 @@ class HoverCardTrigger(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HoverCardTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -182,99 +123,93 @@ class HoverCardContent(elements.Div, RadixThemesComponent): *children, side: Optional[ Union[ + Breakpoints[str, Literal["bottom", "left", "right", "top"]], + Literal["bottom", "left", "right", "top"], Var[ Union[ - Breakpoints[str, Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Breakpoints[str, Literal["bottom", "left", "right", "top"]], + Literal["bottom", "left", "right", "top"], ] ], - Literal["top", "right", "bottom", "left"], - Breakpoints[str, Literal["top", "right", "bottom", "left"]], ] ] = None, side_offset: Optional[Union[Var[int], int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, + align_offset: Optional[Union[Var[int], int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + collision_padding: Optional[ + Union[ + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, + ] + ] = None, + sticky: Optional[ + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] + ] = None, + hide_when_detached: Optional[Union[Var[bool], bool]] = None, + size: Optional[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], + Var[ + Union[ + Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] + ] + ], + ] + ] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HoverCardContent": """Create a new component instance. @@ -287,8 +222,13 @@ class HoverCardContent(elements.Div, RadixThemesComponent): side: The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled. side_offset: The distance in pixels from the trigger. align: The preferred alignment against the trigger. May change when collisions occur. + align_offset: An offset in pixels from the "start" or "end" alignment options. avoid_collisions: Whether or not the hover card should avoid collisions with its trigger. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }. + 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 + hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. + size: Hovercard size "1" - "3" + 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. @@ -334,55 +274,25 @@ class HoverCard(ComponentNamespace): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HoverCardRoot": """Create a new component instance. @@ -396,6 +306,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 76077057e..68c67485a 100644 --- a/reflex/components/radix/themes/components/icon_button.py +++ b/reflex/components/radix/themes/components/icon_button.py @@ -10,7 +10,7 @@ from reflex.components.core.match import Match from reflex.components.el import elements from reflex.components.lucide import Icon from reflex.style import Style -from reflex.vars import Var +from reflex.vars.base import Var from ..base import ( LiteralAccentColor, @@ -79,7 +79,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent): else: size_map_var = Match.create( props["size"], - *[(size, px) for size, px in RADIX_TO_LUCIDE_SIZE.items()], + *list(RADIX_TO_LUCIDE_SIZE.items()), 12, ) if not isinstance(size_map_var, Var): diff --git a/reflex/components/radix/themes/components/icon_button.pyi b/reflex/components/radix/themes/components/icon_button.pyi index 25de63938..abf77e07b 100644 --- a/reflex/components/radix/themes/components/icon_button.pyi +++ b/reflex/components/radix/themes/components/icon_button.pyi @@ -3,18 +3,15 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from ..base import ( - RadixLoadingProp, - RadixThemesComponent, -) +from ..base import RadixLoadingProp, RadixThemesComponent LiteralButtonSize = Literal["1", "2", "3", "4"] @@ -27,182 +24,152 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, - auto_focus: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + auto_focus: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - form_action: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_enc_type: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_method: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, form_no_validate: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - form_target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - name: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - value: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form_target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + name: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + type: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + value: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "IconButton": """Create a IconButton component. @@ -226,7 +193,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent): name: Name of the button, used when sending form data type: Type of the button (submit, reset, or button) value: Value of the button, used when sending form data - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/components/inset.py b/reflex/components/radix/themes/components/inset.py index 96f1f61ce..059858272 100644 --- a/reflex/components/radix/themes/components/inset.py +++ b/reflex/components/radix/themes/components/inset.py @@ -4,11 +4,9 @@ from typing import Literal, Union from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, -) +from ..base import RadixThemesComponent LiteralButtonSize = Literal["1", "2", "3", "4"] diff --git a/reflex/components/radix/themes/components/inset.pyi b/reflex/components/radix/themes/components/inset.pyi index 0106a23b2..f03275ec0 100644 --- a/reflex/components/radix/themes/components/inset.pyi +++ b/reflex/components/radix/themes/components/inset.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,161 +23,131 @@ class Inset(elements.Div, RadixThemesComponent): *children, side: Optional[ Union[ + Breakpoints[str, Literal["bottom", "left", "right", "top", "x", "y"]], + Literal["bottom", "left", "right", "top", "x", "y"], Var[ Union[ Breakpoints[ - str, Literal["x", "y", "top", "bottom", "right", "left"] + str, Literal["bottom", "left", "right", "top", "x", "y"] ], - Literal["x", "y", "top", "bottom", "right", "left"], + Literal["bottom", "left", "right", "top", "x", "y"], ] ], - Literal["x", "y", "top", "bottom", "right", "left"], - Breakpoints[str, Literal["x", "y", "top", "bottom", "right", "left"]], ] ] = None, clip: Optional[ Union[ + Breakpoints[str, Literal["border-box", "padding-box"]], + Literal["border-box", "padding-box"], Var[ Union[ Breakpoints[str, Literal["border-box", "padding-box"]], Literal["border-box", "padding-box"], ] ], - Literal["border-box", "padding-box"], - Breakpoints[str, Literal["border-box", "padding-box"]], ] ] = None, p: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, px: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, py: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pt: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pr: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pb: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, pl: Optional[ Union[ + Breakpoints[str, Union[int, str]], Var[Union[Breakpoints[str, Union[int, str]], int, str]], int, str, - Breakpoints[str, Union[int, str]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Inset": """Create a new component instance. @@ -196,7 +166,7 @@ class Inset(elements.Div, RadixThemesComponent): pr: Padding on the right pb: Padding on the bottom pl: Padding on the left - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/components/popover.py b/reflex/components/radix/themes/components/popover.py index 7c51cb53b..bdf5f4af3 100644 --- a/reflex/components/radix/themes/components/popover.py +++ b/reflex/components/radix/themes/components/popover.py @@ -1,17 +1,14 @@ """Interactive components provided by @radix-ui/themes.""" -from typing import Literal +from typing import Dict, Literal, Union from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, - RadixThemesTriggerComponent, -) +from ..base import RadixThemesComponent, RadixThemesTriggerComponent class PopoverRoot(RadixThemesComponent): @@ -26,7 +23,10 @@ class PopoverRoot(RadixThemesComponent): modal: Var[bool] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0]] + on_open_change: EventHandler[passthrough_event_spec(bool)] + + # The open state of the popover when it is initially rendered. Use when you do not need to control its open state. + default_open: Var[bool] class PopoverTrigger(RadixThemesTriggerComponent): @@ -58,23 +58,32 @@ class PopoverContent(elements.Div, RadixThemesComponent): # When true, overrides the side andalign preferences to prevent collisions with boundary edges. avoid_collisions: Var[bool] + # The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0. + collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]] + + # 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". + sticky: Var[Literal["partial", "always"]] + + # Whether to hide the content when the trigger becomes fully occluded. Defaults to False. + hide_when_detached: Var[bool] + # Fired when the dialog is opened. - on_open_auto_focus: EventHandler[lambda e0: [e0]] + on_open_auto_focus: EventHandler[no_args_event_spec] # Fired when the dialog is closed. - on_close_auto_focus: EventHandler[lambda e0: [e0]] + on_close_auto_focus: EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when the pointer is down outside the dialog. - on_pointer_down_outside: EventHandler[lambda e0: [e0]] + on_pointer_down_outside: EventHandler[no_args_event_spec] # Fired when focus moves outside the dialog. - on_focus_outside: EventHandler[lambda e0: [e0]] + on_focus_outside: EventHandler[no_args_event_spec] # Fired when the pointer interacts outside the dialog. - on_interact_outside: EventHandler[lambda e0: [e0]] + on_interact_outside: EventHandler[no_args_event_spec] class PopoverClose(RadixThemesTriggerComponent): diff --git a/reflex/components/radix/themes/components/popover.pyi b/reflex/components/radix/themes/components/popover.pyi index 82bec124b..51f114dd2 100644 --- a/reflex/components/radix/themes/components/popover.pyi +++ b/reflex/components/radix/themes/components/popover.pyi @@ -3,14 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent, RadixThemesTriggerComponent @@ -22,60 +22,31 @@ class PopoverRoot(RadixThemesComponent): *children, open: Optional[Union[Var[bool], bool]] = None, modal: Optional[Union[Var[bool], bool]] = None, + default_open: 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "PopoverRoot": """Create a new component instance. @@ -87,6 +58,8 @@ 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. + default_open: The open state of the popover when it is initially rendered. Use when you do not need to control its open state. style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -111,52 +84,22 @@ class PopoverTrigger(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "PopoverTrigger": """Create a new RadixThemesTriggerComponent instance. @@ -178,124 +121,94 @@ class PopoverContent(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[int], int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[int], int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + collision_padding: Optional[ + Union[ + Dict[str, Union[float, int]], + Var[Union[Dict[str, Union[float, int]], float, int]], + float, + int, + ] + ] = None, + sticky: Optional[ + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] + ] = None, + hide_when_detached: Optional[Union[Var[bool], bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_interact_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_open_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_focus_outside: Optional[EventType[[], BASE_STATE]] = None, + on_interact_outside: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_open_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "PopoverContent": """Create a new component instance. @@ -311,7 +224,16 @@ class PopoverContent(elements.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. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. 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_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. context_menu: Defines the ID of a element which will serve as the element's context menu. @@ -351,52 +273,22 @@ class PopoverClose(RadixThemesTriggerComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 a122130c8..e9fe168c6 100644 --- a/reflex/components/radix/themes/components/progress.py +++ b/reflex/components/radix/themes/components/progress.py @@ -4,7 +4,8 @@ from typing import Literal from reflex.components.component import Component from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.style import Style +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -38,6 +39,21 @@ class Progress(RadixThemesComponent): # The duration of the progress bar animation. Once the duration times out, the progress bar will start an indeterminate animation. duration: Var[str] + # The color of the progress bar fill animation. + fill_color: Var[str] + + @staticmethod + def _color_selector(color: str) -> Style: + """Return a style object with the correct color and css selector. + + Args: + color: Color of the fill part. + + Returns: + Style: Style object with the correct css selector and color. + """ + return Style({".rt-ProgressIndicator": {"background_color": color}}) + @classmethod def create(cls, *children, **props) -> Component: """Create a Progress component. @@ -50,6 +66,12 @@ class Progress(RadixThemesComponent): The Progress Component. """ props.setdefault("width", "100%") + if "fill_color" in props: + color = props.get("fill_color", "") + style = props.get("style", {}) + style = style | cls._color_selector(color) + props["style"] = style + return super().create(*children, **props) diff --git a/reflex/components/radix/themes/components/progress.pyi b/reflex/components/radix/themes/components/progress.pyi index 514061ba7..5b3f8ba51 100644 --- a/reflex/components/radix/themes/components/progress.pyi +++ b/reflex/components/radix/themes/components/progress.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,142 +22,113 @@ class Progress(RadixThemesComponent): max: Optional[Union[Var[int], int]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, duration: Optional[Union[Var[str], str]] = None, + fill_color: Optional[Union[Var[str], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Progress": """Create a Progress component. @@ -172,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 53cb35f32..fd24bb6b5 100644 --- a/reflex/components/radix/themes/components/radio.py +++ b/reflex/components/radix/themes/components/radio.py @@ -3,7 +3,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/radio.pyi b/reflex/components/radix/themes/components/radio.pyi index e00a6db58..49490286f 100644 --- a/reflex/components/radix/themes/components/radio.pyi +++ b/reflex/components/radix/themes/components/radio.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -20,80 +20,80 @@ class Radio(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -103,52 +103,22 @@ class Radio(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 88688521f..e075a1ba2 100644 --- a/reflex/components/radix/themes/components/radio_cards.py +++ b/reflex/components/radix/themes/components/radio_cards.py @@ -4,8 +4,8 @@ from types import SimpleNamespace from typing import Literal, Union from reflex.components.core.breakpoints import Responsive -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent @@ -65,7 +65,7 @@ class RadioCardsRoot(RadixThemesComponent): loop: Var[bool] # Event handler called when the value changes. - on_value_change: EventHandler[lambda e0: [e0]] + on_value_change: EventHandler[passthrough_event_spec(str)] class RadioCardsItem(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/radio_cards.pyi b/reflex/components/radix/themes/components/radio_cards.pyi index 4feb78d20..5ba01d0a0 100644 --- a/reflex/components/radix/themes/components/radio_cards.pyi +++ b/reflex/components/radix/themes/components/radio_cards.pyi @@ -4,12 +4,12 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,83 +22,88 @@ class RadioCardsRoot(RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, columns: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -113,15 +118,15 @@ class RadioCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, gap: Optional[ Union[ + Breakpoints[ + str, + Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], + ], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -136,11 +141,6 @@ class RadioCardsRoot(RadixThemesComponent): ] ], str, - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, - Union[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], str], - ], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -150,65 +150,35 @@ class RadioCardsRoot(RadixThemesComponent): required: Optional[Union[Var[bool], bool]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical", "undefined"]], - Literal["horizontal", "vertical", "undefined"], + Literal["horizontal", "undefined", "vertical"], + Var[Literal["horizontal", "undefined", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, loop: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, on_value_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, **props, ) -> "RadioCardsRoot": @@ -233,6 +203,7 @@ class RadioCardsRoot(RadixThemesComponent): 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. @@ -261,52 +232,22 @@ class RadioCardsItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadioCardsItem": """Create a new component instance. diff --git a/reflex/components/radix/themes/components/radio_group.py b/reflex/components/radix/themes/components/radio_group.py index 20ccbd5b5..80b3ee10c 100644 --- a/reflex/components/radix/themes/components/radio_group.py +++ b/reflex/components/radix/themes/components/radio_group.py @@ -9,14 +9,12 @@ 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.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.utils import types +from reflex.vars.base import LiteralVar, Var +from reflex.vars.sequence import StringVar -from ..base import ( - LiteralAccentColor, - LiteralSpacing, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralSpacing, RadixThemesComponent LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"] @@ -27,14 +25,10 @@ class RadioGroupRoot(RadixThemesComponent): tag = "RadioGroup.Root" # The size of the radio group: "1" | "2" | "3" - size: Var[Responsive[Literal["1", "2", "3"]]] = Var.create_safe( - "2", _var_is_string=True - ) + size: Var[Responsive[Literal["1", "2", "3"]]] = LiteralVar.create("2") # The variant of the radio group - variant: Var[Literal["classic", "surface", "soft"]] = Var.create_safe( - "classic", _var_is_string=True - ) + variant: Var[Literal["classic", "surface", "soft"]] = LiteralVar.create("classic") # The color of the radio group color_scheme: Var[LiteralAccentColor] @@ -61,7 +55,7 @@ class RadioGroupRoot(RadixThemesComponent): _rename_props = {"onChange": "onValueChange"} # Fired when the value of the radio group changes. - on_change: EventHandler[lambda e0: [e0]] + on_change: EventHandler[passthrough_event_spec(str)] class RadioGroupItem(RadixThemesComponent): @@ -86,20 +80,16 @@ class HighLevelRadioGroup(RadixThemesComponent): items: Var[List[str]] # The direction of the radio group. - direction: Var[LiteralFlexDirection] = Var.create_safe( - "column", _var_is_string=True - ) + direction: Var[LiteralFlexDirection] = LiteralVar.create("row") # The gap between the items of the radio group. - spacing: Var[LiteralSpacing] = Var.create_safe("2", _var_is_string=True) + spacing: Var[LiteralSpacing] = LiteralVar.create("2") # The size of the radio group. - size: Var[Literal["1", "2", "3"]] = Var.create_safe("2", _var_is_string=True) + size: Var[Literal["1", "2", "3"]] = LiteralVar.create("2") # The variant of the radio group - variant: Var[Literal["classic", "surface", "soft"]] = Var.create_safe( - "classic", _var_is_string=True - ) + variant: Var[Literal["classic", "surface", "soft"]] = LiteralVar.create("classic") # The color of the radio group color_scheme: Var[LiteralAccentColor] @@ -139,42 +129,48 @@ 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", "") - default_value = Var.create(default_value, _var_is_string=True) + 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, _var_is_string=False) - .to_string() # type: ignore - ._replace(_var_is_local=False) - ) + default_value = LiteralVar.create(default_value).to_string() - def radio_group_item(value: str | Var) -> Component: - item_value = Var.create(value, _var_is_string=False) # 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, - disabled=props.get("disabled", Var.create(False)), + disabled=props.get("disabled", LiteralVar.create(False)), ), item_value, spacing="2", @@ -183,8 +179,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( diff --git a/reflex/components/radix/themes/components/radio_group.pyi b/reflex/components/radix/themes/components/radio_group.pyi index 0452450ff..e8e4e4254 100644 --- a/reflex/components/radix/themes/components/radio_group.pyi +++ b/reflex/components/radix/themes/components/radio_group.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,80 +23,80 @@ class RadioGroupRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, @@ -111,55 +111,25 @@ class RadioGroupRoot(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadioGroupRoot": """Create a new component instance. @@ -178,6 +148,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: 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. @@ -205,52 +176,22 @@ class RadioGroupItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadioGroupItem": """Create a new component instance. @@ -282,87 +223,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, @@ -377,52 +318,22 @@ class HighLevelRadioGroup(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HighLevelRadioGroup": """Create a radio group component. @@ -451,6 +362,9 @@ class HighLevelRadioGroup(RadixThemesComponent): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ ... @@ -461,87 +375,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, @@ -556,52 +470,22 @@ class RadioGroup(ComponentNamespace): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HighLevelRadioGroup": """Create a radio group component. @@ -630,6 +514,9 @@ class RadioGroup(ComponentNamespace): Returns: The created radio group component. + + Raises: + TypeError: If the type of items is invalid. """ ... diff --git a/reflex/components/radix/themes/components/scroll_area.py b/reflex/components/radix/themes/components/scroll_area.py index 8920d81d6..516649e12 100644 --- a/reflex/components/radix/themes/components/scroll_area.py +++ b/reflex/components/radix/themes/components/scroll_area.py @@ -2,11 +2,9 @@ from typing import Literal -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, -) +from ..base import RadixThemesComponent class ScrollArea(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/scroll_area.pyi b/reflex/components/radix/themes/components/scroll_area.pyi index e7d2018da..5945cc3af 100644 --- a/reflex/components/radix/themes/components/scroll_area.pyi +++ b/reflex/components/radix/themes/components/scroll_area.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -19,14 +19,14 @@ class ScrollArea(RadixThemesComponent): *children, scrollbars: Optional[ Union[ - Var[Literal["vertical", "horizontal", "both"]], - Literal["vertical", "horizontal", "both"], + Literal["both", "horizontal", "vertical"], + Var[Literal["both", "horizontal", "vertical"]], ] ] = None, type: Optional[ Union[ - Var[Literal["auto", "always", "scroll", "hover"]], - Literal["auto", "always", "scroll", "hover"], + Literal["always", "auto", "hover", "scroll"], + Var[Literal["always", "auto", "hover", "scroll"]], ] ] = None, scroll_hide_delay: Optional[Union[Var[int], int]] = None, @@ -35,52 +35,22 @@ class ScrollArea(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 40beb603a..f2dd9dc7c 100644 --- a/reflex/components/radix/themes/components/segmented_control.py +++ b/reflex/components/radix/themes/components/segmented_control.py @@ -3,15 +3,29 @@ from __future__ import annotations from types import SimpleNamespace -from typing import List, Literal, Union +from typing import List, Literal, Tuple, Union from reflex.components.core.breakpoints import Responsive from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var from ..base import LiteralAccentColor, RadixThemesComponent +def on_value_change( + value: Var[Union[str, List[str]]], +) -> Tuple[Var[Union[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.""" @@ -23,6 +37,7 @@ class SegmentedControlRoot(RadixThemesComponent): # Variant of button: "classic" | "surface" variant: Var[Literal["classic", "surface"]] + # The type of the segmented control, either "single" for selecting one option or "multiple" for selecting multiple options. type: Var[Literal["single", "multiple"]] # Override theme color for button @@ -34,9 +49,11 @@ class SegmentedControlRoot(RadixThemesComponent): # The default value of the segmented control. default_value: Var[Union[str, List[str]]] + # The current value of the segmented control. value: Var[Union[str, List[str]]] - on_change: EventHandler[lambda e0: [e0]] + # Handles the `onChange` event for the SegmentedControl component. + on_change: EventHandler[on_value_change] _rename_props = {"onChange": "onValueChange"} diff --git a/reflex/components/radix/themes/components/segmented_control.pyi b/reflex/components/radix/themes/components/segmented_control.pyi index 4ac662e13..c7e87ca34 100644 --- a/reflex/components/radix/themes/components/segmented_control.pyi +++ b/reflex/components/radix/themes/components/segmented_control.pyi @@ -4,15 +4,19 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ from types import SimpleNamespace -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent +def on_value_change( + value: Var[Union[str, List[str]]], +) -> Tuple[Var[Union[str, List[str]]]]: ... + class SegmentedControlRoot(RadixThemesComponent): @overload @classmethod @@ -21,147 +25,120 @@ class SegmentedControlRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["classic", "surface"]], Literal["classic", "surface"]] + Union[Literal["classic", "surface"], Var[Literal["classic", "surface"]]] ] = None, type: Optional[ - Union[Var[Literal["single", "multiple"]], Literal["single", "multiple"]] + Union[Literal["multiple", "single"], Var[Literal["multiple", "single"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, default_value: Optional[ - Union[Var[Union[List[str], str]], str, List[str]] + Union[List[str], Var[Union[List[str], str]], str] ] = None, - value: Optional[Union[Var[Union[List[str], str]], str, List[str]]] = None, + value: Optional[Union[List[str], Var[Union[List[str], str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[Union[str, List[str]]], BASE_STATE], + ] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SegmentedControlRoot": """Create a new component instance. @@ -173,9 +150,12 @@ class SegmentedControlRoot(RadixThemesComponent): *children: Child components. size: The size of the segmented control: "1" | "2" | "3" variant: Variant of button: "classic" | "surface" + type: The type of the segmented control, either "single" for selecting one option or "multiple" for selecting multiple options. color_scheme: Override theme color for button radius: The radius of the segmented control: "none" | "small" | "medium" | "large" | "full" default_value: The default value of the segmented control. + value: The current value of the segmented control. + 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. @@ -201,52 +181,22 @@ class SegmentedControlItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 fc10d00de..45e5712bc 100644 --- a/reflex/components/radix/themes/components/select.py +++ b/reflex/components/radix/themes/components/select.py @@ -5,13 +5,10 @@ from typing import List, Literal, Union import reflex as rx from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.event import no_args_event_spec, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - LiteralRadius, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent class SelectRoot(RadixThemesComponent): @@ -47,10 +44,10 @@ class SelectRoot(RadixThemesComponent): _rename_props = {"onChange": "onValueChange"} # Fired when the value of the select changes. - on_change: rx.EventHandler[lambda e0: [e0]] + on_change: rx.EventHandler[passthrough_event_spec(str)] # Fired when the select is opened or closed. - on_open_change: rx.EventHandler[lambda e0: [e0]] + on_open_change: rx.EventHandler[passthrough_event_spec(bool)] class SelectTrigger(RadixThemesComponent): @@ -103,13 +100,13 @@ class SelectContent(RadixThemesComponent): align_offset: Var[int] # Fired when the select content is closed. - on_close_auto_focus: rx.EventHandler[lambda e0: [e0]] + on_close_auto_focus: rx.EventHandler[no_args_event_spec] # Fired when the escape key is pressed. - on_escape_key_down: rx.EventHandler[lambda e0: [e0]] + on_escape_key_down: rx.EventHandler[no_args_event_spec] # Fired when a pointer down event happens outside the select content. - on_pointer_down_outside: rx.EventHandler[lambda e0: [e0]] + on_pointer_down_outside: rx.EventHandler[no_args_event_spec] class SelectGroup(RadixThemesComponent): diff --git a/reflex/components/radix/themes/components/select.pyi b/reflex/components/radix/themes/components/select.pyi index 125ced252..a6c1ff144 100644 --- a/reflex/components/radix/themes/components/select.pyi +++ b/reflex/components/radix/themes/components/select.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,13 +21,13 @@ class SelectRoot(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -42,58 +42,28 @@ class SelectRoot(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectRoot": """Create a new component instance. @@ -111,6 +81,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: 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. @@ -132,76 +104,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, @@ -210,52 +182,22 @@ class SelectTrigger(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectTrigger": """Create a new component instance. @@ -289,88 +231,88 @@ class SelectContent(RadixThemesComponent): cls, *children, variant: Optional[ - Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]] + Union[Literal["soft", "solid"], Var[Literal["soft", "solid"]]] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, position: Optional[ Union[ - Var[Literal["item-aligned", "popper"]], Literal["item-aligned", "popper"], + Var[Literal["item-aligned", "popper"]], ] ] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[int], int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[int], int]] = None, @@ -379,61 +321,25 @@ class SelectContent(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_close_auto_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_close_auto_focus: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectContent": """Create a new component instance. @@ -451,6 +357,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. @@ -475,52 +384,22 @@ class SelectGroup(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectGroup": """Create a new component instance. @@ -556,52 +435,22 @@ class SelectItem(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectItem": """Create a new component instance. @@ -637,52 +486,22 @@ class SelectLabel(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectLabel": """Create a new component instance. @@ -716,52 +535,22 @@ class SelectSeparator(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SelectSeparator": """Create a new component instance. @@ -790,100 +579,100 @@ class HighLevelSelect(SelectRoot): def create( # type: ignore cls, *children, - items: Optional[Union[Var[List[str]], List[str]]] = None, + items: Optional[Union[List[str], Var[List[str]]]] = None, placeholder: Optional[Union[Var[str], str]] = None, label: Optional[Union[Var[str], str]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft", "ghost"]], - Literal["classic", "surface", "soft", "ghost"], + Literal["classic", "ghost", "soft", "surface"], + Var[Literal["classic", "ghost", "soft", "surface"]], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, width: Optional[Union[Var[str], str]] = None, position: Optional[ Union[ - Var[Literal["item-aligned", "popper"]], Literal["item-aligned", "popper"], + Var[Literal["item-aligned", "popper"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -898,58 +687,28 @@ class HighLevelSelect(SelectRoot): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HighLevelSelect": """Create a select component. @@ -973,6 +732,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: 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. @@ -998,100 +759,100 @@ class Select(ComponentNamespace): @staticmethod def __call__( *children, - items: Optional[Union[Var[List[str]], List[str]]] = None, + items: Optional[Union[List[str], Var[List[str]]]] = None, placeholder: Optional[Union[Var[str], str]] = None, label: Optional[Union[Var[str], str]] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft", "ghost"]], - Literal["classic", "surface", "soft", "ghost"], + Literal["classic", "ghost", "soft", "surface"], + Var[Literal["classic", "ghost", "soft", "surface"]], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, width: Optional[Union[Var[str], str]] = None, position: Optional[ Union[ - Var[Literal["item-aligned", "popper"]], Literal["item-aligned", "popper"], + Var[Literal["item-aligned", "popper"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, default_value: Optional[Union[Var[str], str]] = None, @@ -1106,58 +867,28 @@ class Select(ComponentNamespace): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "HighLevelSelect": """Create a select component. @@ -1181,6 +912,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: 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 fbc445878..9fc06807a 100644 --- a/reflex/components/radix/themes/components/separator.py +++ b/reflex/components/radix/themes/components/separator.py @@ -3,12 +3,9 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, RadixThemesComponent LiteralSeperatorSize = Literal["1", "2", "3", "4"] @@ -19,9 +16,7 @@ class Separator(RadixThemesComponent): tag = "Separator" # The size of the select: "1" | "2" | "3" | "4" - size: Var[Responsive[LiteralSeperatorSize]] = Var.create_safe( - "4", _var_is_string=True - ) + size: Var[Responsive[LiteralSeperatorSize]] = LiteralVar.create("4") # The color of the select color_scheme: Var[LiteralAccentColor] diff --git a/reflex/components/radix/themes/components/separator.pyi b/reflex/components/radix/themes/components/separator.pyi index 0c5dc64ec..7c4bcd55f 100644 --- a/reflex/components/radix/themes/components/separator.pyi +++ b/reflex/components/radix/themes/components/separator.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -22,88 +22,88 @@ class Separator(RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, orientation: Optional[ Union[ + Breakpoints[str, Literal["horizontal", "vertical"]], + Literal["horizontal", "vertical"], Var[ Union[ Breakpoints[str, Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], ] ], - Literal["horizontal", "vertical"], - Breakpoints[str, Literal["horizontal", "vertical"]], ] ] = None, decorative: Optional[Union[Var[bool], bool]] = None, @@ -112,52 +112,22 @@ class Separator(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 0738512aa..1fb6390a1 100644 --- a/reflex/components/radix/themes/components/skeleton.py +++ b/reflex/components/radix/themes/components/skeleton.py @@ -1,7 +1,7 @@ """Skeleton theme from Radix components.""" from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent diff --git a/reflex/components/radix/themes/components/skeleton.pyi b/reflex/components/radix/themes/components/skeleton.pyi index 3f2c048f6..859954ccc 100644 --- a/reflex/components/radix/themes/components/skeleton.pyi +++ b/reflex/components/radix/themes/components/skeleton.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent @@ -19,22 +19,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent): cls, *children, width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, min_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, max_width: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, height: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, min_height: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, max_height: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, loading: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, @@ -42,52 +42,22 @@ class Skeleton(RadixLoadingProp, RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 c03fffe7b..6acc21497 100644 --- a/reflex/components/radix/themes/components/slider.py +++ b/reflex/components/radix/themes/components/slider.py @@ -1,15 +1,20 @@ """Interactive components provided by @radix-ui/themes.""" +from __future__ import annotations + from typing import List, Literal, Optional, Union from reflex.components.component import Component from reflex.components.core.breakpoints import Responsive -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, +from ..base import LiteralAccentColor, RadixThemesComponent + +on_value_event_spec = ( + passthrough_event_spec(list[Union[int, float]]), + passthrough_event_spec(list[int]), + passthrough_event_spec(list[float]), ) @@ -45,6 +50,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]] @@ -64,29 +72,28 @@ class Slider(RadixThemesComponent): _rename_props = {"onChange": "onValueChange"} # Fired when the value of the slider changes. - on_change: EventHandler[lambda e0: [e0]] + on_change: EventHandler[on_value_event_spec] # Fired when a thumb is released after being dragged. - on_value_commit: EventHandler[lambda e0: [e0]] + 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 57fda44d2..f2552fbc6 100644 --- a/reflex/components/radix/themes/components/slider.pyi +++ b/reflex/components/radix/themes/components/slider.pyi @@ -3,128 +3,134 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType, passthrough_event_spec from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent +on_value_event_spec = ( + passthrough_event_spec(list[Union[int, float]]), + passthrough_event_spec(list[int]), + passthrough_event_spec(list[float]), +) + class Slider(RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, - width: Optional[str] = "100%", as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "full"]], Literal["none", "small", "full"] + Literal["full", "none", "small"], Var[Literal["full", "none", "small"]] ] ] = None, default_value: Optional[ Union[ - Var[Union[List[Union[float, int]], float, int]], List[Union[float, int]], + Var[Union[List[Union[float, int]], float, int]], float, int, ] ] = None, value: Optional[ - Union[Var[List[Union[float, int]]], List[Union[float, int]]] + Union[List[Union[float, int]], Var[List[Union[float, int]]]] ] = None, name: Optional[Union[Var[str], str]] = None, + 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, @@ -132,57 +138,41 @@ class Slider(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + Union[ + EventType[[], BASE_STATE], + EventType[[list[Union[int, float]]], BASE_STATE], + ], + Union[EventType[[], BASE_STATE], EventType[[list[int]], BASE_STATE]], + Union[EventType[[], BASE_STATE], EventType[[list[float]], BASE_STATE]], + ] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, on_value_commit: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + Union[ + EventType[[], BASE_STATE], + EventType[[list[Union[int, float]]], BASE_STATE], + ], + Union[EventType[[], BASE_STATE], EventType[[list[int]], BASE_STATE]], + Union[EventType[[], BASE_STATE], EventType[[list[float]], BASE_STATE]], + ] ] = None, **props, ) -> "Slider": @@ -190,7 +180,6 @@ class Slider(RadixThemesComponent): 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 @@ -200,11 +189,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: 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 22f5bba0b..620d248c4 100644 --- a/reflex/components/radix/themes/components/spinner.py +++ b/reflex/components/radix/themes/components/spinner.py @@ -3,12 +3,9 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - RadixLoadingProp, - RadixThemesComponent, -) +from ..base import RadixLoadingProp, RadixThemesComponent LiteralSpinnerSize = Literal["1", "2", "3"] diff --git a/reflex/components/radix/themes/components/spinner.pyi b/reflex/components/radix/themes/components/spinner.pyi index f061e5813..1c2b9c65e 100644 --- a/reflex/components/radix/themes/components/spinner.pyi +++ b/reflex/components/radix/themes/components/spinner.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixLoadingProp, RadixThemesComponent @@ -22,13 +22,13 @@ class Spinner(RadixLoadingProp, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, loading: Optional[Union[Var[bool], bool]] = None, @@ -37,52 +37,22 @@ class Spinner(RadixLoadingProp, RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 f5109faf5..2af4f55bb 100644 --- a/reflex/components/radix/themes/components/switch.py +++ b/reflex/components/radix/themes/components/switch.py @@ -3,13 +3,10 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, RadixThemesComponent LiteralSwitchSize = Literal["1", "2", "3"] @@ -59,7 +56,7 @@ class Switch(RadixThemesComponent): _rename_props = {"onChange": "onCheckedChange"} # Fired when the value of the switch changes - on_change: EventHandler[lambda checked: [checked]] + on_change: EventHandler[passthrough_event_spec(bool)] switch = Switch.create diff --git a/reflex/components/radix/themes/components/switch.pyi b/reflex/components/radix/themes/components/switch.pyi index cd01cc604..4aabd7da2 100644 --- a/reflex/components/radix/themes/components/switch.pyi +++ b/reflex/components/radix/themes/components/switch.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -29,87 +29,87 @@ class Switch(RadixThemesComponent): value: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "full"]], Literal["none", "small", "full"] + Literal["full", "none", "small"], Var[Literal["full", "none", "small"]] ] ] = None, style: Optional[Style] = None, @@ -117,55 +117,25 @@ class Switch(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Switch": """Create a new component instance. @@ -187,6 +157,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: 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 27b0e3563..a16002f58 100644 --- a/reflex/components/radix/themes/components/table.py +++ b/reflex/components/radix/themes/components/table.py @@ -5,11 +5,9 @@ from typing import List, Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, -) +from ..base import CommonPaddingProps, RadixThemesComponent class TableRoot(elements.Table, RadixThemesComponent): @@ -53,6 +51,12 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent): # The justification of the column justify: Var[Literal["start", "center", "end"]] + # The minimum width of the cell + min_width: Var[Responsive[str]] + + # The maximum width of the cell + max_width: Var[Responsive[str]] + _invalid_children: List[str] = [ "TableBody", "TableHeader", @@ -78,7 +82,7 @@ class TableBody(elements.Tbody, RadixThemesComponent): _valid_parents: List[str] = ["TableRoot"] -class TableCell(elements.Td, RadixThemesComponent): +class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent): """A cell containing data.""" tag = "Table.Cell" @@ -86,6 +90,12 @@ class TableCell(elements.Td, RadixThemesComponent): # The justification of the column justify: Var[Literal["start", "center", "end"]] + # The minimum width of the cell + min_width: Var[Responsive[str]] + + # The maximum width of the cell + max_width: Var[Responsive[str]] + _invalid_children: List[str] = [ "TableBody", "TableHeader", @@ -95,7 +105,7 @@ class TableCell(elements.Td, RadixThemesComponent): ] -class TableRowHeaderCell(elements.Th, RadixThemesComponent): +class TableRowHeaderCell(elements.Th, CommonPaddingProps, RadixThemesComponent): """A table cell that is semantically treated as a row header.""" tag = "Table.RowHeaderCell" @@ -103,6 +113,12 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent): # The justification of the column justify: Var[Literal["start", "center", "end"]] + # The minimum width of the cell + min_width: Var[Responsive[str]] + + # The maximum width of the cell + max_width: Var[Responsive[str]] + _invalid_children: List[str] = [ "TableBody", "TableHeader", diff --git a/reflex/components/radix/themes/components/table.pyi b/reflex/components/radix/themes/components/table.pyi index 01b4e61c4..99a0ba96d 100644 --- a/reflex/components/radix/themes/components/table.pyi +++ b/reflex/components/radix/themes/components/table.pyi @@ -3,16 +3,16 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from ..base import RadixThemesComponent +from ..base import CommonPaddingProps, RadixThemesComponent class TableRoot(elements.Table, RadixThemesComponent): @overload @@ -22,95 +22,65 @@ class TableRoot(elements.Table, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ - Union[Var[Literal["surface", "ghost"]], Literal["surface", "ghost"]] + Union[Literal["ghost", "surface"], Var[Literal["ghost", "surface"]]] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - summary: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + summary: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableRoot": """Create a new component instance. @@ -124,7 +94,7 @@ class TableRoot(elements.Table, RadixThemesComponent): variant: The variant of the table align: Alignment of the table summary: Provides a summary of the table's purpose and structure - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -159,82 +129,52 @@ class TableHeader(elements.Thead, RadixThemesComponent): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableHeader": """Create a new component instance. @@ -245,7 +185,7 @@ class TableHeader(elements.Thead, RadixThemesComponent): Args: *children: Child components. align: Alignment of the content within the table header - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -282,85 +222,55 @@ class TableRow(elements.Tr, RadixThemesComponent): *children, align: Optional[ Union[ - Var[Literal["start", "center", "end", "baseline"]], - Literal["start", "center", "end", "baseline"], + Literal["baseline", "center", "end", "start"], + Var[Literal["baseline", "center", "end", "start"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableRow": """Create a new component instance. @@ -371,7 +281,7 @@ class TableRow(elements.Tr, RadixThemesComponent): Args: *children: Child components. align: Alignment of the content within the table row - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -408,90 +318,66 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent): *children, justify: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + 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, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableColumnHeaderCell": """Create a new component instance. @@ -502,12 +388,14 @@ class TableColumnHeaderCell(elements.Th, RadixThemesComponent): Args: *children: Child components. justify: The justification of the column + min_width: The minimum width of the cell + max_width: The maximum width of the cell align: Alignment of the content within the table header cell col_span: Number of columns a header cell should span headers: IDs of the headers associated with this header cell row_span: Number of rows a header cell should span scope: Scope of the header cell (row, col, rowgroup, colgroup) - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -542,82 +430,52 @@ class TableBody(elements.Tbody, RadixThemesComponent): def create( # type: ignore cls, *children, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableBody": """Create a new component instance. @@ -628,7 +486,7 @@ class TableBody(elements.Tbody, RadixThemesComponent): Args: *children: Child components. align: Alignment of the content within the table body - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -657,7 +515,7 @@ class TableBody(elements.Tbody, RadixThemesComponent): """ ... -class TableCell(elements.Td, RadixThemesComponent): +class TableCell(elements.Td, CommonPaddingProps, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -665,89 +523,184 @@ class TableCell(elements.Td, RadixThemesComponent): *children, justify: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + 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, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + p: Optional[ + Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + Union[ + Breakpoints[ + 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[ + 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[ + 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[ + 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[ + 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[ + 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[ + 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, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableCell": """Create a new component instance. @@ -758,11 +711,13 @@ class TableCell(elements.Td, RadixThemesComponent): Args: *children: Child components. justify: The justification of the column + min_width: The minimum width of the cell + max_width: The maximum width of the cell align: Alignment of the content within the table cell col_span: Number of columns a cell should span headers: IDs of the headers associated with this cell row_span: Number of rows a cell should span - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -778,6 +733,13 @@ class TableCell(elements.Td, RadixThemesComponent): 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. + p: Padding: "0" - "9" + px: Padding horizontal: "0" - "9" + py: Padding vertical: "0" - "9" + pt: Padding top: "0" - "9" + pr: Padding right: "0" - "9" + pb: Padding bottom: "0" - "9" + pl: Padding left: "0" - "9" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -791,7 +753,7 @@ class TableCell(elements.Td, RadixThemesComponent): """ ... -class TableRowHeaderCell(elements.Th, RadixThemesComponent): +class TableRowHeaderCell(elements.Th, CommonPaddingProps, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -799,90 +761,185 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent): *children, justify: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, - align: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - col_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - headers: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - row_span: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - scope: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + 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, + align: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + col_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + headers: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + row_span: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + scope: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + p: Optional[ + Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[ + Union[ + Breakpoints[ + 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[ + 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[ + 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[ + 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[ + 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[ + 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[ + 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, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TableRowHeaderCell": """Create a new component instance. @@ -893,12 +950,14 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent): Args: *children: Child components. justify: The justification of the column + min_width: The minimum width of the cell + max_width: The maximum width of the cell align: Alignment of the content within the table header cell col_span: Number of columns a header cell should span headers: IDs of the headers associated with this header cell row_span: Number of rows a header cell should span scope: Scope of the header cell (row, col, rowgroup, colgroup) - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -914,6 +973,13 @@ class TableRowHeaderCell(elements.Th, RadixThemesComponent): 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. + p: Padding: "0" - "9" + px: Padding horizontal: "0" - "9" + py: Padding vertical: "0" - "9" + pt: Padding top: "0" - "9" + pr: Padding right: "0" - "9" + pb: Padding bottom: "0" - "9" + pl: Padding left: "0" - "9" 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/tabs.py b/reflex/components/radix/themes/components/tabs.py index 08e09262b..adfb32fab 100644 --- a/reflex/components/radix/themes/components/tabs.py +++ b/reflex/components/radix/themes/components/tabs.py @@ -7,13 +7,10 @@ from typing import Any, Dict, List, Literal from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.core.colors import color -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, passthrough_event_spec +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, RadixThemesComponent vertical_orientation_css = "&[data-orientation='vertical']" @@ -42,7 +39,7 @@ class TabsRoot(RadixThemesComponent): _rename_props = {"onChange": "onValueChange"} # Fired when the value of the tabs changes. - on_change: EventHandler[lambda e0: [e0]] + on_change: EventHandler[passthrough_event_spec(str)] def add_style(self) -> Dict[str, Any] | None: """Add style for the component. diff --git a/reflex/components/radix/themes/components/tabs.pyi b/reflex/components/radix/themes/components/tabs.pyi index 7d324e96d..8830c8e21 100644 --- a/reflex/components/radix/themes/components/tabs.pyi +++ b/reflex/components/radix/themes/components/tabs.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -26,68 +26,38 @@ class TabsRoot(RadixThemesComponent): value: Optional[Union[Var[str], str]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, activation_mode: Optional[ - Union[Var[Literal["automatic", "manual"]], Literal["automatic", "manual"]] + Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TabsRoot": """Create a new component instance. @@ -102,6 +72,7 @@ class TabsRoot(RadixThemesComponent): 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: 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. @@ -124,9 +95,9 @@ class TabsList(RadixThemesComponent): *children, size: Optional[ Union[ - Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], - Literal["1", "2"], Breakpoints[str, Literal["1", "2"]], + Literal["1", "2"], + Var[Union[Breakpoints[str, Literal["1", "2"]], Literal["1", "2"]]], ] ] = None, loop: Optional[Union[Var[bool], bool]] = None, @@ -135,52 +106,22 @@ class TabsList(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TabsList": """Create a new component instance. @@ -215,63 +156,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, @@ -280,52 +221,22 @@ class TabsTrigger(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TabsTrigger": """Create a TabsTrigger component. @@ -364,52 +275,22 @@ class TabsContent(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TabsContent": """Create a new component instance. @@ -447,68 +328,38 @@ class Tabs(ComponentNamespace): value: Optional[Union[Var[str], str]] = None, orientation: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - dir: Optional[Union[Var[Literal["ltr", "rtl"]], Literal["ltr", "rtl"]]] = None, + dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None, activation_mode: Optional[ - Union[Var[Literal["automatic", "manual"]], Literal["automatic", "manual"]] + Union[Literal["automatic", "manual"], Var[Literal["automatic", "manual"]]] ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TabsRoot": """Create a new component instance. @@ -523,6 +374,7 @@ class Tabs(ComponentNamespace): 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: 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 5218f1d7b..83fa8a593 100644 --- a/reflex/components/radix/themes/components/text_area.py +++ b/reflex/components/radix/themes/components/text_area.py @@ -6,14 +6,9 @@ from reflex.components.component import Component from reflex.components.core.breakpoints import Responsive from reflex.components.core.debounce import DebounceInput from reflex.components.el import elements -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - LiteralRadius, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent LiteralTextAreaSize = Literal["1", "2", "3"] @@ -46,6 +41,9 @@ class TextArea(RadixThemesComponent, elements.Textarea): # Automatically focuses the textarea when the page loads auto_focus: Var[bool] + # The default value of the textarea when initially rendered + default_value: Var[str] + # Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted dirname: Var[str] @@ -82,21 +80,6 @@ class TextArea(RadixThemesComponent, elements.Textarea): # How the text in the textarea is to be wrapped when submitting the form wrap: Var[str] - # Fired when the value of the textarea changes. - on_change: EventHandler[lambda e0: [e0.target.value]] - - # Fired when the textarea is focused. - on_focus: EventHandler[lambda e0: [e0.target.value]] - - # Fired when the textarea is blurred. - on_blur: EventHandler[lambda e0: [e0.target.value]] - - # Fired when a key is pressed down. - on_key_down: EventHandler[lambda e0: [e0.key]] - - # Fired when a key is released. - on_key_up: EventHandler[lambda e0: [e0.key]] - @classmethod def create(cls, *children, **props) -> Component: """Create an Input component. diff --git a/reflex/components/radix/themes/components/text_area.pyi b/reflex/components/radix/themes/components/text_area.pyi index 231158c84..f0903ba98 100644 --- a/reflex/components/radix/themes/components/text_area.pyi +++ b/reflex/components/radix/themes/components/text_area.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType, KeyInputInfo from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -24,108 +24,109 @@ class TextArea(RadixThemesComponent, elements.Textarea): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, resize: Optional[ Union[ + Breakpoints[str, Literal["both", "horizontal", "none", "vertical"]], + Literal["both", "horizontal", "none", "vertical"], Var[ Union[ Breakpoints[ - str, Literal["none", "vertical", "horizontal", "both"] + str, Literal["both", "horizontal", "none", "vertical"] ], - Literal["none", "vertical", "horizontal", "both"], + Literal["both", "horizontal", "none", "vertical"], ] ], - Literal["none", "vertical", "horizontal", "both"], - Breakpoints[str, Literal["none", "vertical", "horizontal", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, auto_complete: Optional[Union[Var[bool], bool]] = None, auto_focus: Optional[Union[Var[bool], bool]] = None, + default_value: Optional[Union[Var[str], str]] = None, dirname: Optional[Union[Var[str], str]] = None, disabled: Optional[Union[Var[bool], bool]] = None, - form: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, max_length: Optional[Union[Var[int], int]] = None, min_length: Optional[Union[Var[int], int]] = None, name: Optional[Union[Var[str], str]] = None, @@ -136,92 +137,74 @@ class TextArea(RadixThemesComponent, elements.Textarea): value: Optional[Union[Var[str], str]] = None, wrap: Optional[Union[Var[str], str]] = None, auto_height: Optional[Union[Var[bool], bool]] = None, - cols: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cols: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_submit: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TextArea": """Create an Input component. @@ -235,6 +218,7 @@ class TextArea(RadixThemesComponent, elements.Textarea): 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 + default_value: The default value of the textarea when initially rendered dirname: Name part of the textarea to submit in 'dir' and 'name' pair when form is submitted disabled: Disables the textarea form: Associates the textarea with a form (by id) @@ -250,7 +234,12 @@ class TextArea(RadixThemesComponent, elements.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) - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. context_menu: Defines the ID of a element which will serve as the element's context menu. diff --git a/reflex/components/radix/themes/components/text_field.py b/reflex/components/radix/themes/components/text_field.py index c6d7ddf48..c8bdab443 100644 --- a/reflex/components/radix/themes/components/text_field.py +++ b/reflex/components/radix/themes/components/text_field.py @@ -4,27 +4,22 @@ from __future__ import annotations from typing import Literal, Union -from reflex.components.base.fragment import Fragment from reflex.components.component import Component, ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.core.debounce import DebounceInput from reflex.components.el import elements -from reflex.event import EventHandler -from reflex.style import Style, format_as_emotion -from reflex.utils import console -from reflex.vars import Var +from reflex.event import EventHandler, input_event, key_event +from reflex.utils.types import is_optional +from reflex.vars.base import Var +from reflex.vars.number import ternary_operation -from ..base import ( - LiteralAccentColor, - LiteralRadius, - RadixThemesComponent, -) +from ..base import LiteralAccentColor, LiteralRadius, RadixThemesComponent LiteralTextFieldSize = Literal["1", "2", "3"] LiteralTextFieldVariant = Literal["classic", "surface", "soft"] -class TextFieldRoot(elements.Div, RadixThemesComponent): +class TextFieldRoot(elements.Input, RadixThemesComponent): """Captures user input with an optional slot for buttons and icons.""" tag = "TextField.Root" @@ -74,20 +69,23 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): # Value of the input value: Var[Union[str, int, float]] + # References a datalist for suggested options + list: Var[Union[str, int, bool]] + # Fired when the value of the textarea changes. - on_change: EventHandler[lambda e0: [e0.target.value]] + on_change: EventHandler[input_event] # Fired when the textarea is focused. - on_focus: EventHandler[lambda e0: [e0.target.value]] + on_focus: EventHandler[input_event] # Fired when the textarea is blurred. - on_blur: EventHandler[lambda e0: [e0.target.value]] + on_blur: EventHandler[input_event] # Fired when a key is pressed down. - on_key_down: EventHandler[lambda e0: [e0.key]] + on_key_down: EventHandler[key_event] # Fired when a key is released. - on_key_up: EventHandler[lambda e0: [e0.key]] + on_key_up: EventHandler[key_event] @classmethod def create(cls, *children, **props) -> Component: @@ -100,86 +98,25 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): Returns: The component. """ + value = props.get("value") + + # React expects an empty string(instead of null) for controlled inputs. + if value is not None and is_optional( + (value_var := Var.create(value))._var_type + ): + props["value"] = ternary_operation( + (value_var != Var.create(None)) # pyright: ignore [reportGeneralTypeIssues] + & (value_var != Var(_js_expr="undefined")), + value, + Var.create(""), + ) + component = super().create(*children, **props) 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) - class TextFieldSlot(RadixThemesComponent): """Contains icons or buttons associated with an Input.""" @@ -193,8 +130,6 @@ class TextFieldSlot(RadixThemesComponent): class TextField(ComponentNamespace): """TextField components namespace.""" - root = staticmethod(TextFieldRoot.create_root_deprecated) - input = staticmethod(TextFieldRoot.create_input_deprecated) slot = staticmethod(TextFieldSlot.create) __call__ = staticmethod(TextFieldRoot.create) diff --git a/reflex/components/radix/themes/components/text_field.pyi b/reflex/components/radix/themes/components/text_field.pyi index 86ba7e70f..81c991899 100644 --- a/reflex/components/radix/themes/components/text_field.pyi +++ b/reflex/components/radix/themes/components/text_field.pyi @@ -3,21 +3,21 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.components.component import Component, ComponentNamespace +from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType, KeyInputInfo from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent LiteralTextFieldSize = Literal["1", "2", "3"] LiteralTextFieldVariant = Literal["classic", "surface", "soft"] -class TextFieldRoot(elements.Div, RadixThemesComponent): +class TextFieldRoot(elements.Input, RadixThemesComponent): @overload @classmethod def create( # type: ignore @@ -25,87 +25,87 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, auto_complete: Optional[Union[Var[bool], bool]] = None, @@ -118,103 +118,110 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = 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_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, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_enc_type: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_no_validate: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_target: 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, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + pattern: 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, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TextFieldRoot": """Create an Input component. Args: *children: The children of the component. - size: Text field size "1" - "3" + size: Specifies the visible width of a text control variant: Variant of text field: "classic" | "surface" | "soft" color_scheme: Override theme color for text field radius: Override theme radius for text field: "none" | "small" | "medium" | "large" | "full" auto_complete: Whether the input should have autocomplete enabled - default_value: The value of the input when initially rendered. + default_value: The initial value for a text field disabled: Disables the input max_length: Specifies the maximum number of characters allowed in the input min_length: Specifies the minimum number of characters required in the input @@ -224,7 +231,33 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): required: Indicates that the input is required type: Specifies the type of input value: Value of the input - access_key: Provides a hint for generating a keyboard shortcut for the current element. + list: References a datalist for suggested options + 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 + accept: Accepted types of files when the input is file type + alt: Alternate text for input type="image" + auto_focus: Automatically focuses the input when the page loads + capture: Captures media from the user (camera or microphone) + checked: Indicates whether the input is checked (for checkboxes and radio buttons) + default_checked: The initial value (for checkboxes and radio buttons) + dirname: Name part of the input to submit in 'dir' and 'name' pair when form is submitted + form: Associates the input with a form (by id) + form_action: URL to send the form data to (for type="submit" buttons) + form_enc_type: How the form data should be encoded when submitting to the server (for type="submit" buttons) + form_method: HTTP method to use for sending form data (for type="submit" buttons) + form_no_validate: Bypasses form validation when submitting (for type="submit" buttons) + form_target: Specifies where to display the response after submitting the form (for type="submit" buttons) + max: Specifies the maximum value for the input + min: Specifies the minimum value for the input + multiple: Indicates whether multiple values can be entered in an input of the type email or file + pattern: Regex pattern the input's value must match to be valid + src: URL for image inputs + step: Specifies the legal number intervals for an input + use_map: Name of the image map used with the input + 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. @@ -253,11 +286,6 @@ class TextFieldRoot(elements.Div, RadixThemesComponent): """ ... - @classmethod - def create_root_deprecated(cls, *children, **props) -> Component: ... - @classmethod - def create_input_deprecated(cls, *children, **props) -> Component: ... - class TextFieldSlot(RadixThemesComponent): @overload @classmethod @@ -266,63 +294,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, @@ -331,52 +359,22 @@ class TextFieldSlot(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TextFieldSlot": """Create a new component instance. @@ -401,8 +399,6 @@ class TextFieldSlot(RadixThemesComponent): ... class TextField(ComponentNamespace): - root = staticmethod(TextFieldRoot.create_root_deprecated) - input = staticmethod(TextFieldRoot.create_input_deprecated) slot = staticmethod(TextFieldSlot.create) @staticmethod @@ -410,87 +406,87 @@ class TextField(ComponentNamespace): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, variant: Optional[ Union[ - Var[Literal["classic", "surface", "soft"]], - Literal["classic", "surface", "soft"], + Literal["classic", "soft", "surface"], + Var[Literal["classic", "soft", "surface"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, radius: Optional[ Union[ - Var[Literal["none", "small", "medium", "large", "full"]], - Literal["none", "small", "medium", "large", "full"], + Literal["full", "large", "medium", "none", "small"], + Var[Literal["full", "large", "medium", "none", "small"]], ] ] = None, auto_complete: Optional[Union[Var[bool], bool]] = None, @@ -503,103 +499,110 @@ class TextField(ComponentNamespace): read_only: Optional[Union[Var[bool], bool]] = None, required: Optional[Union[Var[bool], bool]] = None, type: Optional[Union[Var[str], str]] = None, - value: Optional[Union[Var[Union[float, int, str]], str, int, float]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + value: Optional[Union[Var[Union[float, int, str]], float, int, str]] = None, + list: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = 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_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, + dirname: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_action: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_enc_type: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_method: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + form_no_validate: Optional[ + Union[Var[Union[bool, int, str]], bool, int, str] + ] = None, + form_target: 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, + multiple: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + pattern: 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, + use_map: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, on_key_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, KeyInputInfo], BASE_STATE], + ] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "TextFieldRoot": """Create an Input component. Args: *children: The children of the component. - size: Text field size "1" - "3" + size: Specifies the visible width of a text control variant: Variant of text field: "classic" | "surface" | "soft" color_scheme: Override theme color for text field radius: Override theme radius for text field: "none" | "small" | "medium" | "large" | "full" auto_complete: Whether the input should have autocomplete enabled - default_value: The value of the input when initially rendered. + default_value: The initial value for a text field disabled: Disables the input max_length: Specifies the maximum number of characters allowed in the input min_length: Specifies the minimum number of characters required in the input @@ -609,7 +612,33 @@ class TextField(ComponentNamespace): required: Indicates that the input is required type: Specifies the type of input value: Value of the input - access_key: Provides a hint for generating a keyboard shortcut for the current element. + list: References a datalist for suggested options + 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 + accept: Accepted types of files when the input is file type + alt: Alternate text for input type="image" + auto_focus: Automatically focuses the input when the page loads + capture: Captures media from the user (camera or microphone) + checked: Indicates whether the input is checked (for checkboxes and radio buttons) + default_checked: The initial value (for checkboxes and radio buttons) + dirname: Name part of the input to submit in 'dir' and 'name' pair when form is submitted + form: Associates the input with a form (by id) + form_action: URL to send the form data to (for type="submit" buttons) + form_enc_type: How the form data should be encoded when submitting to the server (for type="submit" buttons) + form_method: HTTP method to use for sending form data (for type="submit" buttons) + form_no_validate: Bypasses form validation when submitting (for type="submit" buttons) + form_target: Specifies where to display the response after submitting the form (for type="submit" buttons) + max: Specifies the maximum value for the input + min: Specifies the minimum value for the input + multiple: Indicates whether multiple values can be entered in an input of the type email or file + pattern: Regex pattern the input's value must match to be valid + src: URL for image inputs + step: Specifies the legal number intervals for an input + use_map: Name of the image map used with the input + 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. diff --git a/reflex/components/radix/themes/components/tooltip.py b/reflex/components/radix/themes/components/tooltip.py index 9a1355be5..07bab1a4a 100644 --- a/reflex/components/radix/themes/components/tooltip.py +++ b/reflex/components/radix/themes/components/tooltip.py @@ -3,13 +3,11 @@ from typing import Dict, Literal, Union from reflex.components.component import Component -from reflex.event import EventHandler +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec from reflex.utils import format -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - RadixThemesComponent, -) +from ..base import RadixThemesComponent LiteralSideType = Literal[ "top", @@ -85,13 +83,13 @@ class Tooltip(RadixThemesComponent): aria_label: Var[str] # Fired when the open state changes. - on_open_change: EventHandler[lambda e0: [e0.target.value]] + on_open_change: EventHandler[passthrough_event_spec(bool)] # Fired when the escape key is pressed. - on_escape_key_down: EventHandler[lambda e0: [e0.target.value]] + on_escape_key_down: EventHandler[no_args_event_spec] # Fired when the pointer is down outside the tooltip. - on_pointer_down_outside: EventHandler[lambda e0: [e0.target.value]] + on_pointer_down_outside: EventHandler[no_args_event_spec] @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 0628acff1..fab1d0c12 100644 --- a/reflex/components/radix/themes/components/tooltip.pyi +++ b/reflex/components/radix/themes/components/tooltip.pyi @@ -3,11 +3,11 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -26,30 +26,30 @@ class Tooltip(RadixThemesComponent): open: Optional[Union[Var[bool], bool]] = None, side: Optional[ Union[ - Var[Literal["top", "right", "bottom", "left"]], - Literal["top", "right", "bottom", "left"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, align: Optional[ Union[ - Var[Literal["start", "center", "end"]], - Literal["start", "center", "end"], + Literal["center", "end", "start"], + Var[Literal["center", "end", "start"]], ] ] = None, align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None, avoid_collisions: Optional[Union[Var[bool], bool]] = None, collision_padding: Optional[ Union[ + Dict[str, Union[float, int]], Var[Union[Dict[str, Union[float, int]], float, int]], float, int, - Dict[str, Union[float, int]], ] ] = None, arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None, sticky: Optional[ - Union[Var[Literal["partial", "always"]], Literal["partial", "always"]] + Union[Literal["always", "partial"], Var[Literal["always", "partial"]]] ] = None, hide_when_detached: Optional[Union[Var[bool], bool]] = None, delay_duration: Optional[Union[Var[Union[float, int]], float, int]] = None, @@ -61,61 +61,27 @@ class Tooltip(RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_escape_key_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_escape_key_down: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pointer_down_outside: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_pointer_down_outside: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Tooltip": """Initialize the Tooltip component. @@ -140,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__.pyi b/reflex/components/radix/themes/layout/__init__.pyi index 1420299e0..6712a3068 100644 --- a/reflex/components/radix/themes/layout/__init__.pyi +++ b/reflex/components/radix/themes/layout/__init__.pyi @@ -9,6 +9,7 @@ from .container import container as container from .flex import flex as flex from .grid import grid as grid from .list import list_item as list_item +from .list import list_ns as list # noqa from .list import ordered_list as ordered_list from .list import unordered_list as unordered_list from .section import section as section diff --git a/reflex/components/radix/themes/layout/base.py b/reflex/components/radix/themes/layout/base.py index dd598538e..f31f6a72c 100644 --- a/reflex/components/radix/themes/layout/base.py +++ b/reflex/components/radix/themes/layout/base.py @@ -5,44 +5,19 @@ from __future__ import annotations from typing import Literal from reflex.components.core.breakpoints import Responsive -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - CommonMarginProps, - LiteralSpacing, - RadixThemesComponent, -) +from ..base import CommonMarginProps, CommonPaddingProps, RadixThemesComponent LiteralBoolNumber = Literal["0", "1"] -class LayoutComponent(CommonMarginProps, RadixThemesComponent): +class LayoutComponent(CommonMarginProps, CommonPaddingProps, RadixThemesComponent): """Box, Flex and Grid are foundational elements you'll use to construct layouts. Box provides block-level spacing and sizing, while Flex and Grid let you create flexible columns, rows and grids. """ - # Padding: "0" - "9" - p: Var[Responsive[LiteralSpacing]] - - # Padding horizontal: "0" - "9" - px: Var[Responsive[LiteralSpacing]] - - # Padding vertical: "0" - "9" - py: Var[Responsive[LiteralSpacing]] - - # Padding top: "0" - "9" - pt: Var[Responsive[LiteralSpacing]] - - # Padding right: "0" - "9" - pr: Var[Responsive[LiteralSpacing]] - - # Padding bottom: "0" - "9" - pb: Var[Responsive[LiteralSpacing]] - - # Padding left: "0" - "9" - pl: Var[Responsive[LiteralSpacing]] - # Whether the element will take up the smallest possible space: "0" | "1" flex_shrink: Var[Responsive[LiteralBoolNumber]] diff --git a/reflex/components/radix/themes/layout/base.pyi b/reflex/components/radix/themes/layout/base.pyi index 83e0e018f..440ec882a 100644 --- a/reflex/components/radix/themes/layout/base.pyi +++ b/reflex/components/radix/themes/layout/base.pyi @@ -3,25 +3,85 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from ..base import CommonMarginProps, RadixThemesComponent +from ..base import CommonMarginProps, CommonPaddingProps, RadixThemesComponent LiteralBoolNumber = Literal["0", "1"] -class LayoutComponent(CommonMarginProps, RadixThemesComponent): +class LayoutComponent(CommonMarginProps, CommonPaddingProps, RadixThemesComponent): @overload @classmethod def create( # type: ignore cls, *children, + 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, + m: 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, + mx: 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, + my: 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, + mt: 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, + mr: 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, + mb: 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, + ml: 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, p: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -31,14 +91,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, px: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -48,14 +108,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, py: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -65,14 +125,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pt: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -82,14 +142,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pr: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -99,14 +159,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pb: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -116,14 +176,14 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, pl: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -133,66 +193,6 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], - ] - ] = None, - flex_shrink: Optional[ - Union[ - Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], - Literal["0", "1"], - Breakpoints[str, Literal["0", "1"]], - ] - ] = None, - flex_grow: Optional[ - Union[ - Var[Union[Breakpoints[str, Literal["0", "1"]], Literal["0", "1"]]], - Literal["0", "1"], - Breakpoints[str, 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"], - ] - ] = 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"], - ] - ] = 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"], - ] - ] = 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"], - ] - ] = 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"], - ] - ] = 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"], - ] - ] = 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"], ] ] = None, style: Optional[Style] = None, @@ -200,52 +200,22 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "LayoutComponent": """Create a new component instance. @@ -255,13 +225,6 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): Args: *children: Child components. - p: Padding: "0" - "9" - px: Padding horizontal: "0" - "9" - py: Padding vertical: "0" - "9" - pt: Padding top: "0" - "9" - pr: Padding right: "0" - "9" - pb: Padding bottom: "0" - "9" - pl: Padding left: "0" - "9" flex_shrink: Whether the element will take up the smallest possible space: "0" | "1" flex_grow: Whether the element will take up the largest possible space: "0" | "1" m: Margin: "0" - "9" @@ -271,6 +234,13 @@ class LayoutComponent(CommonMarginProps, RadixThemesComponent): mr: Margin right: "0" - "9" mb: Margin bottom: "0" - "9" ml: Margin left: "0" - "9" + p: Padding: "0" - "9" + px: Padding horizontal: "0" - "9" + py: Padding vertical: "0" - "9" + pt: Padding top: "0" - "9" + pr: Padding right: "0" - "9" + pb: Padding bottom: "0" - "9" + pl: Padding left: "0" - "9" 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/box.pyi b/reflex/components/radix/themes/layout/box.pyi index 9c4bd800d..416e45f3a 100644 --- a/reflex/components/radix/themes/layout/box.pyi +++ b/reflex/components/radix/themes/layout/box.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -18,81 +18,51 @@ class Box(elements.Div, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Box": """Create a new component instance. @@ -102,7 +72,7 @@ class Box(elements.Div, RadixThemesComponent): Args: *children: Child components. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/layout/center.pyi b/reflex/components/radix/themes/layout/center.pyi index bbdf51d07..59062b293 100644 --- a/reflex/components/radix/themes/layout/center.pyi +++ b/reflex/components/radix/themes/layout/center.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .flex import Flex @@ -22,64 +22,68 @@ class Center(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -89,87 +93,53 @@ class Center(Flex): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Center": """Create a new component instance. @@ -180,12 +150,12 @@ class Center(Flex): Args: *children: Child components. 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" + direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse" align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" 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" spacing: Gap between children: "0" - "9" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/layout/container.py b/reflex/components/radix/themes/layout/container.py index c0f1c7dc8..b1d2fbed3 100644 --- a/reflex/components/radix/themes/layout/container.py +++ b/reflex/components/radix/themes/layout/container.py @@ -7,7 +7,7 @@ from typing import Literal 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 @@ -23,9 +23,7 @@ class Container(elements.Div, RadixThemesComponent): tag = "Container" # The size of the container: "1" - "4" (default "3") - size: Var[Responsive[LiteralContainerSize]] = Var.create_safe( - "3", _var_is_string=True - ) + size: Var[Responsive[LiteralContainerSize]] = LiteralVar.create("3") @classmethod def create( diff --git a/reflex/components/radix/themes/layout/container.pyi b/reflex/components/radix/themes/layout/container.pyi index 4e4c0bae3..36ea79457 100644 --- a/reflex/components/radix/themes/layout/container.pyi +++ b/reflex/components/radix/themes/layout/container.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,91 +25,61 @@ class Container(elements.Div, RadixThemesComponent): stack_children_full_width: Optional[bool] = False, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4"]], + Literal["1", "2", "3", "4"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3", "4"]], Literal["1", "2", "3", "4"], ] ], - Literal["1", "2", "3", "4"], - Breakpoints[str, Literal["1", "2", "3", "4"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Container": """Create the container component. diff --git a/reflex/components/radix/themes/layout/flex.py b/reflex/components/radix/themes/layout/flex.py index 825c84f42..39982e4f4 100644 --- a/reflex/components/radix/themes/layout/flex.py +++ b/reflex/components/radix/themes/layout/flex.py @@ -6,14 +6,9 @@ from typing import Dict, Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAlign, - LiteralJustify, - LiteralSpacing, - RadixThemesComponent, -) +from ..base import LiteralAlign, LiteralJustify, LiteralSpacing, RadixThemesComponent LiteralFlexDirection = Literal["row", "column", "row-reverse", "column-reverse"] LiteralFlexWrap = Literal["nowrap", "wrap", "wrap-reverse"] @@ -27,7 +22,7 @@ class Flex(elements.Div, RadixThemesComponent): # Change the default rendered element for the one passed as a child, merging their props and behavior. as_child: Var[bool] - # How child items are layed out: "row" | "column" | "row-reverse" | "column-reverse" + # How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse" direction: Var[Responsive[LiteralFlexDirection]] # Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" diff --git a/reflex/components/radix/themes/layout/flex.pyi b/reflex/components/radix/themes/layout/flex.pyi index f4e851d09..dafa91c6c 100644 --- a/reflex/components/radix/themes/layout/flex.pyi +++ b/reflex/components/radix/themes/layout/flex.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -25,64 +25,68 @@ class Flex(elements.Div, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -92,87 +96,53 @@ class Flex(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Flex": """Create a new component instance. @@ -183,12 +153,12 @@ class Flex(elements.Div, RadixThemesComponent): Args: *children: Child components. 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" + direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse" align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" 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" spacing: Gap between children: "0" - "9" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/layout/grid.py b/reflex/components/radix/themes/layout/grid.py index ab7fbdb3b..133e19d10 100644 --- a/reflex/components/radix/themes/layout/grid.py +++ b/reflex/components/radix/themes/layout/grid.py @@ -6,14 +6,9 @@ from typing import Dict, Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAlign, - LiteralJustify, - LiteralSpacing, - RadixThemesComponent, -) +from ..base import LiteralAlign, LiteralJustify, LiteralSpacing, RadixThemesComponent LiteralGridFlow = Literal["row", "column", "dense", "row-dense", "column-dense"] @@ -32,7 +27,7 @@ class Grid(elements.Div, RadixThemesComponent): # Number of rows rows: Var[Responsive[str]] - # How the grid items are layed out: "row" | "column" | "dense" | "row-dense" | "column-dense" + # How the grid items are laid out: "row" | "column" | "dense" | "row-dense" | "column-dense" flow: Var[Responsive[LiteralGridFlow]] # Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" diff --git a/reflex/components/radix/themes/layout/grid.pyi b/reflex/components/radix/themes/layout/grid.pyi index 1acc6f9b1..55153fca3 100644 --- a/reflex/components/radix/themes/layout/grid.pyi +++ b/reflex/components/radix/themes/layout/grid.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,61 +23,65 @@ class Grid(elements.Div, RadixThemesComponent): *children, as_child: Optional[Union[Var[bool], bool]] = None, columns: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, rows: Optional[ - Union[Var[Union[Breakpoints[str, str], str]], str, Breakpoints[str, str]] + Union[Breakpoints[str, str], Var[Union[Breakpoints[str, str], str]], str] ] = None, flow: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-dense", "dense", "row", "row-dense"] + ], + Literal["column", "column-dense", "dense", "row", "row-dense"], Var[ Union[ Breakpoints[ str, Literal[ - "row", "column", "dense", "row-dense", "column-dense" + "column", "column-dense", "dense", "row", "row-dense" ], ], - Literal["row", "column", "dense", "row-dense", "column-dense"], + Literal["column", "column-dense", "dense", "row", "row-dense"], ] ], - Literal["row", "column", "dense", "row-dense", "column-dense"], - Breakpoints[ - str, Literal["row", "column", "dense", "row-dense", "column-dense"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -87,14 +91,14 @@ class Grid(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, spacing_x: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -104,14 +108,14 @@ class Grid(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, spacing_y: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -121,87 +125,53 @@ class Grid(elements.Div, RadixThemesComponent): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Grid": """Create a new component instance. @@ -214,13 +184,13 @@ class Grid(elements.Div, RadixThemesComponent): as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. columns: Number of columns rows: Number of rows - flow: How the grid items are layed out: "row" | "column" | "dense" | "row-dense" | "column-dense" + flow: How the grid items are laid out: "row" | "column" | "dense" | "row-dense" | "column-dense" align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" justify: Alignment of children along the cross axis: "start" | "center" | "end" | "between" spacing: Gap between children: "0" - "9" spacing_x: Gap between children horizontal: "0" - "9" spacing_y: Gap between children vertical: "0" - "9" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/layout/list.py b/reflex/components/radix/themes/layout/list.py index fb77b223d..a306e19a4 100644 --- a/reflex/components/radix/themes/layout/list.py +++ b/reflex/components/radix/themes/layout/list.py @@ -2,14 +2,15 @@ from __future__ import annotations -from typing import Any, 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.markdown.markdown import MarkdownComponentMap from reflex.components.radix.themes.typography.text import Text -from reflex.vars import Var +from reflex.vars.base import Var LiteralListStyleTypeUnordered = Literal[ "none", @@ -36,7 +37,7 @@ LiteralListStyleTypeOrdered = Literal[ ] -class BaseList(Component): +class BaseList(Component, MarkdownComponentMap): """Base class for ordered and unordered lists.""" tag = "ul" @@ -44,27 +45,29 @@ 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)] @@ -87,6 +90,9 @@ class BaseList(Component): "direction": "column", } + def _exclude_props(self) -> list[str]: + return ["items", "list_style_type"] + class UnorderedList(BaseList, Ul): """Display an unordered list.""" @@ -97,22 +103,20 @@ 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 @@ -128,29 +132,27 @@ 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 ) -class ListItem(Li): +class ListItem(Li, MarkdownComponentMap): """Display an item of an ordered or unordered list.""" @classmethod @@ -163,7 +165,6 @@ class ListItem(Li): Returns: The list item component. - """ for child in children: if isinstance(child, Text): diff --git a/reflex/components/radix/themes/layout/list.pyi b/reflex/components/radix/themes/layout/list.pyi index f6cc3141e..8517a6897 100644 --- a/reflex/components/radix/themes/layout/list.pyi +++ b/reflex/components/radix/themes/layout/list.pyi @@ -3,13 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Iterable, Literal, Optional, Union, overload +from typing import Any, Dict, Iterable, Literal, Optional, Union, overload from reflex.components.component import Component, ComponentNamespace from reflex.components.el.elements.typography import Li, Ol, Ul -from reflex.event import EventHandler, EventSpec +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var LiteralListStyleTypeUnordered = Literal["none", "disc", "circle", "square"] LiteralListStyleTypeOrdered = Literal[ @@ -29,114 +30,84 @@ LiteralListStyleTypeOrdered = Literal[ "katakana", ] -class BaseList(Component): +class BaseList(Component, MarkdownComponentMap): @overload @classmethod 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", + "armenian", "decimal", "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", "georgian", - "lower-alpha", - "upper-alpha", "hiragana", "katakana", + "lower-alpha", + "lower-greek", + "lower-latin", + "lower-roman", + "none", + "upper-alpha", + "upper-latin", + "upper-roman", ], - Literal["none", "disc", "circle", "square"], + Literal["circle", "disc", "none", "square"], ] ], - Literal["none", "disc", "circle", "square"], - Literal[ - "none", - "decimal", - "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", - "georgian", - "lower-alpha", - "upper-alpha", - "hiragana", - "katakana", - ], ] ] = None, + 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -147,7 +118,6 @@ class BaseList(Component): Returns: The list component. - """ ... @@ -159,92 +129,103 @@ 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[bool, int, str]], str, int, bool]] = 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[ + "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[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. + 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. @@ -270,7 +251,6 @@ class UnorderedList(BaseList, Ul): Returns: The list component. - """ ... @@ -280,98 +260,109 @@ 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[bool, int, str]], str, int, bool]] = None, - start: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - type: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + 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[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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). - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -397,98 +388,67 @@ class OrderedList(BaseList, Ol): Returns: The list component. - """ ... -class ListItem(Li): +class ListItem(Li, MarkdownComponentMap): @overload @classmethod def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ListItem": """Create a list item component. Args: *children: The children of the component. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -514,7 +474,6 @@ class ListItem(Li): Returns: The list item component. - """ ... @@ -526,108 +485,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", + "armenian", "decimal", "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", "georgian", - "lower-alpha", - "upper-alpha", "hiragana", "katakana", + "lower-alpha", + "lower-greek", + "lower-latin", + "lower-roman", + "none", + "upper-alpha", + "upper-latin", + "upper-roman", ], - Literal["none", "disc", "circle", "square"], + Literal["circle", "disc", "none", "square"], ] ], - Literal["none", "disc", "circle", "square"], - Literal[ - "none", - "decimal", - "decimal-leading-zero", - "lower-roman", - "upper-roman", - "lower-greek", - "lower-latin", - "upper-latin", - "armenian", - "georgian", - "lower-alpha", - "upper-alpha", - "hiragana", - "katakana", - ], ] ] = None, + 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -638,7 +567,6 @@ class List(ComponentNamespace): Returns: The list component. - """ ... diff --git a/reflex/components/radix/themes/layout/section.py b/reflex/components/radix/themes/layout/section.py index d9b27bdf9..68a131751 100644 --- a/reflex/components/radix/themes/layout/section.py +++ b/reflex/components/radix/themes/layout/section.py @@ -6,7 +6,7 @@ from typing import Literal from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import LiteralVar, Var from ..base import RadixThemesComponent @@ -19,9 +19,7 @@ class Section(elements.Section, RadixThemesComponent): tag = "Section" # The size of the section: "1" - "3" (default "2") - size: Var[Responsive[LiteralSectionSize]] = Var.create_safe( - "2", _var_is_string=True - ) + 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 31cf355e8..c005f273f 100644 --- a/reflex/components/radix/themes/layout/section.pyi +++ b/reflex/components/radix/themes/layout/section.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -23,90 +23,60 @@ class Section(elements.Section, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3"]], + Literal["1", "2", "3"], Var[ Union[ Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"] ] ], - Literal["1", "2", "3"], - Breakpoints[str, Literal["1", "2", "3"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Section": """Create a new component instance. @@ -117,7 +87,7 @@ class Section(elements.Section, RadixThemesComponent): Args: *children: Child components. size: The size of the section: "1" - "3" (default "2") - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/layout/spacer.pyi b/reflex/components/radix/themes/layout/spacer.pyi index aedd9b041..9854aa1ba 100644 --- a/reflex/components/radix/themes/layout/spacer.pyi +++ b/reflex/components/radix/themes/layout/spacer.pyi @@ -3,12 +3,12 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from .flex import Flex @@ -22,64 +22,68 @@ class Spacer(Flex): as_child: Optional[Union[Var[bool], bool]] = None, direction: Optional[ Union[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, align: Optional[ Union[ + Breakpoints[ + str, Literal["baseline", "center", "end", "start", "stretch"] + ], + Literal["baseline", "center", "end", "start", "stretch"], Var[ Union[ Breakpoints[ str, - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ], - Literal["start", "center", "end", "baseline", "stretch"], + Literal["baseline", "center", "end", "start", "stretch"], ] ], - Literal["start", "center", "end", "baseline", "stretch"], - Breakpoints[ - str, Literal["start", "center", "end", "baseline", "stretch"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, spacing: Optional[ Union[ + Breakpoints[ + str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + ], + Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -89,87 +93,53 @@ class Spacer(Flex): Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[ - str, Literal["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] - ], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Spacer": """Create a new component instance. @@ -180,12 +150,12 @@ class Spacer(Flex): Args: *children: Child components. 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" + direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse" align: Alignment of children along the main axis: "start" | "center" | "end" | "baseline" | "stretch" 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" spacing: Gap between children: "0" - "9" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/layout/stack.py b/reflex/components/radix/themes/layout/stack.py index 13f80dc1e..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, ) diff --git a/reflex/components/radix/themes/layout/stack.pyi b/reflex/components/radix/themes/layout/stack.pyi index 0296f92ca..d96c72504 100644 --- a/reflex/components/radix/themes/layout/stack.pyi +++ b/reflex/components/radix/themes/layout/stack.pyi @@ -3,14 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from ..base import LiteralAlign, LiteralSpacing from .flex import Flex class Stack(Flex): @@ -19,138 +18,118 @@ 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[ + Breakpoints[ + str, Literal["column", "column-reverse", "row", "row-reverse"] + ], + Literal["column", "column-reverse", "row", "row-reverse"], Var[ Union[ Breakpoints[ str, - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ], - Literal["row", "column", "row-reverse", "column-reverse"], + Literal["column", "column-reverse", "row", "row-reverse"], ] ], - Literal["row", "column", "row-reverse", "column-reverse"], - Breakpoints[ - str, Literal["row", "column", "row-reverse", "column-reverse"] - ], ] ] = None, justify: Optional[ Union[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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" + direction: How child items are laid out: "row" | "column" | "row-reverse" | "column-reverse" 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" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -185,127 +164,107 @@ 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[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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" + direction: How child items are laid 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" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -340,127 +299,107 @@ 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[ + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], Var[ Union[ - Breakpoints[str, Literal["start", "center", "end", "between"]], - Literal["start", "center", "end", "between"], + Breakpoints[str, Literal["between", "center", "end", "start"]], + Literal["between", "center", "end", "start"], ] ], - Literal["start", "center", "end", "between"], - Breakpoints[str, Literal["start", "center", "end", "between"]], ] ] = None, wrap: Optional[ Union[ + Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], + Literal["nowrap", "wrap", "wrap-reverse"], Var[ Union[ Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], Literal["nowrap", "wrap", "wrap-reverse"], ] ], - Literal["nowrap", "wrap", "wrap-reverse"], - Breakpoints[str, Literal["nowrap", "wrap", "wrap-reverse"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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" + direction: How child items are laid 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" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/typography/blockquote.py b/reflex/components/radix/themes/typography/blockquote.py index a4f3069b8..e32172e00 100644 --- a/reflex/components/radix/themes/typography/blockquote.py +++ b/reflex/components/radix/themes/typography/blockquote.py @@ -7,16 +7,10 @@ from __future__ import annotations from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) -from .base import ( - LiteralTextSize, - LiteralTextWeight, -) +from ..base import LiteralAccentColor, RadixThemesComponent +from .base import LiteralTextSize, LiteralTextWeight class Blockquote(elements.Blockquote, RadixThemesComponent): diff --git a/reflex/components/radix/themes/typography/blockquote.pyi b/reflex/components/radix/themes/typography/blockquote.pyi index 5ffe71355..747724763 100644 --- a/reflex/components/radix/themes/typography/blockquote.pyi +++ b/reflex/components/radix/themes/typography/blockquote.pyi @@ -3,13 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -21,6 +21,8 @@ class Blockquote(elements.Blockquote, RadixThemesComponent): *children, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -29,161 +31,129 @@ class Blockquote(elements.Blockquote, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Blockquote": """Create a new component instance. @@ -198,7 +168,7 @@ class Blockquote(elements.Blockquote, RadixThemesComponent): color_scheme: Overrides the accent color inherited from the Theme. high_contrast: Whether to render the text with higher contrast color cite: Define the title of a work. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/typography/code.py b/reflex/components/radix/themes/typography/code.py index 2c0212b8b..ab610b505 100644 --- a/reflex/components/radix/themes/typography/code.py +++ b/reflex/components/radix/themes/typography/code.py @@ -7,20 +7,14 @@ from __future__ import annotations from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - LiteralVariant, - RadixThemesComponent, -) -from .base import ( - LiteralTextSize, - LiteralTextWeight, -) +from ..base import LiteralAccentColor, LiteralVariant, RadixThemesComponent +from .base import LiteralTextSize, LiteralTextWeight -class Code(elements.Code, RadixThemesComponent): +class Code(elements.Code, RadixThemesComponent, MarkdownComponentMap): """A block level extended quotation.""" tag = "Code" diff --git a/reflex/components/radix/themes/typography/code.pyi b/reflex/components/radix/themes/typography/code.pyi index f1fc274e1..847df267c 100644 --- a/reflex/components/radix/themes/typography/code.pyi +++ b/reflex/components/radix/themes/typography/code.pyi @@ -3,17 +3,18 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent -class Code(elements.Code, RadixThemesComponent): +class Code(elements.Code, RadixThemesComponent, MarkdownComponentMap): @overload @classmethod def create( # type: ignore @@ -21,12 +22,14 @@ class Code(elements.Code, RadixThemesComponent): *children, variant: Optional[ Union[ - Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], - Literal["classic", "solid", "soft", "surface", "outline", "ghost"], + Literal["classic", "ghost", "outline", "soft", "solid", "surface"], + Var[Literal["classic", "ghost", "outline", "soft", "solid", "surface"]], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -35,160 +38,128 @@ class Code(elements.Code, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Code": """Create a new component instance. @@ -203,7 +174,7 @@ class Code(elements.Code, RadixThemesComponent): weight: Thickness of text: "light" | "regular" | "medium" | "bold" color_scheme: Overrides the accent color inherited from the Theme. high_contrast: Whether to render the text with higher contrast color - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/typography/heading.py b/reflex/components/radix/themes/typography/heading.py index 374fe8dcc..ce1eaa68f 100644 --- a/reflex/components/radix/themes/typography/heading.py +++ b/reflex/components/radix/themes/typography/heading.py @@ -7,21 +7,14 @@ from __future__ import annotations from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) -from .base import ( - LiteralTextAlign, - LiteralTextSize, - LiteralTextTrim, - LiteralTextWeight, -) +from ..base import LiteralAccentColor, RadixThemesComponent +from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight -class Heading(elements.H1, RadixThemesComponent): +class Heading(elements.H1, RadixThemesComponent, MarkdownComponentMap): """A foundational text primitive based on the element.""" tag = "Heading" diff --git a/reflex/components/radix/themes/typography/heading.pyi b/reflex/components/radix/themes/typography/heading.pyi index 1dad3b97f..4a1e30dbf 100644 --- a/reflex/components/radix/themes/typography/heading.pyi +++ b/reflex/components/radix/themes/typography/heading.pyi @@ -3,17 +3,18 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent -class Heading(elements.H1, RadixThemesComponent): +class Heading(elements.H1, RadixThemesComponent, MarkdownComponentMap): @overload @classmethod def create( # type: ignore @@ -23,6 +24,8 @@ class Heading(elements.H1, RadixThemesComponent): as_: Optional[Union[Var[str], str]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -31,184 +34,152 @@ class Heading(elements.H1, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Heading": """Create a new component instance. @@ -226,7 +197,7 @@ class Heading(elements.H1, RadixThemesComponent): trim: Removes the leading trim space: "normal" | "start" | "end" | "both" color_scheme: Overrides the accent color inherited from the Theme. high_contrast: Whether to render the text with higher contrast color - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/typography/link.py b/reflex/components/radix/themes/typography/link.py index 92fa47173..25a0902cc 100644 --- a/reflex/components/radix/themes/typography/link.py +++ b/reflex/components/radix/themes/typography/link.py @@ -12,26 +12,20 @@ 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.markdown.markdown import MarkdownComponentMap from reflex.components.next.link import NextLink from reflex.utils.imports import ImportDict -from reflex.vars import Var +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) -from .base import ( - LiteralTextSize, - LiteralTextTrim, - LiteralTextWeight, -) +from ..base import LiteralAccentColor, RadixThemesComponent +from .base import LiteralTextSize, LiteralTextTrim, LiteralTextWeight LiteralLinkUnderline = Literal["auto", "hover", "always", "none"] next_link = NextLink.create() -class Link(RadixThemesComponent, A, MemoizationLeaf): +class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap): """A semantic element for navigation between pages.""" tag = "Link" @@ -83,13 +77,14 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): Component: The link component """ props.setdefault(":hover", {"color": color("accent", 8)}) + href = props.get("href") is_external = props.pop("is_external", None) if is_external is not None: props["target"] = cond(is_external, "_blank", "") - if props.get("href") is not None: + if href is not None: if not len(children): raise ValueError("Link without a child will not display") @@ -107,6 +102,9 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): as_child=True, **props, ) + else: + props["href"] = "#" + return super().create(*children, **props) diff --git a/reflex/components/radix/themes/typography/link.pyi b/reflex/components/radix/themes/typography/link.pyi index ab29e8f59..807f8dda0 100644 --- a/reflex/components/radix/themes/typography/link.pyi +++ b/reflex/components/radix/themes/typography/link.pyi @@ -3,23 +3,24 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import MemoizationLeaf from reflex.components.core.breakpoints import Breakpoints from reflex.components.el.elements.inline import A +from reflex.components.markdown.markdown import MarkdownComponentMap from reflex.components.next.link import NextLink -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +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): +class Link(RadixThemesComponent, A, MemoizationLeaf, MarkdownComponentMap): def add_imports(self) -> ImportDict: ... @overload @classmethod @@ -29,6 +30,8 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -37,190 +40,158 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, underline: Optional[ Union[ - Var[Literal["auto", "hover", "always", "none"]], - Literal["auto", "hover", "always", "none"], + Literal["always", "auto", "hover", "none"], + Var[Literal["always", "auto", "hover", "none"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, is_external: Optional[Union[Var[bool], bool]] = None, - download: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - href_lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - media: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - ping: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + download: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + href_lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + media: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + ping: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, referrer_policy: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - rel: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - shape: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - target: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + rel: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + shape: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + target: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Link": """Create a Link component. @@ -244,7 +215,7 @@ class Link(RadixThemesComponent, A, MemoizationLeaf): rel: Specifies the relationship between the linked document and the current document shape: Specifies the shape of the area target: Specifies where to open the linked document - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. diff --git a/reflex/components/radix/themes/typography/text.py b/reflex/components/radix/themes/typography/text.py index fe4b17afc..1663ddedf 100644 --- a/reflex/components/radix/themes/typography/text.py +++ b/reflex/components/radix/themes/typography/text.py @@ -10,18 +10,11 @@ from typing import Literal from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Responsive from reflex.components.el import elements -from reflex.vars import Var +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.vars.base import Var -from ..base import ( - LiteralAccentColor, - RadixThemesComponent, -) -from .base import ( - LiteralTextAlign, - LiteralTextSize, - LiteralTextTrim, - LiteralTextWeight, -) +from ..base import LiteralAccentColor, RadixThemesComponent +from .base import LiteralTextAlign, LiteralTextSize, LiteralTextTrim, LiteralTextWeight LiteralType = Literal[ "p", @@ -45,7 +38,7 @@ LiteralType = Literal[ ] -class Text(elements.Span, RadixThemesComponent): +class Text(elements.Span, RadixThemesComponent, MarkdownComponentMap): """A foundational text primitive based on the element.""" tag = "Text" diff --git a/reflex/components/radix/themes/typography/text.pyi b/reflex/components/radix/themes/typography/text.pyi index 1d7857a5d..d96b5799b 100644 --- a/reflex/components/radix/themes/typography/text.pyi +++ b/reflex/components/radix/themes/typography/text.pyi @@ -3,14 +3,15 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import ComponentNamespace from reflex.components.core.breakpoints import Breakpoints from reflex.components.el import elements -from reflex.event import EventHandler, EventSpec +from reflex.components.markdown.markdown import MarkdownComponentMap +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var from ..base import RadixThemesComponent @@ -35,7 +36,7 @@ LiteralType = Literal[ "sup", ] -class Text(elements.Span, RadixThemesComponent): +class Text(elements.Span, RadixThemesComponent, MarkdownComponentMap): @overload @classmethod def create( # type: ignore @@ -44,52 +45,54 @@ class Text(elements.Span, RadixThemesComponent): as_child: Optional[Union[Var[bool], bool]] = None, as_: Optional[ Union[ - Var[ - Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", - "abbr", - "cite", - "del", - "em", - "ins", - "kbd", - "mark", - "s", - "samp", - "sub", - "sup", - ] - ], Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", "abbr", + "b", "cite", "del", + "div", "em", + "i", "ins", "kbd", + "label", "mark", + "p", "s", "samp", + "span", "sub", "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] ], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -98,184 +101,152 @@ class Text(elements.Span, RadixThemesComponent): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Text": """Create a new component instance. @@ -293,7 +264,7 @@ class Text(elements.Span, RadixThemesComponent): trim: Removes the leading trim space: "normal" | "start" | "end" | "both" color_scheme: Overrides the accent color inherited from the Theme. high_contrast: Whether to render the text with higher contrast color - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -330,53 +301,55 @@ class Span(Text): *children, as_: Optional[ Union[ - Var[ - Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", - "abbr", - "cite", - "del", - "em", - "ins", - "kbd", - "mark", - "s", - "samp", - "sub", - "sup", - ] - ], Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", "abbr", + "b", "cite", "del", + "div", "em", + "i", "ins", "kbd", + "label", "mark", + "p", "s", "samp", + "span", "sub", "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] ], ] ] = None, as_child: Optional[Union[Var[bool], bool]] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -385,184 +358,152 @@ class Span(Text): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Span": """Create a new component instance. @@ -580,7 +521,7 @@ class Span(Text): trim: Removes the leading trim space: "normal" | "start" | "end" | "both" color_scheme: Overrides the accent color inherited from the Theme. high_contrast: Whether to render the text with higher contrast color - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -615,81 +556,51 @@ class Em(elements.Em, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Em": """Create a new component instance. @@ -699,7 +610,7 @@ class Em(elements.Em, RadixThemesComponent): Args: *children: Child components. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -736,85 +647,55 @@ class Kbd(elements.Kbd, RadixThemesComponent): *children, size: Optional[ Union[ - Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], + Var[Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Kbd": """Create a new component instance. @@ -825,7 +706,7 @@ class Kbd(elements.Kbd, RadixThemesComponent): Args: *children: Child components. size: Text size: "1" - "9" - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -860,82 +741,52 @@ class Quote(elements.Q, RadixThemesComponent): def create( # type: ignore cls, *children, - cite: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + cite: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Quote": """Create a new component instance. @@ -946,7 +797,7 @@ class Quote(elements.Q, RadixThemesComponent): Args: *children: Child components. cite: Specifies the source URL of the quote. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -981,81 +832,51 @@ class Strong(elements.Strong, RadixThemesComponent): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Strong": """Create a new component instance. @@ -1065,7 +886,7 @@ class Strong(elements.Strong, RadixThemesComponent): Args: *children: Child components. - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. @@ -1107,52 +928,54 @@ class TextNamespace(ComponentNamespace): as_child: Optional[Union[Var[bool], bool]] = None, as_: Optional[ Union[ - Var[ - Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", - "abbr", - "cite", - "del", - "em", - "ins", - "kbd", - "mark", - "s", - "samp", - "sub", - "sup", - ] - ], Literal[ - "p", - "label", - "div", - "span", - "b", - "i", - "u", "abbr", + "b", "cite", "del", + "div", "em", + "i", "ins", "kbd", + "label", "mark", + "p", "s", "samp", + "span", "sub", "sup", + "u", + ], + Var[ + Literal[ + "abbr", + "b", + "cite", + "del", + "div", + "em", + "i", + "ins", + "kbd", + "label", + "mark", + "p", + "s", + "samp", + "span", + "sub", + "sup", + "u", + ] ], ] ] = None, size: Optional[ Union[ + Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], + Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], Var[ Union[ Breakpoints[ @@ -1161,184 +984,152 @@ class TextNamespace(ComponentNamespace): Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], ] ], - Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"], - Breakpoints[str, Literal["1", "2", "3", "4", "5", "6", "7", "8", "9"]], ] ] = None, weight: Optional[ Union[ + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], Var[ Union[ - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], - Literal["light", "regular", "medium", "bold"], + Breakpoints[str, Literal["bold", "light", "medium", "regular"]], + Literal["bold", "light", "medium", "regular"], ] ], - Literal["light", "regular", "medium", "bold"], - Breakpoints[str, Literal["light", "regular", "medium", "bold"]], ] ] = None, align: Optional[ Union[ + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], Var[ Union[ - Breakpoints[str, Literal["left", "center", "right"]], - Literal["left", "center", "right"], + Breakpoints[str, Literal["center", "left", "right"]], + Literal["center", "left", "right"], ] ], - Literal["left", "center", "right"], - Breakpoints[str, Literal["left", "center", "right"]], ] ] = None, trim: Optional[ Union[ + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], Var[ Union[ - Breakpoints[str, Literal["normal", "start", "end", "both"]], - Literal["normal", "start", "end", "both"], + Breakpoints[str, Literal["both", "end", "normal", "start"]], + Literal["both", "end", "normal", "start"], ] ], - Literal["normal", "start", "end", "both"], - Breakpoints[str, Literal["normal", "start", "end", "both"]], ] ] = None, color_scheme: Optional[ Union[ - Var[ - Literal[ - "tomato", - "red", - "ruby", - "crimson", - "pink", - "plum", - "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", - "sky", - "mint", - "lime", - "yellow", - "amber", - "gold", - "bronze", - "gray", - ] - ], Literal[ - "tomato", - "red", - "ruby", + "amber", + "blue", + "bronze", + "brown", "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", "pink", "plum", "purple", - "violet", - "iris", - "indigo", - "blue", - "cyan", - "teal", - "jade", - "green", - "grass", - "brown", - "orange", + "red", + "ruby", "sky", - "mint", - "lime", + "teal", + "tomato", + "violet", "yellow", - "amber", - "gold", - "bronze", - "gray", + ], + Var[ + Literal[ + "amber", + "blue", + "bronze", + "brown", + "crimson", + "cyan", + "gold", + "grass", + "gray", + "green", + "indigo", + "iris", + "jade", + "lime", + "mint", + "orange", + "pink", + "plum", + "purple", + "red", + "ruby", + "sky", + "teal", + "tomato", + "violet", + "yellow", + ] ], ] ] = None, high_contrast: Optional[Union[Var[bool], bool]] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Text": """Create a new component instance. @@ -1356,7 +1147,7 @@ class TextNamespace(ComponentNamespace): trim: Removes the leading trim space: "normal" | "start" | "end" | "both" color_scheme: Overrides the accent color inherited from the Theme. high_contrast: Whether to render the text with higher contrast color - access_key: Provides a hint for generating a keyboard shortcut for the current element. + 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. 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.pyi b/reflex/components/react_player/audio.pyi index f138d3fd8..797d5ad8a 100644 --- a/reflex/components/react_player/audio.pyi +++ b/reflex/components/react_player/audio.pyi @@ -3,12 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload +import reflex from reflex.components.react_player.react_player import ReactPlayer -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Audio(ReactPlayer): pass @@ -32,100 +33,49 @@ class Audio(ReactPlayer): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_buffer: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_buffer_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click_preview: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_disable_pip: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_buffer: Optional[EventType[[], BASE_STATE]] = None, + on_buffer_end: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_click_preview: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_disable_pip: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_duration: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_enable_pip: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ended: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pause: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_play: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_playback_quality_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_playback_rate_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]] ] = None, + on_enable_pip: Optional[EventType[[], BASE_STATE]] = None, + on_ended: Optional[EventType[[], BASE_STATE]] = None, + on_error: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pause: Optional[EventType[[], BASE_STATE]] = None, + on_play: Optional[EventType[[], BASE_STATE]] = None, + on_playback_quality_change: Optional[EventType[[], BASE_STATE]] = None, + on_playback_rate_change: Optional[EventType[[], BASE_STATE]] = None, on_progress: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ready: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[ + [reflex.components.react_player.react_player.Progress], BASE_STATE + ], + ] ] = None, + on_ready: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_seek: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]] ] = None, + on_start: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Audio": """Create the component. @@ -141,6 +91,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 1c9b20cea..fb0319ceb 100644 --- a/reflex/components/react_player/react_player.py +++ b/reflex/components/react_player/react_player.py @@ -2,9 +2,20 @@ from __future__ import annotations +from typing_extensions import TypedDict + from reflex.components.component import NoSSRComponent -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec +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): @@ -12,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" @@ -46,49 +57,49 @@ class ReactPlayer(NoSSRComponent): 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[lambda: []] + on_ready: EventHandler[no_args_event_spec] # Called when media starts playing. - on_start: EventHandler[lambda: []] + on_start: EventHandler[no_args_event_spec] # Called when media starts or resumes playing after pausing or buffering. - on_play: EventHandler[lambda: []] + on_play: EventHandler[no_args_event_spec] # 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[lambda progress: [progress]] + on_progress: EventHandler[passthrough_event_spec(Progress)] # Callback containing duration of the media, in seconds. - on_duration: EventHandler[lambda seconds: [seconds]] + on_duration: EventHandler[passthrough_event_spec(float)] # Called when media is paused. - on_pause: EventHandler[lambda: []] + on_pause: EventHandler[no_args_event_spec] # Called when media starts buffering. - on_buffer: EventHandler[lambda: []] + on_buffer: EventHandler[no_args_event_spec] # Called when media has finished buffering. Works for files, YouTube and Facebook. - on_buffer_end: EventHandler[lambda: []] + on_buffer_end: EventHandler[no_args_event_spec] # Called when media seeks with seconds parameter. - on_seek: EventHandler[lambda seconds: [seconds]] + on_seek: EventHandler[passthrough_event_spec(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[lambda e0: []] + on_playback_rate_change: EventHandler[no_args_event_spec] # Called when playback quality of the player changed. Only supported by YouTube (if enabled). - on_playback_quality_change: EventHandler[lambda e0: []] + on_playback_quality_change: EventHandler[no_args_event_spec] # Called when media finishes playing. Does not fire when loop is set to true. - on_ended: EventHandler[lambda: []] + on_ended: EventHandler[no_args_event_spec] # Called when an error occurs whilst attempting to play media. - on_error: EventHandler[lambda: []] + on_error: EventHandler[no_args_event_spec] # Called when user clicks the light mode preview. - on_click_preview: EventHandler[lambda: []] + on_click_preview: EventHandler[no_args_event_spec] # Called when picture-in-picture mode is enabled. - on_enable_pip: EventHandler[lambda: []] + on_enable_pip: EventHandler[no_args_event_spec] # Called when picture-in-picture mode is disabled. - on_disable_pip: EventHandler[lambda: []] + on_disable_pip: EventHandler[no_args_event_spec] diff --git a/reflex/components/react_player/react_player.pyi b/reflex/components/react_player/react_player.pyi index 79e38353a..4e2a8a821 100644 --- a/reflex/components/react_player/react_player.pyi +++ b/reflex/components/react_player/react_player.pyi @@ -3,12 +3,20 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload + +from typing_extensions import TypedDict from reflex.components.component import NoSSRComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var + +class Progress(TypedDict): + played: float + playedSeconds: float + loaded: float + loadedSeconds: float class ReactPlayer(NoSSRComponent): @overload @@ -30,100 +38,44 @@ class ReactPlayer(NoSSRComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_buffer: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_buffer_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click_preview: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_disable_pip: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_buffer: Optional[EventType[[], BASE_STATE]] = None, + on_buffer_end: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_click_preview: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_disable_pip: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_duration: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_enable_pip: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ended: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pause: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_play: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_playback_quality_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_playback_rate_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]] ] = None, + on_enable_pip: Optional[EventType[[], BASE_STATE]] = None, + on_ended: Optional[EventType[[], BASE_STATE]] = None, + on_error: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pause: Optional[EventType[[], BASE_STATE]] = None, + on_play: Optional[EventType[[], BASE_STATE]] = None, + on_playback_quality_change: Optional[EventType[[], BASE_STATE]] = None, + on_playback_rate_change: Optional[EventType[[], BASE_STATE]] = None, on_progress: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ready: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[Progress], BASE_STATE]] ] = None, + on_ready: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_seek: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]] ] = None, + on_start: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ReactPlayer": """Create the component. @@ -139,6 +91,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.pyi b/reflex/components/react_player/video.pyi index 4016c6f44..3739d45c0 100644 --- a/reflex/components/react_player/video.pyi +++ b/reflex/components/react_player/video.pyi @@ -3,12 +3,13 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Optional, Union, overload +from typing import Any, Dict, Optional, Union, overload +import reflex from reflex.components.react_player.react_player import ReactPlayer -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Video(ReactPlayer): pass @@ -32,100 +33,49 @@ class Video(ReactPlayer): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_buffer: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_buffer_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click_preview: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_disable_pip: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_buffer: Optional[EventType[[], BASE_STATE]] = None, + on_buffer_end: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_click_preview: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_disable_pip: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, on_duration: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_enable_pip: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ended: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_error: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_pause: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_play: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_playback_quality_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_playback_rate_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]] ] = None, + on_enable_pip: Optional[EventType[[], BASE_STATE]] = None, + on_ended: Optional[EventType[[], BASE_STATE]] = None, + on_error: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_pause: Optional[EventType[[], BASE_STATE]] = None, + on_play: Optional[EventType[[], BASE_STATE]] = None, + on_playback_quality_change: Optional[EventType[[], BASE_STATE]] = None, + on_playback_rate_change: Optional[EventType[[], BASE_STATE]] = None, on_progress: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_ready: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[ + [reflex.components.react_player.react_player.Progress], BASE_STATE + ], + ] ] = None, + on_ready: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, on_seek: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[float], BASE_STATE]] ] = None, + on_start: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Video": """Create the component. @@ -141,6 +91,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/cartesian.py b/reflex/components/recharts/cartesian.py index 0f2ec2f32..9f6bf672b 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -6,8 +6,8 @@ from typing import Any, Dict, List, Union from reflex.constants import EventTriggers from reflex.constants.colors import Color -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, @@ -15,6 +15,7 @@ from .recharts import ( LiteralDirection, LiteralIfOverflow, LiteralInterval, + LiteralIntervalAxis, LiteralLayout, LiteralLegendType, LiteralLineType, @@ -24,6 +25,7 @@ from .recharts import ( LiteralPolarRadiusType, LiteralScale, LiteralShape, + LiteralTextAnchor, Recharts, ) @@ -34,40 +36,46 @@ class Axis(Recharts): # 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 width of axis which is usually calculated internally. width: Var[Union[str, int]] - # The height of axis, which can be setted by user. + # The height of axis, which can be set 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 conjunction 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 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] # 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' | Function + # 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. @@ -82,44 +90,44 @@ class Axis(Recharts): # If set false, no ticks will be drawn. tick: Var[bool] - # The count of axis ticks. + # 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. - tick_line: Var[bool] = Var.create_safe(False) + # If set false, no axis tick lines will be drawn. Default: True + tick_line: Var[bool] - # The length of tick line. + # The length of tick line. Default: 6 tick_size: Var[int] - # The minimum gap between two adjacent labels + # The minimum gap between two adjacent labels. Default: 5 min_tick_gap: Var[int] - # The stroke color of axis - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 9)) + # 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 - text_anchor: Var[str] # 'start', 'middle', 'end' + # 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[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the ticks of this axis - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the ticks of this axis - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the ticks of this axis - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the ticks of this axis - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the ticks of this axis - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the ticks of this axis - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class XAxis(Axis): @@ -129,17 +137,20 @@ class XAxis(Axis): alias = "RechartsXAxis" - # The orientation of axis 'top' | 'bottom' + # The orientation of axis 'top' | 'bottom'. Default: "bottom" orientation: Var[LiteralOrientationTopBottom] - # 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]] - # Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden - include_hidden: Var[bool] = Var.create_safe(False) + # Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden. Default: False + include_hidden: Var[bool] - # The range of the axis. Work best in conjuction with allow_data_overflow. - domain: Var[List] + # 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): @@ -149,14 +160,14 @@ class YAxis(Axis): alias = "RechartsYAxis" - # The orientation of axis 'left' | 'right' + # The orientation of axis 'left' | 'right'. Default: "left" orientation: Var[LiteralOrientationLeftRight] - # 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 range of the axis. Work best in conjuction with allow_data_overflow. - domain: Var[List] + # Specify the padding of y-axis. Default: {"top": 0, "bottom": 0} + padding: Var[Dict[str, int]] class ZAxis(Recharts): @@ -164,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. @@ -178,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] @@ -189,40 +203,40 @@ class Brush(Recharts): alias = "RechartsBrush" - # Stroke color - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 9)) + # Stroke color. Default: rx.color("gray", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9)) - # The fill color of brush. - fill: Var[Union[str, Color]] = Var.create_safe(Color("gray", 2)) + # 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 @@ -238,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: no_args_event_spec, } @@ -251,38 +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 + # 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] + # If set false, animation of bar 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. 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[no_args_event_spec] + + # The customized event handler of animation end + on_animation_end: EventHandler[no_args_event_spec] + # The customized event handler of click on the component in this group - on_click: EventHandler[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the component in this group - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the component in this group - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the component in this group - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the component in this group - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the component in this group - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the component in this group - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the component in this group - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class Area(Cartesian): @@ -292,40 +330,43 @@ class Area(Cartesian): alias = "RechartsArea" - # The color of the line stroke. - stroke: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9)) + # 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. - stroke_width: Var[int] = Var.create_safe(1) + # The width of the line stroke. Default: 1 + stroke_width: Var[int] - # The color of the area fill. - fill: Var[Union[str, Color]] = Var.create_safe(Color("accent", 5)) + # 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] = Var.create_safe("monotone", _var_is_string=True) + # 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. + # 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[Union[bool, Dict[str, Any]]] = Var.create_safe( + # 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 set false, labels will not be drawn. If set true, 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 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]] - # 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 a bar. If no value was set to this option, the value of dataKey will be used alternatively. - name: 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"] @@ -344,12 +385,13 @@ class Bar(Cartesian): # The width of the line stroke. stroke_width: Var[int] - # The width of the line stroke. - fill: Var[Union[str, Color]] = Var.create_safe(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. + # 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. 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 bars have the same value axis and same stack_id, then the two bars are stacked in order. @@ -370,30 +412,15 @@ class Bar(Cartesian): # 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]]] + # active_bar: Var[Union[bool, Dict[str, Any]]] #noqa: ERA001 # Valid children components _valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"] - # If set false, animation of bar will be disabled. - 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, default 'ease' - animation_easing: Var[LiteralAnimationEasing] - - # The customized event handler of animation start - on_animation_start: EventHandler[lambda: []] - - # The customized event handler of animation end - on_animation_end: EventHandler[lambda: []] - class Line(Cartesian): """A Line component in Recharts.""" @@ -405,32 +432,32 @@ 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[Union[str, Color]] = Var.create_safe(Color("accent", 9)) + # 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 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[Union[bool, Dict[str, Any]]] = Var.create_safe( + # 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[Union[bool, Dict[str, Any]]] = Var.create_safe( + # 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. @@ -439,8 +466,11 @@ class Line(Cartesian): # The unit of data. This option will be used in tooltip. unit: Var[Union[str, int]] - # 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]] + # 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"] @@ -456,71 +486,68 @@ class Scatter(Recharts): # The source data, in which each element is an object. data: Var[List[Dict[str, Any]]] - # 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' + # 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] - # 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 id of z-axis which is corresponding to the data. - z_axis_id: Var[str] + # 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. + # 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[Union[str, Color]] = Var.create_safe(Color("accent", 9)) - - # 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. + # If set false, animation of bar will be disabled. Default: True in CSR, False in SSR is_animation_active: Var[bool] - # Specifies when the animation should begin, the unit of this option is ms, default 0. + # 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. + # 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' + # 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[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the component in this group - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the component in this group - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the component in this group - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the component in this group - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the component in this group - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the component in this group - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the component in this group - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class Funnel(Recharts): @@ -533,62 +560,65 @@ class Funnel(Recharts): # The source data, in which each element is an object. data: Var[List[Dict[str, Any]]] - # The key of a group of data which should be unique in an area chart. + # The key or getter of a group of data which should be unique in a FunnelChart. data_key: Var[Union[str, int]] - # The key or getter of a group of data which should be unique in a LineChart. + # 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. + # 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. + # 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. + # 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 - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 3)) + # 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[lambda: []] + on_animation_start: EventHandler[no_args_event_spec] # The customized event handler of animation end - on_animation_end: EventHandler[lambda: []] + on_animation_end: EventHandler[no_args_event_spec] # The customized event handler of click on the component in this group - on_click: EventHandler[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the component in this group - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the component in this group - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the component in this group - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the component in this group - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the component in this group - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the component in this group - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the component in this group - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class ErrorBar(Recharts): @@ -598,38 +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[Union[str, Color]] = Var.create_safe(Color("gray", 8)) + # 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]] - # 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 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. + # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False is_front: Var[bool] @@ -649,7 +679,7 @@ class ReferenceLine(Reference): # The color of the reference line. stroke: Var[Union[str, Color]] - # The width of the stroke. + # The width of the stroke. Default: 1 stroke_width: Var[Union[str, int]] # Valid children components @@ -685,28 +715,28 @@ class ReferenceDot(Reference): _valid_children: List[str] = ["Label"] # The customized event handler of click on the component in this chart - on_click: EventHandler[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the component in this chart - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the component in this chart - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the component in this chart - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the component in this chart - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the component in this chart - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the component in this chart - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the component in this chart - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class ReferenceArea(Recharts): @@ -743,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 @@ -756,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] @@ -776,29 +806,29 @@ class CartesianGrid(Grid): alias = "RechartsCartesianGrid" - # The horizontal line configuration. + # The horizontal line configuration. Default: True horizontal: Var[bool] - # The vertical line configuration. + # The vertical line configuration. Default: True vertical: Var[bool] - # The x-coordinates in pixel values of all vertical lines. + # 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. + # The x-coordinates in pixel values of all vertical lines. Default: [] horizontal_points: Var[List[Union[str, int]]] # The background of grid. 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 - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 7)) + # the stroke color of grid. Default: rx.color("gray", 7) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 7)) class CartesianAxis(Grid): @@ -808,28 +838,31 @@ 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. diff --git a/reflex/components/recharts/cartesian.pyi b/reflex/components/recharts/cartesian.pyi index 498ed7444..64921ec55 100644 --- a/reflex/components/recharts/cartesian.pyi +++ b/reflex/components/recharts/cartesian.pyi @@ -3,16 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.constants.colors import Color -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from .recharts import ( - Recharts, -) +from .recharts import Recharts class Axis(Recharts): @overload @@ -20,125 +18,123 @@ class Axis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, hide: Optional[Union[Var[bool], bool]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] + ] = None, + 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, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str] ] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - text_anchor: Optional[Union[Var[str], str]] = 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Axis": """Create the component. @@ -146,28 +142,37 @@ class Axis(Recharts): Args: *children: The children of the component. data_key: The key of data displayed in the axis. - hide: If set true, the axis do not display in the chart. + 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. + height: The height of axis, which can be set 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. - 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. + 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 conjunction 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' | Function + 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. - tick_line: If set false, no axis tick lines will be drawn. - tick_size: The length of tick line. - min_tick_gap: The minimum gap between two adjacent labels - stroke: The stroke color of axis - text_anchor: The text anchor of axis + 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. @@ -188,163 +193,172 @@ class XAxis(Axis): cls, *children, orientation: Optional[ - Union[Var[Literal["top", "bottom"]], Literal["top", "bottom"]] + Union[Literal["bottom", "top"], Var[Literal["bottom", "top"]]] ] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, include_hidden: Optional[Union[Var[bool], bool]] = None, - domain: Optional[Union[Var[List], List]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + 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]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] + ] = None, + 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, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str] ] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - text_anchor: Optional[Union[Var[str], str]] = 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "XAxis": """Create the component. Args: *children: The children of the component. - orientation: The orientation of axis 'top' | 'bottom' - x_axis_id: The id of x-axis which is corresponding to the data. - include_hidden: Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden - domain: The range of the axis. Work best in conjuction with allow_data_overflow. + 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. + 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. + height: The height of axis, which can be set 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. - 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. + 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 conjunction 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' | Function + 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. - tick_line: If set false, no axis tick lines will be drawn. - tick_size: The length of tick line. - min_tick_gap: The minimum gap between two adjacent labels - stroke: The stroke color of axis - text_anchor: The text anchor of axis + 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. @@ -365,161 +379,168 @@ class YAxis(Axis): cls, *children, orientation: Optional[ - Union[Var[Literal["left", "right"]], Literal["left", "right"]] + Union[Literal["left", "right"], Var[Literal["left", "right"]]] ] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - domain: Optional[Union[Var[List], List]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + 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]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, type_: Optional[ - Union[Var[Literal["number", "category"]], Literal["number", "category"]] + Union[Literal["category", "number"], Var[Literal["category", "number"]]] + ] = None, + 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, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, label: Optional[ - Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], int, str]], int, str] ] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, ticks: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, tick: Optional[Union[Var[bool], bool]] = None, tick_count: Optional[Union[Var[int], int]] = None, tick_line: Optional[Union[Var[bool], bool]] = None, tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - text_anchor: Optional[Union[Var[str], str]] = 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "YAxis": """Create the component. Args: *children: The children of the component. - orientation: The orientation of axis 'left' | 'right' - y_axis_id: The id of y-axis which is corresponding to the data. - domain: The range of the axis. Work best in conjuction with allow_data_overflow. + 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. + 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. + height: The height of axis, which can be set 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. - 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. + 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 conjunction 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' | Function + 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. - tick_line: If set false, no axis tick lines will be drawn. - tick_size: The length of tick line. - min_tick_gap: The minimum gap between two adjacent labels - stroke: The stroke color of axis - text_anchor: The text anchor of axis + 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. @@ -539,48 +560,49 @@ class ZAxis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - range: Optional[Union[Var[List[int]], List[int]]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + 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, @@ -588,52 +610,22 @@ class ZAxis(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ZAxis": """Create the component. @@ -641,10 +633,11 @@ class ZAxis(Recharts): 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. @@ -665,14 +658,14 @@ class Brush(Recharts): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, x: Optional[Union[Var[int], int]] = None, y: Optional[Union[Var[int], int]] = None, width: Optional[Union[Var[int], int]] = None, height: Optional[Union[Var[int], int]] = None, - data: Optional[Union[Var[List[Any]], List[Any]]] = None, + data: Optional[Union[List[Any], Var[List[Any]]]] = None, traveller_width: Optional[Union[Var[int], int]] = None, gap: Optional[Union[Var[int], int]] = None, start_index: Optional[Union[Var[int], int]] = None, @@ -682,10 +675,8 @@ class Brush(Recharts): id: Optional[Any] = None, 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, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_change: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Brush": """Create the component. @@ -695,15 +686,15 @@ class Brush(Recharts): 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. @@ -725,96 +716,79 @@ class Cartesian(Recharts): *children, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, + 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Cartesian": """Create the component. @@ -823,9 +797,25 @@ 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. - 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 + 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. @@ -845,172 +835,175 @@ class Area(Cartesian): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, type_: Optional[ Union[ + Literal[ + "basis", + "basisClosed", + "basisOpen", + "bump", + "bumpX", + "bumpY", + "linear", + "linearClosed", + "monotone", + "monotoneX", + "monotoneY", + "natural", + "step", + "stepAfter", + "stepBefore", + ], Var[ Literal[ "basis", "basisClosed", "basisOpen", + "bump", "bumpX", "bumpY", - "bump", "linear", "linearClosed", - "natural", + "monotone", "monotoneX", "monotoneY", - "monotone", + "natural", "step", - "stepBefore", "stepAfter", + "stepBefore", ] ], - Literal[ - "basis", - "basisClosed", - "basisOpen", - "bumpX", - "bumpY", - "bump", - "linear", - "linearClosed", - "natural", - "monotoneX", - "monotoneY", - "monotone", - "step", - "stepBefore", - "stepAfter", - ], ] ] = None, dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, active_dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, label: Optional[Union[Var[bool], bool]] = None, - stack_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + 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[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, + 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. + 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. - 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 a bar. If no value was set to this option, the value of dataKey will be used alternatively. + 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. - 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 + 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. @@ -1030,65 +1023,66 @@ class Bar(Cartesian): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, background: Optional[Union[Var[bool], bool]] = None, label: Optional[Union[Var[bool], bool]] = None, stack_id: Optional[Union[Var[str], str]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, min_point_size: Optional[Union[Var[int], int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + name: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_size: Optional[Union[Var[int], int]] = None, max_bar_size: Optional[Union[Var[int], int]] = None, + radius: Optional[Union[List[int], Var[Union[List[int], int]], int]] = 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[ + "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"], - ] - ] = None, - layout: Optional[ - Union[ - Var[Literal["horizontal", "vertical"]], - Literal["horizontal", "vertical"], - ] - ] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - legend_type: Optional[ - Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ], + 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, @@ -1096,58 +1090,24 @@ class Bar(Cartesian): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_animation_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animation_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Bar": """Create the component. @@ -1156,24 +1116,35 @@ 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. + 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 a bar. If no value was set to this option, the value of dataKey will be used alternatively. + 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 - is_animation_active: If set false, animation of bar will be disabled. - 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' + 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. - 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 + 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. @@ -1195,149 +1166,132 @@ class Line(Cartesian): *children, type_: Optional[ Union[ + Literal[ + "basis", + "basisClosed", + "basisOpen", + "bump", + "bumpX", + "bumpY", + "linear", + "linearClosed", + "monotone", + "monotoneX", + "monotoneY", + "natural", + "step", + "stepAfter", + "stepBefore", + ], Var[ Literal[ "basis", "basisClosed", "basisOpen", + "bump", "bumpX", "bumpY", - "bump", "linear", "linearClosed", - "natural", + "monotone", "monotoneX", "monotoneY", - "monotone", + "natural", "step", - "stepBefore", "stepAfter", + "stepBefore", ] ], - Literal[ - "basis", - "basisClosed", - "basisOpen", - "bumpX", - "bumpY", - "bump", - "linear", - "linearClosed", - "natural", - "monotoneX", - "monotoneY", - "monotone", - "step", - "stepBefore", - "stepAfter", - ], ] ] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke_width: Optional[Union[Var[int], int]] = None, dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, active_dot: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, label: Optional[Union[Var[bool], bool]] = None, hide: Optional[Union[Var[bool], bool]] = None, connect_nulls: Optional[Union[Var[bool], bool]] = None, - unit: Optional[Union[Var[Union[int, str]], str, int]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + unit: Optional[Union[Var[Union[int, str]], int, str]] = None, + 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[int, str]], str, int]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, + 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Line": """Create the component. @@ -1345,20 +1299,36 @@ class Line(Cartesian): 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. - stroke_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. - name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart. + 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. - 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 + 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. @@ -1378,73 +1348,72 @@ class Scatter(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", ], - ] - ] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - z_axis_id: Optional[Union[Var[str], str]] = None, - line: Optional[Union[Var[bool], bool]] = None, - shape: Optional[ - Union[ 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[Union[Color, str]], str, Color]] = None, - name: Optional[Union[Var[Union[int, str]], str, int]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, 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, @@ -1452,52 +1421,22 @@ class Scatter(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Scatter": """Create the component. @@ -1505,19 +1444,26 @@ class Scatter(Recharts): Args: *children: The children of the component. data: The source data, in which each element is an object. - 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' - 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. - 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 - is_animation_active: If set false, animation of bar will be disabled. - 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' + 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. @@ -1537,38 +1483,38 @@ class Funnel(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, name_key: Optional[Union[Var[str], str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, @@ -1577,68 +1523,37 @@ class Funnel(Recharts): animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + trapezoids: Optional[ + Union[List[Dict[str, Any]], Var[List[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_animation_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animation_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Funnel": """Create the component. @@ -1646,14 +1561,25 @@ class Funnel(Recharts): Args: *children: The children of the component. data: The source data, in which each element is an object. - data_key: The key of a group of data which should be unique in an area chart. - name_key: The key or getter of a group of data which should be unique in a LineChart. - legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. - is_animation_active: If set false, animation of line 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' - stroke: stroke color + 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. @@ -1673,75 +1599,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[int, str]], 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[Union[Color, str]], str, Color]] = 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, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -1761,78 +1655,48 @@ class Reference(Recharts): def create( # type: ignore cls, *children, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, - label: Optional[Union[Var[Union[int, str]], str, int]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. - 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. + 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. + 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. @@ -1852,72 +1716,42 @@ class ReferenceLine(Reference): def create( # type: ignore cls, *children, - x: Optional[Union[Var[Union[int, str]], str, int]] = None, - y: Optional[Union[Var[Union[int, str]], str, int]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - stroke_width: Optional[Union[Var[Union[int, str]], str, int]] = None, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke_width: Optional[Union[Var[Union[int, str]], int, str]] = None, segment: Optional[List[Any]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, - label: Optional[Union[Var[Union[int, str]], str, int]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ReferenceLine": """Create the component. @@ -1927,13 +1761,13 @@ class ReferenceLine(Reference): 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. stroke: The color of the reference line. - stroke_width: The width of the stroke. + 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. - y_axis_id: The id of y-axis which is corresponding to the data. - 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. + 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. + 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. @@ -1953,72 +1787,42 @@ class ReferenceDot(Reference): def create( # type: ignore cls, *children, - x: Optional[Union[Var[Union[int, str]], str, int]] = None, - y: Optional[Union[Var[Union[int, str]], str, int]] = None, + x: Optional[Union[Var[Union[int, str]], int, str]] = None, + y: Optional[Union[Var[Union[int, str]], int, str]] = None, r: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, - label: Optional[Union[Var[Union[int, str]], str, int]] = None, + label: Optional[Union[Var[Union[int, str]], int, str]] = None, is_front: Optional[Union[Var[bool], bool]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ReferenceDot": """Create the component. @@ -2030,11 +1834,19 @@ class ReferenceDot(Reference): r: The radius of dot. fill: The color of the area fill. stroke: The color of the line 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. - 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. + 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. + 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. @@ -2054,19 +1866,19 @@ class ReferenceArea(Recharts): def create( # type: ignore cls, *children, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, - x_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - y_axis_id: Optional[Union[Var[Union[int, str]], str, int]] = None, - x1: Optional[Union[Var[Union[int, str]], str, int]] = None, - x2: Optional[Union[Var[Union[int, str]], str, int]] = None, - y1: Optional[Union[Var[Union[int, str]], str, int]] = None, - y2: Optional[Union[Var[Union[int, str]], str, int]] = None, + x_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + y_axis_id: Optional[Union[Var[Union[int, str]], int, str]] = None, + x1: Optional[Union[Var[Union[int, str]], int, str]] = None, + x2: Optional[Union[Var[Union[int, str]], int, str]] = None, + y1: Optional[Union[Var[Union[int, str]], int, str]] = None, + y2: Optional[Union[Var[Union[int, str]], int, str]] = None, if_overflow: Optional[ Union[ - Var[Literal["discard", "hidden", "visible", "extendDomain"]], - Literal["discard", "hidden", "visible", "extendDomain"], + Literal["discard", "extendDomain", "hidden", "visible"], + Var[Literal["discard", "extendDomain", "hidden", "visible"]], ] ] = None, is_front: Optional[Union[Var[bool], bool]] = None, @@ -2075,52 +1887,22 @@ class ReferenceArea(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ReferenceArea": """Create the component. @@ -2136,8 +1918,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. @@ -2166,62 +1948,32 @@ class Grid(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. @@ -2244,15 +1996,15 @@ class CartesianGrid(Grid): horizontal: Optional[Union[Var[bool], bool]] = None, vertical: Optional[Union[Var[bool], bool]] = None, vertical_points: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, horizontal_points: Optional[ - Union[Var[List[Union[int, str]]], List[Union[int, str]]] + Union[List[Union[int, str]], Var[List[Union[int, str]]]] ] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, stroke_dasharray: Optional[Union[Var[str], str]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, x: Optional[Union[Var[int], int]] = None, y: Optional[Union[Var[int], int]] = None, width: Optional[Union[Var[int], int]] = None, @@ -2262,70 +2014,40 @@ class CartesianGrid(Grid): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CartesianGrid": """Create the component. Args: *children: The children of the component. - horizontal: The horizontal line configuration. - vertical: The vertical line configuration. - vertical_points: The x-coordinates in pixel values of all vertical lines. - horizontal_points: The x-coordinates in pixel values of all vertical lines. + 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 - stroke: the stroke color of 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. @@ -2347,21 +2069,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, @@ -2373,71 +2096,42 @@ class CartesianAxis(Grid): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. diff --git a/reflex/components/recharts/charts.py b/reflex/components/recharts/charts.py index 0f52545d0..85e10c2c5 100644 --- a/reflex/components/recharts/charts.py +++ b/reflex/components/recharts/charts.py @@ -8,8 +8,8 @@ from reflex.components.component import Component from reflex.components.recharts.general import ResponsiveContainer from reflex.constants import EventTriggers from reflex.constants.colors import Color -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec +from reflex.vars.base import Var from .recharts import ( LiteralAnimationEasing, @@ -31,16 +31,16 @@ class ChartBase(RechartsCharts): height: Var[Union[str, int]] = "100%" # type: ignore # The customized event handler of click on the component in this chart - on_click: EventHandler[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the component in this chart - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the component in this chart - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the component in this chart - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] @staticmethod def _ensure_valid_dimension(name: str, value: Any) -> None: @@ -84,10 +84,10 @@ class ChartBase(RechartsCharts): cls._ensure_valid_dimension("width", width) cls._ensure_valid_dimension("height", height) - dim_props = dict( - width=width or "100%", - height=height or "100%", - ) + dim_props = { + "width": width or "100%", + "height": height or "100%", + } # Provide min dimensions so the graph always appears, even if the outer container is zero-size. if width is None: dim_props["min_width"] = 200 @@ -112,10 +112,10 @@ class CategoricalChartBase(ChartBase): # 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 + # 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' + # 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' @@ -129,7 +129,7 @@ class AreaChart(CategoricalChartBase): 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]] # Valid children components @@ -155,11 +155,11 @@ class BarChart(CategoricalChartBase): 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]] = Var.create_safe("10%", _var_is_string=True) # 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]] = Var.create_safe(4) # 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] @@ -167,10 +167,10 @@ class BarChart(CategoricalChartBase): # 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 @@ -217,19 +217,19 @@ class ComposedChart(CategoricalChartBase): 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 - bar_gap: Var[Union[str, int]] # type: ignore + # 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 @@ -270,16 +270,16 @@ class PieChart(ChartBase): ] # The customized event handler of mousedown on the sectors in this group - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the sectors in this group - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the sectors in this group - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the sectors in this group - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] class RadarChart(ChartBase): @@ -292,25 +292,25 @@ class RadarChart(ChartBase): # 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}. + # 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 + # 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 @@ -330,9 +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_LEAVE: lambda: [], + EventTriggers.ON_CLICK: no_args_event_spec, + EventTriggers.ON_MOUSE_ENTER: no_args_event_spec, + EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec, } @@ -346,31 +346,31 @@ class RadialBarChart(ChartBase): # The source data 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}. + # 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 + # 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. @@ -394,7 +394,7 @@ class ScatterChart(ChartBase): alias = "RechartsScatterChart" - # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5} margin: Var[Dict[str, Any]] # Valid children components @@ -419,14 +419,14 @@ 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_DOWN: lambda: [], - EventTriggers.ON_MOUSE_UP: 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: no_args_event_spec, + EventTriggers.ON_MOUSE_DOWN: no_args_event_spec, + EventTriggers.ON_MOUSE_UP: no_args_event_spec, + EventTriggers.ON_MOUSE_MOVE: no_args_event_spec, + EventTriggers.ON_MOUSE_OVER: no_args_event_spec, + EventTriggers.ON_MOUSE_OUT: no_args_event_spec, + EventTriggers.ON_MOUSE_ENTER: no_args_event_spec, + EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec, } @@ -437,10 +437,10 @@ class FunnelChart(ChartBase): alias = "RechartsFunnelChart" - # The layout of bars in the chart. centeric + # The layout of bars in the chart. Default: "centric" layout: Var[str] - # The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + # The sizes of whitespace around the chart. Default: {"top": 5, "right": 5, "bottom": 5, "left": 5} margin: Var[Dict[str, Any]] # The stroke color of each bar. String | Object @@ -457,38 +457,41 @@ 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[lambda: []] + on_animation_start: EventHandler[no_args_event_spec] # The customized event handler of animation end - on_animation_end: EventHandler[lambda: []] + on_animation_end: EventHandler[no_args_event_spec] @classmethod def create(cls, *children, **props) -> Component: diff --git a/reflex/components/recharts/charts.pyi b/reflex/components/recharts/charts.pyi index 9984bd8c5..6bf9b6a60 100644 --- a/reflex/components/recharts/charts.pyi +++ b/reflex/components/recharts/charts.pyi @@ -3,16 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.constants.colors import Color -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from .recharts import ( - RechartsCharts, -) +from .recharts import RechartsCharts class ChartBase(RechartsCharts): @overload @@ -20,59 +18,29 @@ class ChartBase(RechartsCharts): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ChartBase": """Create a chart component. @@ -81,6 +49,10 @@ class ChartBase(RechartsCharts): *children: The children of the chart component. 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. @@ -100,77 +72,47 @@ class CategoricalChartBase(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "CategoricalChartBase": """Create a chart component. @@ -180,11 +122,15 @@ class CategoricalChartBase(ChartBase): 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 - layout: The layout of area in the chart. 'horizontal' | 'vertical' + 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. @@ -206,97 +152,71 @@ class AreaChart(CategoricalChartBase): *children, base_value: Optional[ Union[ - Var[Union[Literal["dataMin", "dataMax", "auto"], int]], + Literal["auto", "dataMax", "dataMin"], + Var[Union[Literal["auto", "dataMax", "dataMin"], int]], int, - Literal["dataMin", "dataMax", "auto"], ] ] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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' + 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 - layout: The layout of area in the chart. 'horizontal' | 'vertical' + 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. @@ -316,101 +236,75 @@ class BarChart(CategoricalChartBase): def create( # type: ignore cls, *children, - bar_category_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, - bar_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, + bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, + bar_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_size: Optional[Union[Var[int], int]] = None, max_bar_size: Optional[Union[Var[int], int]] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, reverse_stack_order: Optional[Union[Var[bool], bool]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 - layout: The layout of area in the chart. 'horizontal' | 'vertical' + 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. + 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. @@ -430,77 +324,47 @@ class LineChart(CategoricalChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "LineChart": """Create a chart component. @@ -510,11 +374,15 @@ class LineChart(CategoricalChartBase): 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 - layout: The layout of area in the chart. 'horizontal' | 'vertical' + 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. @@ -536,105 +404,79 @@ class ComposedChart(CategoricalChartBase): *children, base_value: Optional[ Union[ - Var[Union[Literal["dataMin", "dataMax", "auto"], int]], + Literal["auto", "dataMax", "dataMin"], + Var[Union[Literal["auto", "dataMax", "dataMin"], int]], int, - Literal["dataMin", "dataMax", "auto"], ] ] = None, - bar_category_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, - bar_gap: Optional[Union[Var[Union[int, str]], str, int]] = None, + bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, + bar_gap: Optional[Union[Var[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, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, sync_id: Optional[Union[Var[str], str]] = None, sync_method: Optional[ - Union[Var[Literal["index", "value"]], Literal["index", "value"]] + Union[Literal["index", "value"], Var[Literal["index", "value"]]] ] = None, layout: Optional[ Union[ - Var[Literal["horizontal", "vertical"]], Literal["horizontal", "vertical"], + Var[Literal["horizontal", "vertical"]], ] ] = None, stack_offset: Optional[ Union[ - Var[Literal["expand", "none", "wiggle", "silhouette"]], - Literal["expand", "none", "wiggle", "silhouette"], + Literal["expand", "none", "silhouette", "wiggle"], + Var[Literal["expand", "none", "silhouette", "wiggle"]], ] ] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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 - layout: The layout of area in the chart. 'horizontal' | 'vertical' + 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. @@ -654,60 +496,30 @@ class PieChart(ChartBase): def create( # type: ignore cls, *children, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "PieChart": """Create a chart component. @@ -715,8 +527,16 @@ class PieChart(ChartBase): Args: *children: The children of the chart component. 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. + 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. @@ -737,31 +557,25 @@ class RadarChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, start_angle: Optional[Union[Var[int], int]] = None, end_angle: Optional[Union[Var[int], int]] = None, inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, outer_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, 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, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadarChart": """Create a chart component. @@ -769,15 +583,18 @@ class RadarChart(ChartBase): 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}. - 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 + 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. + 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. @@ -797,8 +614,8 @@ class RadialBarChart(ChartBase): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, start_angle: Optional[Union[Var[int], int]] = None, @@ -808,59 +625,29 @@ class RadialBarChart(ChartBase): bar_category_gap: Optional[Union[Var[Union[int, str]], int, str]] = None, bar_gap: Optional[Union[Var[str], str]] = None, bar_size: Optional[Union[Var[int], int]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadialBarChart": """Create a chart component. @@ -868,18 +655,22 @@ class RadialBarChart(ChartBase): Args: *children: The children of the chart component. data: The source data which each element is an object. - margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "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 - 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 + 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. 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. @@ -900,48 +691,36 @@ class ScatterChart(ChartBase): def create( # type: ignore cls, *children, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, 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, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ScatterChart": """Create a chart component. Args: *children: The children of the chart component. - margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + 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. + 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. @@ -962,72 +741,46 @@ class FunnelChart(ChartBase): cls, *children, layout: Optional[Union[Var[str], str]] = None, - margin: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, + margin: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "FunnelChart": """Create a chart component. Args: *children: The children of the chart component. - layout: The layout of bars in the chart. centeric - margin: The sizes of whitespace around the chart, i.e. {"top": 50, "right": 30, "left": 20, "bottom": 5}. + 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. + 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. @@ -1047,18 +800,19 @@ class Treemap(RechartsCharts): def create( # type: ignore cls, *children, - width: Optional[Union[Var[Union[int, str]], str, int]] = None, - height: Optional[Union[Var[Union[int, str]], str, int]] = None, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + width: Optional[Union[Var[Union[int, str]], int, str]] = None, + height: Optional[Union[Var[Union[int, str]], int, str]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + 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, @@ -1066,73 +820,42 @@ class Treemap(RechartsCharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_animation_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animation_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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. diff --git a/reflex/components/recharts/general.py b/reflex/components/recharts/general.py index 613e6fbf0..1769ea125 100644 --- a/reflex/components/recharts/general.py +++ b/reflex/components/recharts/general.py @@ -6,8 +6,8 @@ from typing import Any, Dict, List, Union from reflex.components.component import MemoizationLeaf from reflex.constants.colors import Color -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, @@ -30,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[no_args_event_spec] + # Valid children components _valid_children: List[str] = [ "AreaChart", @@ -73,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] @@ -98,28 +104,28 @@ class Legend(Recharts): margin: Var[Dict[str, Any]] # The customized event handler of click on the items in this group - on_click: EventHandler[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the items in this group - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the items in this group - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the items in this group - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the items in this group - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the items in this group - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of mouseenter on the items in this group - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the items in this group - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class GraphingTooltip(Recharts): @@ -129,17 +135,17 @@ class GraphingTooltip(Recharts): alias = "RechartsTooltip" - # The separator between name and value. + # The separator between name and value. Default: ":" separator: Var[str] - # The offset size of tooltip. Number + # The offset size of tooltip. Number. Default: 10 offset: Var[int] - # When an item of the payload has value null or undefined, this item won't be displayed. + # When an item of the payload has value null or undefined, this item won't be displayed. Default: True filter_null: Var[bool] - # If set false, no cursor will be drawn when tooltip is active. - cursor: Var[Union[Dict[str, Any], bool]] = Var.create_safe( + # If set false, no cursor will be drawn when tooltip is active. Default: {"strokeWidth": 1, "fill": rx.color("gray", 3)} + cursor: Var[Union[Dict[str, Any], bool]] = LiteralVar.create( { "strokeWidth": 1, "fill": Color("gray", 3), @@ -149,17 +155,18 @@ class GraphingTooltip(Recharts): # 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]] = Var.create_safe( + # The style of default tooltip content item which is a li element. Default: {"color": rx.color("gray", 12)} + item_style: Var[Dict[str, Any]] = LiteralVar.create( { "color": Color("gray", 12), } ) - # The style of tooltip wrapper which is a dom element. DEFAULT: {} + # 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]] = Var.create_safe( + + # The style of tooltip content which is a dom element. Default: {"background": rx.color("gray", 1), "borderColor": rx.color("gray", 4), "borderRadius": "8px"} + content_style: Var[Dict[str, Any]] = LiteralVar.create( { "background": Color("gray", 1), "borderColor": Color("gray", 4), @@ -167,30 +174,28 @@ class GraphingTooltip(Recharts): } ) - # The style of default tooltip label which is a p element. DEFAULT: {} - label_style: Var[Dict[str, Any]] = Var.create_safe({"color": Color("gray", 11)}) + # The style of default tooltip label which is a p element. Default: {"color": rx.color("gray", 11)} + 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]] = Var.create_safe( - {"x": False, "y": False} - ) + # 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]] - # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. + # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. Default: False active: Var[bool] # If this field is set, the tooltip position will be fixed and will not move anymore. position: Var[Dict[str, Any]] - # The coordinate of tooltip which is usually calculated internally. + # The coordinate of tooltip which is usually calculated internally. Default: {"x": 0, "y": 0} coordinate: Var[Dict[str, Any]] - # If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR + # If set false, animation of tooltip will be disabled. Default: True is_animation_active: Var[bool] - # Specifies the duration of animation, the unit of this option is ms. DEFAULT: 1500 + # 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' + # The type of easing function. Default: "ease" animation_easing: Var[LiteralAnimationEasing] @@ -224,17 +229,17 @@ 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] - # The fill color of each label - fill: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10)) + # The fill color of each label. Default: rx.color("gray", 10) + fill: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 10)) - # The stroke color of each label - stroke: Var[Union[str, Color]] = Var.create_safe("none", _var_is_string=True) + # The stroke color of each label. Default: "none" + stroke: Var[Union[str, Color]] = LiteralVar.create("none") responsive_container = ResponsiveContainer.create diff --git a/reflex/components/recharts/general.pyi b/reflex/components/recharts/general.pyi index 9dd2ae19c..823a50fce 100644 --- a/reflex/components/recharts/general.pyi +++ b/reflex/components/recharts/general.pyi @@ -3,17 +3,15 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.components.component import MemoizationLeaf from reflex.constants.colors import Color -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from .recharts import ( - Recharts, -) +from .recharts import Recharts class ResponsiveContainer(Recharts, MemoizationLeaf): @overload @@ -32,52 +30,23 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_resize: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "ResponsiveContainer": """Create a new memoization leaf component. @@ -85,11 +54,12 @@ class ResponsiveContainer(Recharts, MemoizationLeaf): 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. @@ -113,107 +83,80 @@ 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_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Legend": """Create the component. @@ -222,14 +165,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. @@ -253,25 +205,25 @@ class GraphingTooltip(Recharts): offset: Optional[Union[Var[int], int]] = None, filter_null: Optional[Union[Var[bool], bool]] = None, cursor: Optional[ - Union[Var[Union[Dict[str, Any], bool]], Dict[str, Any], bool] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, - view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - item_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - wrapper_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - content_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - label_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + view_box: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + item_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + wrapper_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + content_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + label_style: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, allow_escape_view_box: Optional[ - Union[Var[Dict[str, bool]], Dict[str, bool]] + Union[Dict[str, bool], Var[Dict[str, bool]]] ] = None, active: Optional[Union[Var[bool], bool]] = None, - position: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, - coordinate: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + position: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, + coordinate: Optional[Union[Dict[str, Any], Var[Dict[str, Any]]]] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, @@ -279,74 +231,44 @@ class GraphingTooltip(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "GraphingTooltip": """Create the component. Args: *children: The children of the component. - separator: The separator between name and value. - offset: The offset size of tooltip. Number - 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. + separator: The separator between name and value. Default: ":" + offset: The offset size of tooltip. Number. Default: 10 + filter_null: When an item of the payload has value null or undefined, this item won't be displayed. Default: True + cursor: If set false, no cursor will be drawn when tooltip is active. Default: {"strokeWidth": 1, "fill": rx.color("gray", 3)} 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. + item_style: The style of default tooltip content item which is a li element. Default: {"color": rx.color("gray", 12)} + 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: {"background": rx.color("gray", 1), "borderColor": rx.color("gray", 4), "borderRadius": "8px"} + label_style: The style of default tooltip label which is a p element. Default: {"color": rx.color("gray", 11)} + 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. Default: False 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' + coordinate: The coordinate of tooltip which is usually calculated internally. Default: {"x": 0, "y": 0} + is_animation_active: If set false, animation of tooltip will be disabled. Default: True + 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. @@ -366,52 +288,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, @@ -420,52 +342,22 @@ class Label(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Label": """Create the component. @@ -495,107 +387,77 @@ class LabelList(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, position: Optional[ Union[ - Var[ - Literal[ - "top", - "left", - "right", - "bottom", - "inside", - "outside", - "insideLeft", - "insideRight", - "insideTop", - "insideBottom", - "insideTopLeft", - "insideBottomLeft", - "insideTopRight", - "insideBottomRight", - "insideStart", - "insideEnd", - "end", - "center", - ] - ], Literal[ - "top", - "left", - "right", "bottom", + "center", + "end", "inside", - "outside", + "insideBottom", + "insideBottomLeft", + "insideBottomRight", + "insideEnd", "insideLeft", "insideRight", - "insideTop", - "insideBottom", - "insideTopLeft", - "insideBottomLeft", - "insideTopRight", - "insideBottomRight", "insideStart", - "insideEnd", - "end", - "center", + "insideTop", + "insideTopLeft", + "insideTopRight", + "left", + "outside", + "right", + "top", + ], + Var[ + Literal[ + "bottom", + "center", + "end", + "inside", + "insideBottom", + "insideBottomLeft", + "insideBottomRight", + "insideEnd", + "insideLeft", + "insideRight", + "insideStart", + "insideTop", + "insideTopLeft", + "insideTopRight", + "left", + "outside", + "right", + "top", + ] ], ] ] = None, offset: Optional[Union[Var[int], int]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "LabelList": """Create the component. @@ -603,10 +465,10 @@ class LabelList(Recharts): 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: The fill color of each label - stroke: The stroke color of each label + 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. diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index 64fa00ecd..1f4974d4c 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -6,13 +6,14 @@ from typing import Any, Dict, List, Union from reflex.constants import EventTriggers from reflex.constants.colors import Color -from reflex.event import EventHandler -from reflex.vars import Var +from reflex.event import EventHandler, no_args_event_spec +from reflex.vars.base import LiteralVar, Var from .recharts import ( LiteralAnimationEasing, LiteralGridType, LiteralLegendType, + LiteralOrientationLeftRightMiddle, LiteralPolarRadiusType, LiteralScale, Recharts, @@ -26,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. + # 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"] - # Stoke color - stroke: Var[Union[str, Color]] = Var.create_safe(Color("accent", 9)) + # Stoke color. Default: rx.color("accent", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # Fill color - fill: Var[Union[str, Color]] = Var.create_safe(Color("accent", 3)) + # 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. @@ -84,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: no_args_event_spec, + EventTriggers.ON_ANIMATION_END: no_args_event_spec, + EventTriggers.ON_CLICK: no_args_event_spec, + EventTriggers.ON_MOUSE_MOVE: no_args_event_spec, + EventTriggers.ON_MOUSE_OVER: no_args_event_spec, + EventTriggers.ON_MOUSE_OUT: no_args_event_spec, + EventTriggers.ON_MOUSE_ENTER: no_args_event_spec, + EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec, } @@ -103,39 +124,53 @@ class Radar(Recharts): # The key of a group of data which should be unique in a radar chart. data_key: Var[Union[str, int]] - # The coordinates of all the vertexes of the radar shape, like [{ x, y }]. + # The coordinates of all the vertices 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[Union[str, Color]] = Var.create_safe(Color("accent", 9)) + # Stoke color. Default: rx.color("accent", 9) + stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9)) - # Fill color - fill: Var[str] = Var.create_safe(Color("accent", 3)) + # Fill color. Default: rx.color("accent", 3) + fill: Var[str] = LiteralVar.create(Color("accent", 3)) - # opacity - fill_opacity: Var[float] = Var.create_safe(0.6) + # The opacity to fill the chart. 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: no_args_event_spec, + EventTriggers.ON_ANIMATION_END: no_args_event_spec, + } + class RadialBar(Recharts): """A RadialBar chart component in Recharts.""" @@ -144,31 +179,34 @@ class RadialBar(Recharts): alias = "RechartsRadialBar" + # The source data which each element is an object. + data: Var[List[Dict[str, Any]]] + # 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. + # 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. + # 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. + # 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. By default true in CSR, and false in SSR + # 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. By default 0 + # 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. By default 1500 + # 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'. By default 'ease' + # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease" animation_easing: Var[LiteralAnimationEasing] # Valid children components @@ -181,14 +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_ANIMATION_START: lambda: [], - EventTriggers.ON_ANIMATION_END: lambda: [], + EventTriggers.ON_CLICK: no_args_event_spec, + EventTriggers.ON_MOUSE_MOVE: no_args_event_spec, + EventTriggers.ON_MOUSE_OVER: no_args_event_spec, + EventTriggers.ON_MOUSE_OUT: no_args_event_spec, + EventTriggers.ON_MOUSE_ENTER: no_args_event_spec, + EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec, + EventTriggers.ON_ANIMATION_START: no_args_event_spec, + EventTriggers.ON_ANIMATION_END: no_args_event_spec, } @@ -211,56 +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]]] = Var.create_safe(False) + # 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] - # The stroke color of axis - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10)) + # 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". + # 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: List[str] = ["Label"] # The customized event handler of click on the ticks of this axis. - on_click: EventHandler[lambda: []] + on_click: EventHandler[no_args_event_spec] # The customized event handler of mousedown on the the ticks of this axis. - on_mouse_down: EventHandler[lambda: []] + on_mouse_down: EventHandler[no_args_event_spec] # The customized event handler of mouseup on the ticks of this axis. - on_mouse_up: EventHandler[lambda: []] + on_mouse_up: EventHandler[no_args_event_spec] # The customized event handler of mousemove on the ticks of this axis. - on_mouse_move: EventHandler[lambda: []] + on_mouse_move: EventHandler[no_args_event_spec] # The customized event handler of mouseover on the ticks of this axis. - on_mouse_over: EventHandler[lambda: []] + on_mouse_over: EventHandler[no_args_event_spec] # The customized event handler of mouseout on the ticks of this axis. - on_mouse_out: EventHandler[lambda: []] + on_mouse_out: EventHandler[no_args_event_spec] # The customized event handler of moustenter on the ticks of this axis. - on_mouse_enter: EventHandler[lambda: []] + on_mouse_enter: EventHandler[no_args_event_spec] # The customized event handler of mouseleave on the ticks of this axis. - on_mouse_leave: EventHandler[lambda: []] + on_mouse_leave: EventHandler[no_args_event_spec] class PolarGrid(Recharts): @@ -270,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]] @@ -288,11 +326,11 @@ 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 - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10)) + # 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"] @@ -305,47 +343,47 @@ 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 function 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. - domain: Var[List[int]] = Var.create_safe([0, 250]) + # 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 - stroke: Var[Union[str, Color]] = Var.create_safe(Color("gray", 10)) + # 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. @@ -354,12 +392,12 @@ 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: no_args_event_spec, + EventTriggers.ON_MOUSE_MOVE: no_args_event_spec, + EventTriggers.ON_MOUSE_OVER: no_args_event_spec, + EventTriggers.ON_MOUSE_OUT: no_args_event_spec, + EventTriggers.ON_MOUSE_ENTER: no_args_event_spec, + EventTriggers.ON_MOUSE_LEAVE: no_args_event_spec, } diff --git a/reflex/components/recharts/polar.pyi b/reflex/components/recharts/polar.pyi index d91186296..5388fbcf2 100644 --- a/reflex/components/recharts/polar.pyi +++ b/reflex/components/recharts/polar.pyi @@ -3,16 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Union, overload from reflex.constants.colors import Color -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var -from .recharts import ( - Recharts, -) +from .recharts import Recharts class Pie(Recharts): def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ... @@ -21,8 +19,8 @@ class Pie(Recharts): def create( # type: ignore cls, *children, - data: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, @@ -34,86 +32,91 @@ class Pie(Recharts): name_key: Optional[Union[Var[str], str]] = None, legend_type: Optional[ Union[ - Var[ - Literal[ - "line", - "plainline", - "square", - "rect", - "circle", - "cross", - "diamond", - "star", - "triangle", - "wye", - "none", - ] - ], Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "none", + "plainline", + "rect", + "square", "star", "triangle", "wye", - "none", + ], + Var[ + Literal[ + "circle", + "cross", + "diamond", + "line", + "none", + "plainline", + "rect", + "square", + "star", + "triangle", + "wye", + ] ], ] ] = None, label: Optional[Union[Var[bool], bool]] = None, label_line: Optional[Union[Var[bool], bool]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, - fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + fill: Optional[Union[Color, Var[Union[Color, str]], str]] = None, + 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, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = 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. - stroke: Stoke color - fill: Fill 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. @@ -128,25 +131,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[int, str]], str, int]] = None, - points: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, + points: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, dot: Optional[Union[Var[bool], bool]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, fill: Optional[Union[Var[str], str]] = None, fill_opacity: Optional[Union[Var[float], float]] = None, - legend_type: Optional[Union[Var[str], str]] = None, + 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, @@ -154,52 +190,9 @@ class Radar(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Radar": """Create the component. @@ -207,16 +200,17 @@ class Radar(Recharts): Args: *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' + points: The coordinates of all the vertices of the radar shape, like [{ x, y }]. + 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: The opacity to fill the chart. 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. @@ -237,22 +231,54 @@ class RadialBar(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, min_angle: Optional[Union[Var[int], int]] = 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[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, background: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, is_animation_active: Optional[Union[Var[bool], bool]] = None, animation_begin: Optional[Union[Var[int], int]] = None, animation_duration: Optional[Union[Var[int], int]] = None, animation_easing: Optional[ Union[ - Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], - Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"], + Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]], ] ] = None, style: Optional[Style] = None, @@ -260,46 +286,31 @@ class RadialBar(Recharts): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_animation_end: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_animation_start: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[EventType[[], BASE_STATE]] = None, + on_animation_start: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RadialBar": """Create the component. Args: *children: The children of the component. + data: The source data which each element is an object. 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. - legend_type: Type of legend - label: If false set, labels will not be drawn. - background: If false set, background sector will not be drawn. - is_animation_active: If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR - animation_begin: Specifies when the animation should begin, the unit of this option is ms. By default 0 - animation_duration: Specifies the duration of animation, the unit of this option is ms. By default 1500 - animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease' + 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. @@ -319,73 +330,47 @@ class PolarAngleAxis(Recharts): def create( # type: ignore cls, *children, - data_key: Optional[Union[Var[Union[int, str]], str, int]] = None, + data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, cx: Optional[Union[Var[Union[int, str]], int, str]] = None, cy: Optional[Union[Var[Union[int, str]], int, str]] = None, radius: Optional[Union[Var[Union[int, str]], int, str]] = None, axis_line: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] + ] = None, + axis_line_type: Optional[ + Union[Literal["circle", "polygon"], Var[Literal["circle", "polygon"]]] ] = None, - axis_line_type: Optional[Union[Var[str], str]] = None, tick_line: Optional[ - Union[Var[Union[Dict[str, Any], bool]], bool, Dict[str, Any]] + Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] ] = None, - tick: Optional[Union[Var[Union[int, str]], int, str]] = None, - ticks: Optional[Union[Var[List[Dict[str, Any]]], List[Dict[str, Any]]]] = None, - orient: Optional[Union[Var[str], str]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = 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, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "PolarAngleAxis": """Create the component. @@ -396,14 +381,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. - stroke: The stroke color of axis - 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. @@ -423,81 +416,51 @@ class PolarGrid(Recharts): 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, - inner_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, - outer_radius: Optional[Union[Var[Union[int, str]], int, str]] = None, - polar_angles: Optional[Union[Var[List[int]], List[int]]] = None, - polar_radius: Optional[Union[Var[List[int]], List[int]]] = None, + 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[Var[Union[Color, str]], str, Color]] = None, + stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = 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' - stroke: The stroke color of grid + 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. @@ -520,103 +483,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]], int, str]] = None, - cy: Optional[Union[Var[Union[int, str]], 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[Dict[str, Any], bool]], 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]], int, str]] = None, tick_count: Optional[Union[Var[int], int]] = None, scale: Optional[ Union[ + Literal[ + "auto", + "band", + "identity", + "linear", + "log", + "ordinal", + "point", + "pow", + "quantile", + "quantize", + "sequential", + "sqrt", + "threshold", + "time", + "utc", + ], Var[ Literal[ "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", "band", - "point", + "identity", + "linear", + "log", "ordinal", + "point", + "pow", "quantile", "quantize", - "utc", "sequential", + "sqrt", "threshold", + "time", + "utc", ] ], - Literal[ - "auto", - "linear", - "pow", - "sqrt", - "log", - "identity", - "time", - "band", - "point", - "ordinal", - "quantile", - "quantize", - "utc", - "sequential", - "threshold", - ], ] ] = None, - domain: Optional[Union[Var[List[int]], List[int]]] = None, - stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None, + domain: Optional[ + Union[List[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, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = 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' - domain: The domain of the polar radius axis, specifying the minimum and maximum values. - stroke: The stroke color of axis + 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 function 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. diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py index adb7bfdf9..b5a4ed113 100644 --- a/reflex/components/recharts/recharts.py +++ b/reflex/components/recharts/recharts.py @@ -3,33 +3,21 @@ 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.12.7" + 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 + def _get_style(self) -> Dict: + return {"wrapperStyle": self.style} class RechartsCharts(NoSSRComponent, MemoizationLeaf): """A component that wraps a recharts lib.""" - library = "recharts@2.12.7" + library = "recharts@2.13.0" LiteralAnimationEasing = Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"] @@ -60,6 +48,7 @@ LiteralScale = Literal[ "sequential", "threshold", ] +LiteralTextAnchor = Literal["start", "middle", "end"] LiteralLayout = Literal["horizontal", "vertical"] LiteralPolarRadiusType = Literal["number", "category"] LiteralGridType = Literal["polygon", "circle"] @@ -131,6 +120,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 409285eb5..65e65bce1 100644 --- a/reflex/components/recharts/recharts.pyi +++ b/reflex/components/recharts/recharts.pyi @@ -3,15 +3,14 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, Literal, Optional, Union, overload +from typing import Any, Dict, Literal, Optional, Union, overload from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Recharts(Component): - def render(self) -> Dict: ... @overload @classmethod def create( # type: ignore @@ -22,52 +21,22 @@ class Recharts(Component): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Recharts": """Create the component. @@ -98,52 +67,22 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "RechartsCharts": """Create a new memoization leaf component. @@ -191,6 +130,7 @@ LiteralScale = Literal[ "sequential", "threshold", ] +LiteralTextAnchor = Literal["start", "middle", "end"] LiteralLayout = Literal["horizontal", "vertical"] LiteralPolarRadiusType = Literal["number", "category"] LiteralGridType = Literal["polygon", "circle"] @@ -262,6 +202,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 e00eaad4e..836c19bf9 100644 --- a/reflex/components/sonner/toast.py +++ b/reflex/components/sonner/toast.py @@ -4,21 +4,19 @@ from __future__ import annotations from typing import Any, ClassVar, Literal, Optional, Union -from pydantic import ValidationError - from reflex.base import Base from reflex.components.component import Component, ComponentNamespace from reflex.components.lucide.icon import Icon -from reflex.components.props import PropsBase -from reflex.event import ( - EventSpec, - call_script, -) +from reflex.components.props import NoExtrasAllowedProps, PropsBase +from reflex.event import EventSpec, run_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, serializer -from reflex.vars import Var, VarData +from reflex.utils.serializers import serializer +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionVar +from reflex.vars.object import ObjectVar LiteralPosition = Literal[ "top-left", @@ -29,7 +27,7 @@ LiteralPosition = Literal[ "bottom-right", ] -toast_ref = Var.create_safe("refs['__toast']", _var_is_string=False) +toast_ref = Var(_js_expr="refs['__toast']") class ToastAction(Base): @@ -65,16 +63,18 @@ def _toast_callback_signature(toast: Var) -> list[Var]: A function call stripping non-serializable members of the toast object. """ return [ - Var.create_safe( - f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {toast}; return rest}})()", - _var_is_string=False, + Var( + _js_expr=f"(() => {{let {{action, cancel, onDismiss, onAutoClose, ...rest}} = {toast!s}; 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: Optional[Union[str, Var]] @@ -98,7 +98,7 @@ class ToastProps(PropsBase): # TODO: fix serialization of icons for toast? (might not be possible yet) # Icon displayed in front of toast's text, aligned vertically. - # icon: Optional[Icon] = None + # icon: Optional[Icon] = None # noqa: ERA001 # TODO: fix implementation for action / cancel buttons # Renders a primary button, clicking it will close the toast. @@ -116,6 +116,9 @@ class ToastProps(PropsBase): # Custom style for the toast. style: Optional[Style] + # Class name for the toast. + class_name: Optional[str] + # XXX: These still do not seem to work # Custom style for the toast primary button. action_button_styles: Optional[Style] @@ -129,24 +132,6 @@ class ToastProps(PropsBase): # Function that gets called when the toast disappears automatically after it's timeout (duration` prop). on_auto_close: Optional[Any] - def __init__(self, **kwargs): - """Initialize the props. - - Args: - kwargs: Kwargs to initialize the props. - - Raises: - ValueError: If invalid props are passed on instantiation. - """ - 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 ValueError( - f"Invalid prop(s) {invalid_fields} for rx.toast. Supported props are {supported_props_str}" - ) from None - def dict(self, *args, **kwargs) -> dict[str, Any]: """Convert the object to a dictionary. @@ -168,28 +153,21 @@ class ToastProps(PropsBase): d["cancel"] = self.cancel if isinstance(self.cancel, dict): d["cancel"] = ToastAction(**self.cancel) - if "on_dismiss" in d: - d["on_dismiss"] = format.format_queue_events( + if "onDismiss" in d: + d["onDismiss"] = format.format_queue_events( self.on_dismiss, _toast_callback_signature ) - if "on_auto_close" in d: - d["on_auto_close"] = format.format_queue_events( + if "onAutoClose" in d: + d["onAutoClose"] = format.format_queue_events( self.on_auto_close, _toast_callback_signature ) return d - class Config: - """Pydantic config.""" - - arbitrary_types_allowed = True - use_enum_values = True - extra = "forbid" - class Toaster(Component): """A Toaster Component for displaying toast notifications.""" - library: str = "sonner@1.4.41" + library: str = "sonner@1.5.0" tag = "Toaster" @@ -197,21 +175,19 @@ class Toaster(Component): 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", _var_is_string=True - ) + 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] @@ -246,13 +222,11 @@ class Toaster(Component): Returns: The hooks for the toaster component. """ - hook = Var.create_safe( - f"{toast_ref} = toast", - _var_is_local=True, - _var_is_string=False, + hook = Var( + _js_expr=f"{toast_ref} = toast", _var_data=VarData( imports={ - "/utils/state": [ImportVar(tag="refs")], + "$/utils/state": [ImportVar(tag="refs")], self.library: [ImportVar(tag="toast", install=False)], } ), @@ -260,7 +234,9 @@ class Toaster(Component): return [hook] @staticmethod - def send_toast(message: str = "", level: str | None = None, **props) -> EventSpec: + def send_toast( + message: str | Var = "", level: str | None = None, **props + ) -> EventSpec: """Send a toast message. Args: @@ -278,20 +254,27 @@ class Toaster(Component): 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)) # type: ignore - toast = f"{toast_command}(`{message}`, {args})" - else: - toast = f"{toast_command}(`{message}`)" - toast_action = Var.create_safe(toast, _var_is_string=False, _var_is_local=True) - return call_script(toast_action) + toast_command = ( + ObjectVar.__getattr__(toast_ref.to(dict), level) if level else toast_ref + ).to(FunctionVar) + + if isinstance(message, Var): + props.setdefault("title", message) + message = "" + elif message == "" and "title" not in props and "description" not in props: + raise ValueError("Toast message or title or description must be provided.") + + if props: + args = LiteralVar.create(ToastProps(component_name="rx.toast", **props)) # pyright: ignore [reportCallIssue, reportGeneralTypeIssues] + toast = toast_command.call(message, args) + else: + toast = toast_command.call(message) + + return run_script(toast) @staticmethod - def toast_info(message: str, **kwargs): + def toast_info(message: str | Var = "", **kwargs): """Display an info toast message. Args: @@ -304,7 +287,7 @@ class Toaster(Component): return Toaster.send_toast(message, level="info", **kwargs) @staticmethod - def toast_warning(message: str, **kwargs): + def toast_warning(message: str | Var = "", **kwargs): """Display a warning toast message. Args: @@ -317,7 +300,7 @@ class Toaster(Component): return Toaster.send_toast(message, level="warning", **kwargs) @staticmethod - def toast_error(message: str, **kwargs): + def toast_error(message: str | Var = "", **kwargs): """Display an error toast message. Args: @@ -330,7 +313,7 @@ class Toaster(Component): return Toaster.send_toast(message, level="error", **kwargs) @staticmethod - def toast_success(message: str, **kwargs): + def toast_success(message: str | Var = "", **kwargs): """Display a success toast message. Args: @@ -355,19 +338,16 @@ class Toaster(Component): dismiss_var_data = None if isinstance(id, Var): - dismiss = f"{toast_ref}.dismiss({id._var_name_unwrapped})" - dismiss_var_data = id._var_data + dismiss = f"{toast_ref}.dismiss({id!s})" + dismiss_var_data = id._get_all_var_data() elif isinstance(id, str): dismiss = f"{toast_ref}.dismiss('{id}')" else: dismiss = f"{toast_ref}.dismiss()" - dismiss_action = Var.create_safe( - dismiss, - _var_is_string=False, - _var_is_local=True, - _var_data=dismiss_var_data, + dismiss_action = Var( + _js_expr=dismiss, _var_data=VarData.merge(dismiss_var_data) ) - return call_script(dismiss_action) + return run_script(dismiss_action) @classmethod def create(cls, *children, **props) -> Component: @@ -384,9 +364,7 @@ class Toaster(Component): return super().create(*children, **props) -# TODO: figure out why loading toast stay open forever -# def toast_loading(message: str, **kwargs): -# return _toast(message, level="loading", **kwargs) +# TODO: figure out why loading toast stay open forever when using level="loading" in toast() class ToastNamespace(ComponentNamespace): @@ -399,7 +377,6 @@ class ToastNamespace(ComponentNamespace): error = staticmethod(Toaster.toast_error) success = staticmethod(Toaster.toast_success) dismiss = staticmethod(Toaster.toast_dismiss) - # loading = staticmethod(toast_loading) __call__ = staticmethod(Toaster.send_toast) diff --git a/reflex/components/sonner/toast.pyi b/reflex/components/sonner/toast.pyi index c7e626915..7fd9fdf54 100644 --- a/reflex/components/sonner/toast.pyi +++ b/reflex/components/sonner/toast.pyi @@ -3,16 +3,16 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, ClassVar, Dict, Literal, Optional, Union, overload +from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload from reflex.base import Base from reflex.components.component import Component, ComponentNamespace from reflex.components.lucide.icon import Icon -from reflex.components.props import PropsBase -from reflex.event import EventHandler, EventSpec +from reflex.components.props import NoExtrasAllowedProps, PropsBase +from reflex.event import BASE_STATE, EventSpec, EventType from reflex.style import Style from reflex.utils.serializers import serializer -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var LiteralPosition = Literal[ "top-left", @@ -22,7 +22,7 @@ LiteralPosition = Literal[ "bottom-center", "bottom-right", ] -toast_ref = Var.create_safe("refs['__toast']", _var_is_string=False) +toast_ref = Var(_js_expr="refs['__toast']") class ToastAction(Base): label: str @@ -31,7 +31,8 @@ class ToastAction(Base): @serializer def serialize_action(action: ToastAction) -> dict: ... -class ToastProps(PropsBase): +class ToastProps(PropsBase, NoExtrasAllowedProps): + title: Optional[Union[str, Var]] description: Optional[Union[str, Var]] close_button: Optional[bool] invert: Optional[bool] @@ -44,6 +45,7 @@ class ToastProps(PropsBase): id: Optional[Union[str, Var]] unstyled: Optional[bool] style: Optional[Style] + class_name: Optional[str] action_button_styles: Optional[Style] cancel_button_styles: Optional[Style] on_dismiss: Optional[Any] @@ -51,27 +53,22 @@ class ToastProps(PropsBase): def dict(self, *args, **kwargs) -> dict[str, Any]: ... - class Config: - arbitrary_types_allowed = True - use_enum_values = True - extra = "forbid" - 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 + message: str | Var = "", level: str | None = None, **props ) -> EventSpec: ... @staticmethod - def toast_info(message: str, **kwargs): ... + def toast_info(message: str | Var = "", **kwargs): ... @staticmethod - def toast_warning(message: str, **kwargs): ... + def toast_warning(message: str | Var = "", **kwargs): ... @staticmethod - def toast_error(message: str, **kwargs): ... + def toast_error(message: str | Var = "", **kwargs): ... @staticmethod - def toast_success(message: str, **kwargs): ... + def toast_success(message: str | Var = "", **kwargs): ... @staticmethod def toast_dismiss(id: Var | str | None = None): ... @overload @@ -85,24 +82,24 @@ class Toaster(Component): visible_toasts: Optional[Union[Var[int], int]] = None, position: Optional[ Union[ + Literal[ + "bottom-center", + "bottom-left", + "bottom-right", + "top-center", + "top-left", + "top-right", + ], Var[ Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", "bottom-center", + "bottom-left", "bottom-right", + "top-center", + "top-left", + "top-right", ] ], - Literal[ - "top-left", - "top-center", - "top-right", - "bottom-left", - "bottom-center", - "bottom-right", - ], ] ] = None, close_button: Optional[Union[Var[bool], bool]] = None, @@ -110,61 +107,31 @@ 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, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Toaster": """Create a toaster component. @@ -209,7 +176,7 @@ class ToastNamespace(ComponentNamespace): @staticmethod def __call__( - message: str = "", level: Optional[str] = None, **props + message: Union[str, Var] = "", level: Optional[str] = None, **props ) -> "Optional[EventSpec]": """Send a toast message. diff --git a/reflex/components/suneditor/editor.py b/reflex/components/suneditor/editor.py index 6e28b396a..d40f0e9ad 100644 --- a/reflex/components/suneditor/editor.py +++ b/reflex/components/suneditor/editor.py @@ -3,14 +3,14 @@ from __future__ import annotations import enum -from typing import 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.event import EventHandler +from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec from reflex.utils.format import to_camel_case from reflex.utils.imports import ImportDict, ImportVar -from reflex.vars import Var +from reflex.vars.base import Var class EditorButtonList(list, enum.Enum): @@ -68,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), @@ -87,7 +116,7 @@ class Editor(NoSSRComponent): # Please refer to the library docs for this. # options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | # "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" - # default : "en" + # default: "en". lang: Var[ Union[ Literal[ @@ -143,7 +172,7 @@ class Editor(NoSSRComponent): set_options: Var[Dict] # Whether all SunEditor plugins should be loaded. - # default: True + # default: True. set_all_plugins: Var[bool] # Set the content of the editor. @@ -162,52 +191,47 @@ class Editor(NoSSRComponent): set_default_style: Var[str] # Disable the editor - # default: False + # default: False. disable: Var[bool] # Hide the editor - # default: False + # default: False. hide: Var[bool] # Hide the editor toolbar - # default: False + # default: False. hide_toolbar: Var[bool] # Disable the editor toolbar - # default: False + # default: False. disable_toolbar: Var[bool] # Fired when the editor content changes. - on_change: EventHandler[lambda content: [content]] + on_change: EventHandler[passthrough_event_spec(str)] # Fired when the something is inputted in the editor. - on_input: EventHandler[lambda e: [e]] + on_input: EventHandler[no_args_event_spec] # Fired when the editor loses focus. - on_blur: EventHandler[lambda e, content: [content]] + on_blur: EventHandler[on_blur_spec] # Fired when the editor is loaded. - on_load: EventHandler[lambda reload: [reload]] - - # Fired when the editor is resized. - on_resize_editor: EventHandler[lambda height, prev_height: [height, prev_height]] + on_load: EventHandler[passthrough_event_spec(bool)] # Fired when the editor content is copied. - on_copy: EventHandler[lambda e, clipboard_data: [clipboard_data]] + on_copy: EventHandler[no_args_event_spec] # Fired when the editor content is cut. - on_cut: EventHandler[lambda e, clipboard_data: [clipboard_data]] + on_cut: EventHandler[no_args_event_spec] # Fired when the editor content is pasted. - on_paste: EventHandler[ - lambda e, clean_data, max_char_count: [clean_data, max_char_count] - ] + on_paste: EventHandler[on_paste_spec] # Fired when the code view is toggled. - toggle_code_view: EventHandler[lambda is_code_view: [is_code_view]] + toggle_code_view: EventHandler[passthrough_event_spec(bool)] # Fired when the full screen mode is toggled. - toggle_full_screen: EventHandler[lambda is_full_screen: [is_full_screen]] + toggle_full_screen: EventHandler[passthrough_event_spec(bool)] def add_imports(self) -> ImportDict: """Add imports for the Editor component. diff --git a/reflex/components/suneditor/editor.pyi b/reflex/components/suneditor/editor.pyi index 8a86e0270..b52fd43da 100644 --- a/reflex/components/suneditor/editor.pyi +++ b/reflex/components/suneditor/editor.pyi @@ -4,14 +4,14 @@ # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ import enum -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +from typing import Any, Dict, List, Literal, Optional, Tuple, Union, overload from reflex.base import Base from reflex.components.component import NoSSRComponent -from reflex.event import EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.style import Style from reflex.utils.imports import ImportDict -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class EditorButtonList(list, enum.Enum): BASIC = [["font", "fontSize"], ["fontColor"], ["horizontalRule"], ["link", "image"]] @@ -44,6 +44,11 @@ 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 add_imports(self) -> ImportDict: ... @overload @@ -53,51 +58,51 @@ class Editor(NoSSRComponent): *children, lang: Optional[ Union[ + Literal[ + "ckb", + "da", + "de", + "en", + "es", + "fr", + "he", + "it", + "ja", + "ko", + "lv", + "pl", + "pt_br", + "ro", + "ru", + "se", + "ua", + "zh_cn", + ], Var[ Union[ Literal[ - "en", + "ckb", "da", "de", + "en", "es", "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", "he", "it", + "ja", + "ko", + "lv", + "pl", + "pt_br", + "ro", + "ru", + "se", + "ua", + "zh_cn", ], dict, ] ], - Literal[ - "en", - "da", - "de", - "es", - "fr", - "ja", - "ko", - "pt_br", - "ru", - "zh_cn", - "ro", - "pl", - "ckb", - "lv", - "se", - "ua", - "he", - "it", - ], dict, ] ] = None, @@ -107,7 +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, @@ -121,78 +126,45 @@ class Editor(NoSSRComponent): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, on_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_copy: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_cut: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_input: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[str], BASE_STATE]] ] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_copy: Optional[EventType[[], BASE_STATE]] = None, + on_cut: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_input: Optional[EventType[[], BASE_STATE]] = None, on_load: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_paste: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_resize_editor: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[ + EventType[[], BASE_STATE], + EventType[[str], BASE_STATE], + EventType[[str, bool], BASE_STATE], + ] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, toggle_code_view: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, toggle_full_screen: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, **props, ) -> "Editor": @@ -200,7 +172,7 @@ class Editor(NoSSRComponent): Args: set_options(Optional[EditorOptions]): Configuration object to further configure the instance. - lang: Language of the editor. Alternatively to a string, a dict of your language can be passed to this prop. Please refer to the library docs for this. options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" default : "en" + lang: Language of the editor. Alternatively to a string, a dict of your language can be passed to this prop. Please refer to the library docs for this. options: "en" | "da" | "de" | "es" | "fr" | "ja" | "ko" | "pt_br" | "ru" | "zh_cn" | "ro" | "pl" | "ckb" | "lv" | "se" | "ua" | "he" | "it" default: "en". name: This is used to set the HTML form name of the editor. This means on HTML form submission, it will be submitted together with contents of the editor by the name provided. default_value: Sets the default value of the editor. This is useful if you don't want the on_change method to be called on render. If you want the on_change method to be called on render please use the set_contents prop width: Sets the width of the editor. px and percentage values are accepted, eg width="100%" or width="500px" default: 100% @@ -208,14 +180,23 @@ class Editor(NoSSRComponent): placeholder: Sets the placeholder of the editor. auto_focus: Should the editor receive focus when initialized? set_options: Pass an EditorOptions instance to modify the behaviour of Editor even more. - set_all_plugins: Whether all SunEditor plugins should be loaded. default: True + set_all_plugins: Whether all SunEditor plugins should be loaded. default: True. set_contents: Set the content of the editor. Note: To set the initial contents of the editor without calling the on_change event, please use the default_value prop. set_contents is used to set the contents of the editor programmatically. You must be aware that, when the set_contents's prop changes, the on_change event is triggered. append_contents: Append editor content set_default_style: Sets the default style of the editor's edit area - disable: Disable the editor default: False - hide: Hide the editor default: False - hide_toolbar: Hide the editor toolbar default: False - disable_toolbar: Disable the editor toolbar default: False + disable: Disable the editor default: False. + 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 95a496b71..38ecaf81c 100644 --- a/reflex/components/tags/iter_tag.py +++ b/reflex/components/tags/iter_tag.py @@ -2,30 +2,34 @@ 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. @@ -33,15 +37,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 @@ -53,10 +58,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). @@ -66,10 +71,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). @@ -79,11 +84,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). @@ -93,15 +97,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. """ @@ -120,7 +126,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 bacea6a41..0587c61ed 100644 --- a/reflex/components/tags/tag.py +++ b/reflex/components/tags/tag.py @@ -2,49 +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, _var_is_string=False) - 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. @@ -54,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. @@ -63,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 06d8c2193..0579b019f 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -2,11 +2,32 @@ from __future__ import annotations +import dataclasses +import enum import importlib +import inspect import os import sys +import threading import urllib.parse -from typing import Any, Dict, List, Optional, Set +from importlib.util import find_spec +from pathlib import Path +from typing import ( + TYPE_CHECKING, + Any, + Dict, + Generic, + List, + Optional, + Set, + TypeVar, + get_args, +) + +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 @@ -61,7 +82,7 @@ class DBConfig(Base): ) @classmethod - def postgresql_psycopg2( + def postgresql_psycopg( cls, database: str, username: str, @@ -69,7 +90,7 @@ class DBConfig(Base): host: str | None = None, port: int | None = 5432, ) -> DBConfig: - """Create an instance with postgresql+psycopg2 engine. + """Create an instance with postgresql+psycopg engine. Args: database: Database name. @@ -82,7 +103,7 @@ class DBConfig(Base): DBConfig instance. """ return cls( - engine="postgresql+psycopg2", + engine="postgresql+psycopg", username=username, password=password, host=host, @@ -128,6 +149,432 @@ 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." + ) + + +T = TypeVar("T") + + +class EnvVar(Generic[T]): + """Environment variable.""" + + name: str + default: Any + type_: T + + def __init__(self, name: str, default: Any, type_: T) -> None: + """Initialize the environment variable. + + Args: + name: The environment variable name. + default: The default value. + type_: The type of the value. + """ + self.name = name + self.default = default + self.type_ = type_ + + def interpret(self, value: str) -> T: + """Interpret the environment variable value. + + Args: + value: The environment variable value. + + Returns: + The interpreted value. + """ + return interpret_env_var_value(value, self.type_, self.name) + + def getenv(self) -> Optional[T]: + """Get the interpreted environment variable value. + + Returns: + The environment variable value. + """ + env_value = os.getenv(self.name, None) + if env_value is not None: + return self.interpret(env_value) + return None + + def is_set(self) -> bool: + """Check if the environment variable is set. + + Returns: + True if the environment variable is set. + """ + return self.name in os.environ + + def get(self) -> T: + """Get the interpreted environment variable value or the default value if not set. + + Returns: + The interpreted value. + """ + env_value = self.getenv() + if env_value is not None: + return env_value + return self.default + + def set(self, value: T | None) -> None: + """Set the environment variable. None unsets the variable. + + Args: + value: The value to set. + """ + if value is None: + _ = os.environ.pop(self.name, None) + else: + if isinstance(value, enum.Enum): + value = value.value + os.environ[self.name] = str(value) + + +class env_var: # type: ignore + """Descriptor for environment variables.""" + + name: str + default: Any + internal: bool = False + + def __init__(self, default: Any, internal: bool = False) -> None: + """Initialize the descriptor. + + Args: + default: The default value. + internal: Whether the environment variable is reflex internal. + """ + self.default = default + self.internal = internal + + def __set_name__(self, owner, name): + """Set the name of the descriptor. + + Args: + owner: The owner class. + name: The name of the descriptor. + """ + self.name = name + + def __get__(self, instance, owner): + """Get the EnvVar instance. + + Args: + instance: The instance. + owner: The owner class. + + Returns: + The EnvVar instance. + """ + type_ = get_args(get_type_hints(owner)[self.name])[0] + env_name = self.name + if self.internal: + env_name = f"__{env_name}" + return EnvVar(name=env_name, default=self.default, type_=type_) + + +if TYPE_CHECKING: + + def env_var(default, internal=False) -> EnvVar: + """Typing helper for the env_var descriptor. + + Args: + default: The default value. + internal: Whether the environment variable is reflex internal. + + Returns: + The EnvVar instance. + """ + return default + + +class PathExistsFlag: + """Flag to indicate that a path must exist.""" + + +ExistingPath = Annotated[Path, PathExistsFlag] + + +class PerformanceMode(enum.Enum): + """Performance mode for the app.""" + + WARN = "warn" + RAISE = "raise" + OFF = "off" + + +class EnvironmentVariables: + """Environment variables class to instantiate environment variables.""" + + # Whether to use npm over bun to install frontend packages. + REFLEX_USE_NPM: EnvVar[bool] = env_var(False) + + # The npm registry to use. + NPM_CONFIG_REGISTRY: EnvVar[Optional[str]] = env_var(None) + + # Whether to use Granian for the backend. Otherwise, use Uvicorn. + REFLEX_USE_GRANIAN: EnvVar[bool] = env_var(False) + + # The username to use for authentication on python package repository. Username and password must both be provided. + TWINE_USERNAME: EnvVar[Optional[str]] = env_var(None) + + # The password to use for authentication on python package repository. Username and password must both be provided. + TWINE_PASSWORD: EnvVar[Optional[str]] = env_var(None) + + # Whether to use the system installed bun. If set to false, bun will be bundled with the app. + REFLEX_USE_SYSTEM_BUN: EnvVar[bool] = env_var(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: EnvVar[bool] = env_var(False) + + # The working directory for the next.js commands. + REFLEX_WEB_WORKDIR: EnvVar[Path] = env_var(Path(constants.Dirs.WEB)) + + # Path to the alembic config file + ALEMBIC_CONFIG: EnvVar[ExistingPath] = env_var(Path(constants.ALEMBIC_CONFIG)) + + # Disable SSL verification for HTTPX requests. + SSL_NO_VERIFY: EnvVar[bool] = env_var(False) + + # The directory to store uploaded files. + REFLEX_UPLOADED_FILES_DIR: EnvVar[Path] = env_var( + Path(constants.Dirs.UPLOADED_FILES) + ) + + # Whether to use separate processes to compile the frontend and how many. If not set, defaults to thread executor. + REFLEX_COMPILE_PROCESSES: EnvVar[Optional[int]] = env_var(None) + + # Whether to use separate threads to compile the frontend and how many. Defaults to `min(32, os.cpu_count() + 4)`. + REFLEX_COMPILE_THREADS: EnvVar[Optional[int]] = env_var(None) + + # The directory to store reflex dependencies. + REFLEX_DIR: EnvVar[Path] = env_var(Path(constants.Reflex.DIR)) + + # Whether to print the SQL queries if the log level is INFO or lower. + SQLALCHEMY_ECHO: EnvVar[bool] = env_var(False) + + # Whether to check db connections before using them. + SQLALCHEMY_POOL_PRE_PING: EnvVar[bool] = env_var(True) + + # Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration. + REFLEX_IGNORE_REDIS_CONFIG_ERROR: EnvVar[bool] = env_var(False) + + # Whether to skip purging the web directory in dev mode. + REFLEX_PERSIST_WEB_DIR: EnvVar[bool] = env_var(False) + + # The reflex.build frontend host. + REFLEX_BUILD_FRONTEND: EnvVar[str] = env_var( + constants.Templates.REFLEX_BUILD_FRONTEND + ) + + # The reflex.build backend host. + REFLEX_BUILD_BACKEND: EnvVar[str] = env_var( + constants.Templates.REFLEX_BUILD_BACKEND + ) + + # This env var stores the execution mode of the app + REFLEX_ENV_MODE: EnvVar[constants.Env] = env_var(constants.Env.DEV) + + # Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY. + REFLEX_BACKEND_ONLY: EnvVar[bool] = env_var(False) + + # Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY. + REFLEX_FRONTEND_ONLY: EnvVar[bool] = env_var(False) + + # Reflex internal env to reload the config. + RELOAD_CONFIG: EnvVar[bool] = env_var(False, internal=True) + + # If this env var is set to "yes", App.compile will be a no-op + REFLEX_SKIP_COMPILE: EnvVar[bool] = env_var(False, internal=True) + + # Whether to run app harness tests in headless mode. + APP_HARNESS_HEADLESS: EnvVar[bool] = env_var(False) + + # Which app harness driver to use. + APP_HARNESS_DRIVER: EnvVar[str] = env_var("Chrome") + + # Arguments to pass to the app harness driver. + APP_HARNESS_DRIVER_ARGS: EnvVar[str] = env_var("") + + # Where to save screenshots when tests fail. + SCREENSHOT_DIR: EnvVar[Optional[Path]] = env_var(None) + + # Whether to check for outdated package versions. + REFLEX_CHECK_LATEST_VERSION: EnvVar[bool] = env_var(True) + + # In which performance mode to run the app. + REFLEX_PERF_MODE: EnvVar[Optional[PerformanceMode]] = env_var(PerformanceMode.WARN) + + # The maximum size of the reflex state in kilobytes. + REFLEX_STATE_SIZE_LIMIT: EnvVar[int] = env_var(1000) + + +environment = EnvironmentVariables() + + +# These vars are not logged because they may contain sensitive information. +_sensitive_env_vars = {"DB_URL", "ASYNC_DB_URL", "REDIS_URL"} + + class Config(Base): """The config defines runtime settings for the app. @@ -158,7 +605,7 @@ 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 = constants.DefaultPorts.FRONTEND_PORT @@ -181,6 +628,9 @@ class Config(Base): # The database url used by rx.Model. db_url: Optional[str] = "sqlite:///reflex.db" + # The async database url used by rx.Model. + async_db_url: Optional[str] = None + # The redis url redis_url: Optional[str] = None @@ -188,13 +638,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 @@ -209,9 +662,9 @@ class Config(Base): frontend_packages: List[str] = [] # The hosting service backend URL. - cp_backend_url: str = Hosting.CP_BACKEND_URL + cp_backend_url: str = Hosting.HOSTING_SERVICE # The hosting service frontend URL. - cp_web_url: str = Hosting.CP_WEB_URL + cp_web_url: str = Hosting.HOSTING_SERVICE_UI # The worker class used in production mode gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker" @@ -219,21 +672,39 @@ class Config(Base): # 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 + # Maximum lock time before warning for redis state manager. + redis_lock_warning_threshold: int = constants.Expiration.LOCK_WARNING_THRESHOLD + # 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) @@ -247,6 +718,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. @@ -258,14 +737,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. @@ -275,27 +761,19 @@ class Config(Base): # If the env var is set, override the config value. 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}", - 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 + + if key.upper() in _sensitive_env_vars: + env_var = "***" + + console.info( + f"Overriding config value {key} with env var {key.upper()}={env_var}", + dedupe=True, + ) return updated_values @@ -354,6 +832,27 @@ class Config(Base): self._replace_defaults(**kwargs) +def _get_config() -> Config: + """Get the app config. + + Returns: + The app config. + """ + # only import the module if it exists. If a module spec exists then + # the module exists. + spec = find_spec(constants.Config.MODULE) + if not spec: + # we need this condition to ensure that a ModuleNotFound error is not thrown when + # running unit/integration tests or during `reflex init`. + return Config(app_name="") + rxconfig = importlib.import_module(constants.Config.MODULE) + return rxconfig.config + + +# Protect sys.path from concurrent modification +_config_lock = threading.RLock() + + def get_config(reload: bool = False) -> Config: """Get the app config. @@ -363,15 +862,26 @@ def get_config(reload: bool = False) -> Config: Returns: The app config. """ - sys.path.insert(0, os.getcwd()) - # 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 + cached_rxconfig = sys.modules.get(constants.Config.MODULE, None) + if cached_rxconfig is not None: + if reload: + # Remove any cached module when `reload` is requested. + del sys.modules[constants.Config.MODULE] + else: + return cached_rxconfig.config + + with _config_lock: + sys_path = sys.path.copy() + sys.path.clear() + sys.path.append(str(Path.cwd())) + try: + # Try to import the module with only the current directory in the path. + return _get_config() + except Exception: + # If the module import fails, try to import with the original sys.path. + sys.path.extend(sys_path) + return _get_config() + finally: + # Restore the original sys.path. + sys.path.clear() + sys.path.extend(sys_path) diff --git a/reflex/constants/__init__.py b/reflex/constants/__init__.py index e974ab915..e816da0f7 100644 --- a/reflex/constants/__init__.py +++ b/reflex/constants/__init__.py @@ -2,16 +2,15 @@ from .base import ( COOKIES, - ENV_MODE_ENV_VAR, + IS_LINUX, + IS_MACOS, IS_WINDOWS, LOCAL_STORAGE, POLLING_MAX_HTTP_BUFFER_SIZE, PYTEST_CURRENT_TEST, REFLEX_VAR_CLOSING_TAG, REFLEX_VAR_OPENING_TAG, - RELOAD_CONFIG, SESSION_STORAGE, - SKIP_COMPILE_ENV_VAR, ColorMode, Dirs, Env, @@ -42,16 +41,9 @@ from .config import ( GitIgnore, RequirementsTxt, ) -from .custom_components import ( - CustomComponents, -) +from .custom_components import CustomComponents from .event import Endpoint, EventTriggers, SocketEvent -from .installer import ( - Bun, - Fnm, - Node, - PackageJson, -) +from .installer import Bun, Fnm, Node, PackageJson from .route import ( ROUTE_NOT_FOUND, ROUTER, @@ -63,6 +55,7 @@ from .route import ( RouteRegex, RouteVar, ) +from .state import StateManagerMode from .style import Tailwind __ALL__ = [ @@ -103,7 +96,6 @@ __ALL__ = [ POLLING_MAX_HTTP_BUFFER_SIZE, PYTEST_CURRENT_TEST, Reflex, - RELOAD_CONFIG, RequirementsTxt, RouteArgType, RouteRegex, @@ -113,8 +105,8 @@ __ALL__ = [ ROUTER_DATA_INCLUDE, ROUTE_NOT_FOUND, SETTER_PREFIX, - SKIP_COMPILE_ENV_VAR, SocketEvent, + StateManagerMode, Tailwind, Templates, CompileVars, diff --git a/reflex/constants/base.py b/reflex/constants/base.py index a858a69b1..af96583ad 100644 --- a/reflex/constants/base.py +++ b/reflex/constants/base.py @@ -2,15 +2,19 @@ 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" +IS_MACOS = platform.system() == "Darwin" +IS_LINUX = platform.system() == "Linux" class Dirs(SimpleNamespace): @@ -19,9 +23,11 @@ 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). + # The name of the assets directory for external resources (a subfolder of APP_ASSETS). EXTERNAL_APP_ASSETS = "external" # The name of the utils file. UTILS = "utils" @@ -45,6 +51,8 @@ class Dirs(SimpleNamespace): REFLEX_JSON = "reflex.json" # The name of the postcss config file. POSTCSS_JS = "postcss.config.js" + # The name of the states directory. + STATES = "states" class Reflex(SimpleNamespace): @@ -61,23 +69,16 @@ class Reflex(SimpleNamespace): # 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" + RELEASES_URL = "https://api.github.com/repos/reflex-dev/templates/releases" class ReflexHostingCLI(SimpleNamespace): @@ -96,36 +97,75 @@ class Templates(SimpleNamespace): # The default template DEFAULT = "blank" + # The AI template + AI = "ai" + + # The option for the user to choose a remote template. + CHOOSE_TEMPLATES = "choose-templates" + + # The URL to find reflex templates. + REFLEX_TEMPLATES_URL = "https://reflex.dev/templates" + + # Demo url for the default template. + DEFAULT_TEMPLATE_URL = "https://blank-template.reflex.run" + # The reflex.build frontend host - REFLEX_BUILD_FRONTEND = os.environ.get( - "REFLEX_BUILD_FRONTEND", "https://flexgen.reflex.run" - ) + REFLEX_BUILD_FRONTEND = "https://flexgen.reflex.run" # The reflex.build backend host - REFLEX_BUILD_BACKEND = os.environ.get( - "REFLEX_BUILD_BACKEND", "https://rxh-prod-flexgen.fly.dev" - ) + REFLEX_BUILD_BACKEND = "https://flexgen-prod-flexgen.fly.dev" - # The URL to redirect to reflex.build - REFLEX_BUILD_URL = ( - REFLEX_BUILD_FRONTEND + "/gen?reflex_init_token={reflex_init_token}" - ) + @classproperty + @classmethod + def REFLEX_BUILD_URL(cls): + """The URL to redirect to reflex.build. - # The URL to poll waiting for the user to select a generation. - REFLEX_BUILD_POLL_URL = REFLEX_BUILD_BACKEND + "/api/init/{reflex_init_token}" + Returns: + The URL to redirect to reflex.build. + """ + from reflex.config import environment - # The URL to fetch the generation's reflex code - REFLEX_BUILD_CODE_URL = REFLEX_BUILD_BACKEND + "/api/gen/{generation_hash}" + return ( + environment.REFLEX_BUILD_FRONTEND.get() + + "/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.get() + "/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.get() + + "/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" @@ -169,6 +209,7 @@ class LogLevel(str, Enum): """The log levels.""" DEBUG = "debug" + DEFAULT = "default" INFO = "info" WARNING = "warning" ERROR = "error" @@ -186,6 +227,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 @@ -205,16 +254,9 @@ 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" - -# This env var stores the execution mode of the app -ENV_MODE_ENV_VAR = "REFLEX_ENV_MODE" - # Testing variables. # Testing os env set by pytest when running a test case. 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 1de3fc263..7ca55f4dd 100644 --- a/reflex/constants/compiler.py +++ b/reflex/constants/compiler.py @@ -114,8 +114,8 @@ class Imports(SimpleNamespace): EVENTS = { "react": [ImportVar(tag="useContext")], - f"/{Dirs.CONTEXTS_PATH}": [ImportVar(tag="EventLoopContext")], - f"/{Dirs.STATE_PATH}": [ImportVar(tag=CompileVars.TO_EVENT)], + f"$/{Dirs.CONTEXTS_PATH}": [ImportVar(tag="EventLoopContext")], + f"$/{Dirs.STATE_PATH}": [ImportVar(tag=CompileVars.TO_EVENT)], } @@ -132,15 +132,11 @@ class Hooks(SimpleNamespace): } })""" - FRONTEND_ERRORS = f""" - const logFrontendError = (error, info) => {{ - if (process.env.NODE_ENV === "production") {{ - addEvents([Event("{CompileVars.FRONTEND_EXCEPTION_STATE_FULL}.handle_frontend_exception", {{ - stack: error.stack, - }})]) - }} - }} - """ + class HookPosition(enum.Enum): + """The position of the hook in the component.""" + + PRE_TRIGGER = "pre_trigger" + POST_TRIGGER = "post_trigger" class MemoizationDisposition(enum.Enum): @@ -160,3 +156,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 966727426..7425fd864 100644 --- a/reflex/constants/config.py +++ b/reflex/constants/config.py @@ -1,6 +1,6 @@ """Config constants.""" -import os +from pathlib import Path from types import SimpleNamespace from reflex.constants.base import Dirs, Reflex @@ -8,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): @@ -17,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): @@ -31,13 +29,15 @@ class Expiration(SimpleNamespace): LOCK = 10000 # The PING timeout PING = 120 + # The maximum time in milliseconds to hold a lock before throwing a warning. + LOCK_WARNING_THRESHOLD = 1000 class GitIgnore(SimpleNamespace): """Gitignore constants.""" # The gitignore file. - FILE = ".gitignore" + FILE = Path(".gitignore") # Files to gitignore. DEFAULTS = {Dirs.WEB, "*.db", "__pycache__/", "*.py[cod]", "assets/external/"} diff --git a/reflex/constants/custom_components.py b/reflex/constants/custom_components.py index 3ea9cf6ed..a499327b1 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 @@ -9,11 +10,11 @@ class CustomComponents(SimpleNamespace): """Constants for the custom components.""" # The name of the custom components source directory. - SRC_DIR = "custom_components" + SRC_DIR = Path("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 351a1ac52..d454e6ea8 100644 --- a/reflex/constants/event.py +++ b/reflex/constants/event.py @@ -11,6 +11,7 @@ class Endpoint(Enum): EVENT = "_event" UPLOAD = "_upload" AUTH_CODESPACE = "auth-codespace" + HEALTH = "_health" def __str__(self) -> str: """Get the string representation of the endpoint. diff --git a/reflex/constants/installer.py b/reflex/constants/installer.py index 4a7027ee8..0b45586dd 100644 --- a/reflex/constants/installer.py +++ b/reflex/constants/installer.py @@ -2,11 +2,12 @@ from __future__ import annotations -import os import platform +from pathlib import Path from types import SimpleNamespace -from .base import IS_WINDOWS, Reflex +from .base import IS_WINDOWS +from .utils import classproperty def get_fnm_name() -> str | None: @@ -36,24 +37,49 @@ class Bun(SimpleNamespace): """Bun constants.""" # The Bun version. - VERSION = "1.1.10" + 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.get() / "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") + + DEFAULT_CONFIG = """ +[install] +registry = "{registry}" +""" + # FNM config. class Fnm(SimpleNamespace): @@ -61,40 +87,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.get() / "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): @@ -111,20 +178,21 @@ class PackageJson(SimpleNamespace): 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": "14.2.16", + "next-sitemap": "4.2.3", + "next-themes": "0.4.3", + "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.2", } DEV_DEPENDENCIES = { - "autoprefixer": "10.4.14", - "postcss": "8.4.31", + "autoprefixer": "10.4.20", + "postcss": "8.4.49", "postcss-import": "16.1.0", } diff --git a/reflex/constants/route.py b/reflex/constants/route.py index 2af2f33c6..ab00fab15 100644 --- a/reflex/constants/route.py +++ b/reflex/constants/route.py @@ -31,7 +31,7 @@ class RouteVar(SimpleNamespace): # This subset of router_data is included in chained on_load events. -ROUTER_DATA_INCLUDE = set((RouteVar.PATH, RouteVar.ORIGIN, RouteVar.QUERY)) +ROUTER_DATA_INCLUDE = {RouteVar.PATH, RouteVar.ORIGIN, RouteVar.QUERY} class RouteRegex(SimpleNamespace): diff --git a/reflex/constants/state.py b/reflex/constants/state.py new file mode 100644 index 000000000..5ce7cd62a --- /dev/null +++ b/reflex/constants/state.py @@ -0,0 +1,15 @@ +"""State-related constants.""" + +from enum import Enum + + +class StateManagerMode(str, Enum): + """State manager constants.""" + + DISK = "disk" + MEMORY = "memory" + REDIS = "redis" + + +# Used for things like console_log, etc. +FRONTEND_EVENT_STATE = "__reflex_internal_frontend_event_state" diff --git a/reflex/constants/style.py b/reflex/constants/style.py index 2130ab4e0..a1d30bcca 100644 --- a/reflex/constants/style.py +++ b/reflex/constants/style.py @@ -7,7 +7,7 @@ class Tailwind(SimpleNamespace): """Tailwind constants.""" # The Tailwindcss version - VERSION = "tailwindcss@3.3.2" + VERSION = "tailwindcss@3.4.15" # The Tailwind config. CONFIG = "tailwind.config.js" # Default Tailwind content paths 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 a47de6feb..4a169802f 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): @@ -157,27 +150,27 @@ def _populate_demo_app(name_variants: NameVariants): from reflex.compiler import templates from reflex.reflex import _init - demo_app_dir = name_variants.demo_app_dir + demo_app_dir = Path(name_variants.demo_app_dir) demo_app_name = name_variants.demo_app_name - console.info(f"Creating app for testing: {demo_app_dir}") + console.info(f"Creating app for testing: {demo_app_dir!s}") - os.makedirs(demo_app_dir) + demo_app_dir.mkdir(exist_ok=True) with set_directory(demo_app_dir): # We start with the blank template as basis. _init(name=demo_app_name, template=constants.Templates.DEFAULT) # Then overwrite the app source file with the one we want for testing custom components. # This source file is rendered using jinja template file. - with open(f"{demo_app_name}/{demo_app_name}.py", "w") as f: - f.write( - templates.CUSTOM_COMPONENTS_DEMO_APP.render( - custom_component_module_dir=name_variants.custom_component_module_dir, - module_name=name_variants.module_name, - ) + demo_file = Path(f"{demo_app_name}/{demo_app_name}.py") + demo_file.write_text( + templates.CUSTOM_COMPONENTS_DEMO_APP.render( + custom_component_module_dir=name_variants.custom_component_module_dir, + module_name=name_variants.module_name, ) + ) # Append the custom component package to the requirements.txt file. - with open(f"{constants.RequirementsTxt.FILE}", "a") as f: + with Path(f"{constants.RequirementsTxt.FILE}").open(mode="a") as f: f.write(f"{name_variants.package_name}\n") @@ -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. @@ -303,13 +296,14 @@ def _populate_custom_component_project(name_variants: NameVariants): ) console.info( - f"Initializing the component directory: {CustomComponents.SRC_DIR}/{name_variants.custom_component_module_dir}" + f"Initializing the component directory: {CustomComponents.SRC_DIR / name_variants.custom_component_module_dir}" ) - os.makedirs(CustomComponents.SRC_DIR) + CustomComponents.SRC_DIR.mkdir(exist_ok=True) with set_directory(CustomComponents.SRC_DIR): - os.makedirs(name_variants.custom_component_module_dir) + module_dir = Path(name_variants.custom_component_module_dir) + module_dir.mkdir(exist_ok=True, parents=True) _write_source_and_init_py( - custom_component_src_dir=name_variants.custom_component_module_dir, + custom_component_src_dir=module_dir, component_class_name=name_variants.component_class_name, module_name=name_variants.module_name, ) @@ -343,7 +337,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,14 +610,14 @@ 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( - os.getenv("TWINE_USERNAME"), + environment.TWINE_USERNAME.get(), "-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( - os.getenv("TWINE_PASSWORD"), + environment.TWINE_PASSWORD.get(), "-p", "--password", show_default="TWINE_PASSWORD environment variable value if set", @@ -786,8 +780,8 @@ def _validate_project_info(): ) # PyPI only shows the first author. author = project.get("authors", [{}])[0] - author["name"] = console.ask(f"Author Name", default=author.get("name", "")) - author["email"] = console.ask(f"Author Email", default=author.get("email", "")) + author["name"] = console.ask("Author Name", default=author.get("name", "")) + author["email"] = console.ask("Author Email", default=author.get("email", "")) console.print(f'Current keywords are: {project.get("keywords") or []}') keyword_action = console.ask( @@ -821,7 +815,7 @@ def _validate_project_info(): ) pyproject_toml["project"] = project try: - with open(CustomComponents.PYPROJECT_TOML, "w") as f: + with CustomComponents.PYPROJECT_TOML.open("w") as f: tomlkit.dump(pyproject_toml, f) except (OSError, TOMLKitError) as ex: console.error(f"Unable to write to pyproject.toml due to {ex}") @@ -834,11 +828,11 @@ def _collect_details_for_gallery(): Raises: Exit: If pyproject.toml file is ill-formed or the request to the backend services fails. """ - from reflex.reflex import _login + from reflex_cli.utils import hosting console.rule("[bold]Authentication with Reflex Services") console.print("First let's log in to Reflex backend services.") - access_token = _login() + access_token, _ = hosting.authenticated_token() console.rule("[bold]Custom Component Information") params = {} @@ -929,16 +923,15 @@ def _validate_url_with_protocol_prefix(url: str | None) -> bool: def _get_file_from_prompt_in_loop() -> Tuple[bytes, str] | None: image_file = file_extension = None while image_file is None: - image_filepath = console.ask( - f"Upload a preview image of your demo app (enter to skip)" + image_filepath = Path( + console.ask("Upload a preview image of your demo app (enter to skip)") ) if not image_filepath: break - file_extension = image_filepath.split(".")[-1] + file_extension = image_filepath.suffix try: - with open(image_filepath, "rb") as f: - image_file = f.read() - return image_file, file_extension + image_file = image_filepath.read_bytes() + return image_file, file_extension except OSError as ose: console.error(f"Unable to read the {file_extension} file due to {ose}") raise typer.Exit(code=1) from ose @@ -980,6 +973,6 @@ def install( console.set_log_level(loglevel) if _pip_install_on_demand(package_name=".", install_args=["-e"]): - console.info(f"Package installed successfully!") + console.info("Package installed successfully!") else: raise typer.Exit(code=1) diff --git a/reflex/event.py b/reflex/event.py index 7e98ade38..e4ca55c70 100644 --- a/reflex/event.py +++ b/reflex/event.py @@ -2,25 +2,58 @@ from __future__ import annotations +import dataclasses import inspect +import sys +import types import urllib.parse from base64 import b64encode +from functools import partial from typing import ( + TYPE_CHECKING, Any, Callable, Dict, + Generic, List, Optional, + Sequence, Tuple, + Type, Union, get_type_hints, + overload, +) + +import typing_extensions +from typing_extensions import ( + Concatenate, + ParamSpec, + Protocol, + TypeAliasType, + TypedDict, + TypeVar, + 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.constants.state import FRONTEND_EVENT_STATE +from reflex.utils import console, format +from reflex.utils.exceptions import EventFnArgMismatch, 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, + ArgsFunctionOperationBuilder, + BuilderFunctionVar, + FunctionArgs, + FunctionStringVar, + FunctionVar, + VarOperationCall, +) +from reflex.vars.object import ObjectVar try: from typing import Annotated @@ -28,7 +61,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 +75,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 +94,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 +107,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 +137,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 +149,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 +163,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 +177,37 @@ 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}, + ) + + @property + def temporal(self): + """Do not queue the event if the backend is down. + + Returns: + New EventHandler-like with temporal set to True. + """ + return dataclasses.replace( + self, + event_actions={"temporal": True, **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 +248,7 @@ class EventHandler(EventActionsMixin): # Get the function args. fn_args = inspect.getfullargspec(self.fn).args[1:] - fn_args = (Var.create_safe(arg, _var_is_string=False) for arg in fn_args) + fn_args = (Var(_js_expr=arg) for arg in fn_args) # Construct the payload. values = [] @@ -197,7 +259,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 +272,10 @@ class EventHandler(EventActionsMixin): ) +@dataclasses.dataclass( + init=True, + frozen=True, +) class EventSpec(EventActionsMixin): """An event specification. @@ -218,19 +284,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], ...] = (), + ): + """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 ()) def with_args(self, args: Tuple[Tuple[Var, Var], ...]) -> EventSpec: """Copy the event spec, with updated args. @@ -264,21 +346,25 @@ 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, _var_is_string=False) 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))) - except TypeError as e: - raise EventHandlerTypeError( - f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." - ) from e + arg = None + try: + for arg in args: + values.append(LiteralVar.create(value=arg)) # noqa: PERF401 + except TypeError as e: + raise EventHandlerTypeError( + f"Arguments to event handlers must be Vars or JSON-serializable. Got {arg} of type {type(arg)}." + ) from e new_payload = tuple(zip(fn_args, values)) 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 +384,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 +414,196 @@ 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() # noqa: RUF009 + + +@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 = "" + altKey: bool = False + ctrlKey: bool = False + metaKey: bool = False + shiftKey: bool = False + + +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,) + + +class KeyInputInfo(TypedDict): + """Information about a key input event.""" + + alt_key: bool + ctrl_key: bool + meta_key: bool + shift_key: bool + + +def key_event(e: Var[JavasciptKeyboardEvent]) -> Tuple[Var[str], Var[KeyInputInfo]]: + """Get the key from a keyboard event. + + Args: + e: The keyboard event. + + Returns: + The key from the keyboard event. + """ + return ( + e.key, + Var.create( + { + "alt_key": e.altKey, + "ctrl_key": e.ctrlKey, + "meta_key": e.metaKey, + "shift_key": e.shiftKey, + }, + ), + ) + + +def no_args_event_spec() -> Tuple[()]: + """Empty event handler. + + Returns: + An empty tuple. + """ + return () # 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=no_args_event_spec).stop_propagation +prevent_default = EventChain(events=[], args_spec=no_args_event_spec).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.""" +class IdentityEventReturn(Generic[T], Protocol): + """Protocol for an identity event return.""" - target: Target = Target() - key: str = "" - value: Any = None + 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 -class FileUpload(Base): +@overload +def passthrough_event_spec( + event_type: Type[T], / +) -> Callable[[Var[T]], Tuple[Var[T]]]: ... # type: ignore + + +@overload +def passthrough_event_spec( + event_type_1: Type[T], event_type2: Type[U], / +) -> Callable[[Var[T], Var[U]], Tuple[Var[T], Var[U]]]: ... + + +@overload +def passthrough_event_spec(*event_types: Type[T]) -> IdentityEventReturn[T]: ... + + +def passthrough_event_spec(*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: @@ -388,15 +631,16 @@ class FileUpload(Base): upload_id = self.upload_id or DEFAULT_UPLOAD_ID spec_args = [ ( - Var.create_safe("files", _var_is_string=False), - Var.create_safe( - f"filesById[{Var.create_safe(upload_id, _var_is_string=True)._var_name_unwrapped}]", - _var_is_string=False, - )._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_is_string=False), - 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: @@ -418,17 +662,16 @@ class FileUpload(Base): 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", _var_is_string=False), - 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,37 +705,72 @@ def server_side(name: str, sig: inspect.Signature, **kwargs) -> EventSpec: fn.__qualname__ = name fn.__signature__ = sig return EventSpec( - handler=EventHandler(fn=fn), + handler=EventHandler(fn=fn, state_full_name=FRONTEND_EVENT_STATE), args=tuple( ( - Var.create_safe(k, _var_is_string=False), - Var.create_safe(v, _var_is_string=isinstance(v, str)), + Var(_js_expr=k), + LiteralVar.create(v), ) for k, v in kwargs.items() ), ) +@overload def redirect( path: str | Var[str], - external: Optional[bool] = False, - replace: Optional[bool] = False, + is_external: Optional[bool] = None, + replace: bool = False, +) -> EventSpec: ... + + +@overload +@typing_extensions.deprecated("`external` is deprecated use `is_external` instead") +def redirect( + path: str | Var[str], + is_external: Optional[bool] = None, + replace: bool = False, + external: Optional[bool] = None, +) -> EventSpec: ... + + +def redirect( + path: str | Var[str], + is_external: Optional[bool] = None, + replace: bool = False, + external: Optional[bool] = None, ) -> EventSpec: """Redirect to a new path. Args: path: The path to redirect to. - external: Whether to open in new tab or not. + is_external: Whether to open in new tab or not. replace: If True, the current page will not create a new history entry. + external(Deprecated): Whether to open in new tab or not. Returns: An event to redirect to the path. """ + if external is not None: + console.deprecate( + "The `external` prop in `rx.redirect`", + "use `is_external` instead.", + "0.6.6", + "0.7.0", + ) + + # is_external should take precedence over external. + is_external = ( + (False if external is None else external) + if is_external is None + else is_external + ) + return server_side( "_redirect", get_fn_signature(redirect), path=path, - external=external, + external=is_external, replace=replace, ) @@ -506,7 +784,16 @@ def console_log(message: str | Var[str]) -> EventSpec: Returns: An event to log the message. """ - return server_side("_console", get_fn_signature(console_log), message=message) + return run_script(Var("console").to(dict).log.to(FunctionVar).call(message)) + + +def noop() -> EventSpec: + """Do nothing. + + Returns: + An event to do nothing. + """ + return run_script(Var.create(None)) def back() -> EventSpec: @@ -515,7 +802,9 @@ def back() -> EventSpec: Returns: An event to go back one page. """ - return call_script("window.history.back()") + return run_script( + Var("window").to(dict).history.to(dict).back.to(FunctionVar).call() + ) def window_alert(message: str | Var[str]) -> EventSpec: @@ -527,7 +816,7 @@ def window_alert(message: str | Var[str]) -> EventSpec: Returns: An event to alert the message. """ - return server_side("_alert", get_fn_signature(window_alert), message=message) + return run_script(Var("window").to(dict).alert.to(FunctionVar).call(message)) def set_focus(ref: str) -> EventSpec: @@ -542,22 +831,28 @@ 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 run_script( + get_element_by_id.call(elem_id) + .to(ObjectVar) + .scrollIntoView.to(FunctionVar) + .call(align_to_top), + ) def set_value(ref: str, value: Any) -> EventSpec: @@ -573,7 +868,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, ) @@ -654,7 +949,7 @@ def remove_session_storage(key: str) -> EventSpec: ) -def set_clipboard(content: str) -> EventSpec: +def set_clipboard(content: Union[str, Var[str]]) -> EventSpec: """Set the text in content in the clipboard. Args: @@ -663,10 +958,12 @@ def set_clipboard(content: str) -> EventSpec: Returns: EventSpec: An event to set some content in the clipboard. """ - return server_side( - "_set_clipboard", - get_fn_signature(set_clipboard), - content=content, + return run_script( + Var("navigator") + .to(dict) + .clipboard.to(dict) + .writeText.to(FunctionVar) + .call(content) ) @@ -711,19 +1008,15 @@ def download( 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): @@ -757,11 +1050,7 @@ def _callback_arg_spec(eval_result): def call_script( javascript_code: str | Var[str], - callback: EventSpec - | EventHandler - | Callable - | List[EventSpec | EventHandler | Callable] - | None = None, + callback: EventType | None = None, ) -> EventSpec: """Create an event handler that executes arbitrary javascript code. @@ -775,13 +1064,21 @@ def call_script( callback_kwargs = {} if callback is not None: callback_kwargs = { - "callback": str( - format.format_queue_events( - callback, - args_spec=lambda result: [result], - ), - ), + "callback": format.format_queue_events( + callback, + args_spec=lambda result: [result], + )._js_expr, } + 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), @@ -790,6 +1087,60 @@ def call_script( ) +def call_function( + javascript_code: str | Var, + callback: EventType | None = None, +) -> EventSpec: + """Create an event handler that executes arbitrary javascript code. + + Args: + javascript_code: The code to execute. + callback: EventHandler that will receive the result of evaluating the javascript code. + + Returns: + EventSpec: An event that will execute the client side javascript. + """ + callback_kwargs = {} + if callback is not None: + callback_kwargs = { + "callback": format.format_queue_events( + callback, + args_spec=lambda result: [result], + ), + } + + javascript_code = ( + Var(javascript_code) if isinstance(javascript_code, str) else javascript_code + ) + + return server_side( + "_call_function", + get_fn_signature(call_function), + function=javascript_code, + **callback_kwargs, + ) + + +def run_script( + javascript_code: str | Var, + callback: EventType | None = None, +) -> EventSpec: + """Create an event handler that executes arbitrary javascript code. + + Args: + javascript_code: The code to execute. + callback: EventHandler that will receive the result of evaluating the javascript code. + + Returns: + EventSpec: An event that will execute the client side javascript. + """ + javascript_code = ( + Var(javascript_code) if isinstance(javascript_code, str) else javascript_code + ) + + return call_function(ArgsFunctionOperation.create((), javascript_code), callback) + + def get_event(state, event): """Get the event from the given state. @@ -816,8 +1167,9 @@ def get_hydrate_event(state) -> str: def call_event_handler( - event_handler: EventHandler | EventSpec, - arg_spec: ArgsSpec, + event_callback: EventHandler | EventSpec, + event_spec: ArgsSpec | Sequence[ArgsSpec], + key: Optional[str] = None, ) -> EventSpec: """Call an event handler to get the event spec. @@ -826,33 +1178,175 @@ def call_event_handler( Otherwise, the event handler will be called with no args. Args: - event_handler: The event handler. - arg_spec: The lambda that define the argument(s) to pass to the event handler. - - Raises: - ValueError: if number of arguments expected by event_handler doesn't match the spec. + event_callback: The event handler. + event_spec: The lambda that define the argument(s) to pass to the event handler. + key: The key to pass to the event handler. Returns: The event spec from calling the event handler. + + # noqa: DAR401 failure + """ - parsed_args = parse_args_spec(arg_spec) # type: ignore + event_spec_args = parse_args_spec(event_spec) # type: ignore - if isinstance(event_handler, EventSpec): - # 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(',')}'" + if isinstance(event_callback, EventSpec): + check_fn_match_arg_spec( + event_callback.handler.fn, + event_spec, + key, + bool(event_callback.handler.state_full_name) + len(event_callback.args), + event_callback.handler.fn.__qualname__, ) + # Handle partial application of EventSpec args + return event_callback.add_args(*event_spec_args) + + check_fn_match_arg_spec( + event_callback.fn, + event_spec, + key, + bool(event_callback.state_full_name), + event_callback.fn.__qualname__, + ) + + all_acceptable_specs = ( + [event_spec] if not isinstance(event_spec, Sequence) else event_spec + ) + + 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_acceptable_specs + ), + ) + ) + + if event_spec_return_types: + failures = [] + + event_callback_spec = inspect.getfullargspec(event_callback.fn) + + 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_callback.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(event_callback_spec.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}." # noqa: ERA001 + # ) 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_callback.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_callback.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 event_callback_spec.args[1:] + ).replace("[", "\\[") + + console.warn( + f"Event handler {key} expects ({expect_string}) -> () but got ({given_string}) -> () as annotated in {event_callback.fn.__qualname__} instead. " + f"This may lead to unexpected behavior but is intentionally ignored for {key}." + ) + return event_callback(*event_spec_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_callback(*event_spec_args) # type: ignore -def parse_args_spec(arg_spec: ArgsSpec): +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: @@ -861,72 +1355,114 @@ 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] | Var: +def check_fn_match_arg_spec( + user_func: Callable, + arg_spec: ArgsSpec | Sequence[ArgsSpec], + key: str | None = None, + number_of_bound_args: int = 0, + func_name: str | None = None, +): + """Ensures that the function signature matches the passed argument specification + or raises an EventFnArgMismatch if they do not. + + Args: + user_func: The function to be validated. + arg_spec: The argument specification for the event trigger. + key: The key of the event trigger. + number_of_bound_args: The number of bound arguments to the function. + func_name: The name of the function to be validated. + + Raises: + EventFnArgMismatch: Raised if the number of mandatory arguments do not match + """ + user_args = inspect.getfullargspec(user_func).args + # Drop the first argument if it's a bound method + if inspect.ismethod(user_func) and user_func.__self__ is not None: + user_args = user_args[1:] + + user_default_args = inspect.getfullargspec(user_func).defaults + number_of_user_args = len(user_args) - number_of_bound_args + number_of_user_default_args = len(user_default_args) if user_default_args else 0 + + parsed_event_args = parse_args_spec(arg_spec) + + number_of_event_args = len(parsed_event_args) + + if number_of_user_args - number_of_user_default_args > number_of_event_args: + raise EventFnArgMismatch( + f"Event {key} only provides {number_of_event_args} arguments, but " + f"{func_name or user_func} requires at least {number_of_user_args - number_of_user_default_args} " + "arguments to be passed to the event handler.\n" + "See https://reflex.dev/docs/events/event-arguments/" + ) + + +def call_event_fn( + fn: Callable, + arg_spec: ArgsSpec | Sequence[ArgsSpec], + key: Optional[str] = None, +) -> list[EventSpec] | Var: """Call a function to a list of event specs. The function should return a single EventSpec, a list of EventSpecs, or a - single Var. If the function takes in an arg, the arg will be passed to the - function. Otherwise, the function will be called with no args. + single Var. 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 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 + 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.") + parsed_args = parse_args_spec(arg_spec) + + number_of_fn_args = len(inspect.getfullargspec(fn).args) + + # Call the function with the parsed args. + out = fn(*[*parsed_args][:number_of_fn_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): @@ -941,7 +1477,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: @@ -952,7 +1490,7 @@ def get_handler_args(event_spec: EventSpec) -> tuple[tuple[Var, Var], ...]: """ args = inspect.getfullargspec(event_spec.handler.fn).args - return event_spec.args if len(args) > 1 else tuple() + return event_spec.args if len(args) > 1 else () def fix_events( @@ -967,6 +1505,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. """ @@ -990,9 +1531,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 = { @@ -1024,6 +1566,376 @@ def get_fn_signature(fn: Callable) -> inspect.Signature: """ signature = inspect.signature(fn) new_param = inspect.Parameter( - "state", inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=Any + FRONTEND_EVENT_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((type(self).__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(BuilderFunctionVar, 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(ArgsFunctionOperationBuilder, 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((type(self).__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=FunctionArgs(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 + + +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 + + +G = ParamSpec("G") + +if TYPE_CHECKING: + from reflex.state import BaseState + + BASE_STATE = TypeVar("BASE_STATE", bound=BaseState) +else: + BASE_STATE = TypeVar("BASE_STATE") + +StateCallable = TypeAliasType( + "StateCallable", + Callable[Concatenate[BASE_STATE, G], Any], + type_params=(G, BASE_STATE), +) + +IndividualEventType = Union[ + EventSpec, + EventHandler, + Callable[G, Any], + StateCallable[G, BASE_STATE], + EventCallback[G, Any], + Var[Any], +] + +ItemOrList = Union[V, List[V]] + +EventType = ItemOrList[IndividualEventType[G, BASE_STATE]] + + +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 + + @overload + @staticmethod + def __call__( + func: None = None, *, background: bool | None = None + ) -> Callable[[Callable[Concatenate[BASE_STATE, P], T]], EventCallback[P, T]]: ... + + @overload + @staticmethod + def __call__( + func: Callable[Concatenate[BASE_STATE, P], T], + *, + background: bool | None = None, + ) -> EventCallback[P, T]: ... + + @staticmethod + def __call__( + func: Callable[Concatenate[BASE_STATE, P], T] | None = None, + *, + background: bool | None = None, + ) -> Union[ + EventCallback[P, T], + Callable[[Callable[Concatenate[BASE_STATE, 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[BASE_STATE, 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 + + 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) + passthrough_event_spec = staticmethod(passthrough_event_spec) + input_event = staticmethod(input_event) + key_event = staticmethod(key_event) + no_args_event_spec = staticmethod(no_args_event_spec) + server_side = staticmethod(server_side) + redirect = staticmethod(redirect) + console_log = staticmethod(console_log) + noop = staticmethod(noop) + 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) + call_function = staticmethod(call_function) + run_script = staticmethod(run_script) + + +event = EventNamespace() diff --git a/reflex/experimental/__init__.py b/reflex/experimental/__init__.py index 060f7e7f1..164790fe5 100644 --- a/reflex/experimental/__init__.py +++ b/reflex/experimental/__init__.py @@ -2,13 +2,13 @@ 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 . import vars as vars from .assets import asset as asset from .client_state import ClientStateVar as ClientStateVar from .layout import layout as layout @@ -33,19 +33,40 @@ class ExperimentalNamespace(SimpleNamespace): Returns: The toast namespace. """ - if "toast" not in _EMITTED_PROMOTION_WARNINGS: - _EMITTED_PROMOTION_WARNINGS.add("toast") - warn(f"`rx._x.toast` was promoted to `rx.toast`.") + self.register_component_warning("toast") return toast + @property + def progress(self): + """Temporary property returning the toast namespace. + + Remove this property when toast is fully promoted. + + Returns: + The toast namespace. + """ + self.register_component_warning("progress") + return progress + + @staticmethod + def register_component_warning(component_name: str): + """Add component to emitted warnings and throw a warning if it + doesn't exist. + + Args: + component_name: name of the component. + """ + if component_name not in _EMITTED_PROMOTION_WARNINGS: + _EMITTED_PROMOTION_WARNINGS.add(component_name) + warn(f"`rx._x.{component_name}` was promoted to `rx.{component_name}`.") + _x = ExperimentalNamespace( asset=asset, client_state=ClientStateVar.create, hooks=hooks, - vars=vars, layout=layout, - progress=progress, PropsBase=PropsBase, run_in_thread=run_in_thread, + code_block=code_block, ) diff --git a/reflex/experimental/assets.py b/reflex/experimental/assets.py index c18ac1e84..e9be19aaf 100644 --- a/reflex/experimental/assets.py +++ b/reflex/experimental/assets.py @@ -1,14 +1,15 @@ """Helper functions for adding assets to the app.""" -import inspect -from pathlib import Path from typing import Optional -from reflex import constants +from reflex import assets +from reflex.utils import console def asset(relative_filename: str, subfolder: Optional[str] = None) -> str: - """Add an asset to the app. + """DEPRECATED: use `rx.asset` with `shared=True` instead. + + 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. @@ -22,36 +23,15 @@ def asset(relative_filename: str, subfolder: Optional[str] = None) -> str: relative_filename: The relative filename of the asset. subfolder: The directory to place the asset in. - Raises: - FileNotFoundError: If the file does not exist. - 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]) - assert module is not 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 + console.deprecate( + feature_name="rx._x.asset", + reason="Use `rx.asset` with `shared=True` instead of `rx._x.asset`.", + deprecation_version="0.6.6", + removal_version="0.7.0", + ) + return assets.asset( + relative_filename, shared=True, subfolder=subfolder, _stack_level=2 + ) diff --git a/reflex/experimental/client_state.py b/reflex/experimental/client_state.py index 3033b94dd..1982b3dfe 100644 --- a/reflex/experimental/client_state.py +++ b/reflex/experimental/client_state.py @@ -3,19 +3,22 @@ from __future__ import annotations import dataclasses +import re import sys -from typing import Any, Callable, Optional, Type, Union +from typing import Any, Callable, Union from reflex import constants -from reflex.event import EventChain, EventHandler, EventSpec, call_script +from reflex.event import EventChain, EventHandler, EventSpec, run_script from reflex.utils.imports import ImportVar -from reflex.vars import Var, VarData, get_unique_variable_name +from reflex.vars import VarData, get_unique_variable_name +from reflex.vars.base import LiteralVar, Var +from reflex.vars.function import FunctionVar NoValue = object() _refs_import = { - f"/{constants.Dirs.STATE_PATH}": [ImportVar(tag="refs")], + f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="refs")], } @@ -33,36 +36,19 @@ def _client_state_ref(var_name: str) -> str: @dataclasses.dataclass( eq=False, + frozen=True, **{"slots": True} if sys.version_info >= (3, 10) else {}, ) class ClientStateVar(Var): """A Var that exists on the client via useState.""" - # The name of the var. - _var_name: str = dataclasses.field() - # Track the names of the getters and setters - _setter_name: str = dataclasses.field() - _getter_name: str = dataclasses.field() + _setter_name: str = dataclasses.field(default="") + _getter_name: str = dataclasses.field(default="") # Whether to add the var and setter to the global `refs` object for use in any Component. _global_ref: bool = dataclasses.field(default=True) - # The type of the var. - _var_type: Type = dataclasses.field(default=Any) - - # Whether this is a local javascript variable. - _var_is_local: bool = dataclasses.field(default=False) - - # Whether the var is a string literal. - _var_is_string: bool = dataclasses.field(default=False) - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False) - - # Extra metadata associated with the Var - _var_data: Optional[VarData] = dataclasses.field(default=None) - def __hash__(self) -> int: """Define a hash function for a var. @@ -70,7 +56,7 @@ class ClientStateVar(Var): The hash of the var. """ return hash( - (self._var_name, str(self._var_type), self._getter_name, self._setter_name) + (self._js_expr, str(self._var_type), self._getter_name, self._setter_name) ) @classmethod @@ -102,24 +88,25 @@ class ClientStateVar(Var): 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() - assert isinstance(var_name, str), "var_name must be a string." + if not isinstance(var_name, str): + raise ValueError("var_name must be a string.") if default is NoValue: - default_var = Var.create_safe("", _var_is_local=False, _var_is_string=False) + default_var = Var(_js_expr="") elif not isinstance(default, Var): - default_var = Var.create_safe( - default, - _var_is_string=isinstance(default, str), - ) + default_var = LiteralVar.create(default) else: default_var = default setter_name = f"set{var_name.capitalize()}" hooks = { - f"const [{var_name}, {setter_name}] = useState({default_var._var_name_unwrapped})": None, + f"const [{var_name}, {setter_name}] = useState({default_var!s})": None, } imports = { "react": [ImportVar(tag="useState")], @@ -129,16 +116,14 @@ class ClientStateVar(Var): hooks[f"{_client_state_ref(setter_name)} = {setter_name}"] = None imports.update(_refs_import) return cls( - _var_name="", + _js_expr="", _setter_name=setter_name, _getter_name=var_name, _global_ref=global_ref, - _var_is_local=False, - _var_is_string=False, _var_type=default_var._var_type, _var_data=VarData.merge( default_var._var_data, - VarData( # type: ignore + VarData( hooks=hooks, imports=imports, ), @@ -157,12 +142,12 @@ class ClientStateVar(Var): an accessor for the client state variable. """ return ( - Var.create_safe( - _client_state_ref(self._getter_name) - if self._global_ref - else self._getter_name, - _var_is_local=False, - _var_is_string=False, + Var( + _js_expr=( + _client_state_ref(self._getter_name) + if self._global_ref + else self._getter_name + ) ) .to(self._var_type) ._replace( @@ -190,27 +175,23 @@ class ClientStateVar(Var): 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.create_safe(value, _var_is_string=isinstance(value, str)) - if not value._var_is_string and value._var_full_name.startswith("_"): - arg = value._var_name_unwrapped.partition(".")[0] + 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: - arg = "" - setter = f"({arg}) => {setter}({value._var_name_unwrapped})" - return ( - Var.create_safe( - setter, - _var_is_local=False, - _var_is_string=False, - ) - .to(EventChain) - ._replace( - merge_var_data=VarData( # type: ignore - imports=_refs_import if self._global_ref else {} - ) - ) - ) + setter = f"(() => {setter}({value_str}))" + return Var( + _js_expr=setter, + _var_data=_var_data, + ).to(FunctionVar, EventChain) @property def set(self) -> Var: @@ -243,7 +224,7 @@ class ClientStateVar(Var): """ 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) + return run_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. @@ -261,4 +242,5 @@ class ClientStateVar(Var): """ 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})") + value = Var.create(value) + return run_script(f"{_client_state_ref(self._setter_name)}({value})") diff --git a/reflex/experimental/hooks.py b/reflex/experimental/hooks.py index 848ad7fb7..7d648225a 100644 --- a/reflex/experimental/hooks.py +++ b/reflex/experimental/hooks.py @@ -3,7 +3,8 @@ from __future__ import annotations from reflex.utils.imports import ImportVar -from reflex.vars import Var, VarData +from reflex.vars import VarData +from reflex.vars.base import Var def _compose_react_imports(tags: list[str]) -> dict[str, list[ImportVar]]: @@ -21,10 +22,8 @@ def const(name, value) -> Var: The constant Var. """ if isinstance(name, list): - return Var.create_safe( - f"const [{', '.join(name)}] = {value}", _var_is_string=False - ) - return Var.create_safe(f"const {name} = {value}", _var_is_string=False) + return Var(_js_expr=f"const [{', '.join(name)}] = {value}") + return Var(_js_expr=f"const {name} = {value}") def useCallback(func, deps) -> Var: @@ -37,9 +36,8 @@ def useCallback(func, deps) -> Var: Returns: The useCallback hook. """ - return Var.create_safe( - f"useCallback({func}, {deps})" if deps else f"useCallback({func})", - _var_is_string=False, + return Var( + _js_expr=f"useCallback({func}, {deps})" if deps else f"useCallback({func})", _var_data=VarData(imports=_compose_react_imports(["useCallback"])), ) @@ -53,9 +51,8 @@ def useContext(context) -> Var: Returns: The useContext hook. """ - return Var.create_safe( - f"useContext({context})", - _var_is_string=False, + return Var( + _js_expr=f"useContext({context})", _var_data=VarData(imports=_compose_react_imports(["useContext"])), ) @@ -69,9 +66,8 @@ def useRef(default) -> Var: Returns: The useRef hook. """ - return Var.create_safe( - f"useRef({default})", - _var_is_string=False, + return Var( + _js_expr=f"useRef({default})", _var_data=VarData(imports=_compose_react_imports(["useRef"])), ) @@ -88,9 +84,8 @@ def useState(var_name, default=None) -> Var: """ return const( [var_name, f"set{var_name.capitalize()}"], - Var.create_safe( - f"useState({default})", - _var_is_string=False, + Var( + _js_expr=f"useState({default})", _var_data=VarData(imports=_compose_react_imports(["useState"])), ), ) diff --git a/reflex/experimental/layout.py b/reflex/experimental/layout.py index cf39ccb6c..e5a1bab04 100644 --- a/reflex/experimental/layout.py +++ b/reflex/experimental/layout.py @@ -12,11 +12,11 @@ from reflex.components.radix.themes.components.icon_button import IconButton 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.event import run_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): @@ -33,12 +33,6 @@ class Sidebar(Box, MemoizationLeaf): Returns: The sidebar component. """ - # props.setdefault("border_right", f"1px solid {color('accent', 12)}") - # props.setdefault("background_color", color("accent", 1)) - # props.setdefault("width", "20vw") - # props.setdefault("height", "100vh") - # props.setdefault("position", "fixed") - return super().create( Box.create(*children, **props), # sidebar for content Box.create(width=props.get("width")), # spacer for layout @@ -55,7 +49,7 @@ class Sidebar(Box, MemoizationLeaf): open = ( self.State.open # type: ignore if self.State - else Var.create_safe("open", _var_is_string=False) + else Var(_js_expr="open") ) sidebar.style["display"] = spacer.style["display"] = cond(open, "block", "none") @@ -172,8 +166,8 @@ class SidebarTrigger(Fragment): open, toggle = sidebar.State.open, sidebar.State.toggle # type: ignore else: open, toggle = ( - Var.create_safe("open", _var_is_string=False), - call_script(Var.create_safe("setOpen(!open)", _var_is_string=False)), + Var(_js_expr="open"), + run_script("setOpen(!open)"), ) trigger_props["left"] = cond(open, f"calc({sidebar_width} - 32px)", "0") diff --git a/reflex/experimental/layout.pyi b/reflex/experimental/layout.pyi index 68e7e1ecd..4c7fc8d47 100644 --- a/reflex/experimental/layout.pyi +++ b/reflex/experimental/layout.pyi @@ -3,17 +3,17 @@ # ------------------- DO NOT EDIT ---------------------- # This file was generated by `reflex/utils/pyi_generator.py`! # ------------------------------------------------------ -from typing import Any, Callable, Dict, List, Literal, Optional, Union, overload +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 EventHandler, EventSpec +from reflex.event import BASE_STATE, EventType from reflex.state import ComponentState from reflex.style import Style -from reflex.vars import BaseVar, Var +from reflex.vars.base import Var class Sidebar(Box, MemoizationLeaf): @overload @@ -21,81 +21,51 @@ class Sidebar(Box, MemoizationLeaf): def create( # type: ignore cls, *children, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Sidebar": """Create the sidebar component. @@ -125,75 +95,51 @@ class DrawerSidebar(DrawerRoot): def create( # type: ignore cls, *children, + default_open: Optional[Union[Var[bool], bool]] = None, 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[ - Var[Literal["top", "bottom", "left", "right"]], - Literal["top", "bottom", "left", "right"], + Literal["bottom", "left", "right", "top"], + Var[Literal["bottom", "left", "right", "top"]], ] ] = None, + dismissible: Optional[Union[Var[bool], bool]] = None, + handle_only: Optional[Union[Var[bool], bool]] = 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, preventScrollRestoration: Optional[Union[Var[bool], bool]] = None, + should_scale_background: Optional[Union[Var[bool], bool]] = None, + close_threshold: Optional[Union[Var[float], float]] = 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[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_animation_end: Optional[ + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, on_open_change: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] + Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]] ] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "DrawerSidebar": """Create the sidebar component. @@ -226,52 +172,22 @@ class SidebarTrigger(Fragment): id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "SidebarTrigger": """Create the sidebar trigger component. @@ -292,81 +208,51 @@ class Layout(Box): cls, *children, sidebar: Optional[Component] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Layout": """Create the layout component. @@ -390,81 +276,51 @@ class LayoutNamespace(ComponentNamespace): def __call__( *children, sidebar: Optional[Component] = None, - access_key: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, auto_capitalize: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, content_editable: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, context_menu: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - dir: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - draggable: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + dir: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + draggable: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, enter_key_hint: Optional[ - Union[Var[Union[bool, int, str]], str, int, bool] + Union[Var[Union[bool, int, str]], bool, int, str] ] = None, - hidden: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - input_mode: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - item_prop: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - lang: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - role: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - slot: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - spell_check: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - tab_index: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, - title: Optional[Union[Var[Union[bool, int, str]], str, int, bool]] = None, + hidden: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + input_mode: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + item_prop: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + lang: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + role: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + slot: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + spell_check: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + tab_index: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, + title: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, class_name: Optional[Any] = None, autofocus: Optional[bool] = None, - custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, - on_blur: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_context_menu: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_double_click: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_focus: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_down: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_enter: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_leave: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_move: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_out: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_over: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_mouse_up: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_scroll: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, - on_unmount: Optional[ - Union[EventHandler, EventSpec, list, Callable, BaseVar] - ] = None, + custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None, + on_blur: Optional[EventType[[], BASE_STATE]] = None, + on_click: Optional[EventType[[], BASE_STATE]] = None, + on_context_menu: Optional[EventType[[], BASE_STATE]] = None, + on_double_click: Optional[EventType[[], BASE_STATE]] = None, + on_focus: Optional[EventType[[], BASE_STATE]] = None, + on_mount: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_down: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_move: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_out: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_over: Optional[EventType[[], BASE_STATE]] = None, + on_mouse_up: Optional[EventType[[], BASE_STATE]] = None, + on_scroll: Optional[EventType[[], BASE_STATE]] = None, + on_unmount: Optional[EventType[[], BASE_STATE]] = None, **props, ) -> "Layout": """Create the layout component. diff --git a/reflex/experimental/misc.py b/reflex/experimental/misc.py index 716d081b8..a2a5a0615 100644 --- a/reflex/experimental/misc.py +++ b/reflex/experimental/misc.py @@ -7,15 +7,17 @@ from typing import Any 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.background() decorated method. + 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 non-async function to run. + Raises: + ValueError: If the function is an async function. + Returns: Any: The return value of the function. """ - assert not asyncio.coroutines.iscoroutinefunction( - func - ), "func must be a non-async function" + 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/experimental/vars/base.py b/reflex/experimental/vars/base.py deleted file mode 100644 index 7da1e6537..000000000 --- a/reflex/experimental/vars/base.py +++ /dev/null @@ -1,583 +0,0 @@ -"""Collection of base classes.""" - -from __future__ import annotations - -import dataclasses -import functools -import inspect -import sys -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Generic, - List, - Optional, - Set, - Tuple, - Type, - TypeVar, - Union, - overload, -) - -from typing_extensions import ParamSpec, get_origin - -from reflex import constants -from reflex.base import Base -from reflex.utils import serializers, types -from reflex.utils.exceptions import VarTypeError -from reflex.vars import ( - ImmutableVarData, - Var, - VarData, - _decode_var_immutable, - _extract_var_data, - _global_vars, -) - -if TYPE_CHECKING: - from .function import FunctionVar, ToFunctionOperation - from .number import ( - BooleanVar, - NumberVar, - ToBooleanVarOperation, - ToNumberVarOperation, - ) - from .object import ObjectVar, ToObjectOperation - from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation - -VAR_TYPE = TypeVar("VAR_TYPE") - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ImmutableVar(Var, Generic[VAR_TYPE]): - """Base class for immutable vars.""" - - # The name of the var. - _var_name: str = dataclasses.field() - - # The type of the var. - _var_type: types.GenericType = dataclasses.field(default=Any) - - # Extra metadata associated with the Var - _var_data: Optional[ImmutableVarData] = dataclasses.field(default=None) - - def __str__(self) -> str: - """String representation of the var. Guaranteed to be a valid Javascript expression. - - Returns: - The name of the var. - """ - return self._var_name - - @property - def _var_is_local(self) -> bool: - """Whether this is a local javascript variable. - - Returns: - False - """ - return False - - @property - def _var_is_string(self) -> bool: - """Whether the var is a string literal. - - Returns: - False - """ - return False - - @property - def _var_full_name_needs_state_prefix(self) -> bool: - """Whether the full name of the var needs a _var_state prefix. - - Returns: - False - """ - return False - - def __post_init__(self): - """Post-initialize the var.""" - # Decode any inline Var markup and apply it to the instance - _var_data, _var_name = _decode_var_immutable(self._var_name) - - if _var_data or _var_name != self._var_name: - self.__init__( - _var_name=_var_name, - _var_type=self._var_type, - _var_data=ImmutableVarData.merge(self._var_data, _var_data), - ) - - def __hash__(self) -> int: - """Define a hash function for the var. - - Returns: - The hash of the var. - """ - return hash((self._var_name, self._var_type, self._var_data)) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return self._var_data - - def _replace(self, merge_var_data=None, **kwargs: Any): - """Make a copy of this Var with updated fields. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - A new ImmutableVar with the updated fields overwriting the corresponding fields in this Var. - - Raises: - TypeError: If _var_is_local, _var_is_string, or _var_full_name_needs_state_prefix is not None. - """ - if kwargs.get("_var_is_local", False) is not False: - raise TypeError( - "The _var_is_local argument is not supported for ImmutableVar." - ) - - if kwargs.get("_var_is_string", False) is not False: - raise TypeError( - "The _var_is_string argument is not supported for ImmutableVar." - ) - - if kwargs.get("_var_full_name_needs_state_prefix", False) is not False: - raise TypeError( - "The _var_full_name_needs_state_prefix argument is not supported for ImmutableVar." - ) - - field_values = dict( - _var_name=kwargs.pop("_var_name", self._var_name), - _var_type=kwargs.pop("_var_type", self._var_type), - _var_data=ImmutableVarData.merge( - kwargs.get("_var_data", self._var_data), merge_var_data - ), - ) - return type(self)(**field_values) - - @classmethod - def create( - cls, - value: Any, - _var_is_local: bool | None = None, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> ImmutableVar | Var | None: - """Create a var from a value. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. Deprecated. - _var_is_string: Whether the var is a string literal. Deprecated. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - - Raises: - VarTypeError: If the value is JSON-unserializable. - TypeError: If _var_is_local or _var_is_string is not None. - """ - if _var_is_local is not None: - raise TypeError( - "The _var_is_local argument is not supported for ImmutableVar." - ) - - if _var_is_string is not None: - raise TypeError( - "The _var_is_string argument is not supported for ImmutableVar." - ) - - from reflex.utils import format - - # Check for none values. - if value is None: - return None - - # If the value is already a var, do nothing. - if isinstance(value, Var): - return value - - # Try to pull the imports and hooks from contained values. - if not isinstance(value, str): - _var_data = VarData.merge(*_extract_var_data(value), _var_data) - - # Try to serialize the value. - type_ = type(value) - if type_ in types.JSONType: - name = value - else: - name, _serialized_type = serializers.serialize(value, get_type=True) - if name is None: - raise VarTypeError( - f"No JSON serializer found for var {value} of type {type_}." - ) - name = name if isinstance(name, str) else format.json_dumps(name) - - return cls( - _var_name=name, - _var_type=type_, - _var_data=( - ImmutableVarData( - state=_var_data.state, - imports=_var_data.imports, - hooks=_var_data.hooks, - ) - if _var_data - else None - ), - ) - - @classmethod - def create_safe( - cls, - value: Any, - _var_is_local: bool | None = None, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> Var | ImmutableVar: - """Create a var from a value, asserting that it is not None. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. Deprecated. - _var_is_string: Whether the var is a string literal. Deprecated. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - var = cls.create( - value, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string, - _var_data=_var_data, - ) - assert var is not None - return var - - def __format__(self, format_spec: str) -> str: - """Format the var into a Javascript equivalent to an f-string. - - Args: - format_spec: The format specifier (Ignored for now). - - Returns: - The formatted var. - """ - hashed_var = hash(self) - - _global_vars[hashed_var] = self - - # Encode the _var_data into the formatted output for tracking purposes. - return f"{constants.REFLEX_VAR_OPENING_TAG}{hashed_var}{constants.REFLEX_VAR_CLOSING_TAG}{self._var_name}" - - @overload - def to( - self, output: Type[NumberVar], var_type: type[int] | type[float] = float - ) -> ToNumberVarOperation: ... - - @overload - def to(self, output: Type[BooleanVar]) -> ToBooleanVarOperation: ... - - @overload - def to( - self, - output: Type[ArrayVar], - var_type: type[list] | type[tuple] | type[set] = list, - ) -> ToArrayOperation: ... - - @overload - def to(self, output: Type[StringVar]) -> ToStringOperation: ... - - @overload - def to( - self, output: Type[ObjectVar], var_type: types.GenericType = dict - ) -> ToObjectOperation: ... - - @overload - def to( - self, output: Type[FunctionVar], var_type: Type[Callable] = Callable - ) -> ToFunctionOperation: ... - - @overload - def to( - self, output: Type[OUTPUT], var_type: types.GenericType | None = None - ) -> OUTPUT: ... - - def to( - self, output: Type[OUTPUT], var_type: types.GenericType | None = None - ) -> Var: - """Convert the var to a different type. - - Args: - output: The output type. - var_type: The type of the var. - - Raises: - TypeError: If the var_type is not a supported type for the output. - - Returns: - The converted var. - """ - from .number import ( - BooleanVar, - NumberVar, - ToBooleanVarOperation, - ToNumberVarOperation, - ) - - fixed_type = ( - var_type - if var_type is None or inspect.isclass(var_type) - else get_origin(var_type) - ) - - if issubclass(output, NumberVar): - if fixed_type is not None and not issubclass(fixed_type, (int, float)): - raise TypeError( - f"Unsupported type {var_type} for NumberVar. Must be int or float." - ) - return ToNumberVarOperation(self, var_type or float) - if issubclass(output, BooleanVar): - return ToBooleanVarOperation(self) - - from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation - - if issubclass(output, ArrayVar): - if fixed_type is not None and not issubclass( - fixed_type, (list, tuple, set) - ): - raise TypeError( - f"Unsupported type {var_type} for ArrayVar. Must be list, tuple, or set." - ) - return ToArrayOperation(self, var_type or list) - if issubclass(output, StringVar): - return ToStringOperation(self) - - from .object import ObjectVar, ToObjectOperation - - if issubclass(output, ObjectVar): - return ToObjectOperation(self, var_type or dict) - - from .function import FunctionVar, ToFunctionOperation - - if issubclass(output, FunctionVar): - if fixed_type is not None and not issubclass(fixed_type, Callable): - raise TypeError( - f"Unsupported type {var_type} for FunctionVar. Must be Callable." - ) - return ToFunctionOperation(self, var_type or Callable) - - return output( - _var_name=self._var_name, - _var_type=self._var_type if var_type is None else var_type, - _var_data=self._var_data, - ) - - def guess_type(self) -> ImmutableVar: - """Guess the type of the var. - - Returns: - The guessed type. - """ - from .number import NumberVar - from .object import ObjectVar - from .sequence import ArrayVar, StringVar - - if self._var_type is Any: - return self - - var_type = self._var_type - - fixed_type = var_type if inspect.isclass(var_type) else get_origin(var_type) - - if issubclass(fixed_type, (int, float)): - return self.to(NumberVar, var_type) - if issubclass(fixed_type, dict): - return self.to(ObjectVar, var_type) - if issubclass(fixed_type, (list, tuple, set)): - return self.to(ArrayVar, var_type) - if issubclass(fixed_type, str): - return self.to(StringVar) - if issubclass(fixed_type, Base): - return self.to(ObjectVar, var_type) - return self - - -OUTPUT = TypeVar("OUTPUT", bound=ImmutableVar) - - -class LiteralVar(ImmutableVar): - """Base class for immutable literal vars.""" - - @classmethod - def create( - cls, - value: Any, - _var_data: VarData | None = None, - ) -> Var: - """Create a var from a value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - - Raises: - TypeError: If the value is not a supported type for LiteralVar. - """ - if isinstance(value, Var): - if _var_data is None: - return value - return value._replace(merge_var_data=_var_data) - - if value is None: - return ImmutableVar.create_safe("null", _var_data=_var_data) - - from .object import LiteralObjectVar - - if isinstance(value, Base): - return LiteralObjectVar( - value.dict(), _var_type=type(value), _var_data=_var_data - ) - - from .number import LiteralBooleanVar, LiteralNumberVar - from .sequence import LiteralArrayVar, LiteralStringVar - - if isinstance(value, str): - return LiteralStringVar.create(value, _var_data=_var_data) - - type_mapping = { - int: LiteralNumberVar, - float: LiteralNumberVar, - bool: LiteralBooleanVar, - dict: LiteralObjectVar, - list: LiteralArrayVar, - tuple: LiteralArrayVar, - set: LiteralArrayVar, - } - - constructor = type_mapping.get(type(value)) - - if constructor is None: - raise TypeError(f"Unsupported type {type(value)} for LiteralVar.") - - return constructor(value, _var_data=_var_data) - - def __post_init__(self): - """Post-initialize the var.""" - - def json(self) -> str: - """Serialize the var to a JSON string. - - Raises: - NotImplementedError: If the method is not implemented. - """ - raise NotImplementedError( - "LiteralVar subclasses must implement the json method." - ) - - -P = ParamSpec("P") -T = TypeVar("T", bound=ImmutableVar) - - -def var_operation(*, output: Type[T]) -> Callable[[Callable[P, str]], Callable[P, T]]: - """Decorator for creating a var operation. - - Example: - ```python - @var_operation(output=NumberVar) - def add(a: NumberVar, b: NumberVar): - return f"({a} + {b})" - ``` - - Args: - output: The output type of the operation. - - Returns: - The decorator. - """ - - def decorator(func: Callable[P, str], output=output): - @functools.wraps(func) - def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: - args_vars = [ - LiteralVar.create(arg) if not isinstance(arg, Var) else arg - for arg in args - ] - kwargs_vars = { - key: LiteralVar.create(value) if not isinstance(value, Var) else value - for key, value in kwargs.items() - } - return output( - _var_name=func(*args_vars, **kwargs_vars), # type: ignore - _var_data=VarData.merge( - *[arg._get_all_var_data() for arg in args if isinstance(arg, Var)], - *[ - arg._get_all_var_data() - for arg in kwargs.values() - if isinstance(arg, Var) - ], - ), - ) - - return wrapper - - return decorator - - -def unionize(*args: Type) -> Type: - """Unionize the types. - - Args: - args: The types to unionize. - - Returns: - The unionized types. - """ - if not args: - return Any - first, *rest = args - if not rest: - return first - return Union[first, unionize(*rest)] - - -def figure_out_type(value: Any) -> Type: - """Figure out the type of the value. - - Args: - value: The value to figure out the type of. - - Returns: - The type of the value. - """ - if isinstance(value, list): - return List[unionize(*(figure_out_type(v) for v in value))] - if isinstance(value, set): - return Set[unionize(*(figure_out_type(v) for v in value))] - if isinstance(value, tuple): - return Tuple[unionize(*(figure_out_type(v) for v in value)), ...] - if isinstance(value, dict): - return Dict[ - unionize(*(figure_out_type(k) for k in value)), - unionize(*(figure_out_type(v) for v in value.values())), - ] - return type(value) diff --git a/reflex/experimental/vars/function.py b/reflex/experimental/vars/function.py deleted file mode 100644 index 4514a482d..000000000 --- a/reflex/experimental/vars/function.py +++ /dev/null @@ -1,290 +0,0 @@ -"""Immutable function vars.""" - -from __future__ import annotations - -import dataclasses -import sys -from functools import cached_property -from typing import Any, Callable, Optional, Tuple, Type, Union - -from reflex.experimental.vars.base import ImmutableVar, LiteralVar -from reflex.vars import ImmutableVarData, Var, VarData - - -class FunctionVar(ImmutableVar[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( - ("...args",), - VarOperationCall(self, *args, ImmutableVar.create_safe("...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(self, *args) - - -class FunctionStringVar(FunctionVar): - """Base class for immutable function vars from a string.""" - - def __init__(self, func: str, _var_data: VarData | None = None) -> None: - """Initialize the function var. - - Args: - func: The function to call. - _var_data: Additional hooks and imports associated with the Var. - """ - super(FunctionVar, self).__init__( - _var_name=func, - _var_type=Callable, - _var_data=ImmutableVarData.merge(_var_data), - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class VarOperationCall(ImmutableVar): - """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) - - def __init__( - self, func: FunctionVar, *args: Var | Any, _var_data: VarData | None = None - ): - """Initialize the 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. - """ - super(VarOperationCall, self).__init__( - _var_name="", - _var_type=Any, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_func", func) - object.__setattr__(self, "_args", args) - object.__delattr__(self, "_var_name") - - def __getattr__(self, name): - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the var. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - 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 - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self._func._get_all_var_data() if self._func is not None else None, - *[var._get_all_var_data() for var in self._args], - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - def __post_init__(self): - """Post-initialize the var.""" - pass - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArgsFunctionOperation(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) - - def __init__( - self, - args_names: Tuple[str, ...], - return_expr: Var | Any, - _var_data: VarData | None = None, - ) -> None: - """Initialize the function with arguments 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. - """ - super(ArgsFunctionOperation, self).__init__( - _var_name=f"", - _var_type=Callable, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_args_names", args_names) - object.__setattr__(self, "_return_expr", return_expr) - object.__delattr__(self, "_var_name") - - def __getattr__(self, name): - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the var. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - 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))}))" - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self._return_expr._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - def __post_init__(self): - """Post-initialize the var.""" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToFunctionOperation(FunctionVar): - """Base class of converting a var to a function.""" - - _original_var: Var = dataclasses.field( - default_factory=lambda: LiteralVar.create(None) - ) - - def __init__( - self, - original_var: Var, - _var_type: Type[Callable] = Callable, - _var_data: VarData | None = None, - ) -> None: - """Initialize the function with arguments var. - - Args: - original_var: The original var to convert to a function. - _var_type: The type of the function. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ToFunctionOperation, self).__init__( - _var_name=f"", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_original_var", original_var) - object.__delattr__(self, "_var_name") - - def __getattr__(self, name): - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the var. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_var) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self._original_var._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data diff --git a/reflex/experimental/vars/number.py b/reflex/experimental/vars/number.py deleted file mode 100644 index 6bd3a7ff7..000000000 --- a/reflex/experimental/vars/number.py +++ /dev/null @@ -1,1458 +0,0 @@ -"""Immutable number vars.""" - -from __future__ import annotations - -import dataclasses -import json -import sys -from functools import cached_property -from typing import Any, Union - -from reflex.experimental.vars.base import ( - ImmutableVar, - LiteralVar, -) -from reflex.vars import ImmutableVarData, Var, VarData - - -class NumberVar(ImmutableVar[Union[int, float]]): - """Base class for immutable number vars.""" - - def __add__(self, other: number_types | boolean_types) -> NumberAddOperation: - """Add two numbers. - - Args: - other: The other number. - - Returns: - The number addition operation. - """ - return NumberAddOperation(self, +other) - - def __radd__(self, other: number_types | boolean_types) -> NumberAddOperation: - """Add two numbers. - - Args: - other: The other number. - - Returns: - The number addition operation. - """ - return NumberAddOperation(+other, self) - - def __sub__(self, other: number_types | boolean_types) -> NumberSubtractOperation: - """Subtract two numbers. - - Args: - other: The other number. - - Returns: - The number subtraction operation. - """ - return NumberSubtractOperation(self, +other) - - def __rsub__(self, other: number_types | boolean_types) -> NumberSubtractOperation: - """Subtract two numbers. - - Args: - other: The other number. - - Returns: - The number subtraction operation. - """ - return NumberSubtractOperation(+other, self) - - def __abs__(self) -> NumberAbsoluteOperation: - """Get the absolute value of the number. - - Returns: - The number absolute operation. - """ - return NumberAbsoluteOperation(self) - - def __mul__(self, other: number_types | boolean_types) -> NumberMultiplyOperation: - """Multiply two numbers. - - Args: - other: The other number. - - Returns: - The number multiplication operation. - """ - return NumberMultiplyOperation(self, +other) - - def __rmul__(self, other: number_types | boolean_types) -> NumberMultiplyOperation: - """Multiply two numbers. - - Args: - other: The other number. - - Returns: - The number multiplication operation. - """ - return NumberMultiplyOperation(+other, self) - - def __truediv__(self, other: number_types | boolean_types) -> NumberTrueDivision: - """Divide two numbers. - - Args: - other: The other number. - - Returns: - The number true division operation. - """ - return NumberTrueDivision(self, +other) - - def __rtruediv__(self, other: number_types | boolean_types) -> NumberTrueDivision: - """Divide two numbers. - - Args: - other: The other number. - - Returns: - The number true division operation. - """ - return NumberTrueDivision(+other, self) - - def __floordiv__(self, other: number_types | boolean_types) -> NumberFloorDivision: - """Floor divide two numbers. - - Args: - other: The other number. - - Returns: - The number floor division operation. - """ - return NumberFloorDivision(self, +other) - - def __rfloordiv__(self, other: number_types | boolean_types) -> NumberFloorDivision: - """Floor divide two numbers. - - Args: - other: The other number. - - Returns: - The number floor division operation. - """ - return NumberFloorDivision(+other, self) - - def __mod__(self, other: number_types | boolean_types) -> NumberModuloOperation: - """Modulo two numbers. - - Args: - other: The other number. - - Returns: - The number modulo operation. - """ - return NumberModuloOperation(self, +other) - - def __rmod__(self, other: number_types | boolean_types) -> NumberModuloOperation: - """Modulo two numbers. - - Args: - other: The other number. - - Returns: - The number modulo operation. - """ - return NumberModuloOperation(+other, self) - - def __pow__(self, other: number_types | boolean_types) -> NumberExponentOperation: - """Exponentiate two numbers. - - Args: - other: The other number. - - Returns: - The number exponent operation. - """ - return NumberExponentOperation(self, +other) - - def __rpow__(self, other: number_types | boolean_types) -> NumberExponentOperation: - """Exponentiate two numbers. - - Args: - other: The other number. - - Returns: - The number exponent operation. - """ - return NumberExponentOperation(+other, self) - - def __neg__(self) -> NumberNegateOperation: - """Negate the number. - - Returns: - The number negation operation. - """ - return NumberNegateOperation(self) - - def __and__(self, other: number_types | boolean_types) -> BooleanAndOperation: - """Boolean AND two numbers. - - Args: - other: The other number. - - Returns: - The boolean AND operation. - """ - boolified_other = other.bool() if isinstance(other, Var) else bool(other) - return BooleanAndOperation(self.bool(), boolified_other) - - def __rand__(self, other: number_types | boolean_types) -> BooleanAndOperation: - """Boolean AND two numbers. - - Args: - other: The other number. - - Returns: - The boolean AND operation. - """ - boolified_other = other.bool() if isinstance(other, Var) else bool(other) - return BooleanAndOperation(boolified_other, self.bool()) - - def __or__(self, other: number_types | boolean_types) -> BooleanOrOperation: - """Boolean OR two numbers. - - Args: - other: The other number. - - Returns: - The boolean OR operation. - """ - boolified_other = other.bool() if isinstance(other, Var) else bool(other) - return BooleanOrOperation(self.bool(), boolified_other) - - def __ror__(self, other: number_types | boolean_types) -> BooleanOrOperation: - """Boolean OR two numbers. - - Args: - other: The other number. - - Returns: - The boolean OR operation. - """ - boolified_other = other.bool() if isinstance(other, Var) else bool(other) - return BooleanOrOperation(boolified_other, self.bool()) - - def __invert__(self) -> BooleanNotOperation: - """Boolean NOT the number. - - Returns: - The boolean NOT operation. - """ - return BooleanNotOperation(self.bool()) - - def __pos__(self) -> NumberVar: - """Positive the number. - - Returns: - The number. - """ - return self - - def __round__(self) -> NumberRoundOperation: - """Round the number. - - Returns: - The number round operation. - """ - return NumberRoundOperation(self) - - def __ceil__(self) -> NumberCeilOperation: - """Ceil the number. - - Returns: - The number ceil operation. - """ - return NumberCeilOperation(self) - - def __floor__(self) -> NumberFloorOperation: - """Floor the number. - - Returns: - The number floor operation. - """ - return NumberFloorOperation(self) - - def __trunc__(self) -> NumberTruncOperation: - """Trunc the number. - - Returns: - The number trunc operation. - """ - return NumberTruncOperation(self) - - def __lt__(self, other: number_types | boolean_types) -> LessThanOperation: - """Less than comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - return LessThanOperation(self, +other) - - def __le__(self, other: number_types | boolean_types) -> LessThanOrEqualOperation: - """Less than or equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - return LessThanOrEqualOperation(self, +other) - - def __eq__(self, other: number_types | boolean_types) -> EqualOperation: - """Equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - return EqualOperation(self, +other) - - def __ne__(self, other: number_types | boolean_types) -> NotEqualOperation: - """Not equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - return NotEqualOperation(self, +other) - - def __gt__(self, other: number_types | boolean_types) -> GreaterThanOperation: - """Greater than comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - return GreaterThanOperation(self, +other) - - def __ge__( - self, other: number_types | boolean_types - ) -> GreaterThanOrEqualOperation: - """Greater than or equal comparison. - - Args: - other: The other number. - - Returns: - The result of the comparison. - """ - return GreaterThanOrEqualOperation(self, +other) - - def bool(self) -> NotEqualOperation: - """Boolean conversion. - - Returns: - The boolean value of the number. - """ - return NotEqualOperation(self, 0) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BinaryNumberOperation(NumberVar): - """Base class for immutable number vars that are the result of a binary operation.""" - - a: number_types = dataclasses.field(default=0) - b: number_types = dataclasses.field(default=0) - - def __init__( - self, - a: number_types, - b: number_types, - _var_data: VarData | None = None, - ): - """Initialize the binary number operation var. - - Args: - a: The first number. - b: The second number. - _var_data: Additional hooks and imports associated with the Var. - """ - super(BinaryNumberOperation, self).__init__( - _var_name="", - _var_type=float, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__setattr__(self, "b", b) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses - """ - raise NotImplementedError( - "BinaryNumberOperation must implement _cached_var_name" - ) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(BinaryNumberOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return ImmutableVarData.merge( - first_value._get_all_var_data(), - second_value._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class UnaryNumberOperation(NumberVar): - """Base class for immutable number vars that are the result of a unary operation.""" - - a: number_types = dataclasses.field(default=0) - - def __init__( - self, - a: number_types, - _var_data: VarData | None = None, - ): - """Initialize the unary number operation var. - - Args: - a: The number. - _var_data: Additional hooks and imports associated with the Var. - """ - super(UnaryNumberOperation, self).__init__( - _var_name="", - _var_type=float, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "UnaryNumberOperation must implement _cached_var_name" - ) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(UnaryNumberOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return ImmutableVarData.merge(value._get_all_var_data(), self._var_data) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class NumberAddOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of an addition operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"({str(first_value)} + {str(second_value)})" - - -class NumberSubtractOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a subtraction operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"({str(first_value)} - {str(second_value)})" - - -class NumberAbsoluteOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of an absolute operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return f"Math.abs({str(value)})" - - -class NumberMultiplyOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a multiplication operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"({str(first_value)} * {str(second_value)})" - - -class NumberNegateOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a negation operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return f"-({str(value)})" - - -class NumberTrueDivision(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a true division operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"({str(first_value)} / {str(second_value)})" - - -class NumberFloorDivision(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a floor division operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"Math.floor({str(first_value)} / {str(second_value)})" - - -class NumberModuloOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of a modulo operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"({str(first_value)} % {str(second_value)})" - - -class NumberExponentOperation(BinaryNumberOperation): - """Base class for immutable number vars that are the result of an exponent operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralNumberVar(self.b) - return f"({str(first_value)} ** {str(second_value)})" - - -class NumberRoundOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a round operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return f"Math.round({str(value)})" - - -class NumberCeilOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a ceil operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return f"Math.ceil({str(value)})" - - -class NumberFloorOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a floor operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return f"Math.floor({str(value)})" - - -class NumberTruncOperation(UnaryNumberOperation): - """Base class for immutable number vars that are the result of a trunc operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralNumberVar(self.a) - return f"Math.trunc({str(value)})" - - -class BooleanVar(ImmutableVar[bool]): - """Base class for immutable boolean vars.""" - - def __and__(self, other: bool) -> BooleanAndOperation: - """AND two booleans. - - Args: - other: The other boolean. - - Returns: - The boolean AND operation. - """ - return BooleanAndOperation(self, other) - - def __rand__(self, other: bool) -> BooleanAndOperation: - """AND two booleans. - - Args: - other: The other boolean. - - Returns: - The boolean AND operation. - """ - return BooleanAndOperation(other, self) - - def __or__(self, other: bool) -> BooleanOrOperation: - """OR two booleans. - - Args: - other: The other boolean. - - Returns: - The boolean OR operation. - """ - return BooleanOrOperation(self, other) - - def __ror__(self, other: bool) -> BooleanOrOperation: - """OR two booleans. - - Args: - other: The other boolean. - - Returns: - The boolean OR operation. - """ - return BooleanOrOperation(other, self) - - def __invert__(self) -> BooleanNotOperation: - """NOT the boolean. - - Returns: - The boolean NOT operation. - """ - return BooleanNotOperation(self) - - def __int__(self) -> BooleanToIntOperation: - """Convert the boolean to an int. - - Returns: - The boolean to int operation. - """ - return BooleanToIntOperation(self) - - def __pos__(self) -> BooleanToIntOperation: - """Convert the boolean to an int. - - Returns: - The boolean to int operation. - """ - return BooleanToIntOperation(self) - - def bool(self) -> BooleanVar: - """Boolean conversion. - - Returns: - The boolean value of the boolean. - """ - return self - - def __lt__(self, other: boolean_types | number_types) -> LessThanOperation: - """Less than comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return LessThanOperation(+self, +other) - - def __le__(self, other: boolean_types | number_types) -> LessThanOrEqualOperation: - """Less than or equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return LessThanOrEqualOperation(+self, +other) - - def __eq__(self, other: boolean_types | number_types) -> EqualOperation: - """Equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return EqualOperation(+self, +other) - - def __ne__(self, other: boolean_types | number_types) -> NotEqualOperation: - """Not equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return NotEqualOperation(+self, +other) - - def __gt__(self, other: boolean_types | number_types) -> GreaterThanOperation: - """Greater than comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return GreaterThanOperation(+self, +other) - - def __ge__( - self, other: boolean_types | number_types - ) -> GreaterThanOrEqualOperation: - """Greater than or equal comparison. - - Args: - other: The other boolean. - - Returns: - The result of the comparison. - """ - return GreaterThanOrEqualOperation(+self, +other) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BooleanToIntOperation(NumberVar): - """Base class for immutable number vars that are the result of a boolean to int operation.""" - - a: boolean_types = dataclasses.field(default=False) - - def __init__( - self, - a: boolean_types, - _var_data: VarData | None = None, - ): - """Initialize the boolean to int operation var. - - Args: - a: The boolean. - _var_data: Additional hooks and imports associated with the Var. - """ - super(BooleanToIntOperation, self).__init__( - _var_name="", - _var_type=int, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"({str(self.a)} ? 1 : 0)" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(BooleanToIntOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data() if isinstance(self.a, Var) else None, - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class NumberComparisonOperation(BooleanVar): - """Base class for immutable boolean vars that are the result of a comparison operation.""" - - a: number_types = dataclasses.field(default=0) - b: number_types = dataclasses.field(default=0) - - def __init__( - self, - a: number_types, - b: number_types, - _var_data: VarData | None = None, - ): - """Initialize the comparison operation var. - - Args: - a: The first value. - b: The second value. - _var_data: Additional hooks and imports associated with the Var. - """ - super(NumberComparisonOperation, self).__init__( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__setattr__(self, "b", b) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError("ComparisonOperation must implement _cached_var_name") - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(NumberComparisonOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return ImmutableVarData.merge( - first_value._get_all_var_data(), second_value._get_all_var_data() - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class GreaterThanOperation(NumberComparisonOperation): - """Base class for immutable boolean vars that are the result of a greater than operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} > {str(second_value)})" - - -class GreaterThanOrEqualOperation(NumberComparisonOperation): - """Base class for immutable boolean vars that are the result of a greater than or equal operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} >= {str(second_value)})" - - -class LessThanOperation(NumberComparisonOperation): - """Base class for immutable boolean vars that are the result of a less than operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} < {str(second_value)})" - - -class LessThanOrEqualOperation(NumberComparisonOperation): - """Base class for immutable boolean vars that are the result of a less than or equal operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} <= {str(second_value)})" - - -class EqualOperation(NumberComparisonOperation): - """Base class for immutable boolean vars that are the result of an equal operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} == {str(second_value)})" - - -class NotEqualOperation(NumberComparisonOperation): - """Base class for immutable boolean vars that are the result of a not equal operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} != {str(second_value)})" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LogicalOperation(BooleanVar): - """Base class for immutable boolean vars that are the result of a logical operation.""" - - a: boolean_types = dataclasses.field(default=False) - b: boolean_types = dataclasses.field(default=False) - - def __init__( - self, a: boolean_types, b: boolean_types, _var_data: VarData | None = None - ): - """Initialize the logical operation var. - - Args: - a: The first value. - b: The second value. - _var_data: Additional hooks and imports associated with the Var. - """ - super(LogicalOperation, self).__init__( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__setattr__(self, "b", b) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError("LogicalOperation must implement _cached_var_name") - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(LogicalOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return ImmutableVarData.merge( - first_value._get_all_var_data(), second_value._get_all_var_data() - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class BooleanAndOperation(LogicalOperation): - """Base class for immutable boolean vars that are the result of a logical AND operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} && {str(second_value)})" - - -class BooleanOrOperation(LogicalOperation): - """Base class for immutable boolean vars that are the result of a logical OR operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - first_value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - second_value = self.b if isinstance(self.b, Var) else LiteralVar.create(self.b) - return f"({str(first_value)} || {str(second_value)})" - - -class BooleanNotOperation(BooleanVar): - """Base class for immutable boolean vars that are the result of a logical NOT operation.""" - - a: boolean_types = dataclasses.field() - - def __init__(self, a: boolean_types, _var_data: VarData | None = None): - """Initialize the logical NOT operation var. - - Args: - a: The value. - _var_data: Additional hooks and imports associated with the Var. - """ - super(BooleanNotOperation, self).__init__( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - return f"!({str(value)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(BooleanNotOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - value = self.a if isinstance(self.a, Var) else LiteralVar.create(self.a) - return ImmutableVarData.merge(value._get_all_var_data()) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@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 __init__( - self, - _var_value: bool, - _var_data: VarData | None = None, - ): - """Initialize the boolean var. - - Args: - _var_value: The value of the var. - _var_data: Additional hooks and imports associated with the Var. - """ - super(LiteralBooleanVar, self).__init__( - _var_name="true" if _var_value else "false", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_var_value", _var_value) - - def __hash__(self) -> int: - """Hash 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 "true" if self._var_value else "false" - - -@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 __init__( - self, - _var_value: float | int, - _var_data: VarData | None = None, - ): - """Initialize the number var. - - Args: - _var_value: The value of the var. - _var_data: Additional hooks and imports associated with the Var. - """ - super(LiteralNumberVar, self).__init__( - _var_name=str(_var_value), - _var_type=type(_var_value), - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_var_value", _var_value) - - def __hash__(self) -> int: - """Hash 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) - - -number_types = Union[NumberVar, LiteralNumberVar, int, float] -boolean_types = Union[BooleanVar, LiteralBooleanVar, bool] - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToNumberVarOperation(NumberVar): - """Base class for immutable number vars that are the result of a number operation.""" - - _original_value: Var = dataclasses.field( - default_factory=lambda: LiteralNumberVar(0) - ) - - def __init__( - self, - _original_value: Var, - _var_type: type[int] | type[float] = float, - _var_data: VarData | None = None, - ): - """Initialize the number var. - - Args: - _original_value: The original value. - _var_type: The type of the Var. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ToNumberVarOperation, self).__init__( - _var_name="", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_original_value", _original_value) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_value) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ToNumberVarOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self._original_value._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToBooleanVarOperation(BooleanVar): - """Base class for immutable boolean vars that are the result of a boolean operation.""" - - _original_value: Var = dataclasses.field( - default_factory=lambda: LiteralBooleanVar(False) - ) - - def __init__( - self, - _original_value: Var, - _var_data: VarData | None = None, - ): - """Initialize the boolean var. - - Args: - _original_value: The original value. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ToBooleanVarOperation, self).__init__( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_original_value", _original_value) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self._original_value) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ToBooleanVarOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self._original_value._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data diff --git a/reflex/experimental/vars/object.py b/reflex/experimental/vars/object.py deleted file mode 100644 index a227f0d7c..000000000 --- a/reflex/experimental/vars/object.py +++ /dev/null @@ -1,804 +0,0 @@ -"""Classes for immutable object vars.""" - -from __future__ import annotations - -import dataclasses -import sys -import typing -from functools import cached_property -from inspect import isclass -from typing import ( - Any, - Dict, - List, - NoReturn, - Tuple, - Type, - TypeVar, - Union, - get_args, - overload, -) - -from typing_extensions import get_origin - -from reflex.experimental.vars.base import ( - ImmutableVar, - LiteralVar, - figure_out_type, -) -from reflex.experimental.vars.number import NumberVar -from reflex.experimental.vars.sequence import ArrayVar, StringVar -from reflex.utils.exceptions import VarAttributeError -from reflex.utils.types import GenericType, get_attribute_access_type -from reflex.vars import ImmutableVarData, Var, VarData - -OBJECT_TYPE = TypeVar("OBJECT_TYPE") - -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(ImmutableVar[OBJECT_TYPE]): - """Base class for immutable object vars.""" - - @overload - def _key_type(self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]) -> KEY_TYPE: ... - - @overload - def _key_type(self) -> Type: ... - - def _key_type(self) -> Type: - """Get the type of the keys of the object. - - Returns: - The type of the keys of the object. - """ - fixed_type = ( - self._var_type if isclass(self._var_type) else get_origin(self._var_type) - ) - args = get_args(self._var_type) if issubclass(fixed_type, dict) else () - return args[0] if args else Any - - @overload - def _value_type(self: ObjectVar[Dict[KEY_TYPE, VALUE_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 = ( - self._var_type if isclass(self._var_type) else get_origin(self._var_type) - ) - args = get_args(self._var_type) if issubclass(fixed_type, dict) else () - return args[1] if args else Any - - @overload - def keys( - self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]], - ) -> ArrayVar[List[KEY_TYPE]]: ... - - @overload - def keys(self) -> ArrayVar: ... - - def keys(self) -> ArrayVar: - """Get the keys of the object. - - Returns: - The keys of the object. - """ - return ObjectKeysOperation(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 ObjectValuesOperation(self) - - @overload - def entries( - self: ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]], - ) -> ArrayVar[List[Tuple[KEY_TYPE, VALUE_TYPE]]]: ... - - @overload - def entries(self) -> ArrayVar: ... - - def entries(self) -> ArrayVar: - """Get the entries of the object. - - Returns: - The entries of the object. - """ - return ObjectEntriesOperation(self) - - def merge(self, other: ObjectVar) -> ObjectMergeOperation: - """Merge two objects. - - Args: - other: The other object to merge. - - Returns: - The merged object. - """ - return ObjectMergeOperation(self, other) - - # NoReturn is used here to catch when key value is Any - @overload - def __getitem__( - self: ObjectVar[Dict[KEY_TYPE, NoReturn]], - key: Var | Any, - ) -> ImmutableVar: ... - - @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) -> ImmutableVar: - """Get an item from the object. - - Args: - key: The key to get from the object. - - Returns: - The item from the object. - """ - return ObjectItemOperation(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, - ) -> ImmutableVar: ... - - @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) -> ImmutableVar: - """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. - """ - fixed_type = ( - self._var_type if isclass(self._var_type) else get_origin(self._var_type) - ) - if not issubclass(fixed_type, dict): - attribute_type = get_attribute_access_type(self._var_type, name) - if attribute_type is None: - raise VarAttributeError( - f"The State var `{self._var_name}` has no attribute '{name}' or may have been annotated " - f"wrongly." - ) - return ObjectItemOperation(self, name, attribute_type).guess_type() - else: - return ObjectItemOperation(self, name).guess_type() - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LiteralObjectVar(LiteralVar, ObjectVar[OBJECT_TYPE]): - """Base class for immutable literal object vars.""" - - _var_value: Dict[Union[Var, Any], Union[Var, Any]] = dataclasses.field( - default_factory=dict - ) - - def __init__( - self: LiteralObjectVar[OBJECT_TYPE], - _var_value: OBJECT_TYPE, - _var_type: Type[OBJECT_TYPE] | None = None, - _var_data: VarData | None = None, - ): - """Initialize the 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. - """ - super(LiteralObjectVar, self).__init__( - _var_name="", - _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type), - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, - "_var_value", - _var_value, - ) - object.__delattr__(self, "_var_name") - - 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 - - def __getattr__(self, name): - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the var. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - 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() - ] - ) - + " })" - ) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - *[ - value._get_all_var_data() - for key, value in self._var_value - if isinstance(value, Var) - ], - *[ - key._get_all_var_data() - for key, value in self._var_value - if isinstance(key, Var) - ], - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - 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._var_name)) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ObjectToArrayOperation(ArrayVar): - """Base class for object to array operations.""" - - value: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({})) - - def __init__( - self, - _var_value: ObjectVar, - _var_type: Type = list, - _var_data: VarData | None = None, - ): - """Initialize the object to array operation. - - Args: - _var_value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ObjectToArrayOperation, self).__init__( - _var_name="", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "value", _var_value) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Raises: - NotImplementedError: Must implement _cached_var_name. - """ - raise NotImplementedError( - "ObjectToArrayOperation must implement _cached_var_name" - ) - - def __getattr__(self, name): - """Get an attribute of the operation. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the operation. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the operation. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.value._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - -class ObjectKeysOperation(ObjectToArrayOperation): - """Operation to get the keys of an object.""" - - def __init__( - self, - value: ObjectVar, - _var_data: VarData | None = None, - ): - """Initialize the object keys operation. - - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ObjectKeysOperation, self).__init__( - value, List[value._key_type()], _var_data - ) - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"Object.keys({self.value._var_name})" - - -class ObjectValuesOperation(ObjectToArrayOperation): - """Operation to get the values of an object.""" - - def __init__( - self, - value: ObjectVar, - _var_data: VarData | None = None, - ): - """Initialize the object values operation. - - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ObjectValuesOperation, self).__init__( - value, List[value._value_type()], _var_data - ) - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"Object.values({self.value._var_name})" - - -class ObjectEntriesOperation(ObjectToArrayOperation): - """Operation to get the entries of an object.""" - - def __init__( - self, - value: ObjectVar, - _var_data: VarData | None = None, - ): - """Initialize the object entries operation. - - Args: - value: The value of the operation. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ObjectEntriesOperation, self).__init__( - value, List[Tuple[value._key_type(), value._value_type()]], _var_data - ) - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"Object.entries({self.value._var_name})" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ObjectMergeOperation(ObjectVar): - """Operation to merge two objects.""" - - left: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({})) - right: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({})) - - def __init__( - self, - left: ObjectVar, - right: ObjectVar, - _var_data: VarData | None = None, - ): - """Initialize the object merge operation. - - Args: - left: The left object to merge. - right: The right object to merge. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ObjectMergeOperation, self).__init__( - _var_name="", - _var_type=left._var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "left", left) - object.__setattr__(self, "right", right) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"Object.assign({self.left._var_name}, {self.right._var_name})" - - def __getattr__(self, name): - """Get an attribute of the operation. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the operation. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the operation. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.left._get_all_var_data(), - self.right._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ObjectItemOperation(ImmutableVar): - """Operation to get an item from an object.""" - - value: ObjectVar = dataclasses.field(default_factory=lambda: LiteralObjectVar({})) - key: Var | Any = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - def __init__( - self, - value: ObjectVar, - key: Var | Any, - _var_type: GenericType | None = None, - _var_data: VarData | None = None, - ): - """Initialize the object item operation. - - Args: - value: The value of the operation. - key: The key to get from the object. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ObjectItemOperation, self).__init__( - _var_name="", - _var_type=value._value_type() if _var_type is None else _var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "value", value) - object.__setattr__( - self, "key", key if isinstance(key, Var) else LiteralVar.create(key) - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return f"{str(self.value)}[{str(self.key)}]" - - def __getattr__(self, name): - """Get an attribute of the operation. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the operation. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the operation. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.value._get_all_var_data(), - self.key._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToObjectOperation(ObjectVar): - """Operation to convert a var to an object.""" - - _original_var: Var = dataclasses.field(default_factory=lambda: LiteralObjectVar({})) - - def __init__( - self, - _original_var: Var, - _var_type: Type = dict, - _var_data: VarData | None = None, - ): - """Initialize the to object operation. - - Args: - _original_var: The original var to convert. - _var_type: The type of the var. - _var_data: Additional hooks and imports associated with the operation. - """ - super(ToObjectOperation, self).__init__( - _var_name="", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_original_var", _original_var) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the operation. - - Returns: - The name of the operation. - """ - return str(self._original_var) - - def __getattr__(self, name): - """Get an attribute of the operation. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the operation. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the operation. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self._original_var._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data diff --git a/reflex/experimental/vars/sequence.py b/reflex/experimental/vars/sequence.py deleted file mode 100644 index f622159a6..000000000 --- a/reflex/experimental/vars/sequence.py +++ /dev/null @@ -1,1764 +0,0 @@ -"""Collection of string classes and utilities.""" - -from __future__ import annotations - -import dataclasses -import functools -import inspect -import json -import re -import sys -import typing -from functools import cached_property -from typing import ( - TYPE_CHECKING, - Any, - Dict, - List, - Literal, - Set, - Tuple, - TypeVar, - Union, - overload, -) - -from typing_extensions import get_origin - -from reflex import constants -from reflex.constants.base import REFLEX_VAR_OPENING_TAG -from reflex.experimental.vars.base import ( - ImmutableVar, - LiteralVar, - figure_out_type, - unionize, -) -from reflex.experimental.vars.number import ( - BooleanVar, - LiteralNumberVar, - NotEqualOperation, - NumberVar, -) -from reflex.utils.types import GenericType -from reflex.vars import ImmutableVarData, Var, VarData, _global_vars - -if TYPE_CHECKING: - from .object import ObjectVar - - -class StringVar(ImmutableVar[str]): - """Base class for immutable string vars.""" - - def __add__(self, other: StringVar | str) -> ConcatVarOperation: - """Concatenate two strings. - - Args: - other: The other string. - - Returns: - The string concatenation operation. - """ - return ConcatVarOperation(self, other) - - def __radd__(self, other: StringVar | str) -> ConcatVarOperation: - """Concatenate two strings. - - Args: - other: The other string. - - Returns: - The string concatenation operation. - """ - return ConcatVarOperation(other, self) - - def __mul__(self, other: int) -> ConcatVarOperation: - """Concatenate two strings. - - Args: - other: The other string. - - Returns: - The string concatenation operation. - """ - return ConcatVarOperation(*[self for _ in range(other)]) - - def __rmul__(self, other: int) -> ConcatVarOperation: - """Concatenate two strings. - - Args: - other: The other string. - - Returns: - The string concatenation operation. - """ - return ConcatVarOperation(*[self for _ in range(other)]) - - @overload - def __getitem__(self, i: slice) -> ArrayJoinOperation: ... - - @overload - def __getitem__(self, i: int | NumberVar) -> StringItemOperation: ... - - def __getitem__( - self, i: slice | int | NumberVar - ) -> ArrayJoinOperation | StringItemOperation: - """Get a slice of the string. - - Args: - i: The slice. - - Returns: - The string slice operation. - """ - if isinstance(i, slice): - return self.split()[i].join() - return StringItemOperation(self, i) - - def length(self) -> NumberVar: - """Get the length of the string. - - Returns: - The string length operation. - """ - return self.split().length() - - def lower(self) -> StringLowerOperation: - """Convert the string to lowercase. - - Returns: - The string lower operation. - """ - return StringLowerOperation(self) - - def upper(self) -> StringUpperOperation: - """Convert the string to uppercase. - - Returns: - The string upper operation. - """ - return StringUpperOperation(self) - - def strip(self) -> StringStripOperation: - """Strip the string. - - Returns: - The string strip operation. - """ - return StringStripOperation(self) - - def bool(self) -> NotEqualOperation: - """Boolean conversion. - - Returns: - The boolean value of the string. - """ - return NotEqualOperation(self.length(), 0) - - def reversed(self) -> ArrayJoinOperation: - """Reverse the string. - - Returns: - The string reverse operation. - """ - return self.split().reverse().join() - - def contains(self, other: StringVar | str) -> StringContainsOperation: - """Check if the string contains another string. - - Args: - other: The other string. - - Returns: - The string contains operation. - """ - return StringContainsOperation(self, other) - - def split(self, separator: StringVar | str = "") -> StringSplitOperation: - """Split the string. - - Args: - separator: The separator. - - Returns: - The string split operation. - """ - return StringSplitOperation(self, separator) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringToStringOperation(StringVar): - """Base class for immutable string vars that are the result of a string to string operation.""" - - a: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - def __init__(self, a: StringVar | str, _var_data: VarData | None = None): - """Initialize the string to string operation var. - - Args: - a: The string. - _var_data: Additional hooks and imports associated with the Var. - """ - super(StringToStringOperation, self).__init__( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a) - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "StringToStringOperation must implement _cached_var_name" - ) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(StringToStringOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data() if isinstance(self.a, Var) else None, - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class StringLowerOperation(StringToStringOperation): - """Base class for immutable string vars that are the result of a string lower operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.toLowerCase()" - - -class StringUpperOperation(StringToStringOperation): - """Base class for immutable string vars that are the result of a string upper operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.toUpperCase()" - - -class StringStripOperation(StringToStringOperation): - """Base class for immutable string vars that are the result of a string strip operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.trim()" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringContainsOperation(BooleanVar): - """Base class for immutable boolean vars that are the result of a string contains operation.""" - - a: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - b: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - def __init__( - self, a: StringVar | str, b: StringVar | str, _var_data: VarData | None = None - ): - """Initialize the string contains operation var. - - Args: - a: The first string. - b: The second string. - _var_data: Additional hooks and imports associated with the Var. - """ - super(StringContainsOperation, self).__init__( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a) - ) - object.__setattr__( - self, "b", b if isinstance(b, Var) else LiteralStringVar.create(b) - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.includes({str(self.b)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(StringContainsOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringItemOperation(StringVar): - """Base class for immutable string vars that are the result of a string item operation.""" - - a: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - i: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0)) - - def __init__( - self, a: StringVar | str, i: int | NumberVar, _var_data: VarData | None = None - ): - """Initialize the string item operation var. - - Args: - a: The string. - i: The index. - _var_data: Additional hooks and imports associated with the Var. - """ - super(StringItemOperation, self).__init__( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a) - ) - object.__setattr__(self, "i", i if isinstance(i, Var) else LiteralNumberVar(i)) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.at({str(self.i)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(StringItemOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), self.i._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class ArrayJoinOperation(StringVar): - """Base class for immutable string vars that are the result of an array join operation.""" - - a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([])) - b: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - def __init__( - self, a: ArrayVar, b: StringVar | str, _var_data: VarData | None = None - ): - """Initialize the array join operation var. - - Args: - a: The array. - b: The separator. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ArrayJoinOperation, self).__init__( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__setattr__( - self, "b", b if isinstance(b, Var) else LiteralStringVar.create(b) - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.join({str(self.b)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ArrayJoinOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -# Compile regex for finding reflex var tags. -_decode_var_pattern_re = ( - rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}" -) -_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class LiteralStringVar(LiteralVar, StringVar): - """Base class for immutable literal string vars.""" - - _var_value: str = dataclasses.field(default="") - - def __init__( - self, - _var_value: str, - _var_data: VarData | None = None, - ): - """Initialize the string var. - - Args: - _var_value: The value of the var. - _var_data: Additional hooks and imports associated with the Var. - """ - super(LiteralStringVar, self).__init__( - _var_name=f'"{_var_value}"', - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "_var_value", _var_value) - - @classmethod - def create( - cls, - value: str, - _var_data: VarData | None = None, - ) -> LiteralStringVar | ConcatVarOperation: - """Create a var from a string value. - - Args: - value: The value to create the var from. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - if REFLEX_VAR_OPENING_TAG in value: - strings_and_vals: list[Var | str] = [] - offset = 0 - - # Initialize some methods for reading json. - var_data_config = VarData().__config__ - - def json_loads(s): - try: - return var_data_config.json_loads(s) - except json.decoder.JSONDecodeError: - return var_data_config.json_loads( - var_data_config.json_loads(f'"{s}"') - ) - - # Find all tags - while m := _decode_var_pattern.search(value): - start, end = m.span() - if start > 0: - strings_and_vals.append(value[:start]) - - serialized_data = m.group(1) - - if serialized_data.isnumeric() or ( - serialized_data[0] == "-" and serialized_data[1:].isnumeric() - ): - # This is a global immutable var. - var = _global_vars[int(serialized_data)] - strings_and_vals.append(var) - value = value[(end + len(var._var_name)) :] - else: - data = json_loads(serialized_data) - string_length = data.pop("string_length", None) - var_data = VarData.parse_obj(data) - - # Use string length to compute positions of interpolations. - if string_length is not None: - realstart = start + offset - var_data.interpolations = [ - (realstart, realstart + string_length) - ] - strings_and_vals.append( - ImmutableVar.create_safe( - value[end : (end + string_length)], _var_data=var_data - ) - ) - value = value[(end + string_length) :] - - offset += end - start - - if value: - strings_and_vals.append(value) - - return ConcatVarOperation(*strings_and_vals, _var_data=_var_data) - - return LiteralStringVar( - value, - _var_data=_var_data, - ) - - def __hash__(self) -> int: - """Get the hash of the var. - - Returns: - The hash of the var. - """ - return hash((self.__class__.__name__, self._var_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(StringVar): - """Representing a concatenation of literal string vars.""" - - _var_value: Tuple[Union[Var, str], ...] = dataclasses.field(default_factory=tuple) - - def __init__(self, *value: Var | str, _var_data: VarData | None = None): - """Initialize the operation of concatenating literal string vars. - - Args: - value: The values to concatenate. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ConcatVarOperation, self).__init__( - _var_name="", _var_data=ImmutableVarData.merge(_var_data), _var_type=str - ) - object.__setattr__(self, "_var_value", value) - object.__delattr__(self, "_var_name") - - def __getattr__(self, name): - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the var. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return ( - "(" - + "+".join( - [ - str(element) if isinstance(element, Var) else f'"{element}"' - for element in self._var_value - ] - ) - + ")" - ) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - *[ - var._get_all_var_data() - for var in self._var_value - if isinstance(var, Var) - ], - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - def __post_init__(self): - """Post-initialize the var.""" - pass - - -ARRAY_VAR_TYPE = TypeVar("ARRAY_VAR_TYPE", bound=Union[List, Tuple, Set]) - -OTHER_TUPLE = TypeVar("OTHER_TUPLE") - -INNER_ARRAY_VAR = TypeVar("INNER_ARRAY_VAR") - -KEY_TYPE = TypeVar("KEY_TYPE") -VALUE_TYPE = TypeVar("VALUE_TYPE") - - -class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]): - """Base class for immutable array vars.""" - - from reflex.experimental.vars.sequence import StringVar - - def join(self, sep: StringVar | str = "") -> ArrayJoinOperation: - """Join the elements of the array. - - Args: - sep: The separator between elements. - - Returns: - The joined elements. - """ - from reflex.experimental.vars.sequence import ArrayJoinOperation - - return ArrayJoinOperation(self, sep) - - def reverse(self) -> ArrayVar[ARRAY_VAR_TYPE]: - """Reverse the array. - - Returns: - The reversed array. - """ - return ArrayReverseOperation(self) - - @overload - def __getitem__(self, i: slice) -> ArrayVar[ARRAY_VAR_TYPE]: ... - - @overload - def __getitem__( - self: ( - ArrayVar[Tuple[int, OTHER_TUPLE]] - | ArrayVar[Tuple[float, OTHER_TUPLE]] - | ArrayVar[Tuple[int | float, OTHER_TUPLE]] - ), - i: Literal[0, -2], - ) -> NumberVar: ... - - @overload - def __getitem__( - self: ( - ArrayVar[Tuple[OTHER_TUPLE, int]] - | ArrayVar[Tuple[OTHER_TUPLE, float]] - | ArrayVar[Tuple[OTHER_TUPLE, int | float]] - ), - i: Literal[1, -1], - ) -> NumberVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[str, OTHER_TUPLE]], i: Literal[0, -2] - ) -> StringVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[OTHER_TUPLE, str]], i: Literal[1, -1] - ) -> StringVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[bool, OTHER_TUPLE]], i: Literal[0, -2] - ) -> BooleanVar: ... - - @overload - def __getitem__( - self: ArrayVar[Tuple[OTHER_TUPLE, bool]], i: Literal[1, -1] - ) -> BooleanVar: ... - - @overload - def __getitem__( - self: ( - ARRAY_VAR_OF_LIST_ELEMENT[int] - | ARRAY_VAR_OF_LIST_ELEMENT[float] - | ARRAY_VAR_OF_LIST_ELEMENT[int | float] - ), - i: int | NumberVar, - ) -> NumberVar: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[str], i: int | NumberVar - ) -> StringVar: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[bool], i: int | NumberVar - ) -> BooleanVar: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[List[INNER_ARRAY_VAR]], - i: int | NumberVar, - ) -> ArrayVar[List[INNER_ARRAY_VAR]]: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[Set[INNER_ARRAY_VAR]], - i: int | NumberVar, - ) -> ArrayVar[Set[INNER_ARRAY_VAR]]: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[Tuple[INNER_ARRAY_VAR, ...]], - i: int | NumberVar, - ) -> ArrayVar[Tuple[INNER_ARRAY_VAR, ...]]: ... - - @overload - def __getitem__( - self: ARRAY_VAR_OF_LIST_ELEMENT[Dict[KEY_TYPE, VALUE_TYPE]], - i: int | NumberVar, - ) -> ObjectVar[Dict[KEY_TYPE, VALUE_TYPE]]: ... - - @overload - def __getitem__(self, i: int | NumberVar) -> ImmutableVar: ... - - def __getitem__( - self, i: slice | int | NumberVar - ) -> ArrayVar[ARRAY_VAR_TYPE] | ImmutableVar: - """Get a slice of the array. - - Args: - i: The slice. - - Returns: - The array slice operation. - """ - if isinstance(i, slice): - return ArraySliceOperation(self, i) - return ArrayItemOperation(self, i).guess_type() - - def length(self) -> NumberVar: - """Get the length of the array. - - Returns: - The length of the array. - """ - return ArrayLengthOperation(self) - - @overload - @classmethod - def range(cls, stop: int | NumberVar, /) -> ArrayVar[List[int]]: ... - - @overload - @classmethod - def range( - cls, - start: int | NumberVar, - end: int | NumberVar, - step: int | NumberVar = 1, - /, - ) -> ArrayVar[List[int]]: ... - - @classmethod - def range( - cls, - first_endpoint: int | NumberVar, - second_endpoint: int | NumberVar | None = None, - step: int | NumberVar | None = None, - ) -> ArrayVar[List[int]]: - """Create a range of numbers. - - Args: - first_endpoint: The end of the range if second_endpoint is not provided, otherwise the start of the range. - second_endpoint: The end of the range. - step: The step of the range. - - Returns: - The range of numbers. - """ - if second_endpoint is None: - start = 0 - end = first_endpoint - else: - start = first_endpoint - end = second_endpoint - - return RangeOperation(start, end, step or 1) - - def contains(self, other: Any) -> BooleanVar: - """Check if the array contains an element. - - Args: - other: The element to check for. - - Returns: - The array contains operation. - """ - return ArrayContainsOperation(self, other) - - -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(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) - - def __init__( - self: LiteralArrayVar[ARRAY_VAR_TYPE], - _var_value: ARRAY_VAR_TYPE, - _var_type: type[ARRAY_VAR_TYPE] | None = None, - _var_data: VarData | None = None, - ): - """Initialize the array 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. - """ - super(LiteralArrayVar, self).__init__( - _var_name="", - _var_data=ImmutableVarData.merge(_var_data), - _var_type=(figure_out_type(_var_value) if _var_type is None else _var_type), - ) - object.__setattr__(self, "_var_value", _var_value) - object.__delattr__(self, "_var_name") - - def __getattr__(self, name): - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute of the var. - """ - if name == "_var_name": - return self._cached_var_name - return super(type(self), self).__getattr__(name) - - @functools.cached_property - 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] - ) - + "]" - ) - - @functools.cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - *[ - var._get_all_var_data() - for var in self._var_value - if isinstance(var, Var) - ], - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - """Wrapper method for cached property. - - Returns: - The VarData of the components and all of its children. - """ - return self._cached_get_all_var_data - - def __hash__(self) -> int: - """Get the hash of the var. - - Returns: - The hash of the var. - """ - return hash((self.__class__.__name__, self._var_name)) - - def json(self) -> str: - """Get the JSON representation of the var. - - Returns: - The JSON representation of the var. - """ - return ( - "[" - + ", ".join( - [LiteralVar.create(element).json() for element in self._var_value] - ) - + "]" - ) - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class StringSplitOperation(ArrayVar): - """Base class for immutable array vars that are the result of a string split operation.""" - - a: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - b: StringVar = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - def __init__( - self, a: StringVar | str, b: StringVar | str, _var_data: VarData | None = None - ): - """Initialize the string split operation var. - - Args: - a: The string. - b: The separator. - _var_data: Additional hooks and imports associated with the Var. - """ - super(StringSplitOperation, self).__init__( - _var_name="", - _var_type=List[str], - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, "a", a if isinstance(a, Var) else LiteralStringVar.create(a) - ) - object.__setattr__( - self, "b", b if isinstance(b, Var) else LiteralStringVar.create(b) - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.split({str(self.b)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(StringSplitOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayToArrayOperation(ArrayVar): - """Base class for immutable array vars that are the result of an array to array operation.""" - - a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([])) - - def __init__(self, a: ArrayVar, _var_data: VarData | None = None): - """Initialize the array to array operation var. - - Args: - a: The string. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ArrayToArrayOperation, self).__init__( - _var_name="", - _var_type=a._var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "ArrayToArrayOperation must implement _cached_var_name" - ) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ArrayToArrayOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data() if isinstance(self.a, Var) else None, - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArraySliceOperation(ArrayVar): - """Base class for immutable string vars that are the result of a string slice operation.""" - - a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([])) - _slice: slice = dataclasses.field(default_factory=lambda: slice(None, None, None)) - - def __init__(self, a: ArrayVar, _slice: slice, _var_data: VarData | None = None): - """Initialize the string slice operation var. - - Args: - a: The string. - _slice: The slice. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ArraySliceOperation, self).__init__( - _var_name="", - _var_type=a._var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__setattr__(self, "_slice", _slice) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - - Raises: - ValueError: If the slice step is zero. - """ - start, end, step = self._slice.start, self._slice.stop, self._slice.step - - normalized_start = ( - LiteralVar.create(start) - if start is not None - else ImmutableVar.create_safe("undefined") - ) - normalized_end = ( - LiteralVar.create(end) - if end is not None - else ImmutableVar.create_safe("undefined") - ) - if step is None: - return ( - f"{str(self.a)}.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.a.length() - return str( - ArraySliceOperation( - ArrayReverseOperation( - ArraySliceOperation(self.a, slice(actual_start, actual_end)) - ), - slice(None, None, -step), - ) - ) - if step == 0: - raise ValueError("slice step cannot be zero") - return f"{str(self.a)}.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.a.length() - - return f"{str(self.step)} > 0 ? {str(self.a)}.slice({str(normalized_start)}, {str(normalized_end)}).filter((_, i) => i % {str(step)} === 0) : {str(self.a)}.slice({str(actual_start_reverse)}, {str(actual_end_reverse)}).reverse().filter((_, i) => i % {str(-step)} === 0)" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ArraySliceOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), - *[ - slice_value._get_all_var_data() - for slice_value in ( - self._slice.start, - self._slice.stop, - self._slice.step, - ) - if slice_value is not None and isinstance(slice_value, Var) - ], - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class ArrayReverseOperation(ArrayToArrayOperation): - """Base class for immutable string vars that are the result of a string reverse operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.reverse()" - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayToNumberOperation(NumberVar): - """Base class for immutable number vars that are the result of an array to number operation.""" - - a: ArrayVar = dataclasses.field( - default_factory=lambda: LiteralArrayVar([]), - ) - - def __init__(self, a: ArrayVar, _var_data: VarData | None = None): - """Initialize the string to number operation var. - - Args: - a: The array. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ArrayToNumberOperation, self).__init__( - _var_name="", - _var_type=int, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a if isinstance(a, Var) else LiteralArrayVar(a)) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Raises: - NotImplementedError: Must be implemented by subclasses. - """ - raise NotImplementedError( - "StringToNumberOperation must implement _cached_var_name" - ) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ArrayToNumberOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge(self.a._get_all_var_data(), self._var_data) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -class ArrayLengthOperation(ArrayToNumberOperation): - """Base class for immutable number vars that are the result of an array length operation.""" - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.length" - - -def is_tuple_type(t: GenericType) -> bool: - """Check if a type is a tuple type. - - Args: - t: The type to check. - - Returns: - Whether the type is a tuple type. - """ - if inspect.isclass(t): - return issubclass(t, tuple) - return get_origin(t) is tuple - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayItemOperation(ImmutableVar): - """Base class for immutable array vars that are the result of an array item operation.""" - - a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([])) - i: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0)) - - def __init__( - self, - a: ArrayVar, - i: NumberVar | int, - _var_data: VarData | None = None, - ): - """Initialize the array item operation var. - - Args: - a: The array. - i: The index. - _var_data: Additional hooks and imports associated with the Var. - """ - args = typing.get_args(a._var_type) - if args and isinstance(i, int) and is_tuple_type(a._var_type): - element_type = args[i % len(args)] - else: - element_type = unionize(*args) - super(ArrayItemOperation, self).__init__( - _var_name="", - _var_type=element_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a if isinstance(a, Var) else LiteralArrayVar(a)) - object.__setattr__( - self, - "i", - i if isinstance(i, Var) else LiteralNumberVar(i), - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.at({str(self.i)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ArrayItemOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), self.i._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class RangeOperation(ArrayVar): - """Base class for immutable array vars that are the result of a range operation.""" - - start: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0)) - end: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(0)) - step: NumberVar = dataclasses.field(default_factory=lambda: LiteralNumberVar(1)) - - def __init__( - self, - start: NumberVar | int, - end: NumberVar | int, - step: NumberVar | int, - _var_data: VarData | None = None, - ): - """Initialize the range operation var. - - Args: - start: The start of the range. - end: The end of the range. - step: The step of the range. - _var_data: Additional hooks and imports associated with the Var. - """ - super(RangeOperation, self).__init__( - _var_name="", - _var_type=List[int], - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, - "start", - start if isinstance(start, Var) else LiteralNumberVar(start), - ) - object.__setattr__( - self, - "end", - end if isinstance(end, Var) else LiteralNumberVar(end), - ) - object.__setattr__( - self, - "step", - step if isinstance(step, Var) else LiteralNumberVar(step), - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - start, end, step = self.start, self.end, self.step - return f"Array.from({{ length: ({str(end)} - {str(start)}) / {str(step)} }}, (_, i) => {str(start)} + i * {str(step)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(RangeOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.start._get_all_var_data(), - self.end._get_all_var_data(), - self.step._get_all_var_data(), - self._var_data, - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ArrayContainsOperation(BooleanVar): - """Base class for immutable boolean vars that are the result of an array contains operation.""" - - a: ArrayVar = dataclasses.field(default_factory=lambda: LiteralArrayVar([])) - b: Var = dataclasses.field(default_factory=lambda: LiteralVar.create(None)) - - def __init__(self, a: ArrayVar, b: Any | Var, _var_data: VarData | None = None): - """Initialize the array contains operation var. - - Args: - a: The array. - b: The element to check for. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ArrayContainsOperation, self).__init__( - _var_name="", - _var_type=bool, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__(self, "a", a) - object.__setattr__(self, "b", b if isinstance(b, Var) else LiteralVar.create(b)) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return f"{str(self.a)}.includes({str(self.b)})" - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ArrayContainsOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.a._get_all_var_data(), self.b._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToStringOperation(StringVar): - """Base class for immutable string vars that are the result of a to string operation.""" - - original_var: Var = dataclasses.field( - default_factory=lambda: LiteralStringVar.create("") - ) - - def __init__(self, original_var: Var, _var_data: VarData | None = None): - """Initialize the to string operation var. - - Args: - original_var: The original var. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ToStringOperation, self).__init__( - _var_name="", - _var_type=str, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, - "original_var", - original_var, - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self.original_var) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ToStringOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.original_var._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data - - -@dataclasses.dataclass( - eq=False, - frozen=True, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class ToArrayOperation(ArrayVar): - """Base class for immutable array vars that are the result of a to array operation.""" - - original_var: Var = dataclasses.field(default_factory=lambda: LiteralArrayVar([])) - - def __init__( - self, - original_var: Var, - _var_type: type[list] | type[set] | type[tuple] = list, - _var_data: VarData | None = None, - ): - """Initialize the to array operation var. - - Args: - original_var: The original var. - _var_type: The type of the array. - _var_data: Additional hooks and imports associated with the Var. - """ - super(ToArrayOperation, self).__init__( - _var_name="", - _var_type=_var_type, - _var_data=ImmutableVarData.merge(_var_data), - ) - object.__setattr__( - self, - "original_var", - original_var, - ) - object.__delattr__(self, "_var_name") - - @cached_property - def _cached_var_name(self) -> str: - """The name of the var. - - Returns: - The name of the var. - """ - return str(self.original_var) - - def __getattr__(self, name: str) -> Any: - """Get an attribute of the var. - - Args: - name: The name of the attribute. - - Returns: - The attribute value. - """ - if name == "_var_name": - return self._cached_var_name - getattr(super(ToArrayOperation, self), name) - - @cached_property - def _cached_get_all_var_data(self) -> ImmutableVarData | None: - """Get all VarData associated with the Var. - - Returns: - The VarData of the components and all of its children. - """ - return ImmutableVarData.merge( - self.original_var._get_all_var_data(), self._var_data - ) - - def _get_all_var_data(self) -> ImmutableVarData | None: - return self._cached_get_all_var_data diff --git a/reflex/istate/__init__.py b/reflex/istate/__init__.py new file mode 100644 index 000000000..d71d038f8 --- /dev/null +++ b/reflex/istate/__init__.py @@ -0,0 +1 @@ +"""This module will provide interfaces for the state.""" diff --git a/reflex/istate/data.py b/reflex/istate/data.py new file mode 100644 index 000000000..987921889 --- /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): + """Initialize 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): + """Initialize 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): + """Initialize 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/proxy.py b/reflex/istate/proxy.py new file mode 100644 index 000000000..8d6051cf2 --- /dev/null +++ b/reflex/istate/proxy.py @@ -0,0 +1,33 @@ +"""A module to hold state proxy classes.""" + +from typing import Any + +from reflex.state import StateProxy + + +class ReadOnlyStateProxy(StateProxy): + """A read-only proxy for a state.""" + + def __setattr__(self, name: str, value: Any) -> None: + """Prevent setting attributes on the state for read-only proxy. + + Args: + name: The attribute name. + value: The attribute value. + + Raises: + NotImplementedError: Always raised when trying to set an attribute on proxied state. + """ + if name.startswith("_self_"): + # Special case attributes of the proxy itself, not applied to the wrapped object. + super().__setattr__(name, value) + return + raise NotImplementedError("This is a read-only state proxy.") + + def mark_dirty(self): + """Mark the state as dirty. + + Raises: + NotImplementedError: Always raised when trying to mark the proxied state as dirty. + """ + raise NotImplementedError("This is a read-only state proxy.") 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/istate/wrappers.py b/reflex/istate/wrappers.py new file mode 100644 index 000000000..d4e74cf8a --- /dev/null +++ b/reflex/istate/wrappers.py @@ -0,0 +1,27 @@ +"""Wrappers for the state manager.""" + +from typing import Any + +from reflex.istate.proxy import ReadOnlyStateProxy +from reflex.state import _split_substate_key, _substate_key, get_state_manager + + +async def get_state(token, state_cls: Any | None = None) -> ReadOnlyStateProxy: + """Get the instance of a state for a token. + + Args: + token: The token for the state. + state_cls: The class of the state. + + Returns: + A read-only proxy of the state instance. + """ + mng = get_state_manager() + if state_cls is not None: + root_state = await mng.get_state(_substate_key(token, state_cls)) + else: + root_state = await mng.get_state(token) + _, state_path = _split_substate_key(token) + state_cls = root_state.get_class_substate(tuple(state_path.split("."))) + instance = await root_state.get_state(state_cls) + return ReadOnlyStateProxy(instance) diff --git a/reflex/middleware/hydrate_middleware.py b/reflex/middleware/hydrate_middleware.py index 99abf97aa..2ad329e9d 100644 --- a/reflex/middleware/hydrate_middleware.py +++ b/reflex/middleware/hydrate_middleware.py @@ -2,18 +2,19 @@ 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.""" @@ -41,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 76cbcfe9a..ef9de0bde 100644 --- a/reflex/middleware/middleware.py +++ b/reflex/middleware/middleware.py @@ -2,10 +2,9 @@ from __future__ import annotations -from abc import ABC +from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Optional -from reflex.base import Base from reflex.event import Event from reflex.state import BaseState, StateUpdate @@ -13,9 +12,10 @@ if TYPE_CHECKING: from reflex.app import App -class Middleware(Base, ABC): +class Middleware(ABC): """Middleware to preprocess and postprocess requests.""" + @abstractmethod async def preprocess( self, app: App, state: BaseState, event: Event ) -> Optional[StateUpdate]: diff --git a/reflex/model.py b/reflex/model.py index 71e26f76a..de63589fc 100644 --- a/reflex/model.py +++ b/reflex/model.py @@ -2,9 +2,9 @@ from __future__ import annotations -import os +import re from collections import defaultdict -from pathlib import Path +from contextlib import suppress from typing import Any, ClassVar, Optional, Type, Union import alembic.autogenerate @@ -15,13 +15,56 @@ import alembic.runtime.environment import alembic.script import alembic.util import sqlalchemy +import sqlalchemy.exc +import sqlalchemy.ext.asyncio 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 + +_ENGINE: dict[str, sqlalchemy.engine.Engine] = {} +_ASYNC_ENGINE: dict[str, sqlalchemy.ext.asyncio.AsyncEngine] = {} +_AsyncSessionLocal: dict[str | None, sqlalchemy.ext.asyncio.async_sessionmaker] = {} + +# Import AsyncSession _after_ reflex.utils.compat +from sqlmodel.ext.asyncio.session import AsyncSession # noqa: E402 + + +def _safe_db_url_for_logging(url: str) -> str: + """Remove username and password from the database URL for logging. + + Args: + url: The database URL. + + Returns: + The database URL with the username and password removed. + """ + return re.sub(r"://[^@]+@", "://:@", url) + + +def get_engine_args(url: str | None = None) -> dict[str, Any]: + """Get the database engine arguments. + + Args: + url: The database url. + + Returns: + The database engine arguments as a dict. + """ + kwargs: dict[str, Any] = { + # Print the SQL queries if the log level is INFO or lower. + "echo": environment.SQLALCHEMY_ECHO.get(), + # Check connections before returning them. + "pool_pre_ping": environment.SQLALCHEMY_POOL_PRE_PING.get(), + } + conf = get_config() + url = url or conf.db_url + if url is not None and url.startswith("sqlite"): + # Needed for the admin dash on sqlite. + kwargs["connect_args"] = {"check_same_thread": False} + return kwargs def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine: @@ -40,15 +83,81 @@ def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine: url = url or conf.db_url if url is None: raise ValueError("No database url configured") - if not Path(constants.ALEMBIC_CONFIG).exists(): + + global _ENGINE + if url in _ENGINE: + return _ENGINE[url] + + if not environment.ALEMBIC_CONFIG.get().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" - # 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) + _ENGINE[url] = sqlmodel.create_engine( + url, + **get_engine_args(url), + ) + return _ENGINE[url] + + +def get_async_engine(url: str | None) -> sqlalchemy.ext.asyncio.AsyncEngine: + """Get the async database engine. + + Args: + url: The database url. + + Returns: + The async database engine. + + Raises: + ValueError: If the async database url is None. + """ + if url is None: + conf = get_config() + url = conf.async_db_url + if url is not None and conf.db_url is not None: + async_db_url_tail = url.partition("://")[2] + db_url_tail = conf.db_url.partition("://")[2] + if async_db_url_tail != db_url_tail: + console.warn( + f"async_db_url `{_safe_db_url_for_logging(url)}` " + "should reference the same database as " + f"db_url `{_safe_db_url_for_logging(conf.db_url)}`." + ) + if url is None: + raise ValueError("No async database url configured") + + global _ASYNC_ENGINE + if url in _ASYNC_ENGINE: + return _ASYNC_ENGINE[url] + + if not environment.ALEMBIC_CONFIG.get().exists(): + console.warn( + "Database is not initialized, run [bold]reflex db init[/bold] first." + ) + _ASYNC_ENGINE[url] = sqlalchemy.ext.asyncio.create_async_engine( + url, + **get_engine_args(url), + ) + return _ASYNC_ENGINE[url] + + +async def get_db_status() -> dict[str, bool]: + """Checks the status of the database connection. + + Attempts to connect to the database and execute a simple query to verify connectivity. + + Returns: + The status of the database connection. + """ + status = True + try: + engine = get_engine() + with engine.connect() as connection: + connection.execute(sqlalchemy.text("SELECT 1")) + except sqlalchemy.exc.OperationalError: + status = False + + return {"db": status} SQLModelOrSqlAlchemy = Union[ @@ -144,8 +253,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) @@ -181,11 +289,10 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue relationships = {} # SQLModel relationships do not appear in __fields__, but should be included if present. for name in self.__sqlmodel_relationships__: - try: + with suppress( + sqlalchemy.orm.exc.DetachedInstanceError # This happens when the relationship was never loaded and the session is closed. + ): relationships[name] = self._dict_recursive(getattr(self, name)) - except sqlalchemy.orm.exc.DetachedInstanceError: - # This happens when the relationship was never loaded and the session is closed. - continue return { **base_fields, **relationships, @@ -213,7 +320,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.get()) return config, alembic.script.ScriptDirectory( config.get_main_option("script_location", default="version"), ) @@ -248,8 +355,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.get()), + directory=str(environment.ALEMBIC_CONFIG.get().parent / "alembic"), ) @classmethod @@ -269,7 +376,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.get().exists(): return False config, script_directory = cls._alembic_config() @@ -370,7 +477,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.get().exists(): return with cls.get_db_engine().connect() as connection: @@ -407,6 +514,31 @@ def session(url: str | None = None) -> sqlmodel.Session: return sqlmodel.Session(get_engine(url)) +def asession(url: str | None = None) -> AsyncSession: + """Get an async sqlmodel session to interact with the database. + + async with rx.asession() as asession: + ... + + Most operations against the `asession` must be awaited. + + Args: + url: The database url. + + Returns: + An async database session. + """ + global _AsyncSessionLocal + if url not in _AsyncSessionLocal: + _AsyncSessionLocal[url] = sqlalchemy.ext.asyncio.async_sessionmaker( + bind=get_async_engine(url), + class_=AsyncSession, + autocommit=False, + autoflush=False, + ) + return _AsyncSessionLocal[url]() + + def sqla_session(url: str | None = None) -> sqlalchemy.orm.Session: """Get a bare sqlalchemy session to interact with the database. diff --git a/reflex/page.py b/reflex/page.py index 1e5e8603d..44ca6ab31 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 BASE_STATE, 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[[], BASE_STATE] | 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 implicitly 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/reflex.py b/reflex/reflex.py index 224bace47..e333bfbd1 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -3,23 +3,21 @@ from __future__ import annotations import atexit -import os -import webbrowser from pathlib import Path from typing import List, Optional import typer import typer.core -from reflex_cli.deployments import deployments_cli -from reflex_cli.utils import dependency +from reflex_cli.v2.deployments import check_version, hosting_cli 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, redir, telemetry +from reflex.state import reset_disk_state_manager +from reflex.utils import console, telemetry # Disable typer+rich integration for help panels -typer.core.rich = False # type: ignore +typer.core.rich = None # type: ignore # Create the app. try: @@ -85,40 +83,11 @@ 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) - - # 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 - ) - - # Migrate Pynecone projects to Reflex. - prerequisites.migrate_to_reflex() + template = prerequisites.initialize_app(app_name, template, ai) # Initialize the .gitignore. prerequisites.initialize_gitignore() @@ -126,8 +95,9 @@ def _init( # Initialize the requirements.txt. prerequisites.initialize_requirements_txt() + template_msg = f" using the {template} template" if template else "" # Finish initializing the app. - console.success(f"Initialized {app_name}") + console.success(f"Initialized {app_name}{template_msg}") @cli.command() @@ -167,7 +137,7 @@ def _run( console.set_log_level(loglevel) # Set env mode in the environment - os.environ[constants.ENV_MODE_ENV_VAR] = env.value + environment.REFLEX_ENV_MODE.set(env) # Show system info exec.output_system_info() @@ -184,6 +154,9 @@ def _run( if prerequisites.needs_reinit(frontend=frontend): _init(name=config.app_name, loglevel=loglevel) + # Delete the states folder if it exists. + reset_disk_state_manager() + # Find the next available open port if applicable. if frontend: frontend_port = processes.handle_port( @@ -229,7 +202,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}") @@ -247,13 +221,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: @@ -267,9 +251,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=environment.REFLEX_FRONTEND_ONLY.name, + ), + backend: bool = typer.Option( + False, + "--backend-only", + help="Execute only backend.", + envvar=environment.REFLEX_BACKEND_ONLY.name, ), - 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." ), @@ -284,6 +276,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) + environment.REFLEX_BACKEND_ONLY.set(backend) + environment.REFLEX_FRONTEND_ONLY.set(frontend) + _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel) @@ -299,7 +297,7 @@ def export( True, "--frontend-only", help="Export only frontend.", show_default=False ), zip_dest_dir: str = typer.Option( - os.getcwd(), + str(Path.cwd()), help="The directory to export the zip files to.", show_default=False, ), @@ -325,41 +323,21 @@ def export( backend=backend, zip_dest_dir=zip_dest_dir, upload_db_file=upload_db_file, - loglevel=loglevel, + loglevel=loglevel.subprocess_level(), ) -def _login() -> str: - """Helper function to authenticate with Reflex hosting service.""" - from reflex_cli.utils import hosting - - access_token, invitation_code = hosting.authenticated_token() - if access_token: - console.print("You already logged in.") - return access_token - - # If not already logged in, open a browser window/tab to the login page. - access_token = hosting.authenticate_on_browser(invitation_code) - - if not access_token: - console.error(f"Unable to authenticate. Please try again or contact support.") - raise typer.Exit(1) - - console.print("Successfully logged in.") - return access_token - - @cli.command() -def login( - loglevel: constants.LogLevel = typer.Option( - config.loglevel, help="The log level to use." - ), -): - """Authenticate with Reflex hosting service.""" - # Set the log level. - console.set_log_level(loglevel) +def login(loglevel: constants.LogLevel = typer.Option(config.loglevel)): + """Authenticate with experimental Reflex hosting service.""" + from reflex_cli.v2 import cli as hosting_cli - _login() + check_version() + + validated_info = hosting_cli.login() + if validated_info is not None: + _skip_compile() # Allow running outside of an app dir + telemetry.send("login", user_uuid=validated_info.get("user_id")) @cli.command() @@ -369,13 +347,11 @@ def logout( ), ): """Log out of access to Reflex hosting service.""" - from reflex_cli.utils import hosting + from reflex_cli.v2.cli import logout - console.set_log_level(loglevel) + check_version() - hosting.log_out_on_browser() - console.debug("Deleting access token from config locally") - hosting.delete_token_from_config(include_invitation_code=True) + logout(loglevel) # type: ignore db_cli = typer.Typer() @@ -384,7 +360,7 @@ script_cli = typer.Typer() def _skip_compile(): """Skip the compile step.""" - os.environ[constants.SKIP_COMPILE_ENV_VAR] = "yes" + environment.REFLEX_SKIP_COMPILE.set(True) @db_cli.command(name="init") @@ -399,7 +375,7 @@ def db_init(): return # Check the alembic config. - if Path(constants.ALEMBIC_CONFIG).exists(): + if environment.ALEMBIC_CONFIG.get().exists(): console.error( "Database is already initialized. Use " "[bold]reflex db makemigrations[/bold] to create schema change " @@ -458,25 +434,8 @@ 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( - None, - "-k", - "--deployment-key", - help="The name of the deployment. Domain name safe characters only.", - ), app_name: str = typer.Option( config.app_name, "--app-name", @@ -484,71 +443,70 @@ def deploy( hidden=True, ), regions: List[str] = typer.Option( - list(), + [], "-r", "--region", - help="The regions to deploy to.", + help="The regions to deploy to. `reflex cloud regions` For multiple envs, repeat this option, e.g. --region sjc --region iad", ), envs: List[str] = typer.Option( - list(), + [], "--env", help="The environment variables to set: =. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2.", ), - cpus: Optional[int] = typer.Option( - None, help="The number of CPUs to allocate.", hidden=True - ), - memory_mb: Optional[int] = typer.Option( - None, help="The amount of memory to allocate.", hidden=True - ), - auto_start: Optional[bool] = typer.Option( + vmtype: Optional[str] = typer.Option( None, - help="Whether to auto start the instance.", - hidden=True, + "--vmtype", + help="Vm type id. Run `reflex cloud vmtypes` to get options.", ), - auto_stop: Optional[bool] = typer.Option( + hostname: Optional[str] = typer.Option( None, - help="Whether to auto stop the instance.", - hidden=True, - ), - frontend_hostname: Optional[str] = typer.Option( - None, - "--frontend-hostname", + "--hostname", help="The hostname of the frontend.", - hidden=True, ), interactive: bool = typer.Option( True, help="Whether to list configuration options and ask for confirmation.", ), - with_metrics: Optional[str] = typer.Option( + envfile: Optional[str] = typer.Option( None, - help="Setting for metrics scraping for the deployment. Setup required in user code.", - hidden=True, - ), - with_tracing: Optional[str] = typer.Option( - None, - help="Setting to export tracing for the deployment. Setup required in user code.", - hidden=True, - ), - upload_db_file: bool = typer.Option( - False, - help="Whether to include local sqlite db files when uploading to hosting service.", - hidden=True, + "--envfile", + help="The path to an env file to use. Will override any envs set manually.", ), loglevel: constants.LogLevel = typer.Option( config.loglevel, help="The log level to use." ), + project: Optional[str] = typer.Option( + None, + "--project", + help="project id to deploy to", + ), + token: Optional[str] = typer.Option( + None, + "--token", + help="token to use for auth", + ), ): """Deploy the app to the Reflex hosting service.""" - from reflex_cli import cli as hosting_cli + from reflex_cli.utils import dependency + from reflex_cli.v2 import cli as hosting_cli from reflex.utils import export as export_utils from reflex.utils import prerequisites + check_version() + # Set the log level. console.set_log_level(loglevel) - # Only check requirements if interactive. There is user interaction for requirements update. + if not token: + # make sure user is logged in. + if interactive: + hosting_cli.login() + else: + raise SystemExit("Token is required for non-interactive mode.") + + # Only check requirements if interactive. + # There is user interaction for requirements update. if interactive: dependency.check_requirements() @@ -571,42 +529,26 @@ def deploy( frontend=frontend, backend=backend, zipping=zipping, - loglevel=loglevel, - upload_db_file=upload_db_file, + loglevel=loglevel.subprocess_level(), ), - key=key, regions=regions, envs=envs, - cpus=cpus, - memory_mb=memory_mb, - auto_start=auto_start, - auto_stop=auto_stop, - frontend_hostname=frontend_hostname, + vmtype=vmtype, + envfile=envfile, + hostname=hostname, interactive=interactive, - with_metrics=with_metrics, - with_tracing=with_tracing, - loglevel=loglevel.value, + loglevel=type(loglevel).INFO, # type: ignore + token=token, + project=project, ) -@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( - deployments_cli, - name="deployments", - help="Subcommands for managing the Deployments.", + hosting_cli, + name="cloud", + help="Subcommands for managing the reflex cloud.", ) cli.add_typer( custom_components_cli, diff --git a/reflex/state.py b/reflex/state.py index 56b842666..e6724c766 100644 --- a/reflex/state.py +++ b/reflex/state.py @@ -5,18 +5,27 @@ from __future__ import annotations import asyncio import contextlib import copy +import dataclasses import functools import inspect import os import traceback +import json +import pickle +import sys +import time +import typing 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, @@ -24,27 +33,59 @@ from typing import ( Optional, Sequence, Set, + Tuple, Type, + TypeVar, Union, cast, + get_args, + get_type_hints, ) -import dill +from redis.asyncio.client import PubSub from sqlalchemy.orm import DeclarativeBase +from typing_extensions import Self -from reflex.config import get_config +from reflex import event +from reflex.config import PerformanceMode, get_config +from reflex.istate.data import RouterData +from reflex.istate.storage import ClientStorageBase +from reflex.model import Model +from reflex.vars.base import ( + ComputedVar, + DynamicRouteVar, + Var, + computed_var, + dispatch, + get_unique_variable_name, + is_computed_var, +) try: import pydantic.v1 as pydantic except ModuleNotFoundError: import pydantic +from pydantic import BaseModel as BaseModelV2 + +try: + from pydantic.v1 import BaseModel as BaseModelV1 +except ModuleNotFoundError: + BaseModelV1 = BaseModelV2 + +try: + from pydantic.v1 import validator +except ModuleNotFoundError: + from pydantic import validator + 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, @@ -52,11 +93,34 @@ from reflex.event import ( EventSpec, fix_events, ) -from reflex.utils import console, format, prerequisites, types -from reflex.utils.exceptions import ImmutableStateError, LockExpiredError +from reflex.utils import console, format, path_ops, prerequisites, types +from reflex.utils.exceptions import ( + ComputedVarShadowsBaseVars, + ComputedVarShadowsStateVar, + DynamicComponentInvalidSignature, + DynamicRouteArgShadowsStateVar, + EventHandlerShadowsBuiltInStateMethod, + ImmutableStateError, + InvalidLockWarningThresholdError, + InvalidStateManagerMode, + LockExpiredError, + ReflexRuntimeError, + SetUndefinedStateVarError, + StateSchemaMismatchError, + StateSerializationError, + StateTooLargeError, +) 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, + is_optional, + is_union, + override, + value_inside_optional, +) +from reflex.vars import VarData if TYPE_CHECKING: from reflex.components.component import Component @@ -66,8 +130,11 @@ Delta = Dict[str, Any] var = computed_var -# If the state is this large, it's considered a performance issue. -TOO_LARGE_SERIALIZED_STATE = 100 * 1024 # 100kb +if environment.REFLEX_PERF_MODE.get() != PerformanceMode.OFF: + # If the state is this large, it's considered a performance issue. + TOO_LARGE_SERIALIZED_STATE = environment.REFLEX_STATE_SIZE_LIMIT.get() * 1024 + # Only warn about each state class size once. + _WARNED_ABOUT_STATE_SIZE: Set[str] = set() def print_stack(depth: int = 3): @@ -86,97 +153,14 @@ def print_stack(depth: int = 3): ) -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( @@ -252,10 +236,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. @@ -266,8 +251,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. @@ -292,6 +277,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 @@ -300,14 +286,62 @@ 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 _unwrap_field_type(type_: Type) -> Type: + """Unwrap rx.Field type annotations. + + Args: + type_: The type to unwrap. + + Returns: + The unwrapped type. + """ + from reflex.vars import Field + + if get_origin(type_) is Field: + return get_args(type_)[0] + return type_ + + +def get_var_for_field(cls: Type[BaseState], f: ModelField): + """Get a Var instance for a Pydantic field. + + Args: + cls: The state class. + f: The Pydantic field. + + Returns: + The Var instance. + """ + field_name = format.format_state_name(cls.get_full_name()) + "." + f.name + + return dispatch( + field_name=field_name, + var_data=VarData.from_state(cls, f.name), + result_var_type=_unwrap_field_type(f.outer_type_), + ) + + class BaseState(Base, ABC, extra=pydantic.Extra.allow): """The state of the app.""" @@ -315,7 +349,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]] = {} @@ -379,7 +413,6 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): def __init__( self, - *args, parent_state: BaseState | None = None, init_substates: bool = True, _reflex_internal_init: bool = False, @@ -390,11 +423,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): DO NOT INSTANTIATE STATE CLASSES DIRECTLY! Use StateManager.get_state() instead. Args: - *args: The args to pass to the Pydantic init method. parent_state: The parent state. init_substates: Whether to initialize the substates in this instance. _reflex_internal_init: A flag to indicate that the state is being initialized by the framework. - **kwargs: The kwargs to pass to the Pydantic init method. + **kwargs: The kwargs to set as attributes on the state. Raises: ReflexRuntimeError: If the state is instantiated directly by end user. @@ -406,8 +438,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): "State classes should not be instantiated directly in a Reflex app. " "See https://reflex.dev/docs/state/ for further information." ) + if type(self)._mixin: + raise ReflexRuntimeError( + f"{type(self).__name__} is a state mixin and cannot be instantiated directly." + ) kwargs["parent_state"] = parent_state - super().__init__(*args, **kwargs) + super().__init__() + for name, value in kwargs.items(): + setattr(self, name, value) # Setup the substates (for memory state manager only). if init_substates: @@ -418,9 +456,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()} - ) + self._backend_vars = copy.deepcopy(self.backend_vars) def __repr__(self) -> str: """Get the string representation of the state. @@ -428,7 +464,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Returns: The string representation of the state. """ - return f"{self.__class__.__name__}({self.dict()})" + return f"{type(self).__name__}({self.dict()})" @classmethod def _get_computed_vars(cls) -> list[ComputedVar]: @@ -439,9 +475,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): """ return [ v - for mixin in cls._mixins() + [cls] - for v in mixin.__dict__.values() - if isinstance(v, ComputedVar) + 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 @@ -483,6 +519,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # Set the scope of the state. cls._scope = scope + # Handle locally-defined states for pickling. + if "" in cls.__qualname__: + cls._handle_local_def() # Validate the module name. cls._validate_module_name() @@ -491,7 +530,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls._check_overridden_methods() # Computed vars should not shadow builtin state props. - cls._check_overriden_basevars() + cls._check_overridden_basevars() # Reset subclass tracking for this class. cls.class_subclasses = set() @@ -506,35 +545,33 @@ 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.get_name() in set( - c.get_name() for c in parent_state.class_subclasses - ): - if is_testing_env(): - # Clear existing subclass with same name when app is reloaded via - # utils.prerequisites.get_app(reload=True) - parent_state.class_subclasses = set( - c - for c in parent_state.class_subclasses - if c.get_name() != cls.get_name() - ) - else: - # During normal operation, subclasses cannot have the same name, even if they are - # defined in different modules. - raise StateValueError( - f"The substate class '{cls.get_name()}' has been defined multiple times. " - "Shadowing substate classes is not allowed." - ) + if cls.get_name() in {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_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, @@ -543,13 +580,14 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # 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, @@ -570,15 +608,15 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for mixin in cls._mixins(): for name, value in mixin.__dict__.items(): - if isinstance(value, ComputedVar): + if name in cls.inherited_vars: + continue + if is_computed_var(value): fget = cls._copy_fn(value.fget) - newcv = value._replace(fget=fget) + newcv = value._replace(fget=fget, _var_data=VarData.from_state(cls)) # cleanup refs to mixin cls in var_data - newcv._var_data = None - newcv._var_set_state(cls) 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) @@ -601,6 +639,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): cls.event_handlers[name] = handler setattr(cls, name, handler) + # Initialize per-class var dependency tracking. + cls._computed_var_dependencies = defaultdict(set) + cls._substate_var_dependencies = defaultdict(set) cls._init_var_dependency_dicts() @staticmethod @@ -643,6 +684,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. @@ -660,6 +743,39 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): ) ] + @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. @@ -670,10 +786,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), ) @@ -696,11 +808,11 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): ) # ComputedVar with cache=False always need to be recomputed - cls._always_dirty_computed_vars = set( + cls._always_dirty_computed_vars = { cvar_name for cvar_name, cvar in cls.computed_vars.items() if not cvar._cache - ) + } # Any substate containing a ComputedVar with cache=False always needs to be recomputed if cls._always_dirty_computed_vars: # or cls._scope is not None: @@ -714,12 +826,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() @@ -733,21 +848,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 @@ -774,6 +905,9 @@ 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. """ @@ -782,9 +916,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): for base in cls.__bases__ if issubclass(base, BaseState) and base is not BaseState and not base._mixin ] - assert ( - len(parent_states) < 2 - ), f"Only one parent state is allowed {parent_states}." + 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 @@ -869,7 +1002,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: @@ -885,7 +1018,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) @@ -912,8 +1045,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) @@ -932,13 +1068,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): @@ -958,39 +1094,60 @@ 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: prop: The var to create a setter for. """ - setter_name = prop.get_setter_name(include_state=False) + setter_name = prop._get_setter_name(include_state=False) if setter_name not in cls.__dict__: - event_handler = cls._create_event_handler(prop.get_setter()) + event_handler = cls._create_event_handler(prop._get_setter()) cls.event_handlers[setter_name] = event_handler 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() + default_value = prop._get_default_value() if default_value is not None: field.required = False field.default = default_value if ( not field.required and field.default is None + and field.default_factory is None 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]: @@ -1005,6 +1162,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. @@ -1012,21 +1190,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) @@ -1034,13 +1215,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. @@ -1057,13 +1264,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if not super().__getattribute__("__dict__"): return super().__getattribute__(name) - inherited_vars = { - **super().__getattribute__("inherited_vars"), - **super().__getattribute__("inherited_backend_vars"), - } + # Fast path for dunder + if name.startswith("__"): + return super().__getattribute__(name) # For now, handle router_data updates as a special case. - if name in inherited_vars or name == constants.ROUTER_DATA: + if ( + name == constants.ROUTER_DATA + or name in super().__getattribute__("inherited_vars") + or name in super().__getattribute__("inherited_backend_vars") + ): parent_state = super().__getattribute__("parent_state") if parent_state is not None: return getattr(parent_state, name) @@ -1093,7 +1303,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if parent_state is not None: return getattr(parent_state, name) - if isinstance(value, MutableProxy.__mutable_types__) and ( + if MutableProxy._is_mutable_type(value) and ( name in super().__getattribute__("base_vars") or name in backend_vars ): # track changes in mutable containers (list, dict, set, etc) @@ -1109,14 +1319,16 @@ 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 value = value.__wrapped__ # Set the var on the parent state. - inherited_vars = {**self.inherited_vars, **self.inherited_backend_vars} - if name in inherited_vars: + if name in self.inherited_vars or name in self.inherited_backend_vars: setattr(self.parent_state, name, value) return @@ -1126,6 +1338,35 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): 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: + field = fields[name] + field_type = _unwrap_field_type(field.outer_type_) + if field.allow_none and not is_optional(field_type): + field_type = Union[field_type, None] + if not _isinstance(value, field_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) @@ -1153,6 +1394,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() @@ -1255,6 +1500,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. @@ -1312,10 +1568,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: @@ -1495,9 +1748,7 @@ 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._get_token() @@ -1557,6 +1808,44 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): # Get the function to process the event. fn = functools.partial(handler.fn, state) + try: + type_hints = typing.get_type_hints(handler.fn) + except Exception: + type_hints = {} + + for arg, value in list(payload.items()): + hinted_args = type_hints.get(arg, Any) + if hinted_args is Any: + continue + if is_union(hinted_args): + if value is None: + continue + hinted_args = value_inside_optional(hinted_args) + if ( + isinstance(value, dict) + and inspect.isclass(hinted_args) + and not types.is_generic_alias(hinted_args) # py3.9-py3.10 + ): + if issubclass(hinted_args, Model): + # Remove non-fields from the payload + payload[arg] = hinted_args( + **{ + key: value + for key, value in value.items() + if key in hinted_args.__fields__ + } + ) + elif dataclasses.is_dataclass(hinted_args) or issubclass( + hinted_args, (Base, BaseModelV1, BaseModelV2) + ): + payload[arg] = hinted_args(**value) + if isinstance(value, list) and (hinted_args is set or hinted_args is Set): + payload[arg] = set(value) + if isinstance(value, list) and ( + hinted_args is tuple or hinted_args is Tuple + ): + payload[arg] = tuple(value) + # Wrap the function in a try/except block. try: # Handle async functions. @@ -1620,11 +1909,11 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Returns: Set of computed vars to include in the delta. """ - return set( + return { 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 @@ -1638,12 +1927,12 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Returns: Set of computed vars to include in the delta. """ - return set( + return { 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 def _potentially_dirty_substates(cls) -> set[Type[BaseState]]: @@ -1653,16 +1942,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Set of State classes that may need to be fetched to recalc computed vars. """ # _always_dirty_substates need to be fetched to recalc computed vars. - fetch_substates = set( + fetch_substates = { cls.get_class_substate((cls.get_name(), *substate_name.split("."))) for substate_name in cls._always_dirty_substates - ) + } for dependent_substates in cls._substate_var_dependencies.values(): fetch_substates.update( - set( + { cls.get_class_substate((cls.get_name(), *substate_name.split("."))) for substate_name in dependent_substates - ) + } ) return fetch_substates @@ -1694,11 +1983,12 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if len(self.scopes_and_subscopes()) > 1 and "router" in delta_vars: delta_vars.remove("router") - subdelta = { - prop: getattr(self, prop) + subdelta: Dict[str, Any] = { + prop: self.get_value(prop) for prop in delta_vars if not types.is_backend_base_variable(prop, type(self)) } + if len(subdelta) > 0: delta[self.get_full_name()] = subdelta @@ -1710,9 +2000,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 @@ -1751,6 +2038,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): if var in self.base_vars or var in self._backend_vars: self._was_touched = True break + if var == constants.ROUTER_DATA and self.parent_state is None: + self._was_touched = True + break def _get_was_touched(self) -> bool: """Check current dirty_vars and flag to determine if state instance was modified. @@ -1792,9 +2082,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): Returns: The value of the field. """ - if isinstance(key, MutableProxy): - return super().get_value(key.__wrapped__) - return super().get_value(key) + value = super().get_value(key) + if isinstance(value, MutableProxy): + return value.__wrapped__ + return value def dict( self, include_computed: bool = True, initial: bool = False, **kwargs @@ -1816,17 +2107,16 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): self._mark_dirty() base_vars = { - prop_name: self.get_value(getattr(self, prop_name)) - for prop_name in self.base_vars + prop_name: self.get_value(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)) + else self.get_value(prop_name) ) for prop_name, cv in self.computed_vars.items() if not cv._backend @@ -1834,7 +2124,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): elif include_computed: computed_vars = { # Include the computed vars. - prop_name: self.get_value(getattr(self, prop_name)) + prop_name: self.get_value(prop_name) for prop_name, cv in self.computed_vars.items() if not cv._backend } @@ -1879,7 +2169,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. @@ -1888,15 +2178,158 @@ 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() - state["__dict__"]["parent_state"] = None - state["__dict__"]["substates"] = {} + 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__"].pop("parent_state", None) + state["__dict__"].pop("substates", None) 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 + def __setstate__(self, state: dict[str, Any]): + """Set the state from redis deserialization. -EventHandlerSetVar.update_forward_refs() + This method is called by pickle to deserialize the object. + + Args: + state: The state dict for deserialization. + """ + state["__dict__"]["parent_state"] = None + state["__dict__"]["substates"] = {} + super().__setstate__(state) + + def _check_state_size( + self, + pickle_state_size: int, + ): + """Print a warning when the state is too large. + + Args: + pickle_state_size: The size of the pickled state. + + Raises: + StateTooLargeError: If the state is too large. + """ + state_full_name = self.get_full_name() + if ( + state_full_name not in _WARNED_ABOUT_STATE_SIZE + and pickle_state_size > TOO_LARGE_SERIALIZED_STATE + and self.substates + ): + msg = ( + f"State {state_full_name} serializes to {pickle_state_size} bytes " + + "which may present performance issues. Consider reducing the size of this state." + ) + if environment.REFLEX_PERF_MODE.get() == PerformanceMode.WARN: + console.warn(msg) + elif environment.REFLEX_PERF_MODE.get() == PerformanceMode.RAISE: + raise StateTooLargeError(msg) + _WARNED_ABOUT_STATE_SIZE.add(state_full_name) + + @classmethod + @functools.lru_cache() + def _to_schema(cls) -> str: + """Convert a state to a schema. + + 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( + 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. + + Raises: + StateSerializationError: If the state cannot be serialized. + """ + payload = b"" + error = "" + try: + payload = 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 + + payload = 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) + + if environment.REFLEX_PERF_MODE.get() != PerformanceMode.OFF: + self._check_state_size(len(payload)) + + if not payload: + raise StateSerializationError(error) + + return payload + + @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): @@ -1906,10 +2339,56 @@ 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.""" - def handle_frontend_exception(self, stack: str) -> None: + @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. @@ -1917,6 +2396,7 @@ class FrontendEventExceptionState(State): 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) @@ -2016,6 +2496,23 @@ class ComponentState(State, mixin=True): # The number of components created from this class. _per_component_state_instance_count: ClassVar[int] = 0 + def __init__(self, *args, **kwargs): + """Do not allow direct initialization of the ComponentState. + + Args: + *args: The args to pass to the State init method. + **kwargs: The kwargs to pass to the State init method. + + Raises: + ReflexRuntimeError: If the ComponentState is initialized directly. + """ + if type(self)._mixin: + raise ReflexRuntimeError( + f"{ComponentState.__name__} {type(self).__name__} is not meant to be initialized directly. " + + "Use the `create` method to create a new instance and access the state via the `State` attribute." + ) + super().__init__(*args, **kwargs) + @classmethod def __init_subclass__(cls, mixin: bool = True, **kwargs): """Overwrite mixin default to True. @@ -2054,7 +2551,14 @@ class ComponentState(State, mixin=True): """ 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), {}, mixin=False) + 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 @@ -2079,7 +2583,7 @@ 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: @@ -2322,27 +2826,39 @@ 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 scopes: list[str] = [] + 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.""" @@ -2357,20 +2873,33 @@ 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: - # make sure expiration values are obtained only from the config object on creation - config = get_config() - return StateManagerRedis( - state=state, - redis=redis, - token_expiration=config.redis_token_expiration, - lock_expiration=config.redis_lock_expiration, - ) - 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, + lock_warning_threshold=config.redis_lock_warning_threshold, + ) + raise InvalidStateManagerMode( + f"Expected one of: DISK, MEMORY, REDIS, got {config.state_manager_mode}" + ) @abstractmethod async def get_state(self, token: str) -> BaseState: @@ -2427,6 +2956,7 @@ class StateManagerMemory(StateManager): "_states_locks": {"exclude": True}, } + @override async def get_state(self, token: str) -> BaseState: """Get the state for a token. @@ -2447,6 +2977,7 @@ class StateManagerMemory(StateManager): return self.states[token] + @override async def set_state(self, token: str, state: BaseState): """Set the state for a token. @@ -2456,6 +2987,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. @@ -2477,23 +3009,254 @@ 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: @@ -2505,13 +3268,13 @@ def _default_lock_expiration() -> int: return get_config().redis_lock_expiration -def _default_token_expiration() -> int: - """Get the default token expiration time. +def _default_lock_warning_threshold() -> int: + """Get the default lock warning threshold. Returns: - The default token expiration time. + The default lock warning threshold. """ - return get_config().redis_token_expiration + return get_config().redis_lock_warning_threshold class StateManagerRedis(StateManager): @@ -2526,6 +3289,11 @@ class StateManagerRedis(StateManager): # The maximum time to hold a lock (ms). lock_expiration: int = pydantic.Field(default_factory=_default_lock_expiration) + # The maximum time to hold a lock (ms) before warning. + lock_warning_threshold: int = pydantic.Field( + default_factory=_default_lock_warning_threshold + ) + # The keyspace subscription string when redis is waiting for lock to be released _redis_notify_keyspace_events: str = ( "K" # Enable keyspace notifications (target a particular key) @@ -2542,27 +3310,14 @@ class StateManagerRedis(StateManager): b"evicted", } - # 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. @@ -2571,11 +3326,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 @@ -2607,6 +3366,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( @@ -2620,16 +3381,14 @@ class StateManagerRedis(StateManager): for substate_name, substate_task in tasks.items(): state.substates[substate_name] = await substate_task - # async def print_all_keys(self): - # for key in await self.redis.keys(): - # print(f"redis_key: {key}") - + @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. @@ -2638,6 +3397,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. @@ -2652,81 +3412,52 @@ class StateManagerRedis(StateManager): state_cls = self.state.get_class_substate(state_path) else: raise RuntimeError( - "StateManagerRedis requires token to be specified in the form of {token}_{state_full_name}" + f"StateManagerRedis requires token to be specified in the form of {{token}}_{{state_full_name}}, but got {token}" ) if parent_state is None: parent_state = await self._get_parent_state(token) if parent_state is not None: token = f"{parent_state._get_token(state_cls)}_{state_path}" + # 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( - self, - state: BaseState, - pickle_state_size: int, - ): - """Print a warning when the state is too large. - - Args: - state: The state to check. - pickle_state_size: The size of the pickled state. - """ - state_full_name = state.get_full_name() - if ( - state_full_name not in self._warned_about_state_size - and pickle_state_size > TOO_LARGE_SERIALIZED_STATE - and state.substates - ): - console.warn( - f"State {state_full_name} serializes to {pickle_state_size} bytes " - "which may present performance issues. Consider reducing the size of this state." - ) - self._warned_about_state_size.add(state_full_name) - + @override async def set_state( self, token: str, @@ -2752,8 +3483,19 @@ 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." ) + elif lock_id is not None: + time_taken = self.lock_expiration / 1000 - ( + await self.redis.ttl(self._lock_key(token)) + ) + if time_taken > self.lock_warning_threshold / 1000: + console.warn( + f"Lock for token {token} was held too long {time_taken=}s, " + f"use `@rx.event(background=True)` decorator for long-running tasks.", + dedupe=True, + ) + client_token, substate_name = _split_substate_key(token) client_token = state._get_token() @@ -2764,31 +3506,31 @@ class StateManagerRedis(StateManager): ) # Recursively set_state on all known substates. - tasks = [] - for substate in state.substates.values(): - tasks.append( - asyncio.create_task( - self.set_state( - token=_substate_key(client_token, substate), - state=substate, - lock_id=lock_id, - ) + tasks = [ + asyncio.create_task( + self.set_state( + _substate_key(client_token, substate), + substate, + lock_id, ) ) + for substate in state.substates.values() + ] # 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) - self._warn_if_too_large(state, len(pickle_state)) - await self.redis.set( - _substate_key(client_token, state), - pickle_state, - ex=self.token_expiration, - ) + pickle_state = state._serialize() + 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. @@ -2804,6 +3546,27 @@ class StateManagerRedis(StateManager): yield state await self.set_state(token, state, lock_id) + @validator("lock_warning_threshold") + @classmethod + def validate_lock_warning_threshold(cls, lock_warning_threshold: int, values): + """Validate the lock warning threshold. + + Args: + lock_warning_threshold: The lock warning threshold. + values: The validated attributes. + + Returns: + The lock warning threshold. + + Raises: + InvalidLockWarningThresholdError: If the lock warning threshold is invalid. + """ + if lock_warning_threshold >= (lock_expiration := values["lock_expiration"]): + raise InvalidLockWarningThresholdError( + f"The lock warning threshold({lock_warning_threshold}) must be less than the lock expiration time({lock_expiration})." + ) + return lock_warning_threshold + @staticmethod def _lock_key(token: str) -> bytes: """Get the redis key for a token's lock. @@ -2835,6 +3598,35 @@ class StateManagerRedis(StateManager): nx=True, # only set if it doesn't exist ) + async def _get_pubsub_message( + self, pubsub: PubSub, timeout: float | None = None + ) -> None: + """Get lock release events from the pubsub. + + Args: + pubsub: The pubsub to get a message from. + timeout: Remaining time to wait for a message. + + Returns: + The message. + """ + if timeout is None: + timeout = self.lock_expiration / 1000.0 + + started = time.time() + message = await pubsub.get_message( + ignore_subscribe_messages=True, + timeout=timeout, + ) + if ( + message is None + or message["data"] not in self._redis_keyspace_lock_release_events + ): + remaining = timeout - (time.time() - started) + if remaining <= 0: + return + await self._get_pubsub_message(pubsub, timeout=remaining) + async def _wait_lock(self, lock_key: bytes, lock_id: bytes) -> None: """Wait for a redis lock to be released via pubsub. @@ -2847,7 +3639,6 @@ class StateManagerRedis(StateManager): 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. try: @@ -2857,28 +3648,17 @@ class StateManagerRedis(StateManager): ) except ResponseError: # Some redis servers only allow out-of-band configuration, so ignore errors here. - ignore_config_error = os.environ.get( - "REFLEX_IGNORE_REDIS_CONFIG_ERROR", - None, - ) - if not ignore_config_error: + if not environment.REFLEX_IGNORE_REDIS_CONFIG_ERROR.get(): raise async with self.redis.pubsub() as pubsub: await pubsub.psubscribe(lock_key_channel) - while not state_is_locked: - # wait for the lock to be released - while True: - if not await self.redis.exists(lock_key): - break # key was removed, try to get the lock again - message = await pubsub.get_message( - ignore_subscribe_messages=True, - timeout=self.lock_expiration / 1000.0, - ) - if message is None: - continue - if message["data"] in self._redis_keyspace_lock_release_events: - break - state_is_locked = await self._try_get_lock(lock_key, lock_id) + # wait for the lock to be released + while True: + # fast path + if await self._try_get_lock(lock_key, lock_id): + return + # wait for lock events + await self._get_pubsub_message(pubsub) @contextlib.asynccontextmanager async def _lock(self, token: str): @@ -2933,181 +3713,50 @@ 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 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 - - class MutableProxy(wrapt.ObjectProxy): """A proxy for a mutable object that tracks changes.""" # Methods on wrapped objects which should mark the state as dirty. - __mark_dirty_attrs__ = set( - [ - "add", - "append", - "clear", - "difference_update", - "discard", - "extend", - "insert", - "intersection_update", - "pop", - "popitem", - "remove", - "reverse", - "setdefault", - "sort", - "symmetric_difference_update", - "update", - ] - ) + __mark_dirty_attrs__ = { + "add", + "append", + "clear", + "difference_update", + "discard", + "extend", + "insert", + "intersection_update", + "pop", + "popitem", + "remove", + "reverse", + "setdefault", + "sort", + "symmetric_difference_update", + "update", + } + # Methods on wrapped objects might return mutable objects that should be tracked. - __wrap_mutable_attrs__ = set( - [ - "get", - "setdefault", - ] - ) + __wrap_mutable_attrs__ = { + "get", + "setdefault", + } # 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) + # These types will be wrapped in MutableProxy + __mutable_types__ = ( + list, + dict, + set, + Base, + DeclarativeBase, + BaseModelV2, + BaseModelV1, + ) def __init__(self, wrapped: Any, state: BaseState, field_name: str): """Create a proxy for a mutable object that tracks changes. @@ -3122,11 +3771,19 @@ class MutableProxy(wrapt.ObjectProxy): self._self_state = state self._self_field_name = field_name + def __repr__(self) -> str: + """Get the representation of the wrapped object. + + Returns: + The representation of the wrapped object. + """ + return f"{type(self).__name__}({self.__wrapped__})" + def _mark_dirty( self, wrapped=None, instance=None, - args=tuple(), + args=(), kwargs=None, ) -> Any: """Mark the state as dirty, then call a wrapped function. @@ -3147,6 +3804,18 @@ class MutableProxy(wrapt.ObjectProxy): if wrapped is not None: return wrapped(*args, **(kwargs or {})) + @classmethod + def _is_mutable_type(cls, value: Any) -> bool: + """Check if a value is of a mutable type and should be wrapped. + + Args: + value: The value to check. + + Returns: + Whether the value is of a mutable type. + """ + return isinstance(value, cls.__mutable_types__) + def _wrap_recursive(self, value: Any) -> Any: """Wrap a value recursively if it is mutable. @@ -3157,9 +3826,7 @@ class MutableProxy(wrapt.ObjectProxy): The wrapped value. """ # Recursively wrap mutable types, but do not re-wrap MutableProxy instances. - if isinstance(value, self.__mutable_types__) and not isinstance( - value, MutableProxy - ): + if self._is_mutable_type(value) and not isinstance(value, MutableProxy): return type(self)( wrapped=value, state=self._self_state, @@ -3217,7 +3884,7 @@ class MutableProxy(wrapt.ObjectProxy): self._wrap_recursive_decorator, ) - if isinstance(value, self.__mutable_types__) and __name not in ( + if self._is_mutable_type(value) and __name not in ( "__wrapped__", "_self_state", ): @@ -3326,22 +3993,39 @@ 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__ + + +_orig_json_JSONEncoder_default = json.JSONEncoder.default + + +def _json_JSONEncoder_default_wrapper(self: json.JSONEncoder, o: Any) -> Any: + """Wrap JSONEncoder.default to handle MutableProxy objects. + + Args: + self: the JSONEncoder instance. + o: the object to serialize. + + Returns: + A JSON-able object. + """ + try: + return o.__wrapped__ + except AttributeError: + pass + return _orig_json_JSONEncoder_default(self, o) + + +json.JSONEncoder.default = _json_JSONEncoder_default_wrapper class ImmutableMutableProxy(MutableProxy): @@ -3355,7 +4039,7 @@ class ImmutableMutableProxy(MutableProxy): self, wrapped=None, instance=None, - args=tuple(), + args=(), kwargs=None, ) -> Any: """Raise an exception when an attempt is made to modify the object. @@ -3412,5 +4096,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 69e93ed39..a205cdc4a 100644 --- a/reflex/style.py +++ b/reflex/style.py @@ -6,12 +6,15 @@ from typing import Any, Literal, Tuple, Type from reflex import constants from reflex.components.core.breakpoints import Breakpoints, breakpoints_values -from reflex.event import EventChain +from reflex.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, CallableVar, 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" @@ -20,37 +23,35 @@ LiteralColorMode = Literal["system", "light", "dark"] # Reference the global ColorModeContext color_mode_imports = { - f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="ColorModeContext")], + f"$/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="ColorModeContext")], "react": [ImportVar(tag="useContext")], } -def _color_mode_var(_var_name: str, _var_type: Type = str) -> BaseVar: - """Create a Var that destructs the _var_name from ColorModeContext. +def _color_mode_var(_js_expr: str, _var_type: Type = str) -> Var: + """Create a Var that destructs the _js_expr from ColorModeContext. Args: - _var_name: The name of the variable to get from ColorModeContext. + _js_expr: The name of the variable to get from ColorModeContext. _var_type: The type of the Var. Returns: - The BaseVar for accessing _var_name from ColorModeContext. + The Var that resolves to the color mode. """ - return BaseVar( - _var_name=_var_name, + return Var( + _js_expr=_js_expr, _var_type=_var_type, - _var_is_local=False, - _var_is_string=False, _var_data=VarData( imports=color_mode_imports, - hooks={f"const {{ {_var_name} }} = useContext(ColorModeContext)": None}, + hooks={f"const {{ {_js_expr} }} = useContext(ColorModeContext)": None}, ), - ) + ).guess_type() @CallableVar def set_color_mode( new_color_mode: LiteralColorMode | Var[LiteralColorMode] | None = None, -) -> BaseVar[EventChain]: +) -> 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 @@ -63,27 +64,30 @@ def set_color_mode( The EventChain Var that can be passed to an event trigger. """ base_setter = _color_mode_var( - _var_name=constants.ColorMode.SET, + _js_expr=constants.ColorMode.SET, _var_type=EventChain, ) if new_color_mode is None: return base_setter if not isinstance(new_color_mode, Var): - new_color_mode = Var.create_safe(new_color_mode, _var_is_string=True) - return base_setter._replace( - _var_name=f"() => {base_setter._var_name}({new_color_mode._var_name_unwrapped})", - merge_var_data=new_color_mode._var_data, - ) + new_color_mode = LiteralVar.create(new_color_mode) + + return Var( + f"() => {base_setter!s}({new_color_mode!s})", + _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(_var_name=constants.ColorMode.NAME) +color_mode = _color_mode_var(_js_expr=constants.ColorMode.NAME) # Var resolves to the resolved color mode for the app ("light" or "dark") -resolved_color_mode = _color_mode_var(_var_name=constants.ColorMode.RESOLVED_NAME) +resolved_color_mode = _color_mode_var(_js_expr=constants.ColorMode.RESOLVED_NAME) # Var resolves to a function invocation that toggles the color mode toggle_color_mode = _color_mode_var( - _var_name=constants.ColorMode.TOGGLE, + _js_expr=constants.ColorMode.TOGGLE, _var_type=EventChain, ) @@ -111,7 +115,9 @@ def media_query(breakpoint_expr: str): 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: @@ -119,23 +125,28 @@ 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() # Otherwise, convert to Var to collapse VarData encoded in f-string. - new_var = Var.create(style_item, _var_is_string=False) - 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: @@ -157,7 +168,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: @@ -174,8 +187,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) @@ -254,10 +284,10 @@ class Style(dict): value: The value to set. """ # Create a Var to collapse VarData encoded in f-string. - _var = Var.create(value, _var_is_string=False) + _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) @@ -265,14 +295,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(":"): diff --git a/reflex/testing.py b/reflex/testing.py index c52396fc6..ca31054b3 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -8,7 +8,6 @@ import dataclasses import functools import inspect import os -import pathlib import platform import re import signal @@ -20,6 +19,7 @@ import threading import time import types from http.server import SimpleHTTPRequestHandler +from pathlib import Path from typing import ( TYPE_CHECKING, Any, @@ -43,8 +43,11 @@ import reflex.utils.exec import reflex.utils.format import reflex.utils.prerequisites import reflex.utils.processes +from reflex.config import environment from reflex.state import ( BaseState, + StateManager, + StateManagerDisk, StateManagerMemory, StateManagerRedis, reload_state_module, @@ -97,7 +100,7 @@ class chdir(contextlib.AbstractContextManager): def __enter__(self): """Save current directory and perform chdir.""" - self._old_cwd.append(os.getcwd()) + self._old_cwd.append(Path.cwd()) os.chdir(self.path) def __exit__(self, *excinfo): @@ -115,10 +118,10 @@ class AppHarness: app_name: str app_source: Optional[ - types.FunctionType | types.ModuleType | str | functools.partial[Any] + Callable[[], None] | types.ModuleType | str | functools.partial[Any] ] - app_path: pathlib.Path - app_module_path: pathlib.Path + app_path: Path + app_module_path: Path app_module: Optional[types.ModuleType] = None app_instance: Optional[reflex.App] = None frontend_process: Optional[subprocess.Popen] = None @@ -126,16 +129,16 @@ 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) @classmethod def create( cls, - root: pathlib.Path, + root: Path, app_source: Optional[ - types.FunctionType | types.ModuleType | str | functools.partial[Any] + Callable[[], None] | types.ModuleType | str | functools.partial[Any] ] = None, app_name: Optional[str] = None, ) -> "AppHarness": @@ -203,7 +206,7 @@ class AppHarness: 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 = [State.get_name()] + [self.get_state_name(p) for p in path] # noqa: ERA001 path = ["reflex___state____state"] + [self.get_state_name(p) for p in path] return ".".join(path) @@ -247,7 +250,9 @@ 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) @@ -327,7 +332,8 @@ class AppHarness: ) ) self.backend.shutdown = self._get_backend_shutdown_handler() - self.backend_thread = threading.Thread(target=self.backend.run) + with chdir(self.app_path): + self.backend_thread = threading.Thread(target=self.backend.run) self.backend_thread.start() async def _reset_backend_state_manager(self): @@ -335,6 +341,9 @@ class AppHarness: 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 @@ -349,7 +358,8 @@ class AppHarness: self.app_instance._state_manager = StateManagerRedis.create( state=self.app_instance.state, ) - assert isinstance(self.app_instance.state_manager, StateManagerRedis) + if not isinstance(self.app_instance.state_manager, StateManagerRedis): + raise RuntimeError("Failed to reset state manager.") def _start_frontend(self): # Set up the frontend. @@ -387,9 +397,14 @@ class AppHarness: 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) @@ -421,7 +436,6 @@ class AppHarness: Returns: The rendered app global code. - """ if not inspect.isclass(value) and not inspect.isfunction(value): return f"{key} = {value!r}" @@ -602,10 +616,10 @@ class AppHarness: if self.frontend_url is None: raise RuntimeError("Frontend is not running.") want_headless = False - if os.environ.get("APP_HARNESS_HEADLESS"): + if environment.APP_HARNESS_HEADLESS.get(): want_headless = True if driver_clz is None: - requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome") + requested_driver = environment.APP_HARNESS_DRIVER.get() driver_clz = getattr(webdriver, requested_driver) if driver_options is None: driver_options = getattr(webdriver, f"{requested_driver}Options")() @@ -627,7 +641,7 @@ class AppHarness: 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"): + if args := environment.APP_HARNESS_DRIVER_ARGS.get(): for arg in args.split(","): driver_options.add_argument(arg) if driver_option_args is not None: @@ -782,13 +796,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, @@ -800,7 +814,7 @@ class AppHarness: class SimpleHTTPRequestHandlerCustomErrors(SimpleHTTPRequestHandler): """SimpleHTTPRequestHandler with custom error page handling.""" - def __init__(self, *args, error_page_map: dict[int, pathlib.Path], **kwargs): + def __init__(self, *args, error_page_map: dict[int, Path], **kwargs): """Initialize the handler. Args: @@ -843,8 +857,8 @@ class Subdir404TCPServer(socketserver.TCPServer): def __init__( self, *args, - root: pathlib.Path, - error_page_map: dict[int, pathlib.Path] | None, + root: Path, + error_page_map: dict[int, Path] | None, **kwargs, ): """Initialize the server. @@ -864,7 +878,7 @@ class Subdir404TCPServer(socketserver.TCPServer): Args: request: the requesting socket - client_address: (host, port) referring to the client’s address. + client_address: (host, port) referring to the client's address. """ self.RequestHandlerClass( request, @@ -931,7 +945,7 @@ class AppHarnessProd(AppHarness): def _start_backend(self): if self.app_instance is None: raise RuntimeError("App was not initialized.") - os.environ[reflex.constants.SKIP_COMPILE_ENV_VAR] = "yes" + environment.REFLEX_SKIP_COMPILE.set(True) self.backend = uvicorn.Server( uvicorn.Config( app=self.app_instance, @@ -948,7 +962,7 @@ class AppHarnessProd(AppHarness): try: return super()._poll_for_servers(timeout) finally: - os.environ.pop(reflex.constants.SKIP_COMPILE_ENV_VAR, None) + environment.REFLEX_SKIP_COMPILE.set(None) def stop(self): """Stop the frontend python webserver.""" diff --git a/reflex/utils/build.py b/reflex/utils/build.py index 7a67ec32e..e263374e1 100644 --- a/reflex/utils/build.py +++ b/reflex/utils/build.py @@ -23,18 +23,6 @@ def set_env_json(): ) -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. @@ -61,8 +49,8 @@ def generate_sitemap_config(deploy_url: str, export=False): 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,13 +114,13 @@ 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 zip_app( frontend: bool = True, backend: bool = True, - zip_dest_dir: str = os.getcwd(), + zip_dest_dir: str | Path = Path.cwd(), upload_db_file: bool = False, ): """Zip up the app. @@ -143,6 +131,7 @@ def zip_app( zip_dest_dir: The directory to export the zip file to. upload_db_file: Whether to upload the database file. """ + zip_dest_dir = Path(zip_dest_dir) files_to_exclude = { constants.ComponentName.FRONTEND.zip(), constants.ComponentName.BACKEND.zip(), @@ -151,8 +140,8 @@ def zip_app( if frontend: _zip( component_name=constants.ComponentName.FRONTEND, - target=os.path.join(zip_dest_dir, constants.ComponentName.FRONTEND.zip()), - root_dir=str(prerequisites.get_web_dir() / constants.Dirs.STATIC), + 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, ) @@ -160,8 +149,8 @@ def zip_app( if backend: _zip( component_name=constants.ComponentName.BACKEND, - target=os.path.join(zip_dest_dir, constants.ComponentName.BACKEND.zip()), - root_dir=".", + target=zip_dest_dir / constants.ComponentName.BACKEND.zip(), + root_dir=Path.cwd(), dirs_to_exclude={"__pycache__"}, files_to_exclude=files_to_exclude, top_level_dirs_to_exclude={"assets"}, @@ -236,6 +225,9 @@ def setup_frontend( # 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( @@ -266,5 +258,6 @@ def setup_frontend_prod( 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/compat.py b/reflex/utils/compat.py index ef5fcd3e1..e63492a6b 100644 --- a/reflex/utils/compat.py +++ b/reflex/utils/compat.py @@ -19,10 +19,13 @@ async def windows_hot_reload_lifespan_hack(): import asyncio import sys - while True: - sys.stderr.write("\0") - sys.stderr.flush() - await asyncio.sleep(0.5) + try: + while True: + sys.stderr.write("\0") + sys.stderr.flush() + await asyncio.sleep(0.5) + except asyncio.CancelledError: + pass @contextlib.contextmanager @@ -69,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 69500b32f..be545140a 100644 --- a/reflex/utils/console.py +++ b/reflex/utils/console.py @@ -20,13 +20,46 @@ _EMITTED_DEPRECATION_WARNINGS = set() # Info messages which have been printed. _EMITTED_INFO = set() +# Warnings which have been printed. +_EMIITED_WARNINGS = set() + +# Errors which have been printed. +_EMITTED_ERRORS = set() + +# Success messages which have been printed. +_EMITTED_SUCCESS = set() + +# Debug messages which have been printed. +_EMITTED_DEBUG = set() + +# Logs which have been printed. +_EMITTED_LOGS = set() + +# Prints which have been printed. +_EMITTED_PRINTS = set() + def set_log_level(log_level: LogLevel): """Set the log level. Args: log_level: The log level to set. + + Raises: + ValueError: If the log level is invalid. """ + if not isinstance(log_level, LogLevel): + deprecate( + feature_name="Passing a string to set_log_level", + reason="use reflex.constants.LogLevel enum instead", + deprecation_version="0.6.6", + removal_version="0.7.0", + ) + try: + log_level = getattr(LogLevel, log_level.upper()) + except AttributeError as ae: + raise ValueError(f"Invalid log level: {log_level}") from ae + global _LOG_LEVEL _LOG_LEVEL = log_level @@ -40,25 +73,37 @@ def is_debug() -> bool: return _LOG_LEVEL <= LogLevel.DEBUG -def print(msg: str, **kwargs): +def print(msg: str, dedupe: bool = False, **kwargs): """Print a message. Args: msg: The message to print. + dedupe: If True, suppress multiple console logs of print message. kwargs: Keyword arguments to pass to the print function. """ + if dedupe: + if msg in _EMITTED_PRINTS: + return + else: + _EMITTED_PRINTS.add(msg) _console.print(msg, **kwargs) -def debug(msg: str, **kwargs): +def debug(msg: str, dedupe: bool = False, **kwargs): """Print a debug message. Args: msg: The debug message. + dedupe: If True, suppress multiple console logs of debug message. 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 dedupe: + if msg_ in _EMITTED_DEBUG: + return + else: + _EMITTED_DEBUG.add(msg_) if progress := kwargs.pop("progress", None): progress.console.print(msg_, **kwargs) else: @@ -82,25 +127,37 @@ def info(msg: str, dedupe: bool = False, **kwargs): print(f"[cyan]Info: {msg}[/cyan]", **kwargs) -def success(msg: str, **kwargs): +def success(msg: str, dedupe: bool = False, **kwargs): """Print a success message. Args: msg: The success message. + dedupe: If True, suppress multiple console logs of success message. kwargs: Keyword arguments to pass to the print function. """ if _LOG_LEVEL <= LogLevel.INFO: + if dedupe: + if msg in _EMITTED_SUCCESS: + return + else: + _EMITTED_SUCCESS.add(msg) print(f"[green]Success: {msg}[/green]", **kwargs) -def log(msg: str, **kwargs): +def log(msg: str, dedupe: bool = False, **kwargs): """Takes a string and logs it to the console. Args: msg: The message to log. + dedupe: If True, suppress multiple console logs of log message. kwargs: Keyword arguments to pass to the print function. """ if _LOG_LEVEL <= LogLevel.INFO: + if dedupe: + if msg in _EMITTED_LOGS: + return + else: + _EMITTED_LOGS.add(msg) _console.log(msg, **kwargs) @@ -114,14 +171,20 @@ def rule(title: str, **kwargs): _console.rule(title, **kwargs) -def warn(msg: str, **kwargs): +def warn(msg: str, dedupe: bool = False, **kwargs): """Print a warning message. Args: msg: The warning message. + dedupe: If True, suppress multiple console logs of warning message. kwargs: Keyword arguments to pass to the print function. """ if _LOG_LEVEL <= LogLevel.WARNING: + if dedupe: + if msg in _EMIITED_WARNINGS: + return + else: + _EMIITED_WARNINGS.add(msg) print(f"[orange1]Warning: {msg}[/orange1]", **kwargs) @@ -154,14 +217,20 @@ def deprecate( _EMITTED_DEPRECATION_WARNINGS.add(feature_name) -def error(msg: str, **kwargs): +def error(msg: str, dedupe: bool = False, **kwargs): """Print an error message. Args: msg: The error message. + dedupe: If True, suppress multiple console logs of error message. kwargs: Keyword arguments to pass to the print function. """ if _LOG_LEVEL <= LogLevel.ERROR: + if dedupe: + if msg in _EMITTED_ERRORS: + return + else: + _EMITTED_ERRORS.add(msg) print(f"[red]{msg}[/red]", **kwargs) @@ -191,7 +260,6 @@ def ask( def progress(): """Create a new progress bar. - Returns: A new progress bar. """ diff --git a/reflex/utils/exceptions.py b/reflex/utils/exceptions.py index d219dcf0c..ae5ec0168 100644 --- a/reflex/utils/exceptions.py +++ b/reflex/utils/exceptions.py @@ -1,10 +1,20 @@ """Custom Exceptions.""" +from typing import NoReturn + 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.""" @@ -53,6 +63,10 @@ class UploadValueError(ReflexError, ValueError): """Custom ValueError for upload related errors.""" +class PageValueError(ReflexError, ValueError): + """Custom ValueError for page related errors.""" + + class RouteValueError(ReflexError, ValueError): """Custom ValueError for route related errors.""" @@ -79,3 +93,97 @@ class LockExpiredError(ReflexError): class MatchTypeError(ReflexError, TypeError): """Raised when the return types of match cases are different.""" + + +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 required by an event handler is more than 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.""" + + +class StateTooLargeError(ReflexError): + """Raised when the state is too large to be serialized.""" + + +class StateSerializationError(ReflexError): + """Raised when the state cannot be serialized.""" + + +class SystemPackageMissingError(ReflexError): + """Raised when a system package is missing.""" + + +def raise_system_package_missing_error(package: str) -> NoReturn: + """Raise a SystemPackageMissingError. + + Args: + package: The name of the missing system package. + + Raises: + SystemPackageMissingError: The raised exception. + """ + from reflex.constants import IS_MACOS + + raise SystemPackageMissingError( + f"System package '{package}' is missing." + " Please install it through your system package manager." + + (f" You can do so by running 'brew install {package}'." if IS_MACOS else "") + ) + + +class InvalidLockWarningThresholdError(ReflexError): + """Raised when an invalid lock warning threshold is provided.""" diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index 77df98116..621c4a608 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -15,26 +15,16 @@ 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.prerequisites import get_web_dir -from reflex.utils.watch import AssetFolderWatch # For uvicorn windows bug fix (#2335) frontend_process = None -def start_watching_assets_folder(root): - """Start watching assets folder. - - Args: - root: root path of the project. - """ - asset_watch = AssetFolderWatch(root) - asset_watch.start() - - -def detect_package_change(json_file_path: str) -> str: +def detect_package_change(json_file_path: Path) -> str: """Calculates the SHA-256 hash of a JSON file and returns it as a hexadecimal string. Args: @@ -47,7 +37,7 @@ def detect_package_change(json_file_path: str) -> str: >>> detect_package_change("package.json") 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2' """ - with open(json_file_path, "r") as file: + with json_file_path.open("r") as file: json_data = json.load(file) # Calculate the hash @@ -71,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 @@ -84,7 +81,7 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True): from reflex.utils import processes json_file_path = get_web_dir() / constants.PackageJson.PATH - last_hash = detect_package_change(str(json_file_path)) + last_hash = detect_package_change(json_file_path) process = None first_run = True @@ -114,22 +111,20 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True): f"App running at: [bold green]{url}[/bold green]{' (Frontend-only mode)' if not backend_present else ''}" ) if backend_present: - console.print( - f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]" - ) + notify_backend() first_run = False else: console.print("New packages detected: Updating app...") else: if any( - [x in line for x in ("bin executable does not exist on disk",)] + 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)) + new_hash = detect_package_change(json_file_path) if new_hash != last_hash: last_hash = new_hash kill(process.pid) @@ -149,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) @@ -185,13 +178,71 @@ 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.get() + + +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"{app_module_path!s}:{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 @@ -199,23 +250,55 @@ def run_backend( """ import uvicorn - config = get_config() - app_module = f"reflex.app_module_for_backend:{constants.CompileVars.APP}" - - web_dir = get_web_dir() - # Create a .nocompile file to skip compile for backend. - if web_dir.exists(): - (web_dir / constants.NOCOMPILE_FILE).touch() - - # 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=[str(web_dir)], + 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 ) @@ -223,9 +306,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 @@ -234,14 +336,11 @@ def run_backend_prod( from reflex.utils import processes config = get_config() - num_workers = ( - processes.get_num_workers() - if not config.gunicorn_workers - else config.gunicorn_workers - ) - 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, @@ -257,7 +356,7 @@ def run_backend_prod( "--bind", f"{host}:{port}", "--threads", - str(num_workers), + str(_get_backend_workers()), f"{app_module}()", ] ) @@ -266,16 +365,59 @@ def run_backend_prod( "--log-level", loglevel.value, "--workers", - str(num_workers), + str(_get_backend_workers()), ] processes.new_process( command, run=True, show_logs=True, - env={constants.SKIP_COMPILE_ENV_VAR: "yes"}, # skip compile for prod backend + env={ + environment.REFLEX_SKIP_COMPILE.name: "true" + }, # skip compile for prod backend ) +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={ + environment.REFLEX_SKIP_COMPILE.name: "true" + }, # 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: @@ -289,7 +431,7 @@ def output_system_info(): except Exception: config_file = None - console.rule(f"System Info") + console.rule("System Info") console.debug(f"Config file: {config_file!r}") console.debug(f"Config: {config}") @@ -300,10 +442,8 @@ def output_system_info(): system = platform.system() - if ( - system != "Windows" - or system == "Windows" - and prerequisites.is_windows_bun_supported() + if system != "Windows" or ( + system == "Windows" and prerequisites.is_windows_bun_supported() ): dependencies.extend( [ @@ -329,9 +469,11 @@ def output_system_info(): console.debug(f"{dep}") console.debug( - f"Using package installer at: {prerequisites.get_install_package_manager()}" # type: ignore + f"Using package installer at: {prerequisites.get_install_package_manager(on_failure_return_none=True)}" # type: ignore ) - console.debug(f"Using package executer at: {prerequisites.get_package_manager()}") # type: ignore + console.debug( + f"Using package executer at: {prerequisites.get_package_manager(on_failure_return_none=True)}" + ) # type: ignore if system != "Windows": console.debug(f"Unzip path: {path_ops.which('unzip')}") @@ -351,11 +493,38 @@ def is_prod_mode() -> bool: Returns: True if the app is running in production mode or False if running in dev mode. """ - current_mode = os.environ.get( - constants.ENV_MODE_ENV_VAR, - constants.Env.DEV.value, + current_mode = environment.REFLEX_ENV_MODE.get() + return current_mode == constants.Env.PROD + + +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. + """ + console.deprecate( + "is_frontend_only() is deprecated and will be removed in a future release.", + reason="Use `environment.REFLEX_FRONTEND_ONLY.get()` instead.", + deprecation_version="0.6.5", + removal_version="0.7.0", ) - return current_mode == constants.Env.PROD.value + return environment.REFLEX_FRONTEND_ONLY.get() + + +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. + """ + console.deprecate( + "is_backend_only() is deprecated and will be removed in a future release.", + reason="Use `environment.REFLEX_BACKEND_ONLY.get()` instead.", + deprecation_version="0.6.5", + removal_version="0.7.0", + ) + return environment.REFLEX_BACKEND_ONLY.get() def should_skip_compile() -> bool: @@ -364,4 +533,10 @@ def should_skip_compile() -> bool: Returns: True if the app should skip compile. """ - return os.environ.get(constants.SKIP_COMPILE_ENV_VAR) == "yes" + console.deprecate( + "should_skip_compile() is deprecated and will be removed in a future release.", + reason="Use `environment.REFLEX_SKIP_COMPILE.get()` instead.", + deprecation_version="0.6.5", + removal_version="0.7.0", + ) + return environment.REFLEX_SKIP_COMPILE.get() diff --git a/reflex/utils/export.py b/reflex/utils/export.py index 31ac0d0b5..2fbf633f6 100644 --- a/reflex/utils/export.py +++ b/reflex/utils/export.py @@ -1,6 +1,5 @@ """Export utilities.""" -import os from pathlib import Path from typing import Optional @@ -15,7 +14,7 @@ def export( zipping: bool = True, frontend: bool = True, backend: bool = True, - zip_dest_dir: str = os.getcwd(), + zip_dest_dir: str = str(Path.cwd()), upload_db_file: bool = False, api_url: Optional[str] = None, deploy_url: Optional[str] = None, diff --git a/reflex/utils/format.py b/reflex/utils/format.py index 59bbbd91c..1d6671a0b 100644 --- a/reflex/utils/format.py +++ b/reflex/utils/format.py @@ -6,15 +6,16 @@ import inspect import json import os import re -from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union +from typing import TYPE_CHECKING, Any, List, Optional, Union from reflex import constants -from reflex.utils import exceptions, types -from reflex.vars import BaseVar, Var +from reflex.constants.state import FRONTEND_EVENT_STATE +from reflex.utils import exceptions +from reflex.utils.console import deprecate if TYPE_CHECKING: from reflex.components.component import ComponentStyle - from reflex.event import ArgsSpec, EventChain, EventHandler, EventSpec + from reflex.event import ArgsSpec, EventChain, EventHandler, EventSpec, EventType WRAP_MAP = { "{": "}", @@ -197,8 +198,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: @@ -263,32 +272,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. @@ -298,13 +281,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: @@ -329,46 +306,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: @@ -387,17 +329,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({condition!s}):" for condition in conditions] ) + case_code = f"{case_conditions} return ({return_value!s}); break;" switch_code += case_code - switch_code += f"default: return ({default._var_name_unwrapped}); break;" + switch_code += f"default: return ({default!s}); break;" switch_code += "};})()" return switch_code @@ -417,37 +354,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_expr = 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 = "...args" - arg_def_expr = "args" - - chain = ",".join([format_event(event) for event in prop.events]) - event = f"addEvents([{chain}], {arg_def_expr}, {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): @@ -468,7 +389,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) @@ -483,11 +405,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"{LiteralVar.create(prop)!s}") for prop in single_props] def get_event_handler_parts(handler: EventHandler) -> tuple[str, str]: @@ -502,19 +428,19 @@ 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] from reflex.state import State - if state_full_name == "state" and name not in State.__dict__: + if state_full_name == FRONTEND_EVENT_STATE and name not in State.__dict__: return ("", to_snake_case(handler.fn.__qualname__)) return (state_full_name, name) @@ -548,14 +474,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) ), ) ) @@ -572,52 +498,43 @@ def format_event(event_spec: EventSpec) -> str: return f"Event({', '.join(event_args)})" +if TYPE_CHECKING: + from reflex.vars import Var + + def format_event_chain( event_chain: EventChain | Var[EventChain], event_arg: Var | None = None, ) -> str: - """Format an event chain as a javascript invocation. + """DEPRECATED: format an event chain as a javascript invocation. + + Use str(rx.Var.create(event_chain)) instead. Args: - event_chain: The event chain to queue on the frontend. - event_arg: The browser-native event (only used to preventDefault). + event_chain: The event chain to format. + event_arg: this argument is ignored. Returns: Compiled javascript code to queue the given event chain on the frontend. - - Raises: - ValueError: When the given event chain is not a valid event chain. """ - if isinstance(event_chain, Var): - from reflex.event import EventChain - - if event_chain._var_type is not EventChain: - raise ValueError(f"Invalid event chain: {event_chain}") - return "".join( - [ - "(() => {", - format_var(event_chain), - f"; preventDefault({format_var(event_arg)})" if event_arg else "", - "})()", - ] - ) - - chain = ",".join([format_event(event) for event in event_chain.events]) - return "".join( - [ - f"addEvents([{chain}]", - f", {format_var(event_arg)}" if event_arg else "", - ")", - ] + deprecate( + feature_name="format_event_chain", + reason="Use str(rx.Var.create(event_chain)) instead", + deprecation_version="0.6.0", + removal_version="0.7.0", ) + from reflex.vars import Var + from reflex.vars.function import ArgsFunctionOperation + + result = Var.create(event_chain) + if isinstance(result, ArgsFunctionOperation): + result = result._return_expr + return str(result) + def format_queue_events( - events: EventSpec - | EventHandler - | Callable - | List[EventSpec | EventHandler | Callable] - | None = None, + events: EventType | None = None, args_spec: Optional[ArgsSpec] = None, ) -> Var[EventChain]: """Format a list of event handler / event spec as a javascript callback. @@ -645,11 +562,10 @@ def format_queue_events( call_event_fn, call_event_handler, ) + from reflex.vars import FunctionVar, Var if not events: - return Var.create_safe( - "() => null", _var_is_string=False, _var_is_local=False - ).to(EventChain) + return Var("(() => null)").to(FunctionVar, EventChain) # type: ignore # If no spec is provided, the function will take no arguments. def _default_args_spec(): @@ -682,12 +598,10 @@ def format_queue_events( # Return the final code snippet, expecting queueEvents, processEvent, and socket to be in scope. # Typically this snippet will _only_ run from within an rx.call_script eval context. - return Var.create_safe( + return Var( f"{arg_def} => {{queueEvents([{','.join(payloads)}], {constants.CompileVars.SOCKET}); " f"processEvent({constants.CompileVars.SOCKET})}}", - _var_is_string=False, - _var_is_local=False, - ).to(EventChain) + ).to(FunctionVar, EventChain) # type: ignore def format_query_params(router_data: dict[str, Any]) -> dict[str, str]: @@ -703,48 +617,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. - """ - from reflex.utils import serializers - - # 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 = serializers.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. @@ -774,41 +646,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. @@ -818,6 +655,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 @@ -825,54 +664,22 @@ def format_library_name(library_fullname: str): return lib -def json_dumps(obj: Any) -> str: +def json_dumps(obj: Any, **kwargs) -> str: """Takes an object and returns a jsonified string. Args: obj: The object to be serialized. + kwargs: Additional keyword arguments to pass to json.dumps. Returns: A string """ from reflex.utils import serializers - return json.dumps(obj, ensure_ascii=False, default=serializers.serialize) + kwargs.setdefault("ensure_ascii", False) + kwargs.setdefault("default", serializers.serialize) - -def unwrap_vars(value: str) -> str: - """Unwrap var values from a JSON string. - - For example, "{var}" will be unwrapped to "var". - - Args: - value: The JSON string to unwrap. - - Returns: - The unwrapped JSON string. - """ - - def unescape_double_quotes_in_var(m: re.Match) -> str: - prefix = m.group(1) or "" - # Since the outer quotes are removed, the inner escaped quotes must be unescaped. - return prefix + re.sub('\\\\"', '"', m.group(2)) - - # This substitution is necessary to unwrap var values. - return ( - re.sub( - pattern=r""" - (?.*?)? # Optional encoded VarData (non-greedy) - {(.*?)} # extract the value between curly braces (non-greedy) - " # match must end with an unescaped double quote - """, - repl=unescape_double_quotes_in_var, - string=value, - flags=re.VERBOSE, - ) - .replace('"`', "`") - .replace('`"', "`") - ) + return json.dumps(obj, **kwargs) def collect_form_dict_names(form_dict: dict[str, Any]) -> dict[str, Any]: @@ -897,6 +704,22 @@ 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: + return f"refs_{clean_ref}[{idx!s}]" + return f"refs_{clean_ref}" + + def format_data_editor_column(col: str | dict): """Format a given column into the proper format. @@ -909,6 +732,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"} @@ -921,7 +746,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( @@ -938,7 +763,9 @@ def format_data_editor_cell(cell: Any): Returns: The formatted cell. """ + from reflex.vars.base import Var + return { - "kind": Var.create(value="GridCellKind.Text", _var_is_string=False), + "kind": Var(_js_expr="GridCellKind.Text"), "data": cell, } diff --git a/reflex/utils/imports.py b/reflex/utils/imports.py index d58c2bf3f..bd422ecc0 100644 --- a/reflex/utils/imports.py +++ b/reflex/utils/imports.py @@ -2,10 +2,9 @@ from __future__ import annotations +import dataclasses from collections import defaultdict -from typing import Dict, List, Optional, Tuple, Union - -from reflex.base import Base +from typing import DefaultDict, Dict, List, Optional, Tuple, Union def merge_imports( @@ -19,12 +18,28 @@ def merge_imports( Returns: The merged import dicts. """ - all_imports = defaultdict(list) + all_imports: DefaultDict[str, List[ImportVar]] = defaultdict(list) for import_dict in imports: for lib, fields in ( import_dict if isinstance(import_dict, tuple) else import_dict.items() ): - all_imports[lib].extend(fields) + # If 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 @@ -75,7 +90,8 @@ def collapse_imports( } -class ImportVar(Base): +@dataclasses.dataclass(order=True, frozen=True) +class ImportVar: """An import var.""" # The name of the import tag. @@ -111,73 +127,6 @@ class ImportVar(Base): else: return self.tag or "" - def __lt__(self, other: ImportVar) -> bool: - """Compare two ImportVar objects. - - Args: - other: The other ImportVar object to compare. - - Returns: - Whether this ImportVar object is less than the other. - """ - return ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) < ( - other.tag, - other.is_default, - other.alias, - other.install, - other.render, - other.transpile, - ) - - def __eq__(self, other: ImportVar) -> bool: - """Check if two ImportVar objects are equal. - - Args: - other: The other ImportVar object to compare. - - Returns: - Whether the two ImportVar objects are equal. - """ - return ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) == ( - other.tag, - other.is_default, - other.alias, - other.install, - other.render, - other.transpile, - ) - - def __hash__(self) -> int: - """Hash the ImportVar object. - - Returns: - The hash of the ImportVar object. - """ - return hash( - ( - self.tag, - self.is_default, - self.alias, - self.install, - self.render, - self.transpile, - ) - ) - ImportTypes = Union[str, ImportVar, List[Union[str, ImportVar]], List[ImportVar]] ImportDict = Dict[str, ImportTypes] diff --git a/reflex/utils/net.py b/reflex/utils/net.py new file mode 100644 index 000000000..acc202912 --- /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.get() + + +def get(url: str, **kwargs) -> httpx.Response: + """Make an HTTP GET request. + + Args: + url: The URL to request. + **kwargs: Additional keyword arguments to pass to httpx.get. + + Returns: + The response object. + + Raises: + httpx.ConnectError: If the connection cannot be established. + """ + kwargs.setdefault("verify", _httpx_verify_kwarg()) + try: + return httpx.get(url, **kwargs) + except httpx.ConnectError as err: + if "CERTIFICATE_VERIFY_FAILED" in str(err): + # If the error is a certificate verification error, recommend mitigating steps. + console.error( + f"Certificate verification failed for {url}. Set environment variable SSL_CERT_FILE to the " + "path of the certificate file or SSL_NO_VERIFY=1 to disable verification." + ) + raise diff --git a/reflex/utils/path_ops.py b/reflex/utils/path_ops.py index 39f2138f8..38560977e 100644 --- a/reflex/utils/path_ops.py +++ b/reflex/utils/path_ops.py @@ -9,6 +9,7 @@ import shutil from pathlib import Path from reflex import constants +from reflex.config import environment # Shorthand for join. join = os.linesep.join @@ -81,6 +82,18 @@ def mkdir(path: str | Path): Path(path).mkdir(parents=True, exist_ok=True) +def ls(path: str | Path) -> list[Path]: + """List the contents of a directory. + + Args: + path: The path to the directory. + + Returns: + A list of paths to the contents of the directory. + """ + return list(Path(path).iterdir()) + + def ln(src: str | Path, dest: str | Path, overwrite: bool = False) -> bool: """Create a symbolic link. @@ -117,7 +130,25 @@ def which(program: str | Path) -> str | Path | None: 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.get() + + +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.get() + + +def get_node_bin_path() -> Path | None: """Get the node binary dir path. Returns: @@ -126,8 +157,8 @@ def get_node_bin_path() -> str | None: 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(bin_path.resolve()) + return Path(str_path).parent.resolve() if str_path else None + return bin_path.resolve() def get_node_path() -> str | None: @@ -137,8 +168,9 @@ def get_node_path() -> str | None: The path to the node binary file. """ node_path = Path(constants.Node.PATH) - if not node_path.exists(): - return str(which("node")) + 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) @@ -149,8 +181,9 @@ def get_npm_path() -> str | None: The path to the npm binary file. """ npm_path = Path(constants.Node.NPM_PATH) - if not npm_path.exists(): - return str(which("npm")) + 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) @@ -171,15 +204,15 @@ def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]): # Read the existing json object from the file. json_object = {} - if fp.stat().st_size == 0: - with open(fp) as f: + if fp.stat().st_size: + with fp.open() as f: json_object = json.load(f) # Update the json object with the new data. json_object.update(update_dict) # Write the updated json object to the file - with open(fp, "w") as f: + with fp.open("w") as f: json.dump(json_object, f, ensure_ascii=False) @@ -197,4 +230,4 @@ def find_replace(directory: str | Path, find: str, replace: str): filepath = Path(root, file) text = filepath.read_text(encoding="utf-8") text = re.sub(find, replace, text) - filepath.write_text(text) + filepath.write_text(text, encoding="utf-8") diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index a80bcd814..797d28701 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -2,11 +2,11 @@ from __future__ import annotations +import contextlib +import dataclasses import functools -import glob import importlib import importlib.metadata -import inspect import json import os import platform @@ -16,10 +16,9 @@ import shutil import stat import sys import tempfile -import textwrap +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 @@ -29,21 +28,25 @@ 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, redir +from reflex.utils.exceptions import ( + GeneratedCodeHasNoFunctionDefs, + raise_system_package_missing_error, +) from reflex.utils.format import format_library_name -from reflex.utils.registry import _get_best_registry +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 @@ -52,7 +55,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] @@ -68,8 +72,19 @@ def get_web_dir() -> Path: Returns: The working directory. """ - workdir = Path(os.getenv("REFLEX_WEB_WORKDIR", constants.Dirs.WEB)) - return workdir + return environment.REFLEX_WEB_WORKDIR.get() + + +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): @@ -78,21 +93,24 @@ def check_latest_package_version(package_name: str): Args: package_name: The name of the package. """ + if environment.REFLEX_CHECK_LATEST_VERSION.get() is False: + return try: # Get the latest version from PyPI current_version = importlib.metadata.version(package_name) url = f"https://pypi.org/pypi/{package_name}/json" - response = httpx.get(url) + response = net.get(url) latest_version = response.json()["info"]["version"] - if ( - version.parse(current_version) < version.parse(latest_version) - 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 deprecated python versions + _python_version_check() except Exception: pass @@ -117,6 +135,14 @@ def get_or_set_last_reflex_version_check_datetime(): 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. @@ -124,14 +150,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: @@ -177,7 +198,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 @@ -188,34 +209,44 @@ def get_bun_version() -> version.Version | None: return None -def get_install_package_manager() -> str | None: +def get_install_package_manager(on_failure_return_none: bool = False) -> str | None: """Get the package manager executable for installation. Currently, bun is used for installation only. + Args: + on_failure_return_none: Whether to return None on failure. + 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 get_package_manager(on_failure_return_none) + return str(get_config().bun_path) -def get_package_manager() -> str | None: +def get_package_manager(on_failure_return_none: bool = False) -> str | None: """Get the package manager executable for running app. Currently on unix systems, npm is used for running the app only. + Args: + on_failure_return_none: Whether to return None on failure. + Returns: The path to the package manager. + + Raises: + FileNotFoundError: If the package manager is not found. """ npm_path = path_ops.get_npm_path() if npm_path is not None: - npm_path = str(Path(npm_path).resolve()) - return npm_path + return str(Path(npm_path).resolve()) + if on_failure_return_none: + return None + raise FileNotFoundError("NPM not found. You may need to run `reflex init`.") def windows_check_onedrive_in_path() -> bool: @@ -233,7 +264,7 @@ def windows_npm_escape_hatch() -> bool: Returns: If the user has set REFLEX_USE_NPM. """ - return os.environ.get("REFLEX_USE_NPM", "").lower() in ["true", "1", "yes"] + return environment.REFLEX_USE_NPM.get() def get_app(reload: bool = False) -> ModuleType: @@ -251,7 +282,7 @@ def get_app(reload: bool = False) -> ModuleType: from reflex.utils import telemetry try: - os.environ[constants.RELOAD_CONFIG] = str(reload) + environment.RELOAD_CONFIG.set(reload) config = get_config() if not config.app_name: raise RuntimeError( @@ -259,7 +290,7 @@ def get_app(reload: bool = False) -> ModuleType: "If this error occurs in a reflex test case, ensure that `get_app` is mocked." ) module = config.module - sys.path.insert(0, os.getcwd()) + sys.path.insert(0, str(Path.cwd())) app = __import__(module, fromlist=(constants.CompileVars.APP,)) if reload: @@ -289,7 +320,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) @@ -326,24 +357,40 @@ def parse_redis_url() -> str | dict | None: """Parse the REDIS_URL in config if applicable. Returns: - If redis-py syntax, return the URL as it is. Otherwise, return the host/port/db as a dict. + If url is non-empty, return the URL as it is. + + Raises: + ValueError: If the REDIS_URL is not a supported scheme. """ config = get_config() if not config.redis_url: return None - if config.redis_url.startswith(("redis://", "rediss://", "unix://")): - return config.redis_url - console.deprecate( - feature_name="host[:port] style redis urls", - reason="redis-py url syntax is now being used", - deprecation_version="0.3.6", - removal_version="0.6.0", - ) - redis_url, has_port, redis_port = config.redis_url.partition(":") - if not has_port: - redis_port = 6379 - console.info(f"Using redis at {config.redis_url}") - return dict(host=redis_url, port=int(redis_port), db=0) + if not config.redis_url.startswith(("redis://", "rediss://", "unix://")): + raise ValueError( + "REDIS_URL must start with 'redis://', 'rediss://', or 'unix://'." + ) + return config.redis_url + + +async def get_redis_status() -> dict[str, bool | None]: + """Checks the status of the Redis connection. + + Attempts to connect to Redis and send a ping command to verify connectivity. + + Returns: + The status of the Redis connection. + """ + 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 {"redis": status} def validate_app_name(app_name: str | None = None) -> str: @@ -360,9 +407,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( @@ -390,14 +435,16 @@ def create_config(app_name: str): from reflex.compiler import templates config_name = f"{re.sub(r'[^a-zA-Z]', '', app_name).capitalize()}Config" - with open(constants.Config.FILE, "w") as f: - console.debug(f"Creating {constants.Config.FILE}") - f.write(templates.RXCONFIG.render(app_name=app_name, config_name=config_name)) + + console.debug(f"Creating {constants.Config.FILE}") + constants.Config.FILE.write_text( + templates.RXCONFIG.render(app_name=app_name, config_name=config_name) + ) def initialize_gitignore( - gitignore_file: str = constants.GitIgnore.FILE, - files_to_ignore: set[str] = constants.GitIgnore.DEFAULTS, + gitignore_file: Path = constants.GitIgnore.FILE, + files_to_ignore: set[str] | list[str] = constants.GitIgnore.DEFAULTS, ): """Initialize the template .gitignore file. @@ -406,20 +453,20 @@ def initialize_gitignore( files_to_ignore: The files to add to the .gitignore file. """ # Combine with the current ignored files. - current_ignore: set[str] = set() - if os.path.exists(gitignore_file): - with open(gitignore_file, "r") as f: - current_ignore |= set([line.strip() for line in f.readlines()]) + current_ignore: list[str] = [] + if gitignore_file.exists(): + current_ignore = [ln.strip() for ln 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 + files_to_ignore = [ln for ln in files_to_ignore if ln not in current_ignore] + 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()}\n") + gitignore_file.touch(exist_ok=True) + console.debug(f"Creating {gitignore_file}") + gitignore_file.write_text("\n".join(files_to_ignore) + "\n") def initialize_requirements_txt(): @@ -446,14 +493,14 @@ def initialize_requirements_txt(): console.debug(f"Detected encoding for {fp} as {encoding}.") try: other_requirements_exist = False - with open(fp, "r", encoding=encoding) as f: - for req in f.readlines(): + with fp.open("r", encoding=encoding) as f: + for req in f: # Check if we have a package name that is reflex if re.match(r"^reflex[^a-zA-Z0-9]", req): console.debug(f"{fp} already has reflex as dependency.") return other_requirements_exist = True - with open(fp, "a", encoding=encoding) as f: + with fp.open("a", encoding=encoding) as f: preceding_newline = "\n" if other_requirements_exist else "" f.write( f"{preceding_newline}{constants.RequirementsTxt.DEFAULTS_STUB}{constants.Reflex.VERSION}\n" @@ -512,8 +559,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. @@ -544,13 +591,15 @@ def initialize_web_directory(): """Initialize the web directory on reflex init.""" console.log("Initializing the web directory.") - # Re-use the hash if one is already created, so we don't over-write it when running reflex init + # Reuse 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, str(get_web_dir())) initialize_package_json() + initialize_bun_config() + path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC) update_next_config() @@ -575,23 +624,27 @@ def _compile_package_json(): def initialize_package_json(): """Render and write in .web the package.json file.""" output_path = get_web_dir() / constants.PackageJson.PATH - code = _compile_package_json() - output_path.write_text(code) + output_path.write_text(_compile_package_json()) - best_registry = _get_best_registry() + +def initialize_bun_config(): + """Initialize the bun config file.""" bun_config_path = get_web_dir() / constants.Bun.CONFIG_PATH - bun_config_path.write_text( - f""" -[install] -registry = "{best_registry}" -""" - ) + + if (custom_bunfig := Path(constants.Bun.CONFIG_PATH)).exists(): + bunfig_content = custom_bunfig.read_text() + console.info(f"Copying custom bunfig.toml inside {get_web_dir()} folder") + else: + best_registry = _get_npm_registry() + bunfig_content = constants.Bun.DEFAULT_CONFIG.format(registry=best_registry) + + bun_config_path.write_text(bunfig_content) def init_reflex_json(project_hash: int | None): """Write the hash of the Reflex project to a REFLEX_JSON. - Re-use the hash if one is already created, therefore do not + Reuse the hash if one is already created, therefore do not overwrite it every time we run the reflex init command . @@ -641,10 +694,11 @@ def _update_next_config( "compress": config.next_compression, "reactStrictMode": config.react_strict_mode, "trailingSlash": True, + "staticPageGenerationTimeout": config.static_page_generation_timeout, } if transpile_packages: next_config["transpilePackages"] = list( - set((format_library_name(p) for p in transpile_packages)) + {format_library_name(p) for p in transpile_packages} ) if export: next_config["output"] = "export" @@ -657,7 +711,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) @@ -672,18 +726,18 @@ 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() # Save the script to a temporary file. - script = tempfile.NamedTemporaryFile() - with open(script.name, "w") as f: - f.write(response.text) + script = Path(tempfile.NamedTemporaryFile().name) + + script.write_text(response.text) # Run the script. env = {**os.environ, **env} - process = processes.new_process(["bash", f.name, *args], env=env) + process = processes.new_process(["bash", str(script), *args], env=env) show = processes.show_status if show_status else processes.show_logs show(f"Installing {url}", process) @@ -697,16 +751,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: Path = 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 fnm_zip_file.open("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: @@ -736,7 +790,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: @@ -752,7 +806,7 @@ def install_node(): ) else: # All other platforms (Linux, MacOS). # Add execute permissions to fnm executable. - os.chmod(constants.Fnm.EXE, stat.S_IXUSR) + constants.Fnm.EXE.chmod(stat.S_IXUSR) # Install node. # Specify arm64 arch explicitly for M1s and M2s. architecture_arg = ( @@ -775,14 +829,10 @@ def install_node(): def install_bun(): - """Install bun onto the user's system. - - Raises: - FileNotFoundError: If required packages are not found. - """ + """Install bun onto the user's system.""" 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 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." @@ -793,7 +843,7 @@ def install_bun(): ) # 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.") @@ -808,7 +858,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, @@ -818,31 +868,32 @@ def install_bun(): else: unzip_path = path_ops.which("unzip") if unzip_path is None: - raise FileNotFoundError("Reflex requires unzip to be installed.") + raise_system_package_missing_error("unzip") # Run the bun install script. 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]): @@ -873,7 +924,7 @@ def cached_procedure(cache_file: str, payload_fn: Callable[..., str]): @cached_procedure( cache_file=str(get_web_dir() / "reflex.install_frontend_packages.cached"), - payload_fn=lambda p, c: f"{repr(sorted(list(p)))},{c.json()}", + payload_fn=lambda p, c: f"{sorted(p)!r},{c.json()}", ) def install_frontend_packages(packages: set[str], config: Config): """Installs the base and custom frontend packages. @@ -882,20 +933,42 @@ def install_frontend_packages(packages: set[str], config: Config): packages: A list of package names to be installed. config: The config object. + Raises: + FileNotFoundError: If the package manager is not found. + Example: >>> install_frontend_packages(["react", "react-dom"], get_config()) """ # unsupported archs(arm and 32bit machines) will use npm anyway. so we dont have to run npm twice fallback_command = ( - get_package_manager() - if not constants.IS_WINDOWS - or constants.IS_WINDOWS - and is_windows_bun_supported() - and not windows_check_onedrive_in_path() + get_package_manager(on_failure_return_none=True) + if ( + not constants.IS_WINDOWS + or ( + constants.IS_WINDOWS + and ( + is_windows_bun_supported() and not windows_check_onedrive_in_path() + ) + ) + ) else None ) + + install_package_manager = ( + get_install_package_manager(on_failure_return_none=True) or fallback_command + ) + + if install_package_manager is None: + raise FileNotFoundError( + "Could not find a package manager to install frontend packages. You may need to run `reflex init`." + ) + + fallback_command = ( + fallback_command if fallback_command is not install_package_manager else None + ) + processes.run_process_with_fallback( - [get_install_package_manager(), "install"], # type: ignore + [install_package_manager, "install"], # type: ignore fallback=fallback_command, analytics_enabled=True, show_status_message="Installing base frontend packages", @@ -906,7 +979,7 @@ def install_frontend_packages(packages: set[str], config: Config): if config.tailwind is not None: processes.run_process_with_fallback( [ - get_install_package_manager(), + install_package_manager, "add", "-d", constants.Tailwind.VERSION, @@ -922,7 +995,7 @@ def install_frontend_packages(packages: set[str], config: Config): # Install custom packages defined in frontend_packages if len(packages) > 0: processes.run_process_with_fallback( - [get_install_package_manager(), "add", *packages], + [install_package_manager, "add", *packages], fallback=fallback_command, analytics_enabled=True, show_status_message="Installing frontend packages from config and components", @@ -943,7 +1016,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." ) @@ -954,7 +1027,7 @@ 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.get().exists(): return True # Make sure the .web directory exists in frontend mode. @@ -1000,6 +1073,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() @@ -1057,25 +1132,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.get() / "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: @@ -1086,7 +1157,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.get()) def initialize_frontend_dependencies(): @@ -1103,13 +1174,34 @@ def initialize_frontend_dependencies(): initialize_web_directory() +def check_db_used() -> bool: + """Check if the database is used. + + Returns: + True if the database is used. + """ + return bool(get_config().db_url) + + +def check_redis_used() -> bool: + """Check if Redis is used. + + Returns: + True if Redis is used. + """ + return bool(get_config().redis_url) + + def check_db_initialized() -> bool: """Check if the database migrations are initialized. 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.get().exists() + ): console.error( "Database is not initialized. Run [bold]reflex db init[/bold] first." ) @@ -1119,7 +1211,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.get().exists(): return with model.Model.get_db_engine().connect() as connection: try: @@ -1138,7 +1230,7 @@ def check_schema_up_to_date(): ) -def prompt_for_template(templates: list[Template]) -> str: +def prompt_for_template_options(templates: list[Template]) -> str: """Prompt the user to specify a template. Args: @@ -1150,9 +1242,14 @@ def prompt_for_template(templates: list[Template]) -> str: # Show the user the URLs of each template to preview. console.print("\nGet started with a template:") + def format_demo_url_str(url: str) -> str: + return f" ({url})" if url else "" + # Prompt the user to select a template. id_to_name = { - str(idx): f"{template.name} ({template.demo_url}) - {template.description}" + str( + idx + ): f"{template.name.replace('_', ' ').replace('-', ' ')}{format_demo_url_str(template.demo_url)} - {template.description}" for idx, template in enumerate(templates) } for id in range(len(id_to_name)): @@ -1169,158 +1266,6 @@ 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.*?. - - Returns: - bool: True if we should show the migration instructions. - """ - 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 = get_web_dir() / 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(version: str) -> dict[str, Template]: """Fetch a dict of templates from the templates repo using github API. @@ -1332,7 +1277,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]: """ def get_release_by_tag(tag: str) -> dict | None: - response = httpx.get(constants.Reflex.RELEASES_URL) + response = net.get(constants.Reflex.RELEASES_URL) response.raise_for_status() releases = response.json() for release in releases: @@ -1353,7 +1298,7 @@ def fetch_app_templates(version: str) -> dict[str, Template]: else: templates_url = asset["browser_download_url"] - templates_data = httpx.get(templates_url, follow_redirects=True).json()["templates"] + templates_data = net.get(templates_url, follow_redirects=True).json()["templates"] for template in templates_data: if template["name"] == "blank": @@ -1367,11 +1312,16 @@ def fetch_app_templates(version: str) -> dict[str, Template]: ), None, ) - return { - tp["name"]: Template.parse_obj(tp) - for tp in templates_data - if not tp["hidden"] and tp["code_url"] is not None - } + + filtered_templates = {} + for tp in templates_data: + if tp["hidden"] or tp["code_url"] is None: + continue + known_fields = {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): @@ -1393,19 +1343,18 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str raise typer.Exit(1) from ose # Use httpx GET with redirects to download the zip file. - zip_file_path = Path(temp_dir) / "template.zip" + zip_file_path: 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: console.error(f"Failed to download the template: {he}") raise typer.Exit(1) from he try: - with open(zip_file_path, "wb") as f: - f.write(response.content) - console.debug(f"Downloaded the zip to {zip_file_path}") + zip_file_path.write_bytes(response.content) + console.debug(f"Downloaded the zip to {zip_file_path}") except OSError as ose: console.error(f"Unable to write the downloaded zip to disk {ose}") raise typer.Exit(1) from ose @@ -1454,70 +1403,197 @@ def create_config_init_app_from_remote_template(app_name: str, template_url: str shutil.rmtree(unzip_dir) -def initialize_app(app_name: str, template: str | None = None): +def initialize_default_app(app_name: str): + """Initialize the default app. + + Args: + app_name: The name of the app. + """ + create_config(app_name) + initialize_app_directory(app_name) + + +def validate_and_create_app_using_remote_template(app_name, template, templates): + """Validate and create an app using a remote template. + + Args: + app_name: The name of the app. + template: The name of the template. + templates: The available templates. + + Raises: + Exit: If the template is not found. + """ + # If user selects a template, it needs to exist. + if template in templates: + from reflex_cli.v2.utils import hosting + + authenticated_token = hosting.authenticated_token() + if not authenticated_token or not authenticated_token[0]: + console.print( + f"Please use `reflex login` to access the '{template}' template." + ) + raise typer.Exit(3) + + template_url = templates[template].code_url + else: + # Check if the template is a github repo. + if template.startswith("https://github.com"): + template_url = f"{template.strip('/').replace('.git', '')}/archive/main.zip" + else: + console.error(f"Template `{template}` not found or invalid.") + 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 + ) + + +def generate_template_using_ai(template: str | None = None) -> str: + """Generate a template using AI(Flexgen). + + Args: + template: The name of the template. + + Returns: + The generation hash. + + Raises: + Exit: If the template and ai flags are used. + """ + if template is None: + # If AI is requested and no template specified, redirect the user to reflex.build. + return redir.reflex_build_redirect() + elif is_generation_hash(template): + # Otherwise treat the template as a generation hash. + return template + else: + console.error( + "Cannot use `--template` option with `--ai` option. Please remove `--template` option." + ) + raise typer.Exit(2) + + +def fetch_remote_templates( + template: str, +) -> tuple[str, dict[str, Template]]: + """Fetch the available remote templates. + + Args: + template: The name of the template. + + Returns: + The selected template and the available templates. + """ + available_templates = {} + + try: + # Get the available templates + available_templates = fetch_app_templates(constants.Reflex.VERSION) + except Exception as e: + console.warn("Failed to fetch templates. Falling back to default template.") + console.debug(f"Error while fetching templates: {e}") + template = constants.Templates.DEFAULT + + return template, available_templates + + +def initialize_app( + app_name: str, template: str | None = None, ai: bool = False +) -> str | None: """Initialize the app either from a remote template or a blank app. If the config file exists, it is considered as reinit. Args: app_name: The name of the app. template: The name of the template to use. + ai: Whether to use AI to generate the template. + + Returns: + The name of the template. Raises: - Exit: If template is directly provided in the command flag and is invalid. + Exit: If the template is not valid or unspecified. """ # Local imports to avoid circular imports. 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 + generation_hash = None + if ai: + generation_hash = generate_template_using_ai(template) + template = constants.Templates.DEFAULT + templates: dict[str, Template] = {} # 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 template is not None and (template not in (constants.Templates.DEFAULT,)): + template, templates = fetch_remote_templates(template) + + if template is None: + template = prompt_for_template_options(get_init_cli_prompt_options()) + if template == constants.Templates.AI: + generation_hash = generate_template_using_ai() + # change to the default to allow creation of default app + template = constants.Templates.DEFAULT + elif template == constants.Templates.CHOOSE_TEMPLATES: + console.print( + f"Go to the templates page ({constants.Templates.REFLEX_TEMPLATES_URL}) and copy the command to init with a template." + ) + raise typer.Exit(0) # If the blank template is selected, create a blank app. - if template == constants.Templates.DEFAULT: + if template in (constants.Templates.DEFAULT,): # Default app creation behavior: a blank app. - create_config(app_name) - initialize_app_directory(app_name) + initialize_default_app(app_name) else: - # Fetch App templates from the backend server. - console.debug(f"Available templates: {templates}") - - # If user selects a template, it needs to exist. - if template in templates: - template_url = templates[template].code_url - else: - # Check if the template is a github repo. - if template.startswith("https://github.com"): - template_url = ( - f"{template.strip('/').replace('.git', '')}/archive/main.zip" - ) - 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 + validate_and_create_app_using_remote_template( + app_name=app_name, template=template, templates=templates ) + # If a reflex.build generation hash is available, download the code and apply it to the main module. + if generation_hash: + initialize_main_module_index_from_generation( + app_name, generation_hash=generation_hash + ) telemetry.send("init", template=template) + return template + + +def get_init_cli_prompt_options() -> list[Template]: + """Get the CLI options for initializing a Reflex app. + + Returns: + The CLI options. + """ + return [ + Template( + name=constants.Templates.DEFAULT, + description="A blank Reflex app.", + demo_url=constants.Templates.DEFAULT_TEMPLATE_URL, + code_url="", + ), + Template( + name=constants.Templates.AI, + description="Generate a template using AI [Experimental]", + demo_url="", + code_url="", + ), + Template( + name=constants.Templates.CHOOSE_TEMPLATES, + description="Choose an existing template.", + demo_url="", + code_url="", + ), + ] + 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. @@ -1525,19 +1601,37 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash: Args: app_name: The name of the app. generation_hash: The generation hash from reflex.build. + + Raises: + GeneratedCodeHasNoFunctionDefs: If the fetched code has no function definitions + (the refactored reflex code is expected to have at least one root function defined). """ # Download the reflex code for the generation. - resp = httpx.get( - constants.Templates.REFLEX_BUILD_CODE_URL.format( - generation_hash=generation_hash + url = constants.Templates.REFLEX_BUILD_CODE_URL.format( + generation_hash=generation_hash + ) + resp = net.get(url) + while resp.status_code == httpx.codes.SERVICE_UNAVAILABLE: + console.debug("Waiting for the code to be generated...") + time.sleep(1) + resp = net.get(url) + resp.raise_for_status() + + # Determine the name of the last function, which renders the generated code. + defined_funcs = re.findall(r"def ([a-zA-Z_]+)\(", resp.text) + if not defined_funcs: + raise GeneratedCodeHasNoFunctionDefs( + f"No function definitions found in generated code from {url!r}." ) - ).raise_for_status() + render_func_name = defined_funcs[-1] def replace_content(_match): return "\n".join( [ - "def index() -> rx.Component:", - textwrap.indent("return " + resp.text, " "), + resp.text, + "", + "" "def index() -> rx.Component:", + f" return {render_func_name}()", "", "", ], @@ -1545,13 +1639,20 @@ def initialize_main_module_index_from_generation(app_name: str, generation_hash: main_module_path = Path(app_name, app_name + constants.Ext.PY) main_module_code = main_module_path.read_text() - main_module_path.write_text( - re.sub( - r"def index\(\).*:\n([^\n]\s+.*\n+)+", - replace_content, - main_module_code, - ) + + 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: diff --git a/reflex/utils/processes.py b/reflex/utils/processes.py index c435af7d0..871b5f323 100644 --- a/reflex/utils/processes.py +++ b/reflex/utils/processes.py @@ -58,7 +58,9 @@ def get_process_on_port(port) -> Optional[psutil.Process]: The process on the given port. """ for proc in psutil.process_iter(["pid", "name", "cmdline"]): - try: + with contextlib.suppress( + psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess + ): if importlib.metadata.version("psutil") >= "6.0.0": conns = proc.net_connections(kind="inet") # type: ignore else: @@ -66,8 +68,6 @@ def get_process_on_port(port) -> Optional[psutil.Process]: for conn in conns: if conn.laddr.port == int(port): return proc - except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): - pass return None @@ -118,7 +118,7 @@ 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 + We make an assumption that when port is the default port,then it hasn't 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: @@ -156,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 " @@ -167,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"]] @@ -351,7 +351,7 @@ def atexit_handler(): def get_command_with_loglevel(command: list[str]) -> list[str]: """Add the right loglevel flag to the designated command. - npm uses --loglevel , Bun doesnt use the --loglevel flag and + npm uses --loglevel , Bun doesn't use the --loglevel flag and runs in debug mode by default. Args: @@ -364,7 +364,7 @@ def get_command_with_loglevel(command: list[str]) -> list[str]: npm_path = str(Path(npm_path).resolve()) if npm_path else npm_path if command[0] == npm_path: - return command + ["--loglevel", "silly"] + return [*command, "--loglevel", "silly"] return command diff --git a/reflex/utils/pyi_generator.py b/reflex/utils/pyi_generator.py index d279e3910..6a4bd63f8 100644 --- a/reflex/utils/pyi_generator.py +++ b/reflex/utils/pyi_generator.py @@ -16,15 +16,15 @@ 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 +from typing import Any, Callable, Iterable, Sequence, 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") -PWD = Path(".").resolve() +PWD = Path.cwd() EXCLUDED_FILES = [ "app.py", @@ -69,10 +69,17 @@ DEFAULT_TYPING_IMPORTS = { # TODO: fix import ordering and unused imports with ruff later DEFAULT_IMPORTS = { "typing": sorted(DEFAULT_TYPING_IMPORTS), - "reflex.vars": ["Var", "BaseVar", "ComputedVar"], "reflex.components.core.breakpoints": ["Breakpoints"], - "reflex.event": ["EventChain", "EventHandler", "EventSpec"], + "reflex.event": [ + "EventChain", + "EventHandler", + "EventSpec", + "EventType", + "BASE_STATE", + "KeyInputInfo", + ], "reflex.style": ["Style"], + "reflex.vars.base": ["Var"], } @@ -150,7 +157,7 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str: if args: inner_container_type_args = ( - [repr(arg) for arg in args] + sorted((repr(arg) for arg in args)) if rx_types.is_literal(value) else [ _get_type_hint(arg, type_hint_globals, is_optional=False) @@ -184,17 +191,12 @@ 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) if rx_types.is_optional(ev): - # hints = { - # _get_type_hint(arg, type_hint_globals, is_optional=False) - # for arg in ev.__args__ - # } return _get_type_hint(ev, type_hint_globals, is_optional=False) - # return f"Optional[{', '.join(hints)}]" if rx_types.is_union(ev): res = [ @@ -214,7 +216,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: @@ -228,6 +232,7 @@ def _generate_imports(typing_imports: Iterable[str]) -> list[ast.ImportFrom]: 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")]), ] @@ -250,8 +255,15 @@ def _generate_docstrings(clzs: list[Type[Component]], props: list[str]) -> str: # We've reached the functions, so stop. break + if line == "": + # We hit a blank line, so clear comments to avoid commented out prop appearing in next prop docs. + comments.clear() + continue + # Get comments for prop if line.strip().startswith("#"): + # Remove noqa from the comments. + line = line.partition(" # noqa")[0] comments.append(line) continue @@ -275,10 +287,9 @@ def _generate_docstrings(clzs: list[Type[Component]], props: list[str]) -> str: for line in (clz.create.__doc__ or "").splitlines(): if "**" in line: indent = line.split("**")[0] - for nline in [ - f"{indent}{n}:{' '.join(c)}" for n, c in props_comments.items() - ]: - new_docstring.append(nline) + new_docstring.extend( + [f"{indent}{n}:{' '.join(c)}" for n, c in props_comments.items()] + ) new_docstring.append(line) return "\n".join(new_docstring) @@ -372,6 +383,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(): @@ -427,19 +496,117 @@ 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[..., BASE_STATE]") + + 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] + + # Get all prefixes of the type arguments + all_count_args_type = [ + ast.Name( + f"EventType[[{', '.join([ast.unparse(arg) for arg in type_args[:i]])}], BASE_STATE]" + ) + for i in range(len(type_args) + 1) + ] + + # Create EventType using the joined string + return ast.Name( + id=f"Union[{', '.join(map(ast.unparse, all_count_args_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[[], BASE_STATE]") + + 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 + ] + + all_count_args_type = [ + ast.Name( + f"EventType[[{', '.join(arguments_without_var[:i])}], BASE_STATE]" + ) + for i in range(len(arguments) + 1) + ] + + return ast.Name( + id=f"Union[{', '.join(map(ast.unparse, all_count_args_type))}]" + ) + return ast.Name(id="EventType[..., BASE_STATE]") + + event_triggers = clz().get_event_triggers() + # event handler kwargs kwargs.extend( ( ast.arg( arg=trigger, - annotation=ast.Name( - id="Optional[Union[EventHandler, EventSpec, list, Callable, 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], Sequence + ) + 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()) + 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")], @@ -450,12 +617,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(), @@ -664,7 +836,7 @@ class StubGenerator(ast.NodeTransformer): self.inserted_imports = True default_imports = _generate_imports(self.typing_imports) self.import_statements.extend(ast.unparse(i) for i in default_imports) - return default_imports + [node] + return [*default_imports, node] return node def visit_ImportFrom( @@ -851,7 +1023,7 @@ class InitStubGenerator(StubGenerator): class PyiGenerator: """A .pyi file generator that will scan all defined Component in Reflex and - generate the approriate stub. + generate the appropriate stub. """ modules: list = [] @@ -902,7 +1074,13 @@ class PyiGenerator: # construct the import statement and handle special cases for aliases sub_mod_attrs_imports = [ f"from .{path} import {mod if not isinstance(mod, tuple) else mod[0]} as {mod if not isinstance(mod, tuple) else mod[1]}" - + (" # type: ignore" if mod in pyright_ignore_imports else "") + + ( + " # type: ignore" + if mod in pyright_ignore_imports + else " # noqa" # ignore ruff formatting here for cases like rx.list. + if isinstance(mod, tuple) + else "" + ) for mod, path in sub_mod_attrs.items() ] sub_mod_attrs_imports.append("") diff --git a/reflex/utils/redir.py b/reflex/utils/redir.py index 1dbd989e9..b35cbe26e 100644 --- a/reflex/utils/redir.py +++ b/reflex/utils/redir.py @@ -10,6 +10,18 @@ from .. import constants from . import console +def open_browser(target_url: str) -> None: + """Open a browser window to target_url. + + Args: + target_url: The URL to open in the browser. + """ + if not webbrowser.open(target_url): + console.warn( + f"Unable to automatically open the browser. Please navigate to {target_url} in your browser." + ) + + def open_browser_and_wait( target_url: str, poll_url: str, interval: int = 2 ) -> httpx.Response: @@ -23,10 +35,7 @@ def open_browser_and_wait( 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." - ) + open_browser(target_url) console.info("[b]Complete the workflow in the browser to continue.[/b]") while True: try: diff --git a/reflex/utils/registry.py b/reflex/utils/registry.py index 551292f2d..d98178c61 100644 --- a/reflex/utils/registry.py +++ b/reflex/utils/registry.py @@ -2,7 +2,8 @@ import httpx -from reflex.utils import console +from reflex.config import environment +from reflex.utils import console, net def latency(registry: str) -> int: @@ -15,7 +16,7 @@ def latency(registry: str) -> int: int: The latency of the registry in microseconds. """ try: - return httpx.get(registry).elapsed.microseconds + return net.get(registry).elapsed.microseconds except httpx.HTTPError: console.info(f"Failed to connect to {registry}.") return 10_000_000 @@ -34,7 +35,7 @@ def average_latency(registry, attempts: int = 3) -> int: return sum(latency(registry) for _ in range(attempts)) // attempts -def _get_best_registry() -> str: +def get_best_registry() -> str: """Get the best registry based on latency. Returns: @@ -46,3 +47,12 @@ def _get_best_registry() -> str: ] 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.get() or get_best_registry() diff --git a/reflex/utils/serializers.py b/reflex/utils/serializers.py index 6c36647cc..4bb8dea92 100644 --- a/reflex/utils/serializers.py +++ b/reflex/utils/serializers.py @@ -2,9 +2,9 @@ from __future__ import annotations +import dataclasses import functools import json -import types as builtin_types import warnings from datetime import date, datetime, time, timedelta from enum import Enum @@ -12,13 +12,13 @@ from pathlib import Path from typing import ( Any, Callable, - Dict, List, Literal, Optional, Set, Tuple, Type, + TypeVar, Union, get_type_hints, overload, @@ -26,24 +26,40 @@ from typing import ( from reflex.base import Base from reflex.constants.colors import Color, format_color -from reflex.utils import exceptions, types +from reflex.utils import types # Mapping from type to a serializer. # The serializer should convert the type to a JSON object. -SerializedType = Union[str, bool, int, float, list, dict] +SerializedType = Union[str, bool, int, float, list, dict, None] -Serializer = Callable[[Type], SerializedType] +Serializer = Callable[[Any], SerializedType] SERIALIZERS: dict[Type, Serializer] = {} SERIALIZER_TYPES: dict[Type, Type] = {} +SERIALIZED_FUNCTION = TypeVar("SERIALIZED_FUNCTION", bound=Serializer) + + +@overload +def serializer( + fn: None = None, + to: Type[SerializedType] | None = None, +) -> Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]: ... + + +@overload +def serializer( + fn: SERIALIZED_FUNCTION, + to: Type[SerializedType] | None = None, +) -> SERIALIZED_FUNCTION: ... + def serializer( - fn: Serializer | None = None, - to: Type | None = None, -) -> Serializer: + fn: SERIALIZED_FUNCTION | None = None, + to: Any = None, +) -> SERIALIZED_FUNCTION | Callable[[SERIALIZED_FUNCTION], SERIALIZED_FUNCTION]: """Decorator to add a serializer for a given type. Args: @@ -52,43 +68,44 @@ def serializer( Returns: The decorated function. - - Raises: - ValueError: If the function does not take a single argument. """ - 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) - args = [arg for arg in type_hints if arg != "return"] + def wrapper(fn: SERIALIZED_FUNCTION) -> SERIALIZED_FUNCTION: + # Check the type hints to get the type of the argument. + type_hints = get_type_hints(fn) + args = [arg for arg in type_hints if arg != "return"] - # Make sure the function takes a single argument. - if len(args) != 1: - raise ValueError("Serializer must take a single argument.") + # Make sure the function takes a single argument. + if len(args) != 1: + raise ValueError("Serializer must take a single argument.") - # Get the type of the argument. - type_ = type_hints[args[0]] + # Get the type of the argument. + type_ = type_hints[args[0]] - # Make sure the type is not already registered. - registered_fn = SERIALIZERS.get(type_) - if registered_fn is not None and registered_fn != fn: - raise ValueError( - f"Serializer for type {type_} is already registered as {registered_fn.__qualname__}." - ) + # Make sure the type is not already registered. + registered_fn = SERIALIZERS.get(type_) + if registered_fn is not None and registered_fn != fn: + raise ValueError( + 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() + to_type = to or type_hints.get("return") - # Register the serializer. - SERIALIZERS[type_] = fn - get_serializer.cache_clear() + # Apply type transformation if requested + if to_type: + SERIALIZER_TYPES[type_] = to_type + get_serializer_type.cache_clear() - # Return the function. - return fn + # Register the serializer. + SERIALIZERS[type_] = fn + get_serializer.cache_clear() + + # Return the function. + return fn + + if fn is not None: + return wrapper(fn) + return wrapper @overload @@ -125,6 +142,9 @@ def serialize( # 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 @@ -187,16 +207,37 @@ def get_serializer_type(type_: Type) -> Optional[Type]: return None -def has_serializer(type_: Type) -> bool: +def has_serializer(type_: Type, into_type: Type | None = None) -> bool: """Check if there is a serializer for the type. Args: type_: The type to check. + into_type: The type to serialize into. Returns: Whether there is a serializer for the type. """ - return get_serializer(type_) is not None + serializer_for_type = get_serializer(type_) + return serializer_for_type is not None and ( + into_type is None or get_serializer_type(type_) == into_type + ) + + +def can_serialize(type_: Type, into_type: Type | None = None) -> bool: + """Check if there is a serializer for the type. + + Args: + type_: The type to check. + into_type: The type to serialize into. + + Returns: + Whether there is a serializer for the type. + """ + return has_serializer(type_, into_type) or ( + isinstance(type_, type) + and dataclasses.is_dataclass(type_) + and (into_type is None or into_type is dict) + ) @serializer(to=str) @@ -212,36 +253,8 @@ def serialize_type(value: type) -> str: return value.__name__ -@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. - """ - from reflex.utils import format - - return format.json_dumps(value) - - -@serializer -def serialize_base(value: Base) -> str: +@serializer(to=dict) +def serialize_base(value: Base) -> dict: """Serialize a Base instance. Args: @@ -250,61 +263,71 @@ def serialize_base(value: Base) -> str: Returns: The serialized Base. """ - return value.json() + from reflex.vars.base import Var + + return { + k: v for k, v in value.dict().items() if isinstance(v, Var) or not callable(v) + } + + +try: + from pydantic.v1 import BaseModel as BaseModelV1 + + @serializer(to=dict) + def serialize_base_model_v1(model: BaseModelV1) -> dict: + """Serialize a pydantic v1 BaseModel instance. + + Args: + model: The BaseModel to serialize. + + Returns: + The serialized BaseModel. + """ + return model.dict() + + from pydantic import BaseModel as BaseModelV2 + + if BaseModelV1 is not BaseModelV2: + + @serializer(to=dict) + def serialize_base_model_v2(model: BaseModelV2) -> dict: + """Serialize a pydantic v2 BaseModel instance. + + Args: + model: The BaseModel to serialize. + + Returns: + The serialized BaseModel. + """ + return model.model_dump() +except ImportError: + # Older pydantic v1 import + from pydantic import BaseModel as BaseModelV1 + + @serializer(to=dict) + def serialize_base_model_v1(model: BaseModelV1) -> dict: + """Serialize a pydantic v1 BaseModel instance. + + Args: + model: The BaseModel to serialize. + + Returns: + The serialized BaseModel. + """ + return model.dict() @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. """ - from reflex.utils import format - - # Dump the list to a string. - fprop = format.json_dumps(list(value)) - - # Unwrap var values. - return format.unwrap_vars(fprop) - - -@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 - from reflex.utils import format - - prop_dict = {} - - for key, value in prop.items(): - if types._issubclass(type(value), Callable): - raise exceptions.InvalidStylePropError( - f"The style prop `{format.to_snake_case(key)}` cannot have " # type: ignore - f"`{value.fn.__qualname__ if isinstance(value, EventHandler) else value.__qualname__ if isinstance(value, builtin_types.FunctionType) else value}`, " - f"an event handler or callable as its value" - ) - prop_dict[key] = value - - # Dump the dict to a string. - fprop = format.json_dumps(prop_dict) - - # Unwrap var values. - return format.unwrap_vars(fprop) + return list(value) @serializer(to=str) diff --git a/reflex/utils/telemetry.py b/reflex/utils/telemetry.py index e027ed81a..fc90932a6 100644 --- a/reflex/utils/telemetry.py +++ b/reflex/utils/telemetry.py @@ -3,9 +3,13 @@ from __future__ import annotations import asyncio +import dataclasses import multiprocessing import platform import warnings +from contextlib import suppress + +from reflex.config import environment try: from datetime import UTC, datetime @@ -19,7 +23,6 @@ import psutil from reflex import constants from reflex.utils import console -from reflex.utils.exec import should_skip_compile from reflex.utils.prerequisites import ensure_reflex_installation_id, get_project_hash POSTHOG_API_URL: str = "https://app.posthog.com/capture/" @@ -49,7 +52,8 @@ def get_python_version() -> str: Returns: The Python version. """ - return platform.python_version() + # Remove the "+" from the version string in case user is using a pre-release version. + return platform.python_version().rstrip("+") def get_reflex_version() -> str: @@ -93,9 +97,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 environment.REFLEX_SKIP_COMPILE.get() def _prepare_event(event: str, **kwargs) -> dict: @@ -120,7 +122,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 @@ -128,7 +130,7 @@ def _prepare_event(event: str, **kwargs) -> dict: cpuinfo = get_cpu_info() - additional_keys = ["template", "context", "detail"] + additional_keys = ["template", "context", "detail", "user_uuid"] additional_fields = { key: value for key in additional_keys if (value := kwargs.get(key)) is not None } @@ -144,7 +146,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, @@ -170,10 +172,11 @@ def _send(event, telemetry_enabled, **kwargs): if not telemetry_enabled: return False - event_data = _prepare_event(event, **kwargs) - if not event_data: - return False - return _send_event(event_data) + with suppress(Exception): + event_data = _prepare_event(event, **kwargs) + if not event_data: + return False + return _send_event(event_data) def send(event: str, telemetry_enabled: bool | None = None, **kwargs): diff --git a/reflex/utils/types.py b/reflex/utils/types.py index 3bb5eae35..b8bcbf2d6 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -3,29 +3,35 @@ from __future__ import annotations import contextlib +import dataclasses import inspect import sys import types -from functools import cached_property, wraps +from functools import cached_property, lru_cache, wraps from typing import ( + TYPE_CHECKING, Any, Callable, ClassVar, Dict, + FrozenSet, Iterable, List, Literal, + Mapping, 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 +from typing_extensions import is_typeddict import reflex from reflex.components.core.breakpoints import Breakpoints @@ -37,19 +43,14 @@ except ModuleNotFoundError: from sqlalchemy.ext.associationproxy import AssociationProxyInstance from sqlalchemy.ext.hybrid import hybrid_property -from sqlalchemy.orm import ( - DeclarativeBase, - Mapped, - QueryableAttribute, - Relationship, -) +from sqlalchemy.orm import DeclarativeBase, Mapped, QueryableAttribute, Relationship from reflex import constants from reflex.base import Base from reflex.utils import console if sys.version_info >= (3, 12): - from typing import override + from typing import override as override else: def override(func: Callable) -> Callable: @@ -93,8 +94,21 @@ 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[[], 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 = { @@ -109,6 +123,11 @@ RESERVED_BACKEND_VAR_NAMES = { "_was_touched", } +if sys.version_info >= (3, 11): + from typing import Self as Self +else: + from typing_extensions import Self as Self + class Unset: """A class to represent an unset value. @@ -133,6 +152,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. @@ -145,6 +178,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. @@ -157,6 +210,7 @@ def is_none(cls: GenericType) -> bool: return cls is type(None) or cls is None +@lru_cache() def is_union(cls: GenericType) -> bool: """Check if a class is a Union. @@ -169,6 +223,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. @@ -181,6 +236,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. @@ -193,6 +269,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. @@ -222,9 +312,14 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None """ from reflex.model import Model - attr = getattr(cls, name, None) + try: + attr = getattr(cls, name, None) + except NotImplementedError: + attr = None + if hint := get_property_hint(attr): return hint + if ( hasattr(cls, "__fields__") and name in cls.__fields__ @@ -235,7 +330,11 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None type_ = field.outer_type_ if isinstance(type_, ModelField): type_ = type_.type_ - if not field.required and field.default is None: + if ( + not field.required + and field.default is None + and field.default_factory is None + ): # Ensure frontend uses null coalescing when accessing. type_ = Optional[type_] return type_ @@ -293,11 +392,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): @@ -314,6 +411,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. @@ -329,7 +427,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]) @@ -402,6 +500,14 @@ def _issubclass(cls: GenericType, cls_check: GenericType, instance: Any = None) if isinstance(instance, Breakpoints): return _breakpoints_satisfies_typing(cls_check, instance) + if isinstance(cls_check_base, tuple): + cls_check_base = tuple( + cls_check_one if not is_typeddict(cls_check_one) else dict + for cls_check_one in cls_check_base + ) + if is_typeddict(cls_check_base): + cls_check_base = dict + # Check if the types match. try: return cls_check_base == Any or issubclass(cls_base, cls_check_base) @@ -411,16 +517,112 @@ def _issubclass(cls: GenericType, cls_check: GenericType, instance: Any = None) raise TypeError(f"Invalid type for issubclass: {cls_base}") from te -def _isinstance(obj: Any, cls: GenericType) -> bool: +def does_obj_satisfy_typed_dict(obj: Any, cls: GenericType) -> bool: + """Check if an object satisfies a typed dict. + + Args: + obj: The object to check. + cls: The typed dict to check against. + + Returns: + Whether the object satisfies the typed dict. + """ + if not isinstance(obj, Mapping): + return False + + key_names_to_values = get_type_hints(cls) + required_keys: FrozenSet[str] = getattr(cls, "__required_keys__", frozenset()) + + if not all( + isinstance(key, str) + and key in key_names_to_values + and _isinstance(value, key_names_to_values[key]) + for key, value in obj.items() + ): + return False + + # TODO in 3.14: Implement https://peps.python.org/pep-0728/ if it's approved + + # required keys are all present + return required_keys.issubset(required_keys) + + +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 typed dict + if is_typeddict(cls): + if nested: + return does_obj_satisfy_typed_dict(obj, cls) + return isinstance(obj, dict) + + # cls is a float + if cls is float: + return isinstance(obj, (float, int)) + + # 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 in (dict, Breakpoints): + 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 + ) + + if args: + from reflex.vars import Field + + if origin is Field: + return _isinstance(obj, args[0]) + return isinstance(obj, get_base_class(cls)) @@ -451,7 +653,11 @@ def is_valid_var_type(type_: Type) -> bool: if is_union(type_): return all((is_valid_var_type(arg) for arg in get_args(type_))) - return _issubclass(type_, StateVar) or serializers.has_serializer(type_) + return ( + _issubclass(type_, StateVar) + or serializers.has_serializer(type_) + or dataclasses.is_dataclass(type_) + ) def is_backend_base_variable(name: str, cls: Type) -> bool: @@ -476,7 +682,11 @@ def is_backend_base_variable(name: str, cls: Type) -> bool: if name.startswith(f"_{cls.__name__}__"): return False - hints = get_type_hints(cls) + # 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: @@ -485,17 +695,23 @@ def is_backend_base_variable(name: str, cls: Type) -> bool: if name in cls.inherited_backend_vars: return False + from reflex.vars.base import is_computed_var + if name in cls.__dict__: value = cls.__dict__[name] - if type(value) == classmethod: + if type(value) is classmethod: return False if callable(value): return False - from reflex.vars import ComputedVar if isinstance( - value, (types.FunctionType, property, cached_property, ComputedVar) - ): + value, + ( + types.FunctionType, + property, + cached_property, + ), + ) or is_computed_var(value): return False return True @@ -570,7 +786,7 @@ def validate_literal(key: str, value: Any, expected_type: Type, comp_name: str): ) value_str = f"'{value}'" if isinstance(value, str) else value raise ValueError( - f"prop value for {str(key)} of the `{comp_name}` component should be one of the following: {allowed_value_str}. Got {value_str} instead" + f"prop value for {key!s} of the `{comp_name}` component should be one of the following: {allowed_value_str}. Got {value_str} instead" ) @@ -611,3 +827,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 39b177695..000000000 --- a/reflex/utils/watch.py +++ /dev/null @@ -1,96 +0,0 @@ -"""General utility functions.""" - -import contextlib -import os -import shutil -import time - -from watchdog.events import FileSystemEvent, FileSystemEventHandler -from watchdog.observers import Observer - -from reflex.constants import Dirs -from reflex.utils.prerequisites import get_web_dir - - -class AssetFolderWatch: - """Asset folder watch class.""" - - def __init__(self, root): - """Initialize the Watch Class. - - Args: - root: root path of the public. - """ - self.path = str(root / Dirs.APP_ASSETS) - self.event_handler = AssetFolderHandler(root) - - def start(self): - """Start watching asset folder.""" - self.observer = Observer() - self.observer.schedule(self.event_handler, self.path, recursive=True) - self.observer.start() - - -class AssetFolderHandler(FileSystemEventHandler): - """Asset folder event handler.""" - - def __init__(self, root): - """Initialize the AssetFolderHandler Class. - - Args: - root: root path of the public. - """ - super().__init__() - self.root = root - - def on_modified(self, event: FileSystemEvent): - """Event handler when a file or folder was modified. - - This is called every time after a file is created, modified and deleted. - - Args: - event: Event information. - """ - dest_path = self.get_dest_path(event.src_path) - - # wait 1 sec for fully saved - time.sleep(1) - - if os.path.isfile(event.src_path): - with contextlib.suppress(PermissionError): - shutil.copyfile(event.src_path, dest_path) - if os.path.isdir(event.src_path): - if os.path.exists(dest_path): - shutil.rmtree(dest_path) - with contextlib.suppress(PermissionError): - shutil.copytree(event.src_path, dest_path) - - def on_deleted(self, event: FileSystemEvent): - """Event hander when a file or folder was deleted. - - Args: - event: Event infomation. - """ - dest_path = self.get_dest_path(event.src_path) - - if os.path.isfile(dest_path): - # when event is about a file, pass - # this will be deleted at on_modified function - return - - if os.path.exists(dest_path): - shutil.rmtree(dest_path) - - def get_dest_path(self, src_path: str) -> str: - """Get public file path. - - Args: - src_path: The asset file path. - - Returns: - The public file path. - """ - return src_path.replace( - str(self.root / Dirs.APP_ASSETS), - str(self.root / get_web_dir() / Dirs.PUBLIC), - ) diff --git a/reflex/vars.py b/reflex/vars.py deleted file mode 100644 index 057e74e78..000000000 --- a/reflex/vars.py +++ /dev/null @@ -1,2608 +0,0 @@ -"""Define a state var.""" - -from __future__ import annotations - -import contextlib -import dataclasses -import datetime -import dis -import functools -import inspect -import json -import random -import re -import string -import sys -from types import CodeType, FunctionType -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Iterable, - List, - Literal, - Optional, - Tuple, - Type, - Union, - _GenericAlias, # type: ignore - cast, - get_args, - get_origin, - get_type_hints, -) - -from reflex import constants -from reflex.base import Base -from reflex.utils import console, imports, serializers, types -from reflex.utils.exceptions import ( - VarAttributeError, - VarDependencyError, - VarTypeError, - VarValueError, -) - -# This module used to export ImportVar itself, so we still import it for export here -from reflex.utils.imports import ( - ImmutableParsedImportDict, - ImportDict, - ImportVar, - ParsedImportDict, - parse_imports, -) -from reflex.utils.types import override - -if TYPE_CHECKING: - from reflex.state import BaseState - - -# Set of unique variable names. -USED_VARIABLES = set() - -# Supported operators for all types. -ALL_OPS = ["==", "!=", "!==", "===", "&&", "||"] -# Delimiters used between function args or operands. -DELIMITERS = [","] -# Mapping of valid operations for different type combinations. -OPERATION_MAPPING = { - (int, int): { - "+", - "-", - "/", - "//", - "*", - "%", - "**", - ">", - "<", - "<=", - ">=", - "|", - "&", - }, - (int, str): {"*"}, - (int, list): {"*"}, - (str, str): {"+", ">", "<", "<=", ">="}, - (float, float): {"+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="}, - (float, int): {"+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="}, - (list, list): {"+", ">", "<", "<=", ">="}, -} - -# These names were changed in reflex 0.3.0 -REPLACED_NAMES = { - "full_name": "_var_full_name", - "name": "_var_name", - "state": "_var_data.state", - "type_": "_var_type", - "is_local": "_var_is_local", - "is_string": "_var_is_string", - "set_state": "_var_set_state", - "deps": "_deps", -} - -PYTHON_JS_TYPE_MAP = { - (int, float): "number", - (str,): "string", - (bool,): "boolean", - (list, tuple): "Array", - (dict,): "Object", - (None,): "null", -} - - -def get_unique_variable_name() -> str: - """Get a unique variable name. - - Returns: - The unique variable name. - """ - name = "".join([random.choice(string.ascii_lowercase) for _ in range(8)]) - if name not in USED_VARIABLES: - USED_VARIABLES.add(name) - return name - return get_unique_variable_name() - - -class VarData(Base): - """Metadata associated with a Var.""" - - # The name of the enclosing state. - state: str = "" - - # Imports needed to render this var - imports: ParsedImportDict = {} - - # Hooks that need to be present in the component to render this var - hooks: Dict[str, None] = {} - - # Positions of interpolated strings. This is used by the decoder to figure - # out where the interpolations are and only escape the non-interpolated - # segments. - interpolations: List[Tuple[int, int]] = [] - - def __init__( - self, imports: Union[ImportDict, ParsedImportDict] | None = None, **kwargs: Any - ): - """Initialize the var data. - - Args: - imports: The imports needed to render this var. - **kwargs: The var data fields. - """ - if imports: - kwargs["imports"] = parse_imports(imports) - super().__init__(**kwargs) - - @classmethod - def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None: - """Merge multiple var data objects. - - Args: - *others: The var data objects to merge. - - Returns: - The merged var data object. - """ - state = "" - _imports = {} - hooks = {} - interpolations = [] - for var_data in others: - if var_data is None: - continue - state = state or var_data.state - _imports = imports.merge_imports(_imports, var_data.imports) - hooks.update( - var_data.hooks - if isinstance(var_data.hooks, dict) - else {k: None for k in var_data.hooks} - ) - interpolations += ( - var_data.interpolations if isinstance(var_data, VarData) else [] - ) - - return ( - cls( - state=state, - imports=_imports, - hooks=hooks, - interpolations=interpolations, - ) - or None - ) - - def __bool__(self) -> bool: - """Check if the var data is non-empty. - - Returns: - True if any field is set to a non-default value. - """ - return bool(self.state or self.imports or self.hooks or self.interpolations) - - def __eq__(self, other: Any) -> bool: - """Check if two var data objects are equal. - - Args: - other: The other var data object to compare. - - Returns: - True if all fields are equal and collapsed imports are equal. - """ - if not isinstance(other, VarData): - return False - - # Don't compare interpolations - that's added in by the decoder, and - # not part of the vardata itself. - return ( - self.state == other.state - and self.hooks.keys() == other.hooks.keys() - and imports.collapse_imports(self.imports) - == imports.collapse_imports(other.imports) - ) - - def dict(self) -> dict: - """Convert the var data to a dictionary. - - Returns: - The var data dictionary. - """ - return { - "state": self.state, - "interpolations": list(self.interpolations), - "imports": { - lib: [import_var.dict() for import_var in import_vars] - for lib, import_vars in self.imports.items() - }, - "hooks": self.hooks, - } - - -@dataclasses.dataclass( - eq=True, - frozen=True, -) -class ImmutableVarData: - """Metadata associated with a Var.""" - - # The name of the enclosing state. - state: str = dataclasses.field(default="") - - # Imports needed to render this var - imports: ImmutableParsedImportDict = dataclasses.field(default_factory=tuple) - - # Hooks that need to be present in the component to render this var - hooks: Tuple[str, ...] = dataclasses.field(default_factory=tuple) - - def __init__( - self, - state: str = "", - imports: ImportDict | ParsedImportDict | None = None, - hooks: dict[str, None] | None = None, - ): - """Initialize the var data. - - Args: - state: The name of the enclosing state. - imports: Imports needed to render this var. - hooks: Hooks that need to be present in the component to render this var. - """ - immutable_imports: ImmutableParsedImportDict = tuple( - sorted( - ((k, tuple(sorted(v))) for k, v in parse_imports(imports or {}).items()) - ) - ) - object.__setattr__(self, "state", state) - object.__setattr__(self, "imports", immutable_imports) - object.__setattr__(self, "hooks", tuple(hooks or {})) - - @classmethod - def merge( - cls, *others: ImmutableVarData | VarData | None - ) -> ImmutableVarData | None: - """Merge multiple var data objects. - - Args: - *others: The var data objects to merge. - - Returns: - The merged var data object. - """ - state = "" - _imports = {} - hooks = {} - for var_data in others: - if var_data is None: - continue - state = state or var_data.state - _imports = imports.merge_imports(_imports, var_data.imports) - hooks.update( - var_data.hooks - if isinstance(var_data.hooks, dict) - else {k: None for k in var_data.hooks} - ) - - return ( - ImmutableVarData( - state=state, - imports=_imports, - hooks=hooks, - ) - or None - ) - - def __bool__(self) -> bool: - """Check if the var data is non-empty. - - Returns: - True if any field is set to a non-default value. - """ - return bool(self.state or self.imports or self.hooks) - - def __eq__(self, other: Any) -> bool: - """Check if two var data objects are equal. - - Args: - other: The other var data object to compare. - - Returns: - True if all fields are equal and collapsed imports are equal. - """ - if not isinstance(other, (ImmutableVarData, VarData)): - return False - - # Don't compare interpolations - that's added in by the decoder, and - # not part of the vardata itself. - return ( - self.state == other.state - and self.hooks - == ( - other.hooks - if isinstance(other, ImmutableVarData) - else tuple(other.hooks.keys()) - ) - and imports.collapse_imports(self.imports) - == imports.collapse_imports(other.imports) - ) - - -def _decode_var_immutable(value: str) -> tuple[ImmutableVarData | None, str]: - """Decode the state name from a formatted var. - - Args: - value: The value to extract the state name from. - - Returns: - The extracted state name and the value without the state name. - """ - var_datas = [] - if isinstance(value, str): - # fast path if there is no encoded VarData - if constants.REFLEX_VAR_OPENING_TAG not in value: - return None, value - - offset = 0 - - # Initialize some methods for reading json. - var_data_config = VarData().__config__ - - def json_loads(s): - try: - return var_data_config.json_loads(s) - except json.decoder.JSONDecodeError: - return var_data_config.json_loads(var_data_config.json_loads(f'"{s}"')) - - # Find all tags. - while m := _decode_var_pattern.search(value): - start, end = m.span() - value = value[:start] + value[end:] - - serialized_data = m.group(1) - - if serialized_data.isnumeric() or ( - serialized_data[0] == "-" and serialized_data[1:].isnumeric() - ): - # This is a global immutable var. - var = _global_vars[int(serialized_data)] - var_data = var._var_data - - if var_data is not None: - realstart = start + offset - - var_datas.append(var_data) - else: - # Read the JSON, pull out the string length, parse the rest as VarData. - data = json_loads(serialized_data) - string_length = data.pop("string_length", None) - var_data = VarData.parse_obj(data) - - # Use string length to compute positions of interpolations. - if string_length is not None: - realstart = start + offset - var_data.interpolations = [(realstart, realstart + string_length)] - - var_datas.append(var_data) - offset += end - start - - return ImmutableVarData.merge(*var_datas) if var_datas else None, value - - -def _encode_var(value: Var) -> str: - """Encode the state name into a formatted var. - - Args: - value: The value to encode the state name into. - - Returns: - The encoded var. - """ - if value._var_data: - from reflex.utils.serializers import serialize - - final_value = str(value) - data = value._var_data.dict() - data["string_length"] = len(final_value) - data_json = value._var_data.__config__.json_dumps(data, default=serialize) - - return ( - f"{constants.REFLEX_VAR_OPENING_TAG}{data_json}{constants.REFLEX_VAR_CLOSING_TAG}" - + final_value - ) - - return str(value) - - -# Compile regex for finding reflex var tags. -_decode_var_pattern_re = ( - rf"{constants.REFLEX_VAR_OPENING_TAG}(.*?){constants.REFLEX_VAR_CLOSING_TAG}" -) -_decode_var_pattern = re.compile(_decode_var_pattern_re, flags=re.DOTALL) - -# Defined global immutable vars. -_global_vars: Dict[int, Var] = {} - - -def _decode_var(value: str) -> tuple[VarData | None, str]: - """Decode the state name from a formatted var. - - Args: - value: The value to extract the state name from. - - Returns: - The extracted state name and the value without the state name. - """ - var_datas = [] - if isinstance(value, str): - # fast path if there is no encoded VarData - if constants.REFLEX_VAR_OPENING_TAG not in value: - return None, value - - offset = 0 - - # Initialize some methods for reading json. - var_data_config = VarData().__config__ - - def json_loads(s): - try: - return var_data_config.json_loads(s) - except json.decoder.JSONDecodeError: - return var_data_config.json_loads(var_data_config.json_loads(f'"{s}"')) - - # Find all tags. - while m := _decode_var_pattern.search(value): - start, end = m.span() - value = value[:start] + value[end:] - - serialized_data = m.group(1) - - if serialized_data.isnumeric() or ( - serialized_data[0] == "-" and serialized_data[1:].isnumeric() - ): - # This is a global immutable var. - var = _global_vars[int(serialized_data)] - var_data = var._var_data - - if var_data is not None: - realstart = start + offset - - var_datas.append(var_data) - else: - # Read the JSON, pull out the string length, parse the rest as VarData. - data = json_loads(serialized_data) - string_length = data.pop("string_length", None) - var_data = VarData.parse_obj(data) - - # Use string length to compute positions of interpolations. - if string_length is not None: - realstart = start + offset - var_data.interpolations = [(realstart, realstart + string_length)] - - var_datas.append(var_data) - offset += end - start - - return VarData.merge(*var_datas) if var_datas else None, value - - -def _extract_var_data(value: Iterable) -> list[VarData | None]: - """Extract the var imports and hooks from an iterable containing a Var. - - Args: - value: The iterable to extract the VarData from - - Returns: - The extracted VarDatas. - """ - from reflex.style import Style - - var_datas = [] - with contextlib.suppress(TypeError): - for sub in value: - if isinstance(sub, Var): - var_datas.append(sub._var_data) - elif not isinstance(sub, str): - # Recurse into dict values. - if hasattr(sub, "values") and callable(sub.values): - var_datas.extend(_extract_var_data(sub.values())) - # Recurse into iterable values (or dict keys). - var_datas.extend(_extract_var_data(sub)) - - # Style objects should already have _var_data. - if isinstance(value, Style): - var_datas.append(value._var_data) - else: - # Recurse when value is a dict itself. - values = getattr(value, "values", None) - if callable(values): - var_datas.extend(_extract_var_data(values())) - return var_datas - - -class Var: - """An abstract var.""" - - # The name of the var. - _var_name: str - - # The type of the var. - _var_type: Type - - # Whether this is a local javascript variable. - _var_is_local: bool - - # Whether the var is a string literal. - _var_is_string: bool - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool - - # Extra metadata associated with the Var - _var_data: Optional[VarData] - - _var_is_scope: bool = False - - @classmethod - def create( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: Optional[VarData] = None, - _var_is_scope: 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. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - - Raises: - VarTypeError: If the value is JSON-unserializable. - """ - from reflex.utils import format - - # Check for none values. - if value is None: - return None - - # If the value is already a var, do nothing. - if isinstance(value, Var): - return value - - # Try to pull the imports and hooks from contained values. - if not isinstance(value, str): - _var_data = VarData.merge(*_extract_var_data(value), _var_data) - - # Try to serialize the value. - type_ = type(value) - if type_ in types.JSONType: - name = value - else: - name, serialized_type = serializers.serialize(value, get_type=True) - if ( - serialized_type is not None - and _var_is_string is None - and issubclass(serialized_type, str) - ): - _var_is_string = True - if name is None: - raise VarTypeError( - f"No JSON serializer found for var {value} of type {type_}." - ) - name = name if isinstance(name, str) else format.json_dumps(name) - - if _var_is_string is None and type_ is str: - console.deprecate( - feature_name=f"Creating a Var ({value}) from a string without specifying _var_is_string", - reason=( - "Specify _var_is_string=False to create a Var that is not a string literal. " - "In the future, creating a Var from a string will be treated as a string literal " - "by default." - ), - deprecation_version="0.5.4", - removal_version="0.6.0", - ) - - return BaseVar( - _var_name=name, - _var_type=type_, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string if _var_is_string is not None else False, - _var_data=_var_data, - _var_is_scope=_var_is_scope, - ) - - @classmethod - def create_safe( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: Optional[VarData] = None, - ) -> Var: - """Create a var from a value, asserting that it is not None. - - Args: - value: The value to create the var from. - _var_is_local: Whether the var is local. - _var_is_string: Whether the var is a string literal. - _var_data: Additional hooks and imports associated with the Var. - - Returns: - The var. - """ - var = cls.create( - value, - _var_is_local=_var_is_local, - _var_is_string=_var_is_string, - _var_data=_var_data, - ) - assert var is not None - return var - - @classmethod - def __class_getitem__(cls, type_: str) -> _GenericAlias: - """Get a typed var. - - Args: - type_: The type of the var. - - Returns: - The var class item. - """ - return _GenericAlias(cls, type_) - - def __post_init__(self) -> None: - """Post-initialize the var.""" - # Decode any inline Var markup and apply it to the instance - _var_data, _var_name = _decode_var(self._var_name) - if _var_data: - self._var_name = _var_name - self._var_data = VarData.merge(self._var_data, _var_data) - - def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: - """Make a copy of this Var with updated fields. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - A new BaseVar with the updated fields overwriting the corresponding fields in this Var. - - Raises: - TypeError: If kwargs contains keys that are not allowed. - """ - field_values = dict( - _var_name=kwargs.pop("_var_name", self._var_name), - _var_type=kwargs.pop("_var_type", self._var_type), - _var_is_local=kwargs.pop("_var_is_local", self._var_is_local), - _var_is_string=kwargs.pop("_var_is_string", self._var_is_string), - _var_full_name_needs_state_prefix=kwargs.pop( - "_var_full_name_needs_state_prefix", - self._var_full_name_needs_state_prefix, - ), - _var_data=VarData.merge( - kwargs.pop("_var_data", self._var_data), merge_var_data - ), - ) - - if kwargs: - unexpected_kwargs = ", ".join(kwargs.keys()) - raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}") - - return BaseVar(**field_values) - - def _decode(self) -> Any: - """Decode Var as a python value. - - Note that Var with state set cannot be decoded python-side and will be - returned as full_name. - - Returns: - The decoded value or the Var name. - """ - if self._var_is_string: - return self._var_name - try: - return json.loads(self._var_name) - except ValueError: - 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, _var_is_string=False) - return self._replace( - _var_name=f"{{...{self._var_name}, ...{other._var_name}}}" # type: ignore - ) - - def to_string(self, json: bool = True) -> Var: - """Convert a var to a string. - - Args: - json: Whether to convert to a JSON string. - - Returns: - The stringified var. - """ - fn = "JSON.stringify" if json else "String" - return self.operation(fn=fn, type_=str) - - def to_int(self) -> Var: - """Convert a var to an int. - - Returns: - The parseInt var. - """ - return self.operation(fn="parseInt", type_=int) - - def __hash__(self) -> int: - """Define a hash function for a var. - - Returns: - The hash of the var. - """ - return hash((self._var_name, str(self._var_type))) - - def __str__(self) -> str: - """Wrap the var so it can be used in templates. - - Returns: - The wrapped var, i.e. {state.var}. - """ - from reflex.utils import format - - 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. - """ - from reflex.utils import format - - # Indexing is only supported for strings, lists, tuples, dicts, and dataframes. - if not ( - types._issubclass(self._var_type, Union[List, Dict, Tuple, str]) - or types.is_dataframe(self._var_type) - ): - if self._var_type == Any: - raise VarTypeError( - "Could not index into var of type Any. (If you are trying to index into a state var, " - "add the correct type annotation to the var.)" - ) - raise VarTypeError( - f"Var {self._var_name} of type {self._var_type} does not support indexing." - ) - - # The type of the indexed var. - type_ = Any - - # Convert any vars to local vars. - if isinstance(i, Var): - i = i._replace(_var_is_local=True) - - # Handle list/tuple/str indexing. - if types._issubclass(self._var_type, Union[List, Tuple, str]): - # List/Tuple/String indices must be ints, slices, or vars. - if ( - not isinstance(i, types.get_args(Union[int, slice, Var])) - or isinstance(i, Var) - and not i._var_type == int - ): - raise VarTypeError("Index must be an integer or an integer var.") - - # Handle slices first. - if isinstance(i, slice): - # Get the start and stop indices. - start = i.start or 0 - stop = i.stop or "undefined" - - # Use the slice function. - return self._replace( - _var_name=f"{self._var_name}.slice({start}, {stop})", - _var_is_string=False, - ) - - # Get the type of the indexed var. - if types.is_generic_alias(self._var_type): - index = i if not isinstance(i, Var) else 0 - type_ = types.get_args(self._var_type) - type_ = type_[index % len(type_)] if type_ else Any - elif types._issubclass(self._var_type, str): - type_ = str - - # Use `at` to support negative indices. - return self._replace( - _var_name=f"{self._var_name}.at({i})", - _var_type=type_, - _var_is_string=False, - ) - - # Dictionary / dataframe indexing. - # Tuples are currently not supported as indexes. - if ( - ( - types._issubclass(self._var_type, Dict) - or types.is_dataframe(self._var_type) - ) - and not isinstance(i, types.get_args(Union[int, str, float, Var])) - ) or ( - isinstance(i, Var) - and not types._issubclass( - i._var_type, types.get_args(Union[int, str, float]) - ) - ): - raise VarTypeError( - "Index must be one of the following types: int, str, int or str Var" - ) - # Get the type of the indexed var. - if isinstance(i, str): - i = format.wrap(i, '"') - type_ = ( - types.get_args(self._var_type)[1] - if types.is_generic_alias(self._var_type) - else Any - ) - - # Use normal indexing here. - return self._replace( - _var_name=f"{self._var_name}[{i}]", - _var_type=type_, - _var_is_string=False, - ) - - def __getattribute__(self, name: str) -> Any: - """Get a var attribute. - - Args: - name: The name of the attribute. - - Returns: - The var attribute. - - Raises: - VarAttributeError: If the attribute cannot be found, or if __getattr__ fallback should be used. - """ - try: - var_attribute = super().__getattribute__(name) - if ( - not name.startswith("_") - and name not in Var.__dict__ - and name not in BaseVar.__dict__ - ): - # Check if the attribute should be accessed through the Var instead of - # accessing one of the Var operations - type_ = types.get_attribute_access_type( - super().__getattribute__("_var_type"), name - ) - if type_ is not None: - raise VarAttributeError( - f"{name} is being accessed through the Var." - ) - # Return the attribute as-is. - return var_attribute - except VarAttributeError: - raise # fall back to __getattr__ anyway - - def __getattr__(self, name: str) -> Var: - """Get a var attribute. - - Args: - name: The name of the attribute. - - Returns: - The var attribute. - - Raises: - VarAttributeError: If the var is wrongly annotated or can't find attribute. - VarTypeError: If an annotation to the var isn't provided. - """ - # Check if the attribute is one of the class fields. - if not name.startswith("_"): - if self._var_type == Any: - raise VarTypeError( - f"You must provide an annotation for the state var `{self._var_full_name}`. Annotation cannot be `{self._var_type}`" - ) from None - is_optional = types.is_optional(self._var_type) - type_ = types.get_attribute_access_type(self._var_type, name) - - if type_ is not None: - return self._replace( - _var_name=f"{self._var_name}{'?' if is_optional else ''}.{name}", - _var_type=type_, - _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 - """ - from reflex.utils import format - - if isinstance(other, str): - other = Var.create(json.dumps(other), _var_is_string=False) - else: - other = Var.create(other, _var_is_string=False) - - type_ = type_ or self._var_type - - if other is None and flip: - raise VarValueError( - "flip_operands cannot be set to True if the value of 'other' operand is not provided" - ) - - left_operand, right_operand = (other, self) if flip else (self, other) - - def get_operand_full_name(operand): - # operand vars that are string literals need to be wrapped in back ticks. - return ( - operand._var_name_unwrapped - if operand._var_is_string - and not operand._var_state - and operand._var_is_local - else operand._var_full_name - ) - - if other is not None: - # check if the operation between operands is valid. - if op and not self.is_valid_operation( - types.get_base_class(left_operand._var_type), # type: ignore - types.get_base_class(right_operand._var_type), # type: ignore - op, - ): - raise VarTypeError( - f"Unsupported Operand type(s) for {op}: `{left_operand._var_full_name}` of type {left_operand._var_type.__name__} and `{right_operand._var_full_name}` of type {right_operand._var_type.__name__}" # type: ignore - ) - - left_operand_full_name = get_operand_full_name(left_operand) - right_operand_full_name = get_operand_full_name(right_operand) - - left_operand_full_name = format.wrap(left_operand_full_name, "(") - right_operand_full_name = format.wrap(right_operand_full_name, "(") - - # apply function to operands - if fn is not None: - if invoke_fn: - # invoke the function on left operand. - operation_name = ( - f"{left_operand_full_name}.{fn}({right_operand_full_name})" # type: ignore - ) - else: - # pass the operands as arguments to the function. - operation_name = ( - f"{left_operand_full_name} {op} {right_operand_full_name}" # type: ignore - ) - operation_name = f"{fn}({operation_name})" - else: - # apply operator to operands (left operand right_operand) - operation_name = ( - f"{left_operand_full_name} {op} {right_operand_full_name}" # type: ignore - ) - operation_name = format.wrap(operation_name, "(") - else: - # apply operator to left operand ( left_operand) - operation_name = f"{op}{get_operand_full_name(self)}" - # apply function to operands - if fn is not None: - operation_name = ( - f"{fn}({operation_name})" - if not invoke_fn - else f"{get_operand_full_name(self)}.{fn}()" - ) - - return self._replace( - _var_name=operation_name, - _var_type=type_, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - merge_var_data=other._var_data if other is not None else None, - ) - - @staticmethod - def is_valid_operation( - operand1_type: Type, operand2_type: Type, operator: str - ) -> bool: - """Check if an operation between two operands is valid. - - Args: - operand1_type: Type of the operand - operand2_type: Type of the second operand - operator: The operator. - - Returns: - Whether operation is valid or not - - """ - if operator in ALL_OPS or operator in DELIMITERS: - return True - - # bools are subclasses of ints - pair = tuple( - sorted( - [ - int if operand1_type == bool else operand1_type, - int if operand2_type == bool else operand2_type, - ], - key=lambda x: x.__name__, - ) - ) - return pair in OPERATION_MAPPING and operator in OPERATION_MAPPING[pair] - - def compare(self, op: str, other: Var) -> Var: - """Compare two vars with inequalities. - - Args: - op: The comparison operator. - other: The other var to compare with. - - Returns: - The comparison result. - """ - return self.operation(op, other, bool) - - def __invert__(self) -> Var: - """Invert a var. - - Returns: - The inverted var. - """ - return self.operation("!", type_=bool) - - def __neg__(self) -> Var: - """Negate a var. - - Returns: - The negated var. - """ - return self.operation(fn="-") - - def __abs__(self) -> Var: - """Get the absolute value of a var. - - Returns: - A var with the absolute value. - """ - return self.operation(fn="Math.abs") - - def length(self) -> Var: - """Get the length of a list var. - - Returns: - A var with the absolute value. - - Raises: - VarTypeError: If the var is not a list. - """ - if not types._issubclass(self._var_type, List): - raise VarTypeError(f"Cannot get length of non-list var {self}.") - return self._replace( - _var_name=f"{self._var_name}.length", - _var_type=int, - _var_is_string=False, - ) - - def _type(self) -> Var: - """Get the type of the Var in Javascript. - - Returns: - A var representing the type check. - """ - return self._replace( - _var_name=f"typeof {self._var_full_name}", - _var_type=str, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) - - def __eq__(self, other: Union[Var, Type]) -> Var: - """Perform an equality comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the equality comparison. - """ - for python_types, js_type in PYTHON_JS_TYPE_MAP.items(): - if not isinstance(other, Var) and other in python_types: - return self.compare("===", Var.create(js_type, _var_is_string=True)) # type: ignore - return self.compare("===", other) - - def __ne__(self, other: Union[Var, Type]) -> Var: - """Perform an inequality comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the inequality comparison. - """ - for python_types, js_type in PYTHON_JS_TYPE_MAP.items(): - if not isinstance(other, Var) and other in python_types: - return self.compare("!==", Var.create(js_type, _var_is_string=True)) # type: ignore - return self.compare("!==", other) - - def __gt__(self, other: Var) -> Var: - """Perform a greater than comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the greater than comparison. - """ - return self.compare(">", other) - - def __ge__(self, other: Var) -> Var: - """Perform a greater than or equal to comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the greater than or equal to comparison. - """ - return self.compare(">=", other) - - def __lt__(self, other: Var) -> Var: - """Perform a less than comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the less than comparison. - """ - return self.compare("<", other) - - def __le__(self, other: Var) -> Var: - """Perform a less than or equal to comparison. - - Args: - other: The other var to compare with. - - Returns: - A var representing the less than or equal to comparison. - """ - return self.compare("<=", other) - - def __add__(self, other: Var, flip=False) -> Var: - """Add two vars. - - Args: - other: The other var to add. - flip: Whether to flip operands. - - Returns: - A var representing the sum. - """ - other_type = other._var_type if isinstance(other, Var) else type(other) - # For list-list addition, javascript concatenates the content of the lists instead of - # merging the list, and for that reason we use the spread operator available through spreadArraysOrObjects - # utility function - if ( - types.get_base_class(self._var_type) == list - and types.get_base_class(other_type) == list - ): - return self.operation( - ",", other, fn="spreadArraysOrObjects", flip=flip - )._replace( - merge_var_data=VarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": [ - ImportVar(tag="spreadArraysOrObjects") - ] - }, - ), - ) - return self.operation("+", other, flip=flip) - - def __radd__(self, other: Var) -> Var: - """Add two vars. - - Args: - other: The other var to add. - - Returns: - A var representing the sum. - """ - return self.__add__(other=other, flip=True) - - def __sub__(self, other: Var) -> Var: - """Subtract two vars. - - Args: - other: The other var to subtract. - - Returns: - A var representing the difference. - """ - return self.operation("-", other) - - def __rsub__(self, other: Var) -> Var: - """Subtract two vars. - - Args: - other: The other var to subtract. - - Returns: - A var representing the difference. - """ - return self.operation("-", other, flip=True) - - def __mul__(self, other: Var, flip=True) -> Var: - """Multiply two vars. - - Args: - other: The other var to multiply. - flip: Whether to flip operands - - Returns: - A var representing the product. - """ - other_type = other._var_type if isinstance(other, Var) else type(other) - # For str-int multiplication, we use the repeat function. - # i.e "hello" * 2 is equivalent to "hello".repeat(2) in js. - if (types.get_base_class(self._var_type), types.get_base_class(other_type)) in [ - (int, str), - (str, int), - ]: - return self.operation(other=other, fn="repeat", invoke_fn=True) - - # For list-int multiplication, we use the Array function. - # i.e ["hello"] * 2 is equivalent to Array(2).fill().map(() => ["hello"]).flat() in js. - if (types.get_base_class(self._var_type), types.get_base_class(other_type)) in [ - (int, list), - (list, int), - ]: - other_name = other._var_full_name if isinstance(other, Var) else other - name = f"Array({other_name}).fill().map(() => {self._var_full_name}).flat()" - return self._replace( - _var_name=name, - _var_type=str, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) - - return self.operation("*", other) - - def __rmul__(self, other: Var) -> Var: - """Multiply two vars. - - Args: - other: The other var to multiply. - - Returns: - A var representing the product. - """ - return self.__mul__(other=other, flip=True) - - def __pow__(self, other: Var) -> Var: - """Raise a var to a power. - - Args: - other: The power to raise to. - - Returns: - A var representing the power. - """ - return self.operation(",", other, fn="Math.pow") - - def __rpow__(self, other: Var) -> Var: - """Raise a var to a power. - - Args: - other: The power to raise to. - - Returns: - A var representing the power. - """ - return self.operation(",", other, flip=True, fn="Math.pow") - - def __truediv__(self, other: Var) -> Var: - """Divide two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the quotient. - """ - return self.operation("/", other) - - def __rtruediv__(self, other: Var) -> Var: - """Divide two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the quotient. - """ - return self.operation("/", other, flip=True) - - def __floordiv__(self, other: Var) -> Var: - """Divide two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the quotient. - """ - return self.operation("/", other, fn="Math.floor") - - def __mod__(self, other: Var) -> Var: - """Get the remainder of two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the remainder. - """ - return self.operation("%", other) - - def __rmod__(self, other: Var) -> Var: - """Get the remainder of two vars. - - Args: - other: The other var to divide. - - Returns: - A var representing the remainder. - """ - return self.operation("%", other, flip=True) - - def __and__(self, other: Var) -> Var: - """Perform a logical and. - - Args: - other: The other var to perform the logical AND with. - - Returns: - A var representing the logical AND. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '&&' operator) of a logical AND operation. - In JavaScript, the - logical OR operator '&&' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical AND 'and' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. - Therefore, this method leverages the - bitwise AND '__and__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 & var2 - >>> print(js_code._var_full_name) - '(true && false)' - """ - return self.operation("&&", other, type_=bool) - - def __rand__(self, other: Var) -> Var: - """Perform a logical and. - - Args: - other: The other var to perform the logical AND with. - - Returns: - A var representing the logical AND. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '&&' operator) of a logical AND operation. - In JavaScript, the - logical OR operator '&&' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical AND 'and' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. - Therefore, this method leverages the - bitwise AND '__rand__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 & var2 - >>> print(js_code._var_full_name) - '(false && true)' - """ - return self.operation("&&", other, type_=bool, flip=True) - - def __or__(self, other: Var) -> Var: - """Perform a logical or. - - Args: - other: The other var to perform the logical or with. - - Returns: - A var representing the logical or. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '||' operator) of a logical OR operation. In JavaScript, the - logical OR operator '||' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical OR 'or' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. Therefore, this method leverages the - bitwise OR '__or__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 | var2 - >>> print(js_code._var_full_name) - '(true || false)' - """ - return self.operation("||", other, type_=bool) - - def __ror__(self, other: Var) -> Var: - """Perform a logical or. - - Args: - other: The other var to perform the logical or with. - - Returns: - A var representing the logical or. - - Note: - This method provides behavior specific to JavaScript, where it returns the JavaScript - equivalent code (using the '||' operator) of a logical OR operation. In JavaScript, the - logical OR operator '||' is used for Boolean logic, and this method emulates that behavior - by returning the equivalent code as a Var instance. - - In Python, logical OR 'or' operates differently, evaluating expressions immediately, making - it challenging to override the behavior entirely. Therefore, this method leverages the - bitwise OR '__or__' operator for custom JavaScript-like behavior. - - Example: - >>> var1 = Var.create(True) - >>> var2 = Var.create(False) - >>> js_code = var1 | var2 - >>> print(js_code) - 'false || true' - """ - return self.operation("||", other, type_=bool, flip=True) - - def __contains__(self, _: Any) -> Var: - """Override the 'in' operator to alert the user that it is not supported. - - Raises: - VarTypeError: the operation is not supported - """ - raise VarTypeError( - "'in' operator not supported for Var types, use Var.contains() instead." - ) - - def contains(self, other: Any, field: Union[Var, None] = None) -> Var: - """Check if a var contains the object `other`. - - Args: - other: The object to check. - field: Optionally specify a field to check on both object and the other var. - - Raises: - VarTypeError: If the var is not a valid type: dict, list, tuple or str. - - Returns: - A var representing the contain check. - """ - if not (types._issubclass(self._var_type, Union[dict, list, tuple, str, set])): - raise VarTypeError( - f"Var {self._var_full_name} of type {self._var_type} does not support contains check." - ) - method = ( - "hasOwnProperty" - if types.get_base_class(self._var_type) == dict - else "includes" - ) - if isinstance(other, str): - other = Var.create(json.dumps(other), _var_is_string=True) - elif not isinstance(other, Var): - other = Var.create(other, _var_is_string=False) - if types._issubclass(self._var_type, Dict): - return self._replace( - _var_name=f"{self._var_name}.{method}({other._var_full_name})", - _var_type=bool, - _var_is_string=False, - merge_var_data=other._var_data, - ) - else: # str, list, tuple - # For strings, the left operand must be a string. - if types._issubclass(self._var_type, str) and not types._issubclass( - other._var_type, str - ): - raise VarTypeError( - f"'in ' requires string as left operand, not {other._var_type}" - ) - - _var_name = None - if field is None: - _var_name = f"{self._var_name}.includes({other._var_full_name})" - else: - field = Var.create_safe(field, _var_is_string=isinstance(field, str)) - _var_name = f"{self._var_name}.some(e=>e[{field._var_name_unwrapped}]==={other._var_full_name})" - - return self._replace( - _var_name=_var_name, - _var_type=bool, - _var_is_string=False, - merge_var_data=other._var_data, - ) - - def reverse(self) -> Var: - """Reverse a list var. - - Raises: - VarTypeError: If the var is not a list. - - Returns: - A var with the reversed list. - """ - if not types._issubclass(self._var_type, list): - raise VarTypeError(f"Cannot reverse non-list var {self._var_full_name}.") - - return self._replace( - _var_name=f"[...{self._var_full_name}].reverse()", - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - ) - - def lower(self) -> Var: - """Convert a string var to lowercase. - - Returns: - A var with the lowercase string. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError( - f"Cannot convert non-string var {self._var_full_name} to lowercase." - ) - - return self._replace( - _var_name=f"{self._var_name}.toLowerCase()", - _var_is_string=False, - _var_type=str, - ) - - def upper(self) -> Var: - """Convert a string var to uppercase. - - Returns: - A var with the uppercase string. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError( - f"Cannot convert non-string var {self._var_full_name} to uppercase." - ) - - return self._replace( - _var_name=f"{self._var_name}.toUpperCase()", - _var_is_string=False, - _var_type=str, - ) - - def strip(self, other: str | Var[str] = " ") -> Var: - """Strip a string var. - - Args: - other: The string to strip the var with. - - Returns: - A var with the stripped string. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError(f"Cannot strip non-string var {self._var_full_name}.") - - other = ( - Var.create_safe(json.dumps(other), _var_is_string=False) - if isinstance(other, str) - else other - ) - - return self._replace( - _var_name=f"{self._var_name}.replace(/^${other._var_full_name}|${other._var_full_name}$/g, '')", - _var_is_string=False, - merge_var_data=other._var_data, - ) - - def split(self, other: str | Var[str] = " ") -> Var: - """Split a string var into a list. - - Args: - other: The string to split the var with. - - Returns: - A var with the list. - - Raises: - VarTypeError: If the var is not a string. - """ - if not types._issubclass(self._var_type, str): - raise VarTypeError(f"Cannot split non-string var {self._var_full_name}.") - - other = ( - Var.create_safe(json.dumps(other), _var_is_string=False) - if isinstance(other, str) - else other - ) - - return self._replace( - _var_name=f"{self._var_name}.split({other._var_full_name})", - _var_is_string=False, - _var_type=List[str], - merge_var_data=other._var_data, - ) - - def join(self, other: str | Var[str] | None = None) -> Var: - """Join a list var into a string. - - Args: - other: The string to join the list with. - - Returns: - A var with the string. - - Raises: - VarTypeError: If the var is not a list. - """ - if not types._issubclass(self._var_type, list): - raise VarTypeError(f"Cannot join non-list var {self._var_full_name}.") - - if other is None: - other = Var.create_safe('""', _var_is_string=False) - if isinstance(other, str): - other = Var.create_safe(json.dumps(other), _var_is_string=False) - else: - other = Var.create_safe(other, _var_is_string=False) - - return self._replace( - _var_name=f"{self._var_name}.join({other._var_full_name})", - _var_is_string=False, - _var_type=str, - merge_var_data=other._var_data, - ) - - def foreach(self, fn: Callable) -> Var: - """Return a list of components. after doing a foreach on this var. - - Args: - fn: The function to call on each component. - - Returns: - A var representing foreach operation. - - Raises: - VarTypeError: If the var is not a list. - """ - inner_types = get_args(self._var_type) - if not inner_types: - raise VarTypeError( - f"Cannot foreach over non-sequence var {self._var_full_name} of type {self._var_type}." - ) - arg = BaseVar( - _var_name=get_unique_variable_name(), - _var_type=inner_types[0], - ) - index = BaseVar( - _var_name=get_unique_variable_name(), - _var_type=int, - ) - fn_signature = inspect.signature(fn) - fn_args = (arg, index) - fn_ret = fn(*fn_args[: len(fn_signature.parameters)]) - return self._replace( - _var_name=f"{self._var_full_name}.map(({arg._var_name}, {index._var_name}) => {fn_ret})", - _var_is_string=False, - ) - - @classmethod - def range( - cls, - v1: Var | int = 0, - v2: Var | int | None = None, - step: Var | int | None = None, - ) -> Var: - """Return an iterator over indices from v1 to v2 (or 0 to v1). - - Args: - v1: The start of the range or end of range if v2 is not given. - v2: The end of the range. - step: The number of numbers between each item. - - Returns: - A var representing range operation. - - Raises: - VarTypeError: If the var is not an int. - """ - if not isinstance(v1, Var): - v1 = Var.create_safe(v1) - if v1._var_type != int: - raise VarTypeError(f"Cannot get range on non-int var {v1._var_full_name}.") - if not isinstance(v2, Var): - v2 = Var.create(v2) - if v2 is None: - v2 = Var.create_safe("undefined", _var_is_string=False) - elif v2._var_type != int: - raise VarTypeError(f"Cannot get range on non-int var {v2._var_full_name}.") - - if not isinstance(step, Var): - step = Var.create(step) - if step is None: - step = Var.create_safe(1) - elif step._var_type != int: - raise VarTypeError( - f"Cannot get range on non-int var {step._var_full_name}." - ) - - return BaseVar( - _var_name=f"Array.from(range({v1._var_full_name}, {v2._var_full_name}, {step._var_name}))", - _var_type=List[int], - _var_is_local=False, - _var_data=VarData.merge( - v1._var_data, - v2._var_data, - step._var_data, - VarData( - imports={ - "/utils/helpers/range.js": [ - ImportVar(tag="range", is_default=True), - ], - }, - ), - ), - ) - - def to(self, type_: Type) -> Var: - """Convert the type of the var. - - Args: - type_: The type to convert to. - - Returns: - The converted var. - """ - return self._replace(_var_type=type_) - - def as_ref(self) -> Var: - """Convert the var to a ref. - - Returns: - The var as a ref. - """ - return self._replace( - _var_name=f"refs['{self._var_full_name}']", - _var_is_local=True, - _var_is_string=False, - _var_full_name_needs_state_prefix=False, - merge_var_data=VarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": [imports.ImportVar(tag="refs")], - }, - ), - ) - - @property - def _var_full_name(self) -> str: - """Get the full name of the var. - - Returns: - The full name of the var. - """ - from reflex.utils import format - - if not self._var_full_name_needs_state_prefix: - return self._var_name - return ( - self._var_name - if self._var_data is None or self._var_data.state == "" - else ".".join( - [format.format_state_name(self._var_data.state), self._var_name] - ) - ) - - def _var_set_state(self, state: Type[BaseState] | str) -> Any: - """Set the state of the var. - - Args: - state: The state to set or the full name of the state. - - Returns: - The var with the set state. - """ - from reflex.utils import format - - state_name = state if isinstance(state, str) else state.get_full_name() - new_var_data = VarData( - state=state_name, - hooks={ - "const {0} = useContext(StateContexts.{0})".format( - format.format_state_name(state_name) - ): None - }, - imports={ - f"/{constants.Dirs.CONTEXTS_PATH}": [ImportVar(tag="StateContexts")], - "react": [ImportVar(tag="useContext")], - }, - ) - self._var_data = VarData.merge(self._var_data, new_var_data) - self._var_full_name_needs_state_prefix = True - return self - - @property - def _var_state(self) -> str: - """Compat method for getting the state. - - Returns: - The state name associated with the var. - """ - return self._var_data.state if self._var_data else "" - - def _get_all_var_data(self) -> VarData | None: - """Get all the var data. - - Returns: - The var data. - """ - return self._var_data - - def json(self) -> str: - """Serialize the var to a JSON string. - - Raises: - NotImplementedError: If the method is not implemented. - """ - raise NotImplementedError("Var subclasses must implement the json method.") - - @property - def _var_name_unwrapped(self) -> str: - """Get the var str without wrapping in curly braces. - - Returns: - The str var without the wrapped curly braces - """ - from reflex.style import Style - - generic_alias = types.is_generic_alias(self._var_type) - - type_ = get_origin(self._var_type) if generic_alias else self._var_type - wrapped_var = str(self) - - return ( - wrapped_var - if not self._var_state - and not generic_alias - and (types._issubclass(type_, dict) or types._issubclass(type_, Style)) - else wrapped_var.strip("{}") - ) - - -# Allow automatic serialization of Var within JSON structures -serializers.serializer(_encode_var) - - -@dataclasses.dataclass( - eq=False, - **{"slots": True} if sys.version_info >= (3, 10) else {}, -) -class BaseVar(Var): - """A base (non-computed) var of the app state.""" - - # The name of the var. - _var_name: str = dataclasses.field() - - # The type of the var. - _var_type: Type = dataclasses.field(default=Any) - - # Whether this is a local javascript variable. - _var_is_local: bool = dataclasses.field(default=False) - - # Whether the var is a string literal. - _var_is_string: bool = dataclasses.field(default=False) - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False) - - # Extra metadata associated with the Var - _var_data: Optional[VarData] = dataclasses.field(default=None) - - _var_is_scope: bool = dataclasses.field(default=False) - - def __hash__(self) -> int: - """Define a hash function for a var. - - Returns: - The hash of the var. - """ - return hash((self._var_name, str(self._var_type))) - - def get_default_value(self) -> Any: - """Get the default value of the var. - - Returns: - The default value of the var. - - Raises: - ImportError: If the var is a dataframe and pandas is not installed. - """ - if types.is_optional(self._var_type): - return None - - type_ = ( - get_origin(self._var_type) - if types.is_generic_alias(self._var_type) - else self._var_type - ) - if type_ is Literal: - args = get_args(self._var_type) - return args[0] if args else None - if issubclass(type_, str): - return "" - if issubclass(type_, types.get_args(Union[int, float])): - return 0 - if issubclass(type_, bool): - return False - if issubclass(type_, list): - return [] - if issubclass(type_, dict): - return {} - if issubclass(type_, tuple): - return () - if types.is_dataframe(type_): - try: - import pandas as pd - - return pd.DataFrame() - except ImportError as e: - raise ImportError( - "Please install pandas to use dataframes in your app." - ) from e - return set() if issubclass(type_, set) else None - - def get_setter_name(self, include_state: bool = True) -> str: - """Get the name of the var's generated setter function. - - Args: - include_state: Whether to include the state name in the setter name. - - Returns: - The name of the setter function. - """ - setter = constants.SETTER_PREFIX + self._var_name - if self._var_data is None: - return setter - if not include_state or self._var_data.state == "": - return setter - return ".".join((self._var_data.state, setter)) - - def get_setter(self) -> Callable[[BaseState, Any], None]: - """Get the var's setter function. - - Returns: - A function that that creates a setter for the var. - """ - - def setter(state: BaseState, value: Any): - """Get the setter for the var. - - Args: - state: The state within which we add the setter function. - value: The value to set. - """ - if self._var_type in [int, float]: - try: - value = self._var_type(value) - setattr(state, self._var_name, value) - except ValueError: - console.debug( - f"{type(state).__name__}.{self._var_name}: Failed conversion of {value} to '{self._var_type.__name__}'. Value not set.", - ) - else: - setattr(state, self._var_name, value) - - setter.__qualname__ = self.get_setter_name() - - return setter - - -@dataclasses.dataclass(init=False, eq=False) -class ComputedVar(Var, property): - """A field with computed getters.""" - - # Whether to track dependencies and cache computed values - _cache: bool = dataclasses.field(default=False) - - # Whether the computed var is a backend var - _backend: bool = dataclasses.field(default=False) - - # The initial value of the computed var - _initial_value: Any | types.Unset = dataclasses.field(default=types.Unset()) - - # Explicit var dependencies to track - _static_deps: set[str] = dataclasses.field(default_factory=set) - - # Whether var dependencies should be auto-determined - _auto_deps: bool = dataclasses.field(default=True) - - # Interval at which the computed var should be updated - _update_interval: Optional[datetime.timedelta] = dataclasses.field(default=None) - - # The name of the var. - _var_name: str = dataclasses.field() - - # The type of the var. - _var_type: Type = dataclasses.field(default=Any) - - # Whether this is a local javascript variable. - _var_is_local: bool = dataclasses.field(default=False) - - # Whether the var is a string literal. - _var_is_string: bool = dataclasses.field(default=False) - - # _var_full_name should be prefixed with _var_state - _var_full_name_needs_state_prefix: bool = dataclasses.field(default=False) - - # Extra metadata associated with the Var - _var_data: Optional[VarData] = dataclasses.field(default=None) - - def __init__( - self, - fget: Callable[[BaseState], Any], - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[int, datetime.timedelta]] = None, - backend: bool | None = None, - **kwargs, - ): - """Initialize a ComputedVar. - - Args: - fget: The getter function. - initial_value: The initial value of the computed var. - cache: Whether to cache the computed value. - deps: Explicit var dependencies to track. - auto_deps: Whether var dependencies should be auto-determined. - interval: Interval at which the computed var should be updated. - backend: Whether the computed var is a backend var. - **kwargs: additional attributes to set on the instance - - Raises: - TypeError: If the computed var dependencies are not Var instances or var names. - """ - if backend is None: - backend = fget.__name__.startswith("_") - self._backend = backend - - self._initial_value = initial_value - self._cache = cache - if isinstance(interval, int): - interval = datetime.timedelta(seconds=interval) - self._update_interval = interval - if deps is None: - deps = [] - else: - for dep in deps: - if isinstance(dep, Var): - continue - if isinstance(dep, str) and dep != "": - continue - raise TypeError( - "ComputedVar dependencies must be Var instances or var names (non-empty strings)." - ) - self._static_deps = { - dep._var_name if isinstance(dep, Var) else dep for dep in deps - } - self._auto_deps = auto_deps - property.__init__(self, fget) - kwargs["_var_name"] = kwargs.pop("_var_name", fget.__name__) - kwargs["_var_type"] = kwargs.pop("_var_type", self._determine_var_type()) - BaseVar.__init__(self, **kwargs) # type: ignore - - @override - def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar: - """Replace the attributes of the ComputedVar. - - Args: - merge_var_data: VarData to merge into the existing VarData. - **kwargs: Var fields to update. - - Returns: - The new ComputedVar instance. - - Raises: - TypeError: If kwargs contains keys that are not allowed. - """ - field_values = dict( - fget=kwargs.pop("fget", self.fget), - initial_value=kwargs.pop("initial_value", self._initial_value), - cache=kwargs.pop("cache", self._cache), - deps=kwargs.pop("deps", self._static_deps), - auto_deps=kwargs.pop("auto_deps", self._auto_deps), - interval=kwargs.pop("interval", self._update_interval), - backend=kwargs.pop("backend", self._backend), - _var_name=kwargs.pop("_var_name", self._var_name), - _var_type=kwargs.pop("_var_type", self._var_type), - _var_is_local=kwargs.pop("_var_is_local", self._var_is_local), - _var_is_string=kwargs.pop("_var_is_string", self._var_is_string), - _var_full_name_needs_state_prefix=kwargs.pop( - "_var_full_name_needs_state_prefix", - self._var_full_name_needs_state_prefix, - ), - _var_data=VarData.merge(self._var_data, merge_var_data), - ) - - if kwargs: - unexpected_kwargs = ", ".join(kwargs.keys()) - raise TypeError(f"Unexpected keyword arguments: {unexpected_kwargs}") - - return ComputedVar(**field_values) - - @property - def _cache_attr(self) -> str: - """Get the attribute used to cache the value on the instance. - - Returns: - An attribute name. - """ - return f"__cached_{self._var_name}" - - @property - def _last_updated_attr(self) -> str: - """Get the attribute used to store the last updated timestamp. - - Returns: - An attribute name. - """ - return f"__last_updated_{self._var_name}" - - def needs_update(self, instance: BaseState) -> bool: - """Check if the computed var needs to be updated. - - Args: - instance: The state instance that the computed var is attached to. - - Returns: - True if the computed var needs to be updated, False otherwise. - """ - if self._update_interval is None: - return False - last_updated = getattr(instance, self._last_updated_attr, None) - if last_updated is None: - return True - return datetime.datetime.now() - last_updated > self._update_interval - - def __get__(self, instance: BaseState | None, owner): - """Get the ComputedVar value. - - If the value is already cached on the instance, return the cached value. - - Args: - instance: the instance of the class accessing this computed var. - owner: the class that this descriptor is attached to. - - Returns: - The value of the var for the given instance. - """ - if instance is None or not self._cache: - return super().__get__(instance, owner) - - # handle caching - if not hasattr(instance, self._cache_attr) or self.needs_update(instance): - # Set cache attr on state instance. - setattr(instance, self._cache_attr, super().__get__(instance, owner)) - # Ensure the computed var gets serialized to redis. - instance._was_touched = True - # Set the last updated timestamp on the state instance. - setattr(instance, self._last_updated_attr, datetime.datetime.now()) - return getattr(instance, self._cache_attr) - - def _deps( - self, - objclass: Type, - obj: FunctionType | CodeType | None = None, - self_name: Optional[str] = None, - ) -> set[str]: - """Determine var dependencies of this ComputedVar. - - Save references to attributes accessed on "self". Recursively called - when the function makes a method call on "self" or define comprehensions - or nested functions that may reference "self". - - Args: - objclass: the class obj this ComputedVar is attached to. - obj: the object to disassemble (defaults to the fget function). - self_name: if specified, look for this name in LOAD_FAST and LOAD_DEREF instructions. - - Returns: - A set of variable names accessed by the given obj. - - Raises: - VarValueError: if the function references the get_state, parent_state, or substates attributes - (cannot track deps in a related state, only implicitly via parent state). - """ - if not self._auto_deps: - return self._static_deps - d = self._static_deps.copy() - if obj is None: - fget = property.__getattribute__(self, "fget") - if fget is not None: - obj = cast(FunctionType, fget) - else: - return set() - with contextlib.suppress(AttributeError): - # unbox functools.partial - obj = cast(FunctionType, obj.func) # type: ignore - with contextlib.suppress(AttributeError): - # unbox EventHandler - obj = cast(FunctionType, obj.fn) # type: ignore - - if self_name is None and isinstance(obj, FunctionType): - try: - # the first argument to the function is the name of "self" arg - self_name = obj.__code__.co_varnames[0] - except (AttributeError, IndexError): - self_name = None - if self_name is None: - # cannot reference attributes on self if method takes no args - return set() - - invalid_names = ["get_state", "parent_state", "substates", "get_substate"] - self_is_top_of_stack = False - for instruction in dis.get_instructions(obj): - if ( - instruction.opname in ("LOAD_FAST", "LOAD_DEREF") - and instruction.argval == self_name - ): - # bytecode loaded the class instance to the top of stack, next load instruction - # is referencing an attribute on self - self_is_top_of_stack = True - continue - if self_is_top_of_stack and instruction.opname in ( - "LOAD_ATTR", - "LOAD_METHOD", - ): - try: - ref_obj = getattr(objclass, instruction.argval) - except Exception: - ref_obj = None - if instruction.argval in invalid_names: - raise VarValueError( - f"Cached var {self._var_full_name} cannot access arbitrary state via `{instruction.argval}`." - ) - if callable(ref_obj): - # recurse into callable attributes - d.update( - self._deps( - objclass=objclass, - obj=ref_obj, - ) - ) - # recurse into property fget functions - elif isinstance(ref_obj, property) and not isinstance( - ref_obj, ComputedVar - ): - d.update( - self._deps( - objclass=objclass, - obj=ref_obj.fget, # type: ignore - ) - ) - elif ( - instruction.argval in objclass.backend_vars - or instruction.argval in objclass.vars - ): - # var access - d.add(instruction.argval) - elif instruction.opname == "LOAD_CONST" and isinstance( - instruction.argval, CodeType - ): - # recurse into nested functions / comprehensions, which can reference - # instance attributes from the outer scope - d.update( - self._deps( - objclass=objclass, - obj=instruction.argval, - self_name=self_name, - ) - ) - self_is_top_of_stack = False - return d - - def mark_dirty(self, instance) -> None: - """Mark this ComputedVar as dirty. - - Args: - instance: the state instance that needs to recompute the value. - """ - with contextlib.suppress(AttributeError): - delattr(instance, self._cache_attr) - - def _determine_var_type(self) -> Type: - """Get the type of the var. - - Returns: - The type of the var. - """ - hints = get_type_hints(property.__getattribute__(self, "fget")) - if "return" in hints: - return hints["return"] - return Any - - -def computed_var( - fget: Callable[[BaseState], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - backend: bool | None = None, - _deprecated_cached_var: bool = False, - **kwargs, -) -> ComputedVar | Callable[[Callable[[BaseState], Any]], ComputedVar]: - """A ComputedVar decorator with or without kwargs. - - Args: - fget: The getter function. - initial_value: The initial value of the computed var. - cache: Whether to cache the computed value. - deps: Explicit var dependencies to track. - auto_deps: Whether var dependencies should be auto-determined. - interval: Interval at which the computed var should be updated. - backend: Whether the computed var is a backend var. - _deprecated_cached_var: Indicate usage of deprecated cached_var partial function. - **kwargs: additional attributes to set on the instance - - Returns: - A ComputedVar instance. - - Raises: - ValueError: If caching is disabled and an update interval is set. - VarDependencyError: If user supplies dependencies without caching. - """ - if _deprecated_cached_var: - console.deprecate( - feature_name="cached_var", - reason=("Use @rx.var(cache=True) instead of @rx.cached_var."), - deprecation_version="0.5.6", - removal_version="0.6.0", - ) - - if cache is False and interval is not None: - raise ValueError("Cannot set update interval without caching.") - - if cache is False and (deps is not None or auto_deps is False): - raise VarDependencyError("Cannot track dependencies without caching.") - - if fget is not None: - return ComputedVar(fget=fget, cache=cache) - - def wrapper(fget: Callable[[BaseState], Any]) -> ComputedVar: - return ComputedVar( - fget=fget, - initial_value=initial_value, - cache=cache, - deps=deps, - auto_deps=auto_deps, - interval=interval, - backend=backend, - **kwargs, - ) - - return wrapper - - -# Partial function of computed_var with cache=True -cached_var = functools.partial(computed_var, cache=True, _deprecated_cached_var=True) - - -class CallableVar(BaseVar): - """Decorate a Var-returning function to act as both a Var and a function. - - This is used as a compatibility shim for replacing Var objects in the - API with functions that return a family of Var. - """ - - def __init__(self, fn: Callable[..., BaseVar]): - """Initialize a CallableVar. - - Args: - fn: The function to decorate (must return Var) - """ - self.fn = fn - default_var = fn() - super().__init__(**dataclasses.asdict(default_var)) - - def __call__(self, *args, **kwargs) -> BaseVar: - """Call the decorated function. - - Args: - *args: The args to pass to the function. - **kwargs: The kwargs to pass to the function. - - Returns: - The Var returned from calling the function. - """ - return self.fn(*args, **kwargs) - - -def get_uuid_string_var() -> Var: - """Return a Var that generates a single memoized UUID via .web/utils/state.js. - - useMemo with an empty dependency array ensures that the generated UUID is - consistent across re-renders of the component. - - Returns: - A Var that generates a UUID at runtime. - """ - from reflex.utils.imports import ImportVar - - unique_uuid_var_data = VarData( - imports={ - f"/{constants.Dirs.STATE_PATH}": {ImportVar(tag="generateUUID")}, # type: ignore - "react": "useMemo", - } - ) - - return BaseVar( - _var_name="useMemo(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 47d433374..000000000 --- a/reflex/vars.pyi +++ /dev/null @@ -1,218 +0,0 @@ -"""Generated with stubgen from mypy, then manually edited, do not regen.""" - -from __future__ import annotations - -import datetime -from dataclasses import dataclass -from types import FunctionType -from typing import ( - Any, - Callable, - Dict, - Iterable, - List, - Optional, - Set, - Tuple, - Type, - Union, - _GenericAlias, # type: ignore - overload, -) - -from _typeshed import Incomplete - -from reflex import constants as constants -from reflex.base import Base as Base -from reflex.state import BaseState as BaseState -from reflex.state import State as State -from reflex.utils import console as console -from reflex.utils import format as format -from reflex.utils import types as types -from reflex.utils.imports import ImmutableParsedImportDict, ImportDict, ParsedImportDict - -USED_VARIABLES: Incomplete - -def get_unique_variable_name() -> str: ... -def _encode_var(value: Var) -> str: ... - -_global_vars: Dict[int, Var] - -def _decode_var(value: str) -> tuple[VarData, str]: ... -def _extract_var_data(value: Iterable) -> list[VarData | None]: ... - -class VarData(Base): - state: str = "" - imports: Union[ImportDict, ParsedImportDict] = {} - hooks: Dict[str, None] = {} - interpolations: List[Tuple[int, int]] = [] - @classmethod - def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None: ... - -class ImmutableVarData: - state: str = "" - imports: ImmutableParsedImportDict = tuple() - hooks: Tuple[str, ...] = tuple() - def __init__( - self, - state: str = "", - imports: ImportDict | ParsedImportDict | None = None, - hooks: dict[str, None] | None = None, - ) -> None: ... - @classmethod - def merge( - cls, *others: ImmutableVarData | VarData | None - ) -> ImmutableVarData | None: ... - -def _decode_var_immutable(value: str) -> tuple[ImmutableVarData, str]: ... - -class Var: - _var_name: str - _var_type: Type - _var_is_local: bool = False - _var_is_string: bool = False - _var_full_name_needs_state_prefix: bool = False - _var_data: VarData | None = None - @classmethod - def create( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> Optional[Var]: ... - @classmethod - def create_safe( - cls, - value: Any, - _var_is_local: bool = True, - _var_is_string: bool | None = None, - _var_data: VarData | None = None, - ) -> Var: ... - @classmethod - def __class_getitem__(cls, type_: Type) -> _GenericAlias: ... - def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: ... - def equals(self, other: Var) -> bool: ... - def to_string(self) -> Var: ... - def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... - def __getitem__(self, i: Any) -> Var: ... - def __getattribute__(self, name: str) -> Var: ... - def operation( - self, - op: str = ..., - other: Optional[Var] = ..., - type_: Optional[Type] = ..., - flip: bool = ..., - fn: Optional[str] = ..., - ) -> Var: ... - def compare(self, op: str, other: Var) -> Var: ... - def __invert__(self) -> Var: ... - def __neg__(self) -> Var: ... - def __abs__(self) -> Var: ... - def length(self) -> Var: ... - def __eq__(self, other: Var) -> Var: ... - def __ne__(self, other: Var) -> Var: ... - def __gt__(self, other: Var) -> Var: ... - def __ge__(self, other: Var) -> Var: ... - def __lt__(self, other: Var) -> Var: ... - def __le__(self, other: Var) -> Var: ... - def __add__(self, other: Var) -> Var: ... - def __radd__(self, other: Var) -> Var: ... - def __sub__(self, other: Var) -> Var: ... - def __rsub__(self, other: Var) -> Var: ... - def __mul__(self, other: Var) -> Var: ... - def __rmul__(self, other: Var) -> Var: ... - def __pow__(self, other: Var) -> Var: ... - def __rpow__(self, other: Var) -> Var: ... - def __truediv__(self, other: Var) -> Var: ... - def __rtruediv__(self, other: Var) -> Var: ... - def __floordiv__(self, other: Var) -> Var: ... - def __mod__(self, other: Var) -> Var: ... - def __rmod__(self, other: Var) -> Var: ... - def __and__(self, other: Var) -> Var: ... - def __rand__(self, other: Var) -> Var: ... - def __or__(self, other: Var) -> Var: ... - def __ror__(self, other: Var) -> Var: ... - def __contains__(self, _: Any) -> Var: ... - def contains(self, other: Any, field: Union[Var, None] = None) -> Var: ... - def reverse(self) -> Var: ... - def foreach(self, fn: Callable) -> Var: ... - @classmethod - def range( - cls, - v1: Var | int = 0, - v2: Var | int | None = None, - step: Var | int | None = None, - ) -> Var: ... - def to(self, type_: Type) -> Var: ... - def as_ref(self) -> Var: ... - @property - def _var_full_name(self) -> str: ... - def _var_set_state(self, state: Type[BaseState] | str) -> Any: ... - def _get_all_var_data(self) -> VarData: ... - def json(self) -> str: ... - -@dataclass(eq=False) -class BaseVar(Var): - _var_name: str - _var_type: Any - _var_is_local: bool = False - _var_is_string: bool = False - _var_full_name_needs_state_prefix: bool = False - _var_data: VarData | None = None - def __hash__(self) -> int: ... - def get_default_value(self) -> Any: ... - def get_setter_name(self, include_state: bool = ...) -> str: ... - def get_setter(self) -> Callable[[BaseState, Any], None]: ... - -@dataclass(init=False) -class ComputedVar(Var): - _var_cache: bool - fget: FunctionType - @property - def _cache_attr(self) -> str: ... - def __get__(self, instance, owner): ... - def _deps(self, objclass: Type, obj: Optional[FunctionType] = ...) -> Set[str]: ... - def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar: ... - def mark_dirty(self, instance) -> None: ... - def needs_update(self, instance) -> bool: ... - def _determine_var_type(self) -> Type: ... - @overload - def __init__( - self, - fget: Callable[[BaseState], Any], - **kwargs, - ) -> None: ... - @overload - def __init__(self, func) -> None: ... - -@overload -def computed_var( - fget: Callable[[BaseState], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - cache: bool = False, - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - **kwargs, -) -> Callable[[Callable[[Any], Any]], ComputedVar]: ... -@overload -def computed_var(fget: Callable[[Any], Any]) -> ComputedVar: ... -@overload -def cached_var( - fget: Callable[[BaseState], Any] | None = None, - initial_value: Any | types.Unset = types.Unset(), - deps: Optional[List[Union[str, Var]]] = None, - auto_deps: bool = True, - interval: Optional[Union[datetime.timedelta, int]] = None, - **kwargs, -) -> Callable[[Callable[[Any], Any]], ComputedVar]: ... -@overload -def cached_var(fget: Callable[[Any], Any]) -> ComputedVar: ... - -class CallableVar(BaseVar): - def __init__(self, fn: Callable[..., BaseVar]): ... - def __call__(self, *args, **kwargs) -> BaseVar: ... - -def get_uuid_string_var() -> Var: ... diff --git a/reflex/experimental/vars/__init__.py b/reflex/vars/__init__.py similarity index 67% rename from reflex/experimental/vars/__init__.py rename to reflex/vars/__init__.py index 8fa5196ff..cb02319bc 100644 --- a/reflex/experimental/vars/__init__.py +++ b/reflex/vars/__init__.py @@ -1,8 +1,15 @@ -"""Experimental Immutable-Based Var System.""" +"""Immutable-Based Var System.""" -from .base import ImmutableVar as ImmutableVar +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 .datetime import DateTimeVar as DateTimeVar from .function import FunctionStringVar as FunctionStringVar from .function import FunctionVar as FunctionVar from .function import VarOperationCall as VarOperationCall @@ -12,7 +19,6 @@ from .number import LiteralNumberVar as LiteralNumberVar from .number import NumberVar as NumberVar from .object import LiteralObjectVar as LiteralObjectVar from .object import ObjectVar as ObjectVar -from .sequence import ArrayJoinOperation as ArrayJoinOperation from .sequence import ArrayVar as ArrayVar from .sequence import ConcatVarOperation as ConcatVarOperation from .sequence import LiteralArrayVar as LiteralArrayVar diff --git a/reflex/vars/base.py b/reflex/vars/base.py new file mode 100644 index 000000000..094a478c8 --- /dev/null +++ b/reflex/vars/base.py @@ -0,0 +1,2981 @@ +"""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.constants.compiler import Hooks +from reflex.utils import console, exceptions, 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 .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) + + # Dependencies of the var + deps: Tuple[Var, ...] = dataclasses.field(default_factory=tuple) + + # Position of the hook in the component + position: Hooks.HookPosition | None = None + + def __init__( + self, + state: str = "", + field_name: str = "", + imports: ImportDict | ParsedImportDict | None = None, + hooks: dict[str, None] | None = None, + deps: list[Var] | None = None, + position: Hooks.HookPosition | 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. + deps: Dependencies of the var for useCallback. + position: Position of the hook in the component. + """ + 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 {})) + object.__setattr__(self, "deps", tuple(deps or [])) + object.__setattr__(self, "position", position or None) + + def old_school_imports(self) -> ImportDict: + """Return the imports as a mutable dict. + + Returns: + The imports as a mutable dict. + """ + return {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. + + Raises: + ReflexError: If trying to merge VarData with different positions. + + 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) + ) + + deps = [dep for var_data in all_var_datas for dep in var_data.deps] + + positions = list( + { + var_data.position + for var_data in all_var_datas + if var_data.position is not None + } + ) + if positions: + if len(positions) > 1: + raise exceptions.ReflexError( + f"Cannot merge var data with different positions: {positions}" + ) + position = positions[0] + else: + position = None + + if state or _imports or hooks or field_name or deps or position: + return VarData( + state=state, + field_name=field_name, + imports=_imports, + hooks=hooks, + deps=deps, + position=position, + ) + + 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 + or self.deps + or self.position + ) + + @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 + + +def can_use_in_object_var(cls: GenericType) -> bool: + """Check if the class can be used in an ObjectVar. + + Args: + cls: The class to check. + + Returns: + Whether the class can be used in an ObjectVar. + """ + if types.is_union(cls): + return all(can_use_in_object_var(t) for t in types.get_args(cls)) + return ( + inspect.isclass(cls) + and not issubclass(cls, Var) + and serializers.can_serialize(cls, dict) + ) + + +@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(), + default_type: GenericType = types.Unset(), + **kwargs, + ): + """Initialize the subclass. + + Args: + python_types: The python types that the var represents. + default_type: The default type of the var. Defaults to the first python type. + **kwargs: Additional keyword arguments. + """ + super().__init_subclass__(**kwargs) + + if python_types or default_type: + python_types = ( + (python_types if isinstance(python_types, tuple) else (python_types,)) + if python_types + else () + ) + + default_type = default_type or (python_types[0] if python_types else Any) + + @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] = default_type + + 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[str]) -> StringVar: ... + + @overload + def to(self, output: Type[bool]) -> BooleanVar: ... + + @overload + def to(self, output: type[int] | type[float]) -> NumberVar: ... + + @overload + def to( + self, + output: type[list] | type[tuple] | type[set], + ) -> ArrayVar: ... + + @overload + def to( + self, + output: type[dict], + ) -> ObjectVar[dict]: ... + + @overload + def to( + self, output: Type[ObjectVar], var_type: Type[VAR_INSIDE] + ) -> ObjectVar[VAR_INSIDE]: ... + + @overload + def to( + self, output: Type[ObjectVar], var_type: None = None + ) -> ObjectVar[VAR_TYPE]: ... + + @overload + def to(self, output: VAR_SUBCLASS, var_type: None = None) -> VAR_SUBCLASS: ... + + @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. + if can_use_in_object_var(fixed_output_type): + return self.to(ObjectVar, output) + + if inspect.isclass(output): + for var_subclass in _var_subclasses[::-1]: + if issubclass(output, var_subclass.var_subclass): + current_var_type = self._var_type + if current_var_type is Any: + new_var_type = var_type + else: + new_var_type = var_type or current_var_type + to_operation_return = var_subclass.to_var_subclass.create( + value=self, _var_type=new_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 can_use_in_object_var(var_type): + 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) + + if can_use_in_object_var(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 __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 __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 name == "contains": + raise TypeError( + f"Var of type {self._var_type} does not support contains check." + ) + if name == "reverse": + raise TypeError("Cannot reverse non-list var.") + + if self._var_type is Any: + raise TypeError( + f"You must provide an annotation for the state var `{self!s}`. 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: + 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." + ) + + +OUTPUT = TypeVar("OUTPUT", bound=Var) + +VAR_SUBCLASS = TypeVar("VAR_SUBCLASS", bound=Var) +VAR_INSIDE = TypeVar("VAR_INSIDE") + + +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(type(self)) + + 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( + *( + value._get_all_var_data() if isinstance(value, Var) else None + for value in ( + getattr(self, field.name) + for field in 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( + ( + type(self).__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((type(self).__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 = { + "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 {self!s} 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( + *(arg[1]._get_all_var_data() for arg in 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"{self._state_name!s}.{self._field!s}" + + 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 = next( + iter(inspect.signature(fn).parameters.values()) + ).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") + +BASE_TYPE = TypeVar("BASE_TYPE", bound=Base) + + +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: Field[BASE_TYPE], instance: None, owner + ) -> ObjectVar[BASE_TYPE]: ... + + @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/datetime.py b/reflex/vars/datetime.py new file mode 100644 index 000000000..b6f4c24c6 --- /dev/null +++ b/reflex/vars/datetime.py @@ -0,0 +1,222 @@ +"""Immutable datetime and date vars.""" + +from __future__ import annotations + +import dataclasses +import sys +from datetime import date, datetime +from typing import Any, NoReturn, TypeVar, Union, overload + +from reflex.utils.exceptions import VarTypeError +from reflex.vars.number import BooleanVar + +from .base import ( + CustomVarOperationReturn, + LiteralVar, + Var, + VarData, + var_operation, + var_operation_return, +) + +DATETIME_T = TypeVar("DATETIME_T", datetime, date) + +datetime_types = Union[datetime, date] + + +def raise_var_type_error(): + """Raise a VarTypeError. + + Raises: + VarTypeError: Cannot compare a datetime object with a non-datetime object. + """ + raise VarTypeError("Cannot compare a datetime object with a non-datetime object.") + + +class DateTimeVar(Var[DATETIME_T], python_types=(datetime, date)): + """A variable that holds a datetime or date object.""" + + @overload + def __lt__(self, other: datetime_types) -> BooleanVar: ... + + @overload + def __lt__(self, other: NoReturn) -> NoReturn: ... + + def __lt__(self, other: Any): + """Less than comparison. + + Args: + other: The other datetime to compare. + + Returns: + The result of the comparison. + """ + if not isinstance(other, DATETIME_TYPES): + raise_var_type_error() + return date_lt_operation(self, other) + + @overload + def __le__(self, other: datetime_types) -> BooleanVar: ... + + @overload + def __le__(self, other: NoReturn) -> NoReturn: ... + + def __le__(self, other: Any): + """Less than or equal comparison. + + Args: + other: The other datetime to compare. + + Returns: + The result of the comparison. + """ + if not isinstance(other, DATETIME_TYPES): + raise_var_type_error() + return date_le_operation(self, other) + + @overload + def __gt__(self, other: datetime_types) -> BooleanVar: ... + + @overload + def __gt__(self, other: NoReturn) -> NoReturn: ... + + def __gt__(self, other: Any): + """Greater than comparison. + + Args: + other: The other datetime to compare. + + Returns: + The result of the comparison. + """ + if not isinstance(other, DATETIME_TYPES): + raise_var_type_error() + return date_gt_operation(self, other) + + @overload + def __ge__(self, other: datetime_types) -> BooleanVar: ... + + @overload + def __ge__(self, other: NoReturn) -> NoReturn: ... + + def __ge__(self, other: Any): + """Greater than or equal comparison. + + Args: + other: The other datetime to compare. + + Returns: + The result of the comparison. + """ + if not isinstance(other, DATETIME_TYPES): + raise_var_type_error() + return date_ge_operation(self, other) + + +@var_operation +def date_gt_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn: + """Greater than comparison. + + Args: + lhs: The left-hand side of the operation. + rhs: The right-hand side of the operation. + + Returns: + The result of the operation. + """ + return date_compare_operation(rhs, lhs, strict=True) + + +@var_operation +def date_lt_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn: + """Less than comparison. + + Args: + lhs: The left-hand side of the operation. + rhs: The right-hand side of the operation. + + Returns: + The result of the operation. + """ + return date_compare_operation(lhs, rhs, strict=True) + + +@var_operation +def date_le_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn: + """Less than or equal comparison. + + Args: + lhs: The left-hand side of the operation. + rhs: The right-hand side of the operation. + + Returns: + The result of the operation. + """ + return date_compare_operation(lhs, rhs) + + +@var_operation +def date_ge_operation(lhs: Var | Any, rhs: Var | Any) -> CustomVarOperationReturn: + """Greater than or equal comparison. + + Args: + lhs: The left-hand side of the operation. + rhs: The right-hand side of the operation. + + Returns: + The result of the operation. + """ + return date_compare_operation(rhs, lhs) + + +def date_compare_operation( + lhs: DateTimeVar[DATETIME_T] | Any, + rhs: DateTimeVar[DATETIME_T] | Any, + strict: bool = False, +) -> CustomVarOperationReturn: + """Check if the value is less than the other value. + + Args: + lhs: The left-hand side of the operation. + rhs: The right-hand side of the operation. + strict: Whether to use strict comparison. + + Returns: + The result of the operation. + """ + return var_operation_return( + f"({lhs} { '<' if strict else '<='} {rhs})", + bool, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class LiteralDatetimeVar(LiteralVar, DateTimeVar): + """Base class for immutable datetime and date vars.""" + + _var_value: datetime | date = dataclasses.field(default=datetime.now()) + + @classmethod + def create(cls, value: datetime | date, _var_data: VarData | None = None): + """Create a new instance of the class. + + Args: + value: The value to set. + + Returns: + LiteralDatetimeVar: The new instance of the class. + """ + js_expr = f'"{value!s}"' + return cls( + _js_expr=js_expr, + _var_type=type(value), + _var_value=value, + _var_data=_var_data, + ) + + +DATETIME_TYPES = (datetime, date, DateTimeVar) diff --git a/reflex/vars/function.py b/reflex/vars/function.py new file mode 100644 index 000000000..2a7d50e1b --- /dev/null +++ b/reflex/vars/function.py @@ -0,0 +1,479 @@ +"""Immutable function vars.""" + +from __future__ import annotations + +import dataclasses +import sys +from typing import Any, Callable, Optional, Sequence, Tuple, Type, Union, overload + +from typing_extensions import Concatenate, Generic, ParamSpec, Protocol, TypeVar + +from reflex.utils import format +from reflex.utils.types import GenericType + +from .base import CachedVarOperation, LiteralVar, Var, VarData, cached_property_no_lock + +P = ParamSpec("P") +V1 = TypeVar("V1") +V2 = TypeVar("V2") +V3 = TypeVar("V3") +V4 = TypeVar("V4") +V5 = TypeVar("V5") +V6 = TypeVar("V6") +R = TypeVar("R") + + +class ReflexCallable(Protocol[P, R]): + """Protocol for a callable.""" + + __call__: Callable[P, R] + + +CALLABLE_TYPE = TypeVar("CALLABLE_TYPE", bound=ReflexCallable, infer_variance=True) +OTHER_CALLABLE_TYPE = TypeVar( + "OTHER_CALLABLE_TYPE", bound=ReflexCallable, infer_variance=True +) + + +class FunctionVar(Var[CALLABLE_TYPE], default_type=ReflexCallable[Any, Any]): + """Base class for immutable function vars.""" + + @overload + def partial(self) -> FunctionVar[CALLABLE_TYPE]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[Concatenate[V1, P], R]], + arg1: Union[V1, Var[V1]], + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[Concatenate[V1, V2, P], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, P], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, P], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + arg4: Union[V4, Var[V4]], + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, P], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + arg4: Union[V4, Var[V4]], + arg5: Union[V5, Var[V5]], + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[Concatenate[V1, V2, V3, V4, V5, V6, P], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + arg4: Union[V4, Var[V4]], + arg5: Union[V5, Var[V5]], + arg6: Union[V6, Var[V6]], + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial( + self: FunctionVar[ReflexCallable[P, R]], *args: Var | Any + ) -> FunctionVar[ReflexCallable[P, R]]: ... + + @overload + def partial(self, *args: Var | Any) -> FunctionVar: ... + + def partial(self, *args: Var | Any) -> FunctionVar: # type: ignore + """Partially apply the function with the given arguments. + + Args: + *args: The arguments to partially apply the function with. + + Returns: + The partially applied function. + """ + if not args: + return ArgsFunctionOperation.create((), self) + return ArgsFunctionOperation.create( + ("...args",), + VarOperationCall.create(self, *args, Var(_js_expr="...args")), + ) + + @overload + def call( + self: FunctionVar[ReflexCallable[[V1], R]], arg1: Union[V1, Var[V1]] + ) -> VarOperationCall[[V1], R]: ... + + @overload + def call( + self: FunctionVar[ReflexCallable[[V1, V2], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + ) -> VarOperationCall[[V1, V2], R]: ... + + @overload + def call( + self: FunctionVar[ReflexCallable[[V1, V2, V3], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + ) -> VarOperationCall[[V1, V2, V3], R]: ... + + @overload + def call( + self: FunctionVar[ReflexCallable[[V1, V2, V3, V4], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + arg4: Union[V4, Var[V4]], + ) -> VarOperationCall[[V1, V2, V3, V4], R]: ... + + @overload + def call( + self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + arg4: Union[V4, Var[V4]], + arg5: Union[V5, Var[V5]], + ) -> VarOperationCall[[V1, V2, V3, V4, V5], R]: ... + + @overload + def call( + self: FunctionVar[ReflexCallable[[V1, V2, V3, V4, V5, V6], R]], + arg1: Union[V1, Var[V1]], + arg2: Union[V2, Var[V2]], + arg3: Union[V3, Var[V3]], + arg4: Union[V4, Var[V4]], + arg5: Union[V5, Var[V5]], + arg6: Union[V6, Var[V6]], + ) -> VarOperationCall[[V1, V2, V3, V4, V5, V6], R]: ... + + @overload + def call( + self: FunctionVar[ReflexCallable[P, R]], *args: Var | Any + ) -> VarOperationCall[P, R]: ... + + @overload + def call(self, *args: Var | Any) -> Var: ... + + def call(self, *args: Var | Any) -> Var: # type: ignore + """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).guess_type() + + __call__ = call + + +class BuilderFunctionVar( + FunctionVar[CALLABLE_TYPE], default_type=ReflexCallable[Any, Any] +): + """Base class for immutable function vars with the builder pattern.""" + + __call__ = FunctionVar.partial + + +class FunctionStringVar(FunctionVar[CALLABLE_TYPE]): + """Base class for immutable function vars from a string.""" + + @classmethod + def create( + cls, + func: str, + _var_type: Type[OTHER_CALLABLE_TYPE] = ReflexCallable[Any, Any], + _var_data: VarData | None = None, + ) -> FunctionStringVar[OTHER_CALLABLE_TYPE]: + """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 FunctionStringVar( + _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(Generic[P, R], CachedVarOperation, Var[R]): + """Base class for immutable vars that are the result of a function call.""" + + _func: Optional[FunctionVar[ReflexCallable[P, R]]] = 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"({self._func!s}({', '.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[ReflexCallable[P, R]], + *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. + """ + function_return_type = ( + func._var_type.__args__[1] + if getattr(func._var_type, "__args__", None) + else Any + ) + var_type = _var_type if _var_type is not Any else function_return_type + return cls( + _js_expr="", + _var_type=var_type, + _var_data=_var_data, + _func=func, + _args=args, + ) + + +@dataclasses.dataclass(frozen=True) +class DestructuredArg: + """Class for destructured arguments.""" + + fields: Tuple[str, ...] = () + rest: Optional[str] = None + + def to_javascript(self) -> str: + """Convert the destructured argument to JavaScript. + + Returns: + The destructured argument in JavaScript. + """ + return format.wrap( + ", ".join(self.fields) + (f", ...{self.rest}" if self.rest else ""), + "{", + "}", + ) + + +@dataclasses.dataclass( + frozen=True, +) +class FunctionArgs: + """Class for function arguments.""" + + args: Tuple[Union[str, DestructuredArg], ...] = () + rest: Optional[str] = None + + +def format_args_function_operation( + args: FunctionArgs, return_expr: Var | Any, explicit_return: bool +) -> str: + """Format an args function operation. + + Args: + args: The function arguments. + return_expr: The return expression. + explicit_return: Whether to use explicit return syntax. + + Returns: + The formatted args function operation. + """ + arg_names_str = ", ".join( + [arg if isinstance(arg, str) else arg.to_javascript() for arg in args.args] + ) + (f", ...{args.rest}" if args.rest else "") + + return_expr_str = str(LiteralVar.create(return_expr)) + + # Wrap return expression in curly braces if explicit return syntax is used. + return_expr_str_wrapped = ( + format.wrap(return_expr_str, "{", "}") if explicit_return else return_expr_str + ) + + return f"(({arg_names_str}) => {return_expr_str_wrapped})" + + +@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: FunctionArgs = dataclasses.field(default_factory=FunctionArgs) + _return_expr: Union[Var, Any] = dataclasses.field(default=None) + _explicit_return: bool = dataclasses.field(default=False) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + return format_args_function_operation( + self._args, self._return_expr, self._explicit_return + ) + + @classmethod + def create( + cls, + args_names: Sequence[Union[str, DestructuredArg]], + return_expr: Var | Any, + rest: str | None = None, + explicit_return: bool = False, + _var_type: GenericType = Callable, + _var_data: VarData | None = None, + ): + """Create a new function var. + + Args: + args_names: The names of the arguments. + return_expr: The return expression of the function. + rest: The name of the rest argument. + explicit_return: Whether to use explicit return syntax. + _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=FunctionArgs(args=tuple(args_names), rest=rest), + _return_expr=return_expr, + _explicit_return=explicit_return, + ) + + +@dataclasses.dataclass( + eq=False, + frozen=True, + **{"slots": True} if sys.version_info >= (3, 10) else {}, +) +class ArgsFunctionOperationBuilder(CachedVarOperation, BuilderFunctionVar): + """Base class for immutable function defined via arguments and return expression with the builder pattern.""" + + _args: FunctionArgs = dataclasses.field(default_factory=FunctionArgs) + _return_expr: Union[Var, Any] = dataclasses.field(default=None) + _explicit_return: bool = dataclasses.field(default=False) + + @cached_property_no_lock + def _cached_var_name(self) -> str: + """The name of the var. + + Returns: + The name of the var. + """ + return format_args_function_operation( + self._args, self._return_expr, self._explicit_return + ) + + @classmethod + def create( + cls, + args_names: Sequence[Union[str, DestructuredArg]], + return_expr: Var | Any, + rest: str | None = None, + explicit_return: bool = False, + _var_type: GenericType = Callable, + _var_data: VarData | None = None, + ): + """Create a new function var. + + Args: + args_names: The names of the arguments. + return_expr: The return expression of the function. + rest: The name of the rest argument. + explicit_return: Whether to use explicit return syntax. + _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=FunctionArgs(args=tuple(args_names), rest=rest), + _return_expr=return_expr, + _explicit_return=explicit_return, + ) + + +if python_version := sys.version_info[:2] >= (3, 10): + JSON_STRINGIFY = FunctionStringVar.create( + "JSON.stringify", _var_type=ReflexCallable[[Any], str] + ) + ARRAY_ISARRAY = FunctionStringVar.create( + "Array.isArray", _var_type=ReflexCallable[[Any], bool] + ) + PROTOTYPE_TO_STRING = FunctionStringVar.create( + "((__to_string) => __to_string.toString())", + _var_type=ReflexCallable[[Any], str], + ) +else: + JSON_STRINGIFY = FunctionStringVar.create( + "JSON.stringify", _var_type=ReflexCallable[Any, str] + ) + ARRAY_ISARRAY = FunctionStringVar.create( + "Array.isArray", _var_type=ReflexCallable[Any, bool] + ) + PROTOTYPE_TO_STRING = FunctionStringVar.create( + "((__to_string) => __to_string.toString())", + _var_type=ReflexCallable[Any, str], + ) diff --git a/reflex/vars/number.py b/reflex/vars/number.py new file mode 100644 index 000000000..d04aded35 --- /dev/null +++ b/reflex/vars/number.py @@ -0,0 +1,1142 @@ +"""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(t.__name__ for t in 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((type(self).__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((type(self).__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] +) -> CustomVarOperationReturn[Union[T, 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..5de431f5a --- /dev/null +++ b/reflex/vars/object.py @@ -0,0 +1,542 @@ +"""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") + +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[Any, 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[Any, 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[Any, 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[Any, NoReturn]], + key: Var | Any, + ) -> Var: ... + + @overload + def __getitem__( + self: ( + ObjectVar[Dict[Any, int]] + | ObjectVar[Dict[Any, float]] + | ObjectVar[Dict[Any, int | float]] + ), + key: Var | Any, + ) -> NumberVar: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[Any, str]], + key: Var | Any, + ) -> StringVar: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[Any, list[ARRAY_INNER_TYPE]]], + key: Var | Any, + ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[Any, set[ARRAY_INNER_TYPE]]], + key: Var | Any, + ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[Any, tuple[ARRAY_INNER_TYPE, ...]]], + key: Var | Any, + ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ... + + @overload + def __getitem__( + self: ObjectVar[Dict[Any, 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[Any, NoReturn]], + name: str, + ) -> Var: ... + + @overload + def __getattr__( + self: ( + ObjectVar[Dict[Any, int]] + | ObjectVar[Dict[Any, float]] + | ObjectVar[Dict[Any, int | float]] + ), + name: str, + ) -> NumberVar: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[Any, str]], + name: str, + ) -> StringVar: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[Any, list[ARRAY_INNER_TYPE]]], + name: str, + ) -> ArrayVar[list[ARRAY_INNER_TYPE]]: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[Any, set[ARRAY_INNER_TYPE]]], + name: str, + ) -> ArrayVar[set[ARRAY_INNER_TYPE]]: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[Any, tuple[ARRAY_INNER_TYPE, ...]]], + name: str, + ) -> ArrayVar[tuple[ARRAY_INNER_TYPE, ...]]: ... + + @overload + def __getattr__( + self: ObjectVar[Dict[Any, dict[OTHER_KEY_TYPE, VALUE_TYPE]]], + name: str, + ) -> ObjectVar[dict[OTHER_KEY_TYPE, VALUE_TYPE]]: ... + + @overload + def __getattr__( + self: ObjectVar, + name: str, + ) -> ObjectItemOperation: ... + + 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 `{self!s}` 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"[{LiteralVar.create(key)!s}] : {LiteralVar.create(value)!s}" + 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((type(self).__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: dict, + _var_type: Type[OBJECT_TYPE] | 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"{self._object!s}?.[{self._key!s}]" + return f"{self._object!s}[{self._key!s}]" + + @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..476c1e32c --- /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((type(self).__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[Any, int]] + | ArrayVar[Tuple[Any, float]] + | ArrayVar[Tuple[Any, int | float]] + ), + i: Literal[1, -1], + ) -> NumberVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[str, Any]], i: Literal[0, -2] + ) -> StringVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[Any, str]], i: Literal[1, -1] + ) -> StringVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[bool, Any]], i: Literal[0, -2] + ) -> BooleanVar: ... + + @overload + def __getitem__( + self: ArrayVar[Tuple[Any, 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((), 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"{self._array!s}.slice({normalized_start!s}, {normalized_end!s})" + 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"{self._array!s}.slice({normalized_start!s}, {normalized_end!s}).filter((_, i) => i % {step!s} === 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"{self.step!s} > 0 ? {self._array!s}.slice({normalized_start!s}, {normalized_end!s}).filter((_, i) => i % {step!s} === 0) : {self._array!s}.slice({actual_start_reverse!s}, {actual_end_reverse!s}).reverse().filter((_, i) => i % {-step!s} === 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"{array!s}.at({index!s})", + 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: ({stop!s} - {start!s}) / {step!s} }}, (_, i) => {start!s} + i * {step!s})", + 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/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/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 247ff4fba..857ee7c6d 100644 --- a/scripts/wait_for_listening_port.py +++ b/scripts/wait_for_listening_port.py @@ -49,11 +49,10 @@ def main(): parser.add_argument("--server-pid", type=int) args = parser.parse_args() executor = ThreadPoolExecutor(max_workers=len(args.port)) - futures = [] - for p in args.port: - futures.append( - executor.submit(_wait_for_port, p, args.server_pid, args.timeout) - ) + futures = [ + executor.submit(_wait_for_port, p, args.server_pid, args.timeout) + for p in args.port + ] for f in as_completed(futures): ok, msg = f.result() if ok: diff --git a/tests/components/core/test_colors.py b/tests/components/core/test_colors.py deleted file mode 100644 index 0c14c8a7c..000000000 --- a/tests/components/core/test_colors.py +++ /dev/null @@ -1,125 +0,0 @@ -import pytest - -import reflex as rx -from reflex.components.datadisplay.code import CodeBlock -from reflex.constants.colors import Color -from reflex.vars import Var - - -class ColorState(rx.State): - """Test color state.""" - - color: str = "mint" - color_part: str = "tom" - shade: int = 4 - - -color_state_name = ColorState.get_full_name().replace(".", "__") - - -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 - f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})", - ), - ( - create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore - f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})", - ), - ( - create_color_var( - rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}") # type: ignore - ), - f"var(--${{{color_state_name}.color_part}}ato-${{{color_state_name}.shade}})", - ), - ( - create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore - f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})", - ), - ( - create_color_var( - f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore - ), - f"var(--${{{color_state_name}.color}}-${{{color_state_name}.shade}})", - ), - ], -) -def test_color(color, expected): - assert color._var_is_string or color._var_type is str - assert color._var_full_name == expected - if color._var_type == Color: - assert str(color) == f"{{`{expected}`}}" - else: - assert str(color) == expected - - -@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 - f"{{isTrue(true) ? `var(--${{{color_state_name}.color}}-7)` : `var(--${{{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(--${{{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(--${{{color_state_name}.color}}-7)`); break;case JSON.stringify(`second`): " - f"return (`var(--${{{color_state_name}.color}}-5)`); break;default: " - f"return (`var(--${{{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 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_code.py b/tests/components/datadisplay/test_code.py deleted file mode 100644 index 64452e90c..000000000 --- a/tests/components/datadisplay/test_code.py +++ /dev/null @@ -1,31 +0,0 @@ -import pytest - -from reflex.components.datadisplay.code import CodeBlock - - -@pytest.mark.parametrize( - "theme, expected", [("light", "one-light"), ("dark", "one-dark")] -) -def test_code_light_dark_theme(theme, expected): - code_block = CodeBlock.create(theme=theme) - - assert code_block.theme._var_name == expected # type: ignore - - -def generate_custom_code(language, expected_case): - return f"SyntaxHighlighter.registerLanguage('{language}', {expected_case})" - - -@pytest.mark.parametrize( - "language, expected_case", - [ - ("python", "python"), - ("firestore-security-rules", "firestoreSecurityRules"), - ("typescript", "typescript"), - ], -) -def test_get_custom_code(language, expected_case): - code_block = CodeBlock.create(language=language) - assert code_block._get_custom_code() == generate_custom_code( - language, expected_case - ) diff --git a/tests/components/datadisplay/test_table.py b/tests/components/datadisplay/test_table.py deleted file mode 100644 index 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 f8856a20f..000000000 --- a/tests/components/forms/test_uploads.py +++ /dev/null @@ -1,205 +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_id_special(): - 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", - id="#spec!`al-_98ID", - ) - - 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 => {\n" - " const updatedFilesById = Object.assign({}, filesById);\n" - " updatedFilesById[`default`] = e;\n" - " return updatedFilesById;\n" - " })\n" - " }", - "ref={ref_default}", - ] - assert upload["args"] == ("getRootProps", "getInputProps") - - # box inside of upload - [box] = upload["children"] - assert box["name"] == "RadixThemesBox" - assert box["props"] == [ - "className={`rx-Upload`}", - 'css={{"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 => {\n" - " const updatedFilesById = Object.assign({}, filesById);\n" - " updatedFilesById[`default`] = e;\n" - " return updatedFilesById;\n" - " })\n" - " }", - "ref={ref_default}", - ] - assert upload["args"] == ("getRootProps", "getInputProps") - - # box inside of upload - [box] = upload["children"] - assert box["name"] == "RadixThemesBox" - assert box["props"] == [ - "className={`rx-Upload`}", - 'css={{"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 => {\n" - " const updatedFilesById = Object.assign({}, filesById);\n" - " updatedFilesById[`default`] = e;\n" - " return updatedFilesById;\n" - " })\n" - " }", - "ref={ref_default}", - ] - - -def test_upload_component_id_with_special_chars(upload_component_id_special): - upload = upload_component_id_special.render() - - assert upload["props"] == [ - r"id={`#spec!\`al-_98ID`}", - "multiple={true}", - "onDrop={e => setFilesById(filesById => {\n" - " const updatedFilesById = Object.assign({}, filesById);\n" - " updatedFilesById[`#spec!\\`al-_98ID`] = e;\n" - " return updatedFilesById;\n" - " })\n" - " }", - "ref={ref__spec_al__98ID}", - ] 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/tests/experimental/test_assets.py b/tests/experimental/test_assets.py deleted file mode 100644 index 8037bcc75..000000000 --- a/tests/experimental/test_assets.py +++ /dev/null @@ -1,36 +0,0 @@ -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/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 70% rename from integration/conftest.py rename to tests/integration/conftest.py index 212ac9981..d11344903 100644 --- a/integration/conftest.py +++ b/tests/integration/conftest.py @@ -6,6 +6,8 @@ from pathlib import Path import pytest +import reflex.app +from reflex.config import environment from reflex.testing import AppHarness, AppHarnessProd DISPLAY = None @@ -21,7 +23,7 @@ def xvfb(): Yields: the pyvirtualdisplay object that the browser will be open on """ - if os.environ.get("GITHUB_ACTIONS") and not os.environ.get("APP_HARNESS_HEADLESS"): + if os.environ.get("GITHUB_ACTIONS") and not environment.APP_HARNESS_HEADLESS.get(): from pyvirtualdisplay.smartdisplay import ( # pyright: ignore [reportMissingImports] SmartDisplay, ) @@ -42,7 +44,7 @@ def pytest_exception_interact(node, call, report): call: The pytest call describing when/where the test was invoked. report: The pytest log report object. """ - screenshot_dir = os.environ.get("SCREENSHOT_DIR") + screenshot_dir = environment.SCREENSHOT_DIR.get() if DISPLAY is None or screenshot_dir is None: return @@ -75,3 +77,25 @@ def app_harness_env(request): The AppHarness class to use for the test. """ return request.param + + +@pytest.fixture(autouse=True) +def raise_console_error(request, mocker): + """Spy on calls to `console.error` used by the framework. + + Help catch spurious error conditions that might otherwise go unnoticed. + + If a test is marked with `ignore_console_error`, the spy will be ignored + after the test. + + Args: + request: The pytest request object. + mocker: The pytest mocker object. + + Yields: + control to the test function. + """ + spy = mocker.spy(reflex.app.console, "error") + yield + if "ignore_console_error" not in request.keywords: + spy.assert_not_called() 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 100% rename from integration/shared/state.py rename to tests/integration/shared/state.py diff --git a/integration/test_background_task.py b/tests/integration/test_background_task.py similarity index 85% rename from integration/test_background_task.py rename to tests/integration/test_background_task.py index 98b6e48ff..d7fe20824 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 @@ -22,7 +22,7 @@ def BackgroundTask(): _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 @@ -31,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 @@ -42,21 +42,24 @@ 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) @@ -68,13 +71,13 @@ def BackgroundTask(): self.counter += 1 await asyncio.sleep(0.005) - @rx.background + @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.background + @rx.event(background=True) async def nested_async_with_self(self): async with self: self.counter += 1 @@ -86,8 +89,15 @@ def BackgroundTask(): 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.background + @rx.event(background=True) async def get_other_state(self): async with self: state = await self.get_state(State) @@ -108,11 +118,11 @@ def BackgroundTask(): 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 @@ -154,6 +164,11 @@ def BackgroundTask(): on_click=OtherState.get_other_state, id="increment-from-other-state", ), + rx.button( + "Yield in Async with Self", + on_click=State.yield_in_async_with_self, + id="yield-in-async-with-self", + ), rx.button("Reset", on_click=State.reset_counter, id="reset"), ) @@ -174,8 +189,8 @@ def background_task( running AppHarness instance """ with AppHarness.create( - root=tmp_path_factory.mktemp(f"background_task"), - app_source=BackgroundTask, # type: ignore + root=tmp_path_factory.mktemp("background_task"), + app_source=BackgroundTask, ) as harness: yield harness @@ -333,3 +348,30 @@ def test_get_state( increment_button.click() assert background_task._poll_for(lambda: counter.text == "13", timeout=5) + + +def test_yield_in_async_with_self( + background_task: AppHarness, + driver: WebDriver, + token: str, +): + """Test that yielding inside async with self does not disable mutability. + + Args: + background_task: harness for BackgroundTask app. + driver: WebDriver instance. + token: The token for the connected client. + """ + assert background_task.app_instance is not None + + # get a reference to all buttons + yield_in_async_with_self_button = driver.find_element( + By.ID, "yield-in-async-with-self" + ) + + # get a reference to the counter + counter = driver.find_element(By.ID, "counter") + assert background_task._poll_for(lambda: counter.text == "0", timeout=5) + + yield_in_async_with_self_button.click() + assert background_task._poll_for(lambda: counter.text == "2", timeout=5) diff --git a/integration/test_call_script.py b/tests/integration/test_call_script.py similarity index 64% rename from integration/test_call_script.py rename to tests/integration/test_call_script.py index 5a3b83abf..203c20e9b 100644 --- a/integration/test_call_script.py +++ b/tests/integration/test_call_script.py @@ -15,6 +15,7 @@ from .utils import SessionStorage def CallScript(): """A test app for browser javascript integration.""" + from pathlib import Path from typing import Dict, List, Optional, Union import reflex as rx @@ -46,6 +47,7 @@ def CallScript(): inline_counter: int = 0 external_counter: int = 0 value: str = "Initial" + last_result: str = "" def call_script_callback(self, result): self.results.append(result) @@ -53,15 +55,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 @@ -76,11 +81,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()", @@ -89,21 +96,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 @@ -118,11 +129,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()", @@ -131,19 +144,50 @@ 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"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}", + 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"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}" + ), + callback=CallScriptState.set_last_result, # type: ignore + ) + + @rx.event def reset_(self): yield rx.call_script("inline_counter = 0; external_counter = 0") self.reset() app = rx.App(state=rx.State) - with open("assets/external.js", "w") as f: - f.write(external_scripts) + Path("assets/external.js").write_text(external_scripts) @app.add_page def index(): @@ -234,6 +278,68 @@ def CallScript(): 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"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}", + 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"{rx.Var('inline_counter')!s} + {rx.Var('external_counter')!s}" + ), + callback=CallScriptState.set_last_result, # type: ignore + ), + id="call_with_var_str_cast_wrapped_inline", + ), ) @@ -249,7 +355,7 @@ def call_script(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("call_script"), - app_source=CallScript, # type: ignore + app_source=CallScript, ) as harness: yield harness @@ -363,3 +469,73 @@ def test_call_script( 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 83% rename from integration/test_client_storage.py rename to tests/integration/test_client_storage.py index b69009a09..2652d6ccb 100644 --- a/integration/test_client_storage.py +++ b/tests/integration/test_client_storage.py @@ -10,6 +10,13 @@ from selenium.webdriver import Firefox from selenium.webdriver.common.by import By from selenium.webdriver.remote.webdriver import WebDriver +from reflex.state import ( + State, + StateManagerDisk, + StateManagerMemory, + StateManagerRedis, + _substate_key, +) from reflex.testing import AppHarness from . import utils @@ -55,6 +62,7 @@ def ClientSide(): 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 = "" @@ -64,24 +72,25 @@ def ClientSide(): 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, + 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 @@ -135,7 +144,7 @@ def client_side(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("client_side"), - app_source=ClientSide, # type: ignore + app_source=ClientSide, ) as harness: yield harness @@ -311,7 +320,6 @@ async def test_client_side_state( # no cookies should be set yet! assert not driver.get_cookies() local_storage_items = local_storage.items() - local_storage_items.pop("chakra-ui-color-mode", None) local_storage_items.pop("last_compiled_time", None) assert not local_storage_items @@ -427,7 +435,6 @@ async def test_client_side_state( assert f"{sub_state_name}.c3" not in cookie_info_map(driver) local_storage_items = local_storage.items() - local_storage_items.pop("chakra-ui-color-mode", None) local_storage_items.pop("last_compiled_time", None) assert local_storage_items.pop(f"{sub_state_name}.l1") == "l1 value" assert local_storage_items.pop(f"{sub_state_name}.l2") == "l2 value" @@ -604,6 +611,109 @@ async def test_client_side_state( assert s2.text == "s2 value" assert s3.text == "s3 value" + # Simulate state expiration + if isinstance(client_side.state_manager, StateManagerRedis): + await client_side.state_manager.redis.delete( + _substate_key(token, State.get_full_name()) + ) + await client_side.state_manager.redis.delete(_substate_key(token, state_name)) + await client_side.state_manager.redis.delete( + _substate_key(token, sub_state_name) + ) + await client_side.state_manager.redis.delete( + _substate_key(token, sub_sub_state_name) + ) + elif isinstance(client_side.state_manager, (StateManagerMemory, StateManagerDisk)): + del client_side.state_manager.states[token] + if isinstance(client_side.state_manager, StateManagerDisk): + client_side.state_manager.token_expiration = 0 + client_side.state_manager._purge_expired_states() + + # Ensure the state is gone (not hydrated) + async def poll_for_not_hydrated(): + state = await client_side.get_state(_substate_key(token or "", state_name)) + return not state.is_hydrated + + assert await AppHarness._poll_for_async(poll_for_not_hydrated) + + # Trigger event to get a new instance of the state since the old was expired. + set_sub("c1", "c1 post expire") + + # get new references to all cookie and local storage elements (again) + c1 = driver.find_element(By.ID, "c1") + c2 = driver.find_element(By.ID, "c2") + c3 = driver.find_element(By.ID, "c3") + c4 = driver.find_element(By.ID, "c4") + c5 = driver.find_element(By.ID, "c5") + c6 = driver.find_element(By.ID, "c6") + c7 = driver.find_element(By.ID, "c7") + l1 = driver.find_element(By.ID, "l1") + 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 post expire" + assert c2.text == "c2 value" + assert c3.text == "" # temporary cookie expired after reset state! + assert c4.text == "c4 value" + assert c5.text == "c5 value" + assert c6.text == "c6 value" + assert c7.text == "c7 value" + assert l1.text == "l1 value" + 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" + + # Get the backend state and ensure the values are still set + async def get_sub_state(): + root_state = await client_side.get_state( + _substate_key(token or "", sub_state_name) + ) + state = root_state.substates[client_side.get_state_name("_client_side_state")] + sub_state = state.substates[ + client_side.get_state_name("_client_side_sub_state") + ] + return sub_state + + async def poll_for_c1_set(): + sub_state = await get_sub_state() + return sub_state.c1 == "c1 post expire" + + assert await AppHarness._poll_for_async(poll_for_c1_set) + sub_state = await get_sub_state() + assert sub_state.c1 == "c1 post expire" + assert sub_state.c2 == "c2 value" + assert sub_state.c3 == "" + assert sub_state.c4 == "c4 value" + assert sub_state.c5 == "c5 value" + assert sub_state.c6 == "c6 value" + assert sub_state.c7 == "c7 value" + assert sub_state.l1 == "l1 value" + assert sub_state.l2 == "l2 value" + assert sub_state.l3 == "l3 value" + assert sub_state.l4 == "l4 value" + assert sub_state.s1 == "s1 value" + assert sub_state.s2 == "s2 value" + assert sub_state.s3 == "s3 value" + sub_sub_state = sub_state.substates[ + client_side.get_state_name("_client_side_sub_sub_state") + ] + assert sub_sub_state.c1s == "c1s value" + assert sub_sub_state.l1s == "l1s value" + assert sub_sub_state.s1s == "s1s 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..97624e7c5 --- /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, + ) 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/integration/test_computed_vars.py b/tests/integration/test_computed_vars.py similarity index 97% rename from integration/test_computed_vars.py rename to tests/integration/test_computed_vars.py index 28f774de5..03aaf18b4 100644 --- a/integration/test_computed_vars.py +++ b/tests/integration/test_computed_vars.py @@ -58,9 +58,11 @@ def ComputedVars(): 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() @@ -104,7 +106,6 @@ def ComputedVars(): ), ) - # raise Exception(State.count3._deps(objclass=State)) app = rx.App() app.add_page(index) @@ -122,8 +123,8 @@ def computed_vars( running AppHarness instance """ with AppHarness.create( - root=tmp_path_factory.mktemp(f"computed_vars"), - app_source=ComputedVars, # type: ignore + root=tmp_path_factory.mktemp("computed_vars"), + app_source=ComputedVars, ) as harness: yield harness diff --git a/integration/test_connection_banner.py b/tests/integration/test_connection_banner.py similarity index 98% rename from integration/test_connection_banner.py rename to tests/integration/test_connection_banner.py index b83a493ce..44187c8ba 100644 --- a/integration/test_connection_banner.py +++ b/tests/integration/test_connection_banner.py @@ -20,6 +20,7 @@ def ConnectionBanner(): class State(rx.State): foo: int = 0 + @rx.event async def delay(self): await asyncio.sleep(5) @@ -51,7 +52,7 @@ def connection_banner(tmp_path) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path, - app_source=ConnectionBanner, # type: ignore + app_source=ConnectionBanner, ) as harness: yield harness diff --git a/integration/test_deploy_url.py b/tests/integration/test_deploy_url.py similarity index 98% rename from integration/test_deploy_url.py rename to tests/integration/test_deploy_url.py index b0421cfb7..5c840d24d 100644 --- a/integration/test_deploy_url.py +++ b/tests/integration/test_deploy_url.py @@ -17,6 +17,7 @@ def DeployUrlSample() -> None: 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 @@ -43,7 +44,7 @@ def deploy_url_sample( """ with AppHarness.create( root=tmp_path_factory.mktemp("deploy_url_sample"), - app_source=DeployUrlSample, # type: ignore + app_source=DeployUrlSample, ) as harness: yield harness diff --git a/tests/integration/test_dynamic_components.py b/tests/integration/test_dynamic_components.py new file mode 100644 index 000000000..6a68aa1a1 --- /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, + ) 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 65% rename from integration/test_dynamic_routes.py rename to tests/integration/test_dynamic_routes.py index e3686ee1a..8a3cde3a2 100644 --- a/integration/test_dynamic_routes.py +++ b/tests/integration/test_dynamic_routes.py @@ -2,6 +2,7 @@ from __future__ import annotations +import time from typing import Callable, Coroutine, Generator, Type from urllib.parse import urlsplit @@ -21,14 +22,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 @@ -40,17 +44,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"), @@ -61,22 +63,85 @@ 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.input( + value=DynamicState.router.session.client_token, + read_only=True, + id="token", + ), + 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 @@ -94,9 +159,9 @@ def dynamic_route( running AppHarness instance """ with app_harness_env.create( - root=tmp_path_factory.mktemp(f"dynamic_route"), + root=tmp_path_factory.mktemp("dynamic_route"), app_name=f"dynamicroute_{app_harness_env.__name__.lower()}", - app_source=DynamicRoute, # type: ignore + app_source=DynamicRoute, ) as harness: yield harness @@ -113,6 +178,8 @@ def driver(dynamic_route: AppHarness) -> Generator[WebDriver, None, None]: """ assert dynamic_route.app_instance is not None, "app is not running" driver = dynamic_route.frontend() + # TODO: drop after flakiness is resolved + driver.implicitly_wait(30) try: yield driver finally: @@ -166,8 +233,11 @@ def poll_for_order( dynamic_state_name ].order == exp_order - await AppHarness._poll_for_async(_check) - assert (await _backend_state()).substates[dynamic_state_name].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 @@ -305,3 +375,56 @@ 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, + token: str, +): + """Assert that dynamic arg var is rendered correctly in different contexts. + + Args: + dynamic_route: harness for DynamicRoute app. + driver: WebDriver instance. + token: The token visible in the driver browser. + """ + assert dynamic_route.app_instance is not None + with poll_for_navigation(driver): + driver.get(f"{dynamic_route.frontend_url}/arg/0") + + # TODO: drop after flakiness is resolved + time.sleep(3) + + 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, timeout=30, 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 98% rename from integration/test_event_actions.py rename to tests/integration/test_event_actions.py index e2704fa70..15f3c9877 100644 --- a/integration/test_event_actions.py +++ b/tests/integration/test_event_actions.py @@ -24,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") @@ -53,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", @@ -146,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 @@ -170,8 +171,8 @@ def event_action(tmp_path_factory) -> Generator[AppHarness, None, None]: running AppHarness instance """ with AppHarness.create( - root=tmp_path_factory.mktemp(f"event_action"), - app_source=TestEventAction, # type: ignore + root=tmp_path_factory.mktemp("event_action"), + app_source=TestEventAction, ) as harness: yield harness diff --git a/integration/test_event_chain.py b/tests/integration/test_event_chain.py similarity index 97% rename from integration/test_event_chain.py rename to tests/integration/test_event_chain.py index b0feb3e46..c4121ee94 100644 --- a/integration/test_event_chain.py +++ b/tests/integration/test_event_chain.py @@ -27,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 [ @@ -75,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 @@ -85,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): @@ -92,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 @@ -127,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" ) @@ -135,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", @@ -260,7 +277,7 @@ def event_chain(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("event_chain"), - app_source=EventChain, # type: ignore + app_source=EventChain, ) as harness: yield harness diff --git a/integration/test_exception_handlers.py b/tests/integration/test_exception_handlers.py similarity index 72% rename from integration/test_exception_handlers.py rename to tests/integration/test_exception_handlers.py index 00683c48b..a645d1de6 100644 --- a/integration/test_exception_handlers.py +++ b/tests/integration/test_exception_handlers.py @@ -11,7 +11,9 @@ 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 +from reflex.testing import AppHarness, AppHarnessProd + +pytestmark = [pytest.mark.ignore_console_error] def TestApp(): @@ -26,6 +28,8 @@ def TestApp(): class TestAppState(rx.State): """State for the TestApp app.""" + react_error: bool = False + def divide_by_number(self, number: int): """Divide by number and print the result. @@ -50,6 +54,18 @@ def TestApp(): on_click=lambda: TestAppState.divide_by_number(0), # type: ignore id="induce-backend-error-btn", ), + rx.button( + "induce_react_error", + on_click=TestAppState.set_react_error(True), # type: ignore + id="induce-react-error-btn", + ), + rx.box( + rx.cond( + TestAppState.react_error, + rx.Var.create({"invalid": "cannot have object as child"}), + "", + ), + ), ) @@ -70,7 +86,7 @@ def test_app( 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 + app_source=TestApp, ) as harness: yield harness @@ -152,3 +168,37 @@ def test_backend_exception_handler_during_runtime( "divide_by_number" in captured_default_handler_output.out and "ZeroDivisionError" in captured_default_handler_output.out ) + + +def test_frontend_exception_handler_with_react( + test_app: AppHarness, + driver: WebDriver, + capsys, +): + """Test calling frontend exception handler during runtime. + + Render an object as a react child, which is invalid. + + Args: + test_app: harness for TestApp app + 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-react-error-btn")) + ) + + reset_button.click() + + # Wait for the error to be logged + time.sleep(2) + + captured_default_handler_output = capsys.readouterr() + if isinstance(test_app, AppHarnessProd): + assert "Error: Minified React error #31" in captured_default_handler_output.out + else: + assert ( + "Error: Objects are not valid as a React child (found: object with keys \n{invalid})" + in captured_default_handler_output.out + ) diff --git a/integration/test_form_submit.py b/tests/integration/test_form_submit.py similarity index 76% rename from integration/test_form_submit.py rename to tests/integration/test_form_submit.py index c9eb45146..ea8750595 100644 --- a/integration/test_form_submit.py +++ b/tests/integration/test_form_submit.py @@ -35,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, @@ -94,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, @@ -117,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"}, @@ -148,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]: @@ -173,7 +159,7 @@ def form_submit(request, tmp_path_factory) -> Generator[AppHarness, None, None]: param_id = request._pyfuncitem.callspec.id.replace("-", "_") with AppHarness.create( root=tmp_path_factory.mktemp("form_submit"), - app_source=request.param, # type: ignore + app_source=request.param, app_name=request.param.func.__name__ + f"_{param_id}", ) as harness: assert harness.app_instance is not None, "app is not running" @@ -220,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() @@ -268,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 96% rename from integration/test_input.py rename to tests/integration/test_input.py index 4679104a4..e9fec7dc1 100644 --- a/integration/test_input.py +++ b/tests/integration/test_input.py @@ -63,7 +63,7 @@ def fully_controlled_input(tmp_path) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path, - app_source=FullyControlledInput, # type: ignore + app_source=FullyControlledInput, ) as harness: yield harness @@ -183,6 +183,6 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness): clear_button.click() assert AppHarness._poll_for(lambda: on_change_input.get_attribute("value") == "") # potential bug: clearing the on_change field doesn't itself trigger on_change - # assert backend_state.text == "" - # assert debounce_input.get_attribute("value") == "" - # assert value_input.get_attribute("value") == "" + # assert backend_state.text == "" #noqa: ERA001 + # assert debounce_input.get_attribute("value") == "" #noqa: ERA001 + # assert value_input.get_attribute("value") == "" #noqa: ERA001 diff --git a/integration/test_large_state.py b/tests/integration/test_large_state.py similarity index 97% rename from integration/test_large_state.py rename to tests/integration/test_large_state.py index 23a534a2b..a9a8ff2ec 100644 --- a/integration/test_large_state.py +++ b/tests/integration/test_large_state.py @@ -58,7 +58,7 @@ def test_large_state(var_count: int, tmp_path_factory, benchmark): large_state_rendered = template.render(var_count=var_count) with AppHarness.create( - root=tmp_path_factory.mktemp(f"large_state"), + root=tmp_path_factory.mktemp("large_state"), app_source=large_state_rendered, app_name="large_state", ) as large_state: diff --git a/integration/test_lifespan.py b/tests/integration/test_lifespan.py similarity index 98% rename from integration/test_lifespan.py rename to tests/integration/test_lifespan.py index f8bcf2397..cb6c640ab 100644 --- a/integration/test_lifespan.py +++ b/tests/integration/test_lifespan.py @@ -51,6 +51,7 @@ def LifespanApp(): def context_global(self) -> int: return lifespan_context_global + @rx.event def tick(self, date): pass @@ -79,7 +80,7 @@ def lifespan_app(tmp_path) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path, - app_source=LifespanApp, # type: ignore + app_source=LifespanApp, ) as harness: yield harness diff --git a/integration/test_login_flow.py b/tests/integration/test_login_flow.py similarity index 98% rename from integration/test_login_flow.py rename to tests/integration/test_login_flow.py index 7d583e433..1938672a3 100644 --- a/integration/test_login_flow.py +++ b/tests/integration/test_login_flow.py @@ -21,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("/") @@ -60,7 +62,7 @@ def login_sample(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("login_sample"), - app_source=LoginSample, # type: ignore + app_source=LoginSample, ) as harness: yield harness diff --git a/integration/test_media.py b/tests/integration/test_media.py similarity index 99% rename from integration/test_media.py rename to tests/integration/test_media.py index c10f7102b..10af26591 100644 --- a/integration/test_media.py +++ b/tests/integration/test_media.py @@ -84,7 +84,7 @@ def media_app(tmp_path) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path, - app_source=MediaApp, # type: ignore + app_source=MediaApp, ) as harness: yield harness diff --git a/integration/test_navigation.py b/tests/integration/test_navigation.py similarity index 95% rename from integration/test_navigation.py rename to tests/integration/test_navigation.py index 492ae4510..4e81e4155 100644 --- a/integration/test_navigation.py +++ b/tests/integration/test_navigation.py @@ -52,7 +52,7 @@ def navigation_app(tmp_path) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path, - app_source=NavigationApp, # type: ignore + app_source=NavigationApp, ) as harness: yield harness @@ -74,7 +74,7 @@ async def test_navigation_app(navigation_app: AppHarness): with poll_for_navigation(driver): internal_link.click() - assert urlsplit(driver.current_url).path == f"/internal/" + assert urlsplit(driver.current_url).path == "/internal/" with poll_for_navigation(driver): driver.back() diff --git a/integration/test_server_side_event.py b/tests/integration/test_server_side_event.py similarity index 94% rename from integration/test_server_side_event.py rename to tests/integration/test_server_side_event.py index 9bb20c345..f04cc3beb 100644 --- a/integration/test_server_side_event.py +++ b/tests/integration/test_server_side_event.py @@ -14,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", ""), @@ -31,6 +34,7 @@ def ServerSideEvent(): rx.set_value("c", ""), ] + @rx.event def set_value_return_c(self): return rx.set_value("c", "") @@ -39,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", @@ -89,7 +93,7 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("server_side_event"), - app_source=ServerSideEvent, # type: ignore + app_source=ServerSideEvent, ) as harness: yield harness @@ -98,7 +102,6 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]: def driver(server_side_event: AppHarness): """Get an instance of the browser open to the server_side_event app. - Args: server_side_event: harness for ServerSideEvent app diff --git a/integration/test_shared_state.py b/tests/integration/test_shared_state.py similarity index 93% rename from integration/test_shared_state.py rename to tests/integration/test_shared_state.py index a1a3d6080..410669381 100644 --- a/integration/test_shared_state.py +++ b/tests/integration/test_shared_state.py @@ -12,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 @@ -39,7 +39,7 @@ def shared_state( """ with AppHarness.create( root=tmp_path_factory.mktemp("shared_state"), - app_source=SharedStateApp, # type: ignore + app_source=SharedStateApp, ) as harness: yield harness diff --git a/integration/test_state_inheritance.py b/tests/integration/test_state_inheritance.py similarity index 98% rename from integration/test_state_inheritance.py rename to tests/integration/test_state_inheritance.py index 86ab625e1..6b93a2ed7 100644 --- a/integration/test_state_inheritance.py +++ b/tests/integration/test_state_inheritance.py @@ -73,7 +73,7 @@ def StateInheritance(): def on_click_other_mixin(self): self.other_mixin_clicks += 1 self.other_mixin = ( - f"{self.__class__.__name__}.clicked.{self.other_mixin_clicks}" + f"{type(self).__name__}.clicked.{self.other_mixin_clicks}" ) class Base1(Mixin, rx.State): @@ -216,8 +216,8 @@ def state_inheritance( running AppHarness instance """ with AppHarness.create( - root=tmp_path_factory.mktemp(f"state_inheritance"), - app_source=StateInheritance, # type: ignore + root=tmp_path_factory.mktemp("state_inheritance"), + app_source=StateInheritance, ) as harness: yield harness diff --git a/integration/test_tailwind.py b/tests/integration/test_tailwind.py similarity index 97% rename from integration/test_tailwind.py rename to tests/integration/test_tailwind.py index c7320cb21..eb0fde759 100644 --- a/integration/test_tailwind.py +++ b/tests/integration/test_tailwind.py @@ -34,7 +34,7 @@ def TailwindApp( 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), rx.text(paragraph_text, as_="p", class_name=paragraph_class_name), rx.el.div("Test external stylesheet", class_name="external"), @@ -78,7 +78,7 @@ def tailwind_app(tmp_path, tailwind_disabled) -> Generator[AppHarness, None, Non """ with AppHarness.create( root=tmp_path, - app_source=functools.partial(TailwindApp, tailwind_disabled=tailwind_disabled), # type: ignore + app_source=functools.partial(TailwindApp, tailwind_disabled=tailwind_disabled), app_name="tailwind_disabled_app" if tailwind_disabled else "tailwind_app", ) as harness: yield harness diff --git a/integration/test_upload.py b/tests/integration/test_upload.py similarity index 85% rename from integration/test_upload.py rename to tests/integration/test_upload.py index 77199ca4e..156cf0e45 100644 --- a/integration/test_upload.py +++ b/tests/integration/test_upload.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio import time +from pathlib import Path from typing import Generator import pytest @@ -18,10 +19,14 @@ def UploadFile(): import reflex as rx + LARGE_DATA = "DUMMY" * 1024 * 512 + class UploadState(rx.State): _file_data: Dict[str, str] = {} event_order: List[str] = [] progress_dicts: List[dict] = [] + disabled: bool = False + large_data: str = "" async def handle_upload(self, files: List[rx.UploadFile]): for file in files: @@ -32,6 +37,7 @@ def UploadFile(): for file in files: upload_data = await file.read() self._file_data[file.filename or ""] = upload_data.decode("utf-8") + self.large_data = LARGE_DATA yield UploadState.chain_event def upload_progress(self, progress): @@ -40,13 +46,15 @@ def UploadFile(): self.progress_dicts.append(progress) def chain_event(self): + assert self.large_data == LARGE_DATA + self.large_data = "" self.event_order.append("chain_event") def index(): return rx.vstack( - rx.chakra.input( + rx.input( value=UploadState.router.session.client_token, - is_read_only=True, + read_only=True, id="token", ), rx.heading("Default Upload"), @@ -55,6 +63,7 @@ def UploadFile(): rx.button("Select File"), rx.text("Drag and drop files here or click to select files"), ), + disabled=UploadState.disabled, ), rx.button( "Upload", @@ -132,7 +141,7 @@ def upload_file(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("upload_file"), - app_source=UploadFile, # type: ignore + app_source=UploadFile, ) as harness: yield harness @@ -205,11 +214,12 @@ async def test_upload_file( file_data = await AppHarness._poll_for_async(get_file_data) assert isinstance(file_data, dict) - assert file_data[exp_name] == exp_contents + normalized_file_data = {Path(k).name: v for k, v in file_data.items()} + assert normalized_file_data[Path(exp_name).name] == exp_contents # check that the selected files are displayed selected_files = driver.find_element(By.ID, f"selected_files{suffix}") - assert selected_files.text == exp_name + assert Path(selected_files.text).name == Path(exp_name).name state = await upload_file.get_state(substate_token) if secondary: @@ -256,7 +266,9 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver): # check that the selected files are displayed selected_files = driver.find_element(By.ID, "selected_files") - assert selected_files.text == "\n".join(exp_files) + assert [Path(name).name for name in selected_files.text.split("\n")] == [ + Path(name).name for name in exp_files + ] # do the upload upload_button.click() @@ -271,8 +283,9 @@ async def test_upload_file_multiple(tmp_path, upload_file: AppHarness, driver): file_data = await AppHarness._poll_for_async(get_file_data) assert isinstance(file_data, dict) + normalized_file_data = {Path(k).name: v for k, v in file_data.items()} for exp_name, exp_contents in exp_files.items(): - assert file_data[exp_name] == exp_contents + assert normalized_file_data[Path(exp_name).name] == exp_contents @pytest.mark.parametrize("secondary", [False, True]) @@ -317,7 +330,9 @@ def test_clear_files( # check that the selected files are displayed selected_files = driver.find_element(By.ID, f"selected_files{suffix}") - assert selected_files.text == "\n".join(exp_files) + assert [Path(name).name for name in selected_files.text.split("\n")] == [ + Path(name).name for name in exp_files + ] clear_button = driver.find_element(By.ID, f"clear_button{suffix}") assert clear_button @@ -352,8 +367,8 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive 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") - cancel_button = driver.find_element(By.ID, f"cancel_button_secondary") + upload_button = driver.find_element(By.ID, "upload_button_secondary") + cancel_button = driver.find_element(By.ID, "cancel_button_secondary") exp_name = "large.txt" target_file = tmp_path / exp_name @@ -366,9 +381,25 @@ async def test_cancel_upload(tmp_path, upload_file: AppHarness, driver: WebDrive await asyncio.sleep(0.3) cancel_button.click() - # look up the backend state and assert on progress + # Wait a bit for the upload to get cancelled. + await asyncio.sleep(0.5) + + # Get interim progress dicts saved in the on_upload_progress handler. + async def _progress_dicts(): + state = await upload_file.get_state(substate_token) + return state.substates[state_name].progress_dicts + + # We should have _some_ progress + assert await AppHarness._poll_for_async(_progress_dicts) + + # But there should never be a final progress record for a cancelled upload. + for p in await _progress_dicts(): + assert p["progress"] != 1 + state = await upload_file.get_state(substate_token) - assert state.substates[state_name].progress_dicts - assert exp_name not in state.substates[state_name]._file_data + file_data = state.substates[state_name]._file_data + assert isinstance(file_data, dict) + normalized_file_data = {Path(k).name: v for k, v in file_data.items()} + assert Path(exp_name).name not in normalized_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 94% rename from integration/test_var_operations.py rename to tests/integration/test_var_operations.py index 5cf644ca2..7a7c8328d 100644 --- a/integration/test_var_operations.py +++ b/tests/integration/test_var_operations.py @@ -15,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 @@ -25,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) @@ -470,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( @@ -543,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"), ), ), @@ -584,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", + ), ) @@ -599,7 +613,7 @@ def var_operations(tmp_path_factory) -> Generator[AppHarness, None, None]: """ with AppHarness.create( root=tmp_path_factory.mktemp("var_operations"), - app_source=VarOperations, # type: ignore + app_source=VarOperations, ) as harness: assert harness.app_instance is not None, "app is not running" yield harness @@ -745,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"), @@ -780,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_appearance.py b/tests/integration/tests_playwright/test_appearance.py new file mode 100644 index 000000000..60aeeaa6b --- /dev/null +++ b/tests/integration/tests_playwright/test_appearance.py @@ -0,0 +1,218 @@ +from typing import Generator + +import pytest +from playwright.sync_api import Page, expect + +from reflex.testing import AppHarness + + +def DefaultLightModeApp(): + import reflex as rx + from reflex.style import color_mode + + app = rx.App(theme=rx.theme(appearance="light")) + + @app.add_page + def index(): + return rx.text(color_mode) + + +def DefaultDarkModeApp(): + import reflex as rx + from reflex.style import color_mode + + app = rx.App(theme=rx.theme(appearance="dark")) + + @app.add_page + def index(): + return rx.text(color_mode) + + +def DefaultSystemModeApp(): + import reflex as rx + from reflex.style import color_mode + + app = rx.App() + + @app.add_page + def index(): + return rx.text(color_mode) + + +def ColorToggleApp(): + import reflex as rx + from reflex.style import color_mode, resolved_color_mode, set_color_mode + + app = rx.App(theme=rx.theme(appearance="light")) + + @app.add_page + def index(): + return rx.box( + rx.segmented_control.root( + rx.segmented_control.item( + rx.icon(tag="monitor", size=20), + value="system", + ), + rx.segmented_control.item( + rx.icon(tag="sun", size=20), + value="light", + ), + rx.segmented_control.item( + rx.icon(tag="moon", size=20), + value="dark", + ), + on_change=set_color_mode, + variant="classic", + radius="large", + value=color_mode, + ), + rx.text(color_mode, id="current_color_mode"), + rx.text(resolved_color_mode, id="resolved_color_mode"), + rx.text(rx.color_mode_cond("LightMode", "DarkMode"), id="color_mode_cond"), + ) + + +@pytest.fixture() +def light_mode_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Start DefaultLightMode 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("appearance_app"), + app_source=DefaultLightModeApp, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +@pytest.fixture() +def dark_mode_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Start DefaultDarkMode 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("appearance_app"), + app_source=DefaultDarkModeApp, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +@pytest.fixture() +def system_mode_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Start DefaultSystemMode 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("appearance_app"), + app_source=DefaultSystemModeApp, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +@pytest.fixture() +def color_toggle_app(tmp_path_factory) -> Generator[AppHarness, None, None]: + """Start ColorToggle 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("appearance_app"), + app_source=ColorToggleApp, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +def test_appearance_light_mode(light_mode_app: AppHarness, page: Page): + assert light_mode_app.frontend_url is not None + page.goto(light_mode_app.frontend_url) + + expect(page.get_by_text("light")).to_be_visible() + + +def test_appearance_dark_mode(dark_mode_app: AppHarness, page: Page): + assert dark_mode_app.frontend_url is not None + page.goto(dark_mode_app.frontend_url) + + expect(page.get_by_text("dark")).to_be_visible() + + +def test_appearance_system_mode(system_mode_app: AppHarness, page: Page): + assert system_mode_app.frontend_url is not None + page.goto(system_mode_app.frontend_url) + + expect(page.get_by_text("system")).to_be_visible() + + +def test_appearance_color_toggle(color_toggle_app: AppHarness, page: Page): + assert color_toggle_app.frontend_url is not None + page.goto(color_toggle_app.frontend_url) + + # Radio buttons locators. + radio_system = page.get_by_role("radio").nth(0) + radio_light = page.get_by_role("radio").nth(1) + radio_dark = page.get_by_role("radio").nth(2) + + # Text locators to check. + current_color_mode = page.locator("id=current_color_mode") + resolved_color_mode = page.locator("id=resolved_color_mode") + color_mode_cond = page.locator("id=color_mode_cond") + root_body = page.locator('div[data-is-root-theme="true"]') + + # Background colors. + dark_background = "rgb(17, 17, 19)" # value based on dark native appearance, can change depending on the browser + light_background = "rgb(255, 255, 255)" + + # check initial state + expect(current_color_mode).to_have_text("light") + expect(resolved_color_mode).to_have_text("light") + expect(color_mode_cond).to_have_text("LightMode") + expect(root_body).to_have_css("background-color", light_background) + + # click dark mode + radio_dark.click() + expect(current_color_mode).to_have_text("dark") + expect(resolved_color_mode).to_have_text("dark") + expect(color_mode_cond).to_have_text("DarkMode") + expect(root_body).to_have_css("background-color", dark_background) + + # click light mode + radio_light.click() + expect(current_color_mode).to_have_text("light") + expect(resolved_color_mode).to_have_text("light") + expect(color_mode_cond).to_have_text("LightMode") + expect(root_body).to_have_css("background-color", light_background) + page.reload() + expect(root_body).to_have_css("background-color", light_background) + + # click system mode + radio_system.click() + expect(current_color_mode).to_have_text("system") + expect(resolved_color_mode).to_have_text("light") + expect(color_mode_cond).to_have_text("LightMode") + expect(root_body).to_have_css("background-color", light_background) diff --git a/tests/integration/tests_playwright/test_datetime_operations.py b/tests/integration/tests_playwright/test_datetime_operations.py new file mode 100644 index 000000000..fafd15c42 --- /dev/null +++ b/tests/integration/tests_playwright/test_datetime_operations.py @@ -0,0 +1,87 @@ +from typing import Generator + +import pytest +from playwright.sync_api import Page, expect + +from reflex.testing import AppHarness + + +def DatetimeOperationsApp(): + from datetime import datetime + + import reflex as rx + + class DtOperationsState(rx.State): + date1: datetime = datetime(2021, 1, 1) + date2: datetime = datetime(2031, 1, 1) + date3: datetime = datetime(2021, 1, 1) + + app = rx.App(state=DtOperationsState) + + @app.add_page + def index(): + return rx.vstack( + rx.text(DtOperationsState.date1, id="date1"), + rx.text(DtOperationsState.date2, id="date2"), + rx.text(DtOperationsState.date3, id="date3"), + rx.text("Operations between date1 and date2"), + rx.text(DtOperationsState.date1 == DtOperationsState.date2, id="1_eq_2"), + rx.text(DtOperationsState.date1 != DtOperationsState.date2, id="1_neq_2"), + rx.text(DtOperationsState.date1 < DtOperationsState.date2, id="1_lt_2"), + rx.text(DtOperationsState.date1 <= DtOperationsState.date2, id="1_le_2"), + rx.text(DtOperationsState.date1 > DtOperationsState.date2, id="1_gt_2"), + rx.text(DtOperationsState.date1 >= DtOperationsState.date2, id="1_ge_2"), + rx.text("Operations between date1 and date3"), + rx.text(DtOperationsState.date1 == DtOperationsState.date3, id="1_eq_3"), + rx.text(DtOperationsState.date1 != DtOperationsState.date3, id="1_neq_3"), + rx.text(DtOperationsState.date1 < DtOperationsState.date3, id="1_lt_3"), + rx.text(DtOperationsState.date1 <= DtOperationsState.date3, id="1_le_3"), + rx.text(DtOperationsState.date1 > DtOperationsState.date3, id="1_gt_3"), + rx.text(DtOperationsState.date1 >= DtOperationsState.date3, id="1_ge_3"), + ) + + +@pytest.fixture() +def datetime_operations_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("datetime_operations_app"), + app_source=DatetimeOperationsApp, # type: ignore + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +def test_datetime_operations(datetime_operations_app: AppHarness, page: Page): + assert datetime_operations_app.frontend_url is not None + + page.goto(datetime_operations_app.frontend_url) + expect(page).to_have_url(datetime_operations_app.frontend_url + "/") + # Check the actual values + expect(page.locator("id=date1")).to_have_text("2021-01-01 00:00:00") + expect(page.locator("id=date2")).to_have_text("2031-01-01 00:00:00") + expect(page.locator("id=date3")).to_have_text("2021-01-01 00:00:00") + + # Check the operations between date1 and date2 + expect(page.locator("id=1_eq_2")).to_have_text("false") + expect(page.locator("id=1_neq_2")).to_have_text("true") + expect(page.locator("id=1_lt_2")).to_have_text("true") + expect(page.locator("id=1_le_2")).to_have_text("true") + expect(page.locator("id=1_gt_2")).to_have_text("false") + expect(page.locator("id=1_ge_2")).to_have_text("false") + + # Check the operations between date1 and date3 + expect(page.locator("id=1_eq_3")).to_have_text("true") + expect(page.locator("id=1_neq_3")).to_have_text("false") + expect(page.locator("id=1_lt_3")).to_have_text("false") + expect(page.locator("id=1_le_3")).to_have_text("true") + expect(page.locator("id=1_gt_3")).to_have_text("false") + expect(page.locator("id=1_ge_3")).to_have_text("true") 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..0c0b2959b --- /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, + ) 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..db716aa5b --- /dev/null +++ b/tests/integration/tests_playwright/test_table.py @@ -0,0 +1,101 @@ +"""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, + ) 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): + idx = i * 2 + assert [rows[idx], rows[idx + 1]] == expected_row diff --git a/integration/utils.py b/tests/integration/utils.py similarity index 100% rename from integration/utils.py rename to tests/integration/utils.py diff --git a/tests/test_node_version.py b/tests/test_node_version.py new file mode 100644 index 000000000..defba3d20 --- /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, + ) 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/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/experimental/custom_script.js b/tests/units/assets/custom_script.js similarity index 100% rename from tests/experimental/custom_script.js rename to tests/units/assets/custom_script.js diff --git a/tests/units/assets/test_assets.py b/tests/units/assets/test_assets.py new file mode 100644 index 000000000..b957f1902 --- /dev/null +++ b/tests/units/assets/test_assets.py @@ -0,0 +1,94 @@ +import shutil +from pathlib import Path +from typing import Generator + +import pytest + +import reflex as rx +import reflex.constants as constants + + +def test_shared_asset() -> None: + """Test shared assets.""" + # The asset function copies a file to the app's external assets directory. + asset = rx.asset(path="custom_script.js", shared=True, subfolder="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.asset(path="custom_script.js", shared=True, subfolder="subfolder") + + # Test the asset function without a subfolder. + asset = rx.asset(path="custom_script.js", shared=True) + 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.asset("non_existent_file.js") + + # Nothing is done to assets when file does not exist. + assert not Path(Path.cwd() / "assets/external").exists() + + +def test_deprecated_x_asset(capsys) -> None: + """Test that the deprecated asset function raises a warning. + + Args: + capsys: Pytest fixture that captures stdout and stderr. + """ + assert rx.asset("custom_script.js", shared=True) == rx._x.asset("custom_script.js") + assert ( + "DeprecationWarning: rx._x.asset has been deprecated in version 0.6.6" + in capsys.readouterr().out + ) + + +@pytest.mark.parametrize( + "path,shared", + [ + pytest.param("non_existing_file", True), + pytest.param("non_existing_file", False), + ], +) +def test_invalid_assets(path: str, shared: bool) -> None: + """Test that asset raises an error when the file does not exist. + + Args: + path: The path to the asset. + shared: Whether the asset should be shared. + """ + with pytest.raises(FileNotFoundError): + _ = rx.asset(path, shared=shared) + + +@pytest.fixture +def custom_script_in_asset_dir() -> Generator[Path, None, None]: + """Create a custom_script.js file in the app's assets directory. + + Yields: + The path to the custom_script.js file. + """ + asset_dir = Path.cwd() / constants.Dirs.APP_ASSETS + asset_dir.mkdir(exist_ok=True) + path = asset_dir / "custom_script.js" + path.touch() + yield path + path.unlink() + + +def test_local_asset(custom_script_in_asset_dir: Path) -> None: + """Test that no error is raised if shared is set and both files exist. + + Args: + custom_script_in_asset_dir: Fixture that creates a custom_script.js file in the app's assets directory. + + """ + asset = rx.asset("custom_script.js", shared=False) + assert asset == "/custom_script.js" 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 92% rename from tests/compiler/test_compiler.py rename to tests/units/compiler/test_compiler.py index 63014cf33..22f5c8483 100644 --- a/tests/compiler/test_compiler.py +++ b/tests/units/compiler/test_compiler.py @@ -1,4 +1,4 @@ -import os +from pathlib import Path from typing import List import pytest @@ -130,12 +130,12 @@ def test_compile_stylesheets(tmp_path, mocker): ] assert compiler.compile_root_stylesheet(stylesheets) == ( - os.path.join(".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('../public/styles.css'); \n" - f"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n", + str(Path(".web") / "styles" / "styles.css"), + "@import url('./tailwind.css'); \n" + "@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n" + "@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n" + "@import url('../public/styles.css'); \n" + "@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n", ) @@ -164,7 +164,7 @@ def test_compile_stylesheets_exclude_tailwind(tmp_path, mocker): ] assert compiler.compile_root_stylesheet(stylesheets) == ( - os.path.join(".web", "styles", "styles.css"), + 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 66% rename from tests/components/base/test_bare.py rename to tests/units/components/base/test_bare.py index 264d136cb..178820cff 100644 --- a/tests/components/base/test_bare.py +++ b/tests/units/components/base/test_bare.py @@ -1,16 +1,18 @@ 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}"), ], ) 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 372178d5f..e9c40188b 100644 --- a/tests/components/base/test_script.py +++ b/tests/units/components/base/test_script.py @@ -2,6 +2,7 @@ import pytest +import reflex as rx from reflex.components.base.script import Script from reflex.state import BaseState @@ -13,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(): @@ -23,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(): @@ -35,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 @@ -58,14 +62,14 @@ def test_script_event_handler(): ) render_dict = component.render() assert ( - f'onReady={{(...args) => addEvents([Event("{EvState.get_full_name()}.on_ready", {{}})], args, {{}})}}' + f'onReady={{((...args) => (addEvents([(Event("{EvState.get_full_name()}.on_ready", ({{ }}), ({{ }})))], args, ({{ }}))))}}' in render_dict["props"] ) assert ( - f'onLoad={{(...args) => addEvents([Event("{EvState.get_full_name()}.on_load", {{}})], args, {{}})}}' + f'onLoad={{((...args) => (addEvents([(Event("{EvState.get_full_name()}.on_load", ({{ }}), ({{ }})))], args, ({{ }}))))}}' in render_dict["props"] ) assert ( - f'onError={{(...args) => addEvents([Event("{EvState.get_full_name()}.on_error", {{}})], args, {{}})}}' + 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 58% rename from tests/components/core/test_banner.py rename to tests/units/components/core/test_banner.py index 184a65cc9..e1498d12c 100644 --- a/tests/components/core/test_banner.py +++ b/tests/units/components/core/test_banner.py @@ -4,24 +4,30 @@ from reflex.components.core.banner import ( ConnectionPulser, WebsocketTargetURL, ) +from reflex.components.radix.themes.base import RadixThemesComponent 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 tuple(_imports) == ("/utils/state", "/env.json") + var_data = url._get_all_var_data() + assert var_data is not None + assert sorted(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 tuple(_imports) == ( - "react", - "/utils/context", - "/utils/state", - "@radix-ui/themes@^3.0.0", - "/env.json", + assert sorted(_imports) == sorted( + ( + "react", + "$/utils/context", + "$/utils/state", + RadixThemesComponent().library or "", + "$/env.json", + ) ) msg = "Connection error" @@ -32,12 +38,14 @@ def test_connection_banner(): def test_connection_modal(): modal = ConnectionModal.create() _imports = modal._get_all_imports(collapse=True) - assert tuple(_imports) == ( - "react", - "/utils/context", - "/utils/state", - "@radix-ui/themes@^3.0.0", - "/env.json", + assert sorted(_imports) == sorted( + ( + "react", + "$/utils/context", + "$/utils/state", + RadixThemesComponent().library or "", + "$/env.json", + ) ) msg = "Connection error" diff --git a/tests/units/components/core/test_colors.py b/tests/units/components/core/test_colors.py new file mode 100644 index 000000000..c1295fb41 --- /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(--"+{color_state_name!s}.color+"-"+(((__to_string) => __to_string.toString())({color_state_name!s}.shade))+")")', + Color, + ), + ( + create_color_var( + rx.color(ColorState.color, ColorState.shade, ColorState.alpha) # type: ignore + ), + f'("var(--"+{color_state_name!s}.color+"-"+({color_state_name!s}.alpha ? "a" : "")+(((__to_string) => __to_string.toString())({color_state_name!s}.shade))+")")', + Color, + ), + ( + create_color_var(rx.color(f"{ColorState.color}", f"{ColorState.shade}")), # type: ignore + f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")', + Color, + ), + ( + create_color_var( + rx.color(f"{ColorState.color_part}ato", f"{ColorState.shade}") # type: ignore + ), + f'("var(--"+({color_state_name!s}.color_part+"ato")+"-"+{color_state_name!s}.shade+")")', + Color, + ), + ( + create_color_var(f'{rx.color(ColorState.color, f"{ColorState.shade}")}'), # type: ignore + f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.shade+")")', + str, + ), + ( + create_color_var( + f'{rx.color(f"{ColorState.color}", f"{ColorState.shade}")}' # type: ignore + ), + f'("var(--"+{color_state_name!s}.color+"-"+{color_state_name!s}.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(--"+{color_state_name!s}.color+"-7)") : ("var(--"+{color_state_name!s}.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(--"+{color_state_name!s}.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(--"+{color_state_name!s}.color+"-7)")); break;case JSON.stringify("second"): ' + f'return (("var(--"+{color_state_name!s}.color+"-5)")); break;default: ' + f'return (("var(--"+{color_state_name!s}.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 79% rename from tests/components/core/test_cond.py rename to tests/units/components/core/test_cond.py index e18be2217..e88f35c9a 100644 --- a/tests/components/core/test_cond.py +++ b/tests/units/components/core/test_cond.py @@ -6,9 +6,9 @@ import pytest from reflex.components.base.fragment import Fragment from reflex.components.core.cond import Cond, cond from reflex.components.radix.themes.typography.text import Text -from reflex.state import BaseState, State +from reflex.state import BaseState from reflex.utils.format import format_state_name -from reflex.vars import BaseVar, Var, computed_var +from reflex.vars.base import LiteralVar, Var, computed_var @pytest.fixture @@ -21,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( @@ -45,7 +45,7 @@ def test_validate_cond(cond_state: BaseState): 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"] @@ -57,7 +57,7 @@ def test_validate_cond(cond_state: BaseState): [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"] @@ -65,7 +65,7 @@ def test_validate_cond(cond_state: BaseState): [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( @@ -75,7 +75,7 @@ def test_validate_cond(cond_state: BaseState): (32, 0), ("hello", ""), (2.3, 0.0), - (Var.create("a"), Var.create("b")), + (LiteralVar.create("a"), LiteralVar.create("b")), ], ) def test_prop_cond(c1: Any, c2: Any): @@ -93,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 ? {c1!s} : {c2!s})" 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(): @@ -124,7 +124,7 @@ def test_cond_no_else(): def test_cond_computed_var(): """Test if cond works with computed vars.""" - class CondStateComputed(State): + class CondStateComputed(BaseState): @computed_var def computed_int(self) -> int: return 0 @@ -135,13 +135,12 @@ def test_cond_computed_var(): comp = cond(True, CondStateComputed.computed_int, CondStateComputed.computed_str) - # TODO: shouln't this be a ComputedVar? - assert isinstance(comp, BaseVar) + # TODO: shouldn't this be a ComputedVar? + assert isinstance(comp, Var) state_name = format_state_name(CondStateComputed.get_full_name()) assert ( - str(comp) - == f"{{isTrue(true) ? {state_name}.computed_int : {state_name}.computed_str}}" + str(comp) == f"(true ? {state_name}.computed_int : {state_name}.computed_str)" ) assert comp._var_type == Union[int, str] diff --git a/tests/components/core/test_debounce.py b/tests/units/components/core/test_debounce.py similarity index 82% rename from tests/components/core/test_debounce.py rename to tests/units/components/core/test_debounce.py index 8ad15ea58..29d3bcddc 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,10 +37,10 @@ class S(BaseState): value: str = "" + @rx.event def on_change(self, v: str): """Dummy on_change handler. - Args: v: The changed value. """ @@ -57,14 +57,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 +73,7 @@ def test_render_with_class_name(): class_name="foo baz", ) )._render() - assert isinstance(tag.props["className"], rx.Var) + assert isinstance(tag.props["className"], rx.vars.Var) assert "foo baz" in str(tag.props["className"]) @@ -88,7 +84,7 @@ def test_render_with_ref(): id="foo_bar", ) )._render() - assert isinstance(tag.props["inputRef"], rx.Var) + assert isinstance(tag.props["inputRef"], rx.vars.Var) assert "foo_bar" in str(tag.props["inputRef"]) @@ -99,12 +95,12 @@ def test_render_with_key(): key="foo_bar", ) )._render() - assert isinstance(tag.props["key"], rx.Var) + assert isinstance(tag.props["key"], rx.vars.Var) assert "foo_bar" in str(tag.props["key"]) def test_render_with_special_props(): - special_prop = rx.Var.create_safe("{foo_bar}", _var_is_string=False) + special_prop = Var(_js_expr="{foo_bar}") tag = rx.debounce_input( rx.input( on_change=S.on_change, @@ -112,7 +108,7 @@ def test_render_with_special_props(): ) )._render() assert len(tag.special_props) == 1 - assert list(tag.special_props)[0].equals(special_prop) + assert next(iter(tag.special_props)).equals(special_prop) def test_event_triggers(): @@ -153,17 +149,13 @@ def test_render_child_props_recursive(): ), force_notify_by_enter=False, )._render() - assert "css" in tag.props and isinstance(tag.props["css"], rx.Var) + assert "css" in tag.props and isinstance(tag.props["css"], rx.vars.Var) for prop in ["foo", "bar", "baz", "quuc"]: assert prop in str(tag.props["css"]) - assert tag.props["value"].equals( - 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 == "" @@ -175,7 +167,7 @@ def test_full_control_implicit_debounce(): value=S.value, on_change=S.on_change, )._render() - assert tag.props["debounceTimeout"]._var_name == str(DEFAULT_DEBOUNCE_TIMEOUT) + assert tag.props["debounceTimeout"]._js_expr == str(DEFAULT_DEBOUNCE_TIMEOUT) assert len(tag.props["onChange"].events) == 1 assert tag.props["onChange"].events[0].handler == S.on_change assert tag.contents == "" @@ -187,7 +179,7 @@ def test_full_control_implicit_debounce_text_area(): value=S.value, on_change=S.on_change, )._render() - assert tag.props["debounceTimeout"]._var_name == str(DEFAULT_DEBOUNCE_TIMEOUT) + assert tag.props["debounceTimeout"]._js_expr == str(DEFAULT_DEBOUNCE_TIMEOUT) assert len(tag.props["onChange"].events) == 1 assert tag.props["onChange"].events[0].handler == S.on_change assert tag.contents == "" diff --git a/tests/components/core/test_foreach.py b/tests/units/components/core/test_foreach.py similarity index 88% rename from tests/components/core/test_foreach.py rename to tests/units/components/core/test_foreach.py index 6e4fa6b5e..094f6029d 100644 --- a/tests/components/core/test_foreach.py +++ b/tests/units/components/core/test_foreach.py @@ -1,8 +1,10 @@ from typing import Dict, List, Set, Tuple, Union +import pydantic.v1 import pytest from reflex import el +from reflex.base import Base from reflex.components.component import Component from reflex.components.core.foreach import ( Foreach, @@ -13,7 +15,15 @@ from reflex.components.core.foreach import ( from reflex.components.radix.themes.layout.box import box from reflex.components.radix.themes.typography.text import text from reflex.state import BaseState, ComponentState -from reflex.vars import Var +from reflex.vars.base import Var +from reflex.vars.number import NumberVar +from reflex.vars.sequence import ArrayVar + + +class ForEachTag(Base): + """A tag for testing the ForEach component.""" + + name: str = "" class ForEachState(BaseState): @@ -44,8 +54,10 @@ class ForEachState(BaseState): bad_annotation_list: list = [["red", "orange"], ["yellow", "blue"]] color_index_tuple: Tuple[int, str] = (0, "red") + default_factory_list: list[ForEachTag] = pydantic.v1.Field(default_factory=list) -class TestComponentState(ComponentState): + +class ComponentStateTest(ComponentState): """A test component state.""" foo: bool @@ -65,7 +77,7 @@ class TestComponentState(ComponentState): def display_color(color): - assert color._var_type == str + assert color._var_type is str return box(text(color)) @@ -104,18 +116,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])) @@ -237,9 +249,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(): @@ -278,7 +290,7 @@ 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(): @@ -286,5 +298,13 @@ def test_foreach_component_state(): with pytest.raises(TypeError): Foreach.create( ForEachState.colors_list, - TestComponentState.create, + ComponentStateTest.create, ) + + +def test_foreach_default_factory(): + """Test that the default factory is called.""" + _ = Foreach.create( + ForEachState.default_factory_list, + lambda tag: text(tag.name), + ) diff --git a/tests/units/components/core/test_html.py b/tests/units/components/core/test_html.py new file mode 100644 index 000000000..79c258dfb --- /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 "+{TestState.myvar!s}+"!

") }})' + ) + 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 72% rename from tests/components/core/test_match.py rename to tests/units/components/core/test_match.py index 883386ebd..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"]) == f"{{{MatchState.get_name()}.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 == f"(({MatchState.get_name()}.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", ), - 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;};})()", + 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,11 +118,11 @@ def test_match_components(): (MatchState.string, f"{MatchState.value} - string"), MatchState.string, ), - 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'(() => {{ 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 100% rename from tests/components/datadisplay/conftest.py rename to tests/units/components/datadisplay/conftest.py diff --git a/tests/units/components/datadisplay/test_code.py b/tests/units/components/datadisplay/test_code.py new file mode 100644 index 000000000..6b7168756 --- /dev/null +++ b/tests/units/components/datadisplay/test_code.py @@ -0,0 +1,13 @@ +import pytest + +from reflex.components.datadisplay.code import CodeBlock, Theme + + +@pytest.mark.parametrize( + "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._js_expr == expected # type: ignore 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 100% rename from tests/components/datadisplay/test_datatable.py rename to tests/units/components/datadisplay/test_datatable.py 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 100% rename from tests/components/graphing/test_plotly.py rename to tests/units/components/graphing/test_plotly.py diff --git a/tests/components/graphing/test_recharts.py b/tests/units/components/graphing/test_recharts.py similarity index 100% rename from tests/components/graphing/test_recharts.py rename to tests/units/components/graphing/test_recharts.py 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/forms/__init__.py b/tests/units/components/markdown/__init__.py similarity index 100% rename from tests/components/forms/__init__.py rename to tests/units/components/markdown/__init__.py diff --git a/tests/units/components/markdown/test_markdown.py b/tests/units/components/markdown/test_markdown.py new file mode 100644 index 000000000..866f32ae1 --- /dev/null +++ b/tests/units/components/markdown/test_markdown.py @@ -0,0 +1,190 @@ +from typing import Type + +import pytest + +from reflex.components.component import Component, memo +from reflex.components.datadisplay.code import CodeBlock +from reflex.components.datadisplay.shiki_code_block import ShikiHighLevelCodeBlock +from reflex.components.markdown.markdown import Markdown, MarkdownComponentMap +from reflex.components.radix.themes.layout.box import Box +from reflex.components.radix.themes.typography.heading import Heading +from reflex.vars.base import Var + + +class CustomMarkdownComponent(Component, MarkdownComponentMap): + """A custom markdown component.""" + + tag = "CustomMarkdownComponent" + library = "custom" + + @classmethod + def get_fn_args(cls) -> tuple[str, ...]: + """Return the function arguments. + + Returns: + The function arguments. + """ + return ("custom_node", "custom_children", "custom_props") + + @classmethod + def get_fn_body(cls) -> Var: + """Return the function body. + + Returns: + The function body. + """ + return Var(_js_expr="{return custom_node + custom_children + custom_props}") + + +def syntax_highlighter_memoized_component(codeblock: Type[Component]): + @memo + def code_block(code: str, language: str): + return Box.create( + codeblock.create( + code, + language=language, + class_name="code-block", + can_copy=True, + ), + class_name="relative mb-4", + ) + + def code_block_markdown(*children, **props): + return code_block( + code=children[0], language=props.pop("language", "plain"), **props + ) + + return code_block_markdown + + +@pytest.mark.parametrize( + "fn_body, fn_args, explicit_return, expected", + [ + ( + None, + None, + False, + Var(_js_expr="(({node, children, ...props}) => undefined)"), + ), + ("return node", ("node",), True, Var(_js_expr="(({node}) => {return node})")), + ( + "return node + children", + ("node", "children"), + True, + Var(_js_expr="(({node, children}) => {return node + children})"), + ), + ( + "return node + props", + ("node", "...props"), + True, + Var(_js_expr="(({node, ...props}) => {return node + props})"), + ), + ( + "return node + children + props", + ("node", "children", "...props"), + True, + Var( + _js_expr="(({node, children, ...props}) => {return node + children + props})" + ), + ), + ], +) +def test_create_map_fn_var(fn_body, fn_args, explicit_return, expected): + result = MarkdownComponentMap.create_map_fn_var( + fn_body=Var(_js_expr=fn_body, _var_type=str) if fn_body else None, + fn_args=fn_args, + explicit_return=explicit_return, + ) + assert result._js_expr == expected._js_expr + + +@pytest.mark.parametrize( + ("cls", "fn_body", "fn_args", "explicit_return", "expected"), + [ + ( + MarkdownComponentMap, + None, + None, + False, + Var(_js_expr="(({node, children, ...props}) => undefined)"), + ), + ( + MarkdownComponentMap, + "return node", + ("node",), + True, + Var(_js_expr="(({node}) => {return node})"), + ), + ( + CustomMarkdownComponent, + None, + None, + True, + Var( + _js_expr="(({custom_node, custom_children, custom_props}) => {return custom_node + custom_children + custom_props})" + ), + ), + ( + CustomMarkdownComponent, + "return custom_node", + ("custom_node",), + True, + Var(_js_expr="(({custom_node}) => {return custom_node})"), + ), + ], +) +def test_create_map_fn_var_subclass(cls, fn_body, fn_args, explicit_return, expected): + result = cls.create_map_fn_var( + fn_body=Var(_js_expr=fn_body, _var_type=int) if fn_body else None, + fn_args=fn_args, + explicit_return=explicit_return, + ) + assert result._js_expr == expected._js_expr + + +@pytest.mark.parametrize( + "key,component_map, expected", + [ + ( + "code", + {}, + """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; if (_language) { (async () => { try { const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${_language}`); SyntaxHighlighter.registerLanguage(_language, module.default); } catch (error) { console.error(`Error importing language module for ${_language}:`, error); } })(); } ; return inline ? ( {children} ) : ( ); })""", + ), + ( + "code", + { + "codeblock": lambda value, **props: ShikiHighLevelCodeBlock.create( + value, **props + ) + }, + """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; ; return inline ? ( {children} ) : ( ); })""", + ), + ( + "h1", + { + "h1": lambda value: CustomMarkdownComponent.create( + Heading.create(value, as_="h1", size="6", margin_y="0.5em") + ) + }, + """(({custom_node, custom_children, custom_props}) => ({children}))""", + ), + ( + "code", + {"codeblock": syntax_highlighter_memoized_component(CodeBlock)}, + """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; if (_language) { (async () => { try { const module = await import(`react-syntax-highlighter/dist/cjs/languages/prism/${_language}`); SyntaxHighlighter.registerLanguage(_language, module.default); } catch (error) { console.error(`Error importing language module for ${_language}:`, error); } })(); } ; return inline ? ( {children} ) : ( ); })""", + ), + ( + "code", + { + "codeblock": syntax_highlighter_memoized_component( + ShikiHighLevelCodeBlock + ) + }, + """(({node, inline, className, children, ...props}) => { const match = (className || '').match(/language-(?.*)/); const _language = match ? match[1] : ''; ; return inline ? ( {children} ) : ( ); })""", + ), + ], +) +def test_markdown_format_component(key, component_map, expected): + markdown = Markdown.create("# header", component_map=component_map) + result = markdown.format_component_map() + assert str(result[key]) == expected 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..742bd8c38 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 #noqa: ERA001 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 78% rename from tests/components/test_component.py rename to tests/units/components/test_component.py index 78c42f177..674873b69 100644 --- a/tests/components/test_component.py +++ b/tests/units/components/test_component.py @@ -8,20 +8,29 @@ 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, + input_event, + no_args_event_spec, + parse_args_spec, + passthrough_event_spec, +) from reflex.state import BaseState from reflex.style import Style from reflex.utils import imports +from reflex.utils.exceptions import EventFnArgMismatch from reflex.utils.imports import ImportDict, ImportVar, ParsedImportDict, parse_imports -from reflex.vars import BaseVar, Var, VarData +from reflex.vars import VarData +from reflex.vars.base import LiteralVar, Var @pytest.fixture @@ -35,6 +44,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 @@ -77,6 +98,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,8 +108,10 @@ def component2() -> Type[Component]: """ return { **super().get_event_triggers(), - "on_open": lambda e0: [e0], - "on_close": lambda e0: [e0], + "on_open": passthrough_event_spec(bool), + "on_close": passthrough_event_spec(bool), + "on_user_visited_count_changed": passthrough_event_spec(int), + "on_user_list_changed": passthrough_event_spec(List[str]), } def _get_imports(self) -> ParsedImportDict: @@ -229,8 +254,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 +279,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 +290,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 +446,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 +463,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 +519,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( @@ -569,7 +597,14 @@ def test_get_event_triggers(component1, component2): assert component1().get_event_triggers().keys() == default_triggers assert ( component2().get_event_triggers().keys() - == {"on_open", "on_close"} | default_triggers + == { + "on_open", + "on_close", + "on_prop_event", + "on_user_visited_count_changed", + "on_user_list_changed", + } + | default_triggers ) @@ -606,8 +641,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 +664,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 +690,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": [], }, ), ], @@ -790,7 +810,8 @@ def test_component_create_unpack_tuple_child(test_component, element, expected): comp = test_component.create(element) assert len(comp.children) == 1 - assert isinstance((fragment_wrapper := comp.children[0]), Fragment) + fragment_wrapper = comp.children[0] + assert isinstance(fragment_wrapper, Fragment) assert fragment_wrapper.render() == expected @@ -824,9 +845,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(" - f'[Event("{C1State.get_full_name()}.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 +887,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 +904,104 @@ 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(EventFnArgMismatch): component2.create(on_click=test_state.do_something_arg) - component2.create(on_open=test_state.do_something) + + # Multiple EventHandler args: all must match + with pytest.raises(EventFnArgMismatch): component2.create( - on_open=[test_state.do_something_arg, test_state.do_something] + on_click=[test_state.do_something_arg, test_state.do_something] ) - # However lambdas are okay. + + # 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 # noqa: ERA001 RUF100 + # ) # noqa: ERA001 RUF100 + # with pytest.raises(EventHandlerArgTypeMismatch): + # component2.create(on_user_list_changed=test_state.do_something_with_int) #noqa: ERA001 + # with pytest.raises(EventHandlerArgTypeMismatch): + # component2.create(on_user_list_changed=test_state.do_something_with_list_int) #noqa: ERA001 + + # component2.create(on_open=test_state.do_something_with_int) #noqa: ERA001 + # component2.create(on_open=test_state.do_something_with_bool) #noqa: ERA001 + # component2.create(on_user_visited_count_changed=test_state.do_something_with_int) #noqa: ERA001 + # component2.create(on_user_list_changed=test_state.do_something_with_list_str) #noqa: ERA001 + + # 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)) + + # lambda returning EventHandler must match spec + with pytest.raises(EventFnArgMismatch): + component2.create(on_click=lambda: test_state.do_something_arg) + + # Mixed EventSpec and EventHandler must match spec. + with pytest.raises(EventFnArgMismatch): + component2.create( + on_click=lambda: [ + test_state.do_something_arg(1), + test_state.do_something_arg, + ] + ) + + +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)) + + # Does not raise because event handlers are allowed to have less args than the spec. + component2.create(on_open=test_state.do_something) + component2.create(on_prop_event=test_state.do_something) + + # 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()) + + # Multiple EventHandler args: all must match + component2.create(on_open=[test_state.do_something_arg, test_state.do_something]) + component2.create( + on_prop_event=[test_state.do_something_arg, 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) + component2.create(on_open=lambda: test_state.do_something) + component2.create(on_prop_event=lambda: test_state.do_something) + component2.create(on_open=lambda _: test_state.do_something) + component2.create(on_prop_event=lambda _: test_state.do_something) + + # 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 +1009,33 @@ 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()] + ) + 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, + ] + ) def test_get_hooks_nested(component1, component2, component3): @@ -1002,10 +1133,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 +1191,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")]}, 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": "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 +1246,7 @@ class EventState(rx.State): v: int = 42 + @rx.event def handler(self): """A handler that does nothing.""" @@ -1181,12 +1312,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,11 +1430,12 @@ 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), ): assert comp_var.equals(exp_var) @@ -1334,9 +1476,11 @@ def test_instantiate_all_components(): continue component = getattr( rx, - component_name - if not isinstance(component_name, tuple) - else component_name[1], + ( + component_name + if not isinstance(component_name, tuple) + else component_name[1] + ), ) if isinstance(component, type) and issubclass(component, Component): component.create() @@ -1404,7 +1548,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 ), ) ) @@ -1464,7 +1608,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)), ) ), @@ -1531,7 +1675,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 ), ) ) @@ -1594,70 +1740,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(): @@ -1709,7 +1799,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: [], @@ -1718,9 +1808,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[no_args_event_spec] + on_d: EventHandler[no_args_event_spec] on_e: EventHandler on_f: EventHandler[lambda a, b, c: [c, b, a]] @@ -1969,8 +2059,8 @@ def test_component_add_hooks_var(): return [ "const hook3 = useRef(null)", "const hook1 = 42", - Var.create( - "useEffect(() => () => {}, [])", + Var( + _js_expr="useEffect(() => () => {}, [])", _var_data=VarData( hooks={ "const hook2 = 43": None, @@ -1979,11 +2069,9 @@ def test_component_add_hooks_var(): imports={"react": [ImportVar(tag="useEffect")]}, ), ), - Var.create( - "const hook3 = useRef(null)", - _var_data=VarData( - imports={"react": [ImportVar(tag="useRef")]}, - ), + Var( + _js_expr="const hook3 = useRef(null)", + _var_data=VarData(imports={"react": [ImportVar(tag="useRef")]}), ), ] @@ -2007,11 +2095,11 @@ def test_add_style_embedded_vars(test_state: BaseState): 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 ) @@ -2044,7 +2132,7 @@ def test_add_style_embedded_vars(test_state: BaseState): assert "useParent" in page._get_all_hooks_internal() assert ( str(page).count( - f'css={{{{"fakeParent": "parent", "color": "var(--plum-10)", "fake": "text", "margin": `${{{test_state.get_name()}.num}}%`}}}}' + f'css={{({{ ["fakeParent"] : "parent", ["color"] : "var(--plum-10)", ["fake"] : "text", ["margin"] : ({test_state.get_name()}.num+"%") }})}}' ) == 1 ) @@ -2065,15 +2153,16 @@ 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 @@ -2092,7 +2181,7 @@ class TriggerState(rx.State): rx.text("random text", on_click=TriggerState.do_something), rx.text( "random text", - on_click=BaseVar(_var_name="toggleColorMode", _var_type=EventChain), + on_click=Var(_js_expr="toggleColorMode").to(EventChain), ), ), True, @@ -2102,7 +2191,7 @@ class TriggerState(rx.State): rx.text("random text", on_click=rx.console_log("log")), rx.text( "random text", - on_click=BaseVar(_var_name="toggleColorMode", _var_type=EventChain), + on_click=Var(_js_expr="toggleColorMode").to(EventChain), ), ), False, @@ -2142,3 +2231,56 @@ class TriggerState(rx.State): ) 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 82% rename from tests/components/test_component_future_annotations.py rename to tests/units/components/test_component_future_annotations.py index 37aeb813a..0867a2d37 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, input_event, no_args_event_spec # 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[no_args_event_spec] + on_d: EventHandler[no_args_event_spec] 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 66% rename from tests/components/test_component_state.py rename to tests/units/components/test_component_state.py index 0dc0956e2..1b62e35c8 100644 --- a/tests/components/test_component_state.py +++ b/tests/units/components/test_component_state.py @@ -1,7 +1,10 @@ """Ensure that Components returned by ComponentState.create have independent State classes.""" +import pytest + import reflex as rx from reflex.components.base.bare import Bare +from reflex.utils.exceptions import ReflexRuntimeError def test_component_state(): @@ -35,8 +38,26 @@ 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" + + +def test_init_component_state() -> None: + """Ensure that ComponentState subclasses cannot be instantiated directly.""" + + class CS(rx.ComponentState): + @classmethod + def get_component(cls, *children, **props): + return rx.el.div() + + with pytest.raises(ReflexRuntimeError): + CS() + + class SubCS(CS): + pass + + with pytest.raises(ReflexRuntimeError): + SubCS() 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/typography/__init__.py b/tests/units/components/typography/__init__.py similarity index 100% rename from tests/components/typography/__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 96% rename from tests/conftest.py rename to tests/units/conftest.py index 589d35cd7..fb6229aca 100644 --- a/tests/conftest.py +++ b/tests/units/conftest.py @@ -1,5 +1,6 @@ """Test fixtures.""" +import asyncio import contextlib import os import platform @@ -24,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. @@ -200,7 +206,7 @@ class chdir(contextlib.AbstractContextManager): def __enter__(self): """Save current directory and perform chdir.""" - self._old_cwd.append(Path(".").resolve()) + self._old_cwd.append(Path.cwd()) os.chdir(self.path) def __exit__(self, *excinfo): diff --git a/tests/middleware/__init__.py b/tests/units/middleware/__init__.py similarity index 100% rename from tests/middleware/__init__.py rename to tests/units/middleware/__init__.py diff --git a/tests/middleware/conftest.py b/tests/units/middleware/conftest.py similarity index 100% rename from tests/middleware/conftest.py rename to tests/units/middleware/conftest.py 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 100% rename from tests/states/__init__.py rename to tests/units/states/__init__.py diff --git a/tests/states/mutation.py b/tests/units/states/mutation.py similarity index 100% rename from tests/states/mutation.py rename to tests/units/states/mutation.py diff --git a/tests/states/upload.py b/tests/units/states/upload.py similarity index 87% rename from tests/states/upload.py rename to tests/units/states/upload.py index f81e9f235..66d9479b4 100644 --- a/tests/states/upload.py +++ b/tests/units/states/upload.py @@ -61,17 +61,16 @@ class FileUploadState(State): """ for file in files: upload_data = await file.read() - outfile = f"{self._tmp_path}/{file.filename}" + assert file.filename is not None + outfile = self._tmp_path / file.filename # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) + outfile.write_bytes(upload_data) # Update the img var. - 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. @@ -109,17 +108,16 @@ class ChildFileUploadState(FileStateBase1): """ for file in files: upload_data = await file.read() - outfile = f"{self._tmp_path}/{file.filename}" + assert file.filename is not None + outfile = self._tmp_path / file.filename # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) + outfile.write_bytes(upload_data) # Update the img var. - 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. @@ -157,17 +155,16 @@ class GrandChildFileUploadState(FileStateBase2): """ for file in files: upload_data = await file.read() - outfile = f"{self._tmp_path}/{file.filename}" + assert file.filename is not None + outfile = self._tmp_path / file.filename # Save the file. - with open(outfile, "wb") as file_object: - file_object.write(upload_data) + outfile.write_bytes(upload_data) # Update the img var. - 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 92% rename from tests/test_app.py rename to tests/units/test_app.py index 489ace511..48a4bdda1 100644 --- a/tests/test_app.py +++ b/tests/units/test_app.py @@ -41,6 +41,7 @@ from reflex.state import ( OnLoadInternalState, RouterData, State, + StateManagerDisk, StateManagerMemory, StateManagerRedis, StateUpdate, @@ -48,7 +49,7 @@ from reflex.state import ( ) from reflex.style import Style from reflex.utils import exceptions, format -from reflex.vars import computed_var +from reflex.vars.base import computed_var from .conftest import chdir from .states import ( @@ -67,7 +68,7 @@ class EmptyState(BaseState): @pytest.fixture -def index_page(): +def index_page() -> ComponentCallable: """An index page. Returns: @@ -81,7 +82,7 @@ def index_page(): @pytest.fixture -def about_page(): +def about_page() -> ComponentCallable: """An about page. Returns: @@ -236,9 +237,12 @@ 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) + app._compile_page("index") assert app.pages.keys() == {"index"} app.add_page(about_page) + app._compile_page("about") assert app.pages.keys() == {"index", "about"} @@ -251,8 +255,9 @@ 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) + app._compile_page("test") assert app.pages.keys() == {"test"} @@ -266,10 +271,9 @@ 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) + 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) == { @@ -287,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 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): @@ -766,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" @@ -782,11 +787,11 @@ async def test_upload_file(tmp_path, state, delta, token: str, mocker): } file1 = UploadFile( - filename=f"image1.jpg", + filename="image1.jpg", file=bio, ) file2 = UploadFile( - filename=f"image2.jpg", + filename="image2.jpg", file=bio, ) upload_fn = upload(app) @@ -869,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): @@ -894,32 +899,78 @@ class DynamicState(BaseState): loaded: int = 0 counter: int = 0 - # side_effect_counter: int = 0 - def on_load(self): """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 - @computed_var + @computed_var(cache=True) def comp_dynamic(self) -> str: """A computed var that depends on the dynamic var. Returns: same as self.dynamic """ - # self.side_effect_counter = self.side_effect_counter + 1 return self.dynamic 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, @@ -939,8 +990,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 @@ -955,8 +1004,9 @@ async def test_dynamic_route_var_route_change_completed_on_load( substate_token = _substate_key(token, DynamicState) sid = "mock_sid" client_ip = "127.0.0.1" - state = await app.state_manager.get_state(substate_token) - assert state.dynamic == "" + async with app.state_manager.modify_state(substate_token) as state: + state.router_data = {"simulate": "hydrated"} + assert state.dynamic == "" exp_vals = ["foo", "foobar", "baz"] def _event(name, val, **kwargs): @@ -1006,7 +1056,6 @@ async def test_dynamic_route_var_route_change_completed_on_load( arg_name: exp_val, f"comp_{arg_name}": exp_val, constants.CompileVars.IS_HYDRATED: False, - # "side_effect_counter": exp_index, "router": exp_router, } }, @@ -1047,9 +1096,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, }, }, @@ -1071,9 +1117,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, }, }, @@ -1095,9 +1138,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, } }, @@ -1111,8 +1151,6 @@ async def test_dynamic_route_var_route_change_completed_on_load( state = await app.state_manager.get_state(substate_token) assert state.loaded == len(exp_vals) assert state.counter == len(exp_vals) - # print(f"Expected {exp_vals} rendering side effects, got {state.side_effect_counter}") - # assert state.side_effect_counter == len(exp_vals) if isinstance(app.state_manager, StateManagerRedis): await app.state_manager.close() @@ -1137,6 +1175,7 @@ async def test_process_events(mocker, token: str): "ip": "127.0.0.1", } app = App(state=GenState) + mocker.patch.object(app, "_postprocess", AsyncMock()) event = Event( token=token, @@ -1144,6 +1183,8 @@ async def test_process_events(mocker, token: str): payload={"c": 5}, router_data=router_data, ) + async with app.state_manager.modify_state(event.substate_token) as state: + state.router_data = {"simulate": "hydrated"} async for _update in process(app, event, "mock_sid", {}, "127.0.0.1"): pass @@ -1168,7 +1209,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, ): @@ -1200,6 +1241,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"] @@ -1251,7 +1293,7 @@ def test_app_wrap_compile_theme(compilable_app: tuple[App, Path]): "function AppWrap({children}) {" "return (" "" - "" + "" "" "{children}" "" @@ -1274,13 +1316,13 @@ def test_app_wrap_priority(compilable_app: tuple[App, Path]): tag = "Fragment1" def _get_app_wrap_components(self) -> dict[tuple[int, str], Component]: - return {(99, "Box"): 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" @@ -1300,19 +1342,17 @@ def test_app_wrap_priority(compilable_app: tuple[App, Path]): assert ( "function AppWrap({children}) {" "return (" - "" - "" - "" - "" + "" + '' + "" "" "" "{children}" "" "" - "" - "" - "" - "" + "" + "" + "" ")" "}" ) in "".join(app_js_lines) @@ -1329,6 +1369,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() @@ -1336,6 +1377,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() @@ -1343,6 +1385,7 @@ 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() @@ -1354,16 +1397,10 @@ def test_app_state_determination(): 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. @@ -1394,7 +1431,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(): @@ -1431,18 +1470,24 @@ def test_add_page_component_returning_tuple(): app.add_page(index) # type: ignore app.add_page(page2) # type: ignore - 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 isinstance((second_text := fragment_wrapper.children[1]), Text) - assert str(second_text.children[0].contents) == "{`second`}" # type: ignore + app._compile_page("index") + app._compile_page("page2") + + fragment_wrapper = app.pages["index"].children[0] + assert isinstance(fragment_wrapper, Fragment) + first_text = fragment_wrapper.children[0] + assert isinstance(first_text, Text) + assert str(first_text.children[0].contents) == '"first"' # type: ignore + second_text = fragment_wrapper.children[1] + assert isinstance(second_text, Text) + 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 + page2_fragment_wrapper = app.pages["page2"].children[0] + assert isinstance(page2_fragment_wrapper, Fragment) + third_text = page2_fragment_wrapper.children[0] + assert isinstance(third_text, Text) + assert str(third_text.children[0].contents) == '"third"' # type: ignore @pytest.mark.parametrize("export", (True, False)) diff --git a/tests/test_attribute_access_type.py b/tests/units/test_attribute_access_type.py similarity index 58% rename from tests/test_attribute_access_type.py rename to tests/units/test_attribute_access_type.py index 0813a5e62..d08c17c8c 100644 --- a/tests/test_attribute_access_type.py +++ b/tests/units/test_attribute_access_type.py @@ -3,11 +3,19 @@ from __future__ import annotations from typing import Dict, List, Optional, Type, Union import attrs +import pydantic.v1 import pytest import sqlalchemy +import sqlmodel from sqlalchemy import JSON, TypeDecorator from sqlalchemy.ext.hybrid import hybrid_property -from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship +from sqlalchemy.orm import ( + DeclarativeBase, + Mapped, + MappedAsDataclass, + mapped_column, + relationship, +) import reflex as rx from reflex.utils.types import GenericType, get_attribute_access_type @@ -53,6 +61,10 @@ class SQLALabel(SQLABase): id: Mapped[int] = mapped_column(primary_key=True) test_id: Mapped[int] = mapped_column(sqlalchemy.ForeignKey("test.id")) test: Mapped[SQLAClass] = relationship(back_populates="labels") + test_dataclass_id: Mapped[int] = mapped_column( + sqlalchemy.ForeignKey("test_dataclass.id") + ) + test_dataclass: Mapped[SQLAClassDataclass] = relationship(back_populates="labels") class SQLAClass(SQLABase): @@ -94,10 +106,74 @@ 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 SQLAClassDataclass(MappedAsDataclass, SQLABase): + """Test sqlalchemy model.""" + + id: Mapped[int] = mapped_column(primary_key=True) + no_default: Mapped[int] = mapped_column(nullable=True) + count: Mapped[int] = mapped_column() + name: Mapped[str] = mapped_column() + int_list: Mapped[List[int]] = mapped_column( + sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER) + ) + str_list: Mapped[List[str]] = mapped_column( + sqlalchemy.types.ARRAY(item_type=sqlalchemy.String) + ) + optional_int: Mapped[Optional[int]] = mapped_column(nullable=True) + 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_dataclass") + # do not use lower case dict here! + # https://github.com/sqlalchemy/sqlalchemy/issues/9902 + dict_str_str: Mapped[Dict[str, str]] = mapped_column() + default_factory: Mapped[List[int]] = mapped_column( + sqlalchemy.types.ARRAY(item_type=sqlalchemy.INTEGER), + default_factory=list, + ) + __tablename__: str = "test_dataclass" + + @property + def str_property(self) -> str: + """String property. + + Returns: + Name attribute + """ + return self.name + + @hybrid_property + def str_or_int_property(self) -> Union[str, int]: + """String or int property. + + Returns: + Name attribute + """ + 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.""" + no_default: Optional[int] = sqlmodel.Field(nullable=True) count: int = 0 name: str = "test" int_list: List[int] = [] @@ -106,6 +182,7 @@ class ModelClass(rx.Model): sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] dict_str_str: Dict[str, str] = {} + default_factory: List[int] = sqlmodel.Field(default_factory=list) @property def str_property(self) -> str: @@ -125,10 +202,20 @@ 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.""" + no_default: Optional[int] = pydantic.v1.Field(required=False) count: int = 0 name: str = "test" int_list: List[int] = [] @@ -137,6 +224,7 @@ class BaseClass(rx.Base): sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] dict_str_str: Dict[str, str] = {} + default_factory: List[int] = pydantic.v1.Field(default_factory=list) @property def str_property(self) -> str: @@ -156,6 +244,15 @@ class BaseClass(rx.Base): """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. + + Returns: + First label + """ + return self.labels[0] if self.labels else None + class BareClass: """Bare python class.""" @@ -187,6 +284,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: @@ -200,6 +306,7 @@ class AttrClass: sqla_tag: Optional[SQLATag] = None labels: List[SQLALabel] = [] dict_str_str: Dict[str, str] = {} + default_factory: List[int] = attrs.field(factory=list) @property def str_property(self) -> str: @@ -219,28 +326,27 @@ class AttrClass: """ return self.name + @property + def first_label(self) -> Optional[SQLALabel]: + """First label property. -@pytest.fixture( - params=[ + Returns: + First label + """ + return self.labels[0] if self.labels else None + + +@pytest.mark.parametrize( + "cls", + [ SQLAClass, + SQLAClassDataclass, BaseClass, BareClass, ModelClass, AttrClass, - ] + ], ) -def cls(request: pytest.FixtureRequest) -> type: - """Fixture for the class to test. - - Args: - request: pytest request object. - - Returns: - Class to test. - """ - return request.param - - @pytest.mark.parametrize( "attr, expected", [ @@ -254,6 +360,7 @@ def cls(request: pytest.FixtureRequest) -> type: pytest.param("dict_str_str", Dict[str, str], id="Dict[str, str]"), pytest.param("str_property", str, id="str_property"), pytest.param("str_or_int_property", Union[str, int], id="str_or_int_property"), + pytest.param("first_label", Optional[SQLALabel], id="first_label"), ], ) def test_get_attribute_access_type(cls: type, attr: str, expected: GenericType) -> None: @@ -265,3 +372,38 @@ def test_get_attribute_access_type(cls: type, attr: str, expected: GenericType) expected: Expected type. """ assert get_attribute_access_type(cls, attr) == expected + + +@pytest.mark.parametrize( + "cls", + [ + SQLAClassDataclass, + BaseClass, + ModelClass, + AttrClass, + ], +) +def test_get_attribute_access_type_default_factory(cls: type) -> None: + """Test get_attribute_access_type returns the correct type for default factory fields. + + Args: + cls: Class to test. + """ + assert get_attribute_access_type(cls, "default_factory") == List[int] + + +@pytest.mark.parametrize( + "cls", + [ + SQLAClassDataclass, + BaseClass, + ModelClass, + ], +) +def test_get_attribute_access_type_no_default(cls: type) -> None: + """Test get_attribute_access_type returns the correct type for fields with no default which are not required. + + Args: + cls: Class to test. + """ + assert get_attribute_access_type(cls, "no_default") == Optional[int] 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 65% rename from tests/test_config.py rename to tests/units/test_config.py index 31dd77649..e5d4622bd 100644 --- a/tests/test_config.py +++ b/tests/units/test_config.py @@ -1,11 +1,21 @@ 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 ( + EnvVar, + env_var, + environment, + interpret_boolean_env, + interpret_enum_env, + interpret_int_env, +) +from reflex.constants import Endpoint, Env def test_requires_app_name(): @@ -41,7 +51,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 +71,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 +215,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.get() -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: @@ -191,5 +229,54 @@ def test_reflex_dir_env_var(monkeypatch, tmp_path): monkeypatch.setenv("REFLEX_DIR", str(tmp_path)) mp_ctx = multiprocessing.get_context(method="spawn") + assert reflex_dir_constant() == tmp_path 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 + + +def test_env_var(): + class TestEnv: + BLUBB: EnvVar[str] = env_var("default") + INTERNAL: EnvVar[str] = env_var("default", internal=True) + BOOLEAN: EnvVar[bool] = env_var(False) + + assert TestEnv.BLUBB.get() == "default" + assert TestEnv.BLUBB.name == "BLUBB" + TestEnv.BLUBB.set("new") + assert os.environ.get("BLUBB") == "new" + assert TestEnv.BLUBB.get() == "new" + TestEnv.BLUBB.set(None) + assert "BLUBB" not in os.environ + + assert TestEnv.INTERNAL.get() == "default" + assert TestEnv.INTERNAL.name == "__INTERNAL" + TestEnv.INTERNAL.set("new") + assert os.environ.get("__INTERNAL") == "new" + assert TestEnv.INTERNAL.get() == "new" + assert TestEnv.INTERNAL.getenv() == "new" + TestEnv.INTERNAL.set(None) + assert "__INTERNAL" not in os.environ + + assert TestEnv.BOOLEAN.get() is False + assert TestEnv.BOOLEAN.name == "BOOLEAN" + TestEnv.BOOLEAN.set(True) + assert os.environ.get("BOOLEAN") == "True" + assert TestEnv.BOOLEAN.get() is True + TestEnv.BOOLEAN.set(False) + assert os.environ.get("BOOLEAN") == "False" + assert TestEnv.BOOLEAN.get() is False + TestEnv.BOOLEAN.set(None) + assert "BOOLEAN" not in os.environ diff --git a/tests/test_db_config.py b/tests/units/test_db_config.py similarity index 90% rename from tests/test_db_config.py rename to tests/units/test_db_config.py index b8d7c07cb..5b716e6bb 100644 --- a/tests/test_db_config.py +++ b/tests/units/test_db_config.py @@ -164,7 +164,7 @@ def test_constructor_postgresql(username, password, host, port, database, expect "localhost", 5432, "db", - "postgresql+psycopg2://user:pass@localhost:5432/db", + "postgresql+psycopg://user:pass@localhost:5432/db", ), ( "user", @@ -172,17 +172,17 @@ def test_constructor_postgresql(username, password, host, port, database, expect "localhost", None, "db", - "postgresql+psycopg2://user@localhost/db", + "postgresql+psycopg://user@localhost/db", ), - ("user", "", "", None, "db", "postgresql+psycopg2://user@/db"), - ("", "", "localhost", 5432, "db", "postgresql+psycopg2://localhost:5432/db"), - ("", "", "", None, "db", "postgresql+psycopg2:///db"), + ("user", "", "", None, "db", "postgresql+psycopg://user@/db"), + ("", "", "localhost", 5432, "db", "postgresql+psycopg://localhost:5432/db"), + ("", "", "", None, "db", "postgresql+psycopg:///db"), ], ) -def test_constructor_postgresql_psycopg2( +def test_constructor_postgresql_psycopg( username, password, host, port, database, expected_url ): - """Test DBConfig.postgresql_psycopg2 constructor creates the instance correctly. + """Test DBConfig.postgresql_psycopg constructor creates the instance correctly. Args: username: Database username. @@ -192,10 +192,10 @@ def test_constructor_postgresql_psycopg2( database: Database name. expected_url: Expected database URL generated. """ - db_config = DBConfig.postgresql_psycopg2( + db_config = DBConfig.postgresql_psycopg( username=username, password=password, host=host, port=port, database=database ) - assert db_config.engine == "postgresql+psycopg2" + assert db_config.engine == "postgresql+psycopg" assert db_config.username == username assert db_config.password == password assert db_config.host == host diff --git a/tests/test_event.py b/tests/units/test_event.py similarity index 62% rename from tests/test_event.py rename to tests/units/test_event.py index 284542a43..c5198a571 100644 --- a/tests/test_event.py +++ b/tests/units/test_event.py @@ -1,13 +1,20 @@ -import json -from typing import List +from typing import Callable, List import pytest -from reflex import event -from reflex.event import Event, EventHandler, EventSpec, call_event_handler, fix_events +import reflex as rx +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 +26,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 +62,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 +75,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 +83,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,29 +105,32 @@ 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) + handler = EventHandler(fn=test_fn_with_args, state_full_name="BigState") event_spec = handler(make_var("first")) event_spec2 = call_event_handler(event_spec, spec) 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 format.format_event(event_spec) == 'Event("test_fn_with_args", {arg1: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("BigState.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})' + == 'Event("BigState.test_fn_with_args", {arg1:first,arg2:_a2})' ) @@ -160,27 +168,27 @@ def test_fix_events(arg1, arg2): [ ( ("/path", None, None), - 'Event("_redirect", {path:`/path`,external:false,replace:false})', + 'Event("_redirect", {path:"/path",external:false,replace:false})', ), ( ("/path", True, None), - 'Event("_redirect", {path:`/path`,external:true,replace:false})', + 'Event("_redirect", {path:"/path",external:true,replace:false})', ), ( ("/path", False, None), - 'Event("_redirect", {path:`/path`,external:false,replace:false})', + 'Event("_redirect", {path:"/path",external:false,replace:false})', ), ( - (Var.create_safe("path"), None, None), + (Var(_js_expr="path"), None, None), 'Event("_redirect", {path:path,external:false,replace:false})', ), ( ("/path", None, True), - 'Event("_redirect", {path:`/path`,external:false,replace:true})', + 'Event("_redirect", {path:"/path",external:false,replace:true})', ), ( ("/path", True, True), - 'Event("_redirect", {path:`/path`,external:true,replace:true})', + 'Event("_redirect", {path:"/path",external:true,replace:true})', ), ], ) @@ -201,10 +209,6 @@ def test_event_redirect(input, output): 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 format.format_event(spec) == output @@ -212,24 +216,40 @@ def test_event_console_log(): """Test the event console log function.""" 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 format.format_event(spec) == 'Event("_console", {message:message})' + assert spec.handler.fn.__qualname__ == "_call_function" + assert spec.args[0][0].equals(Var(_js_expr="function")) + assert spec.args[0][1].equals( + Var('(() => (console["log"]("message")))', _var_type=Callable) + ) + assert ( + format.format_event(spec) + == 'Event("_call_function", {function:(() => (console["log"]("message")))})' + ) + spec = event.console_log(Var(_js_expr="message")) + assert ( + format.format_event(spec) + == 'Event("_call_function", {function:(() => (console["log"](message)))})' + ) def test_event_window_alert(): """Test the event window alert function.""" 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 format.format_event(spec) == 'Event("_alert", {message:message})' + assert spec.handler.fn.__qualname__ == "_call_function" + assert spec.args[0][0].equals(Var(_js_expr="function")) + assert spec.args[0][1].equals( + Var('(() => (window["alert"]("message")))', _var_type=Callable) + ) + assert ( + format.format_event(spec) + == 'Event("_call_function", {function:(() => (window["alert"]("message")))})' + ) + spec = event.window_alert(Var(_js_expr="message")) + assert ( + format.format_event(spec) + == 'Event("_call_function", {function:(() => (window["alert"](message)))})' + ) def test_set_focus(): @@ -237,11 +257,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(): @@ -249,17 +269,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})' ) @@ -268,13 +288,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"] : "/" })})' ) @@ -289,13 +309,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:{LiteralVar.create(options)!s}}})' ) @@ -313,10 +333,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"})' ) @@ -391,3 +411,42 @@ 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() + + +def test_event_bound_method() -> None: + class S(BaseState): + @event + def e(self, arg: str): + print(arg) + + class Wrapper: + def get_handler(self, arg: str): + return S.e(arg) + + w = Wrapper() + _ = rx.input(on_change=w.get_handler) diff --git a/tests/units/test_health_endpoint.py b/tests/units/test_health_endpoint.py new file mode 100644 index 000000000..6d12d79d6 --- /dev/null +++ b/tests/units/test_health_endpoint.py @@ -0,0 +1,130 @@ +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), {"redis": True}), + # Case 2: Redis client raises RedisError + (Mock(ping=lambda: (_ for _ in ()).throw(RedisError)), {"redis": False}), + # Case 3: Redis client is not used + (None, {"redis": 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, {"db": True}), + # Case 2: Database connection error (OperationalError) + ( + MagicMock(), + sqlalchemy.exc.OperationalError("error", "error", "error"), + {"db": 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_enabled, redis_enabled, db_status, redis_status, expected_status, expected_code", + [ + # Case 1: Both services are connected + (True, True, True, True, {"status": True, "db": True, "redis": True}, 200), + # Case 2: Database not connected, Redis connected + (True, True, False, True, {"status": False, "db": False, "redis": True}, 503), + # Case 3: Database connected, Redis not connected + (True, True, True, False, {"status": False, "db": True, "redis": False}, 503), + # Case 4: Both services not connected + (True, True, False, False, {"status": False, "db": False, "redis": False}, 503), + # Case 5: Database Connected, Redis not used + (True, False, True, None, {"status": True, "db": True}, 200), + # Case 6: Database not used, Redis Connected + (False, True, None, True, {"status": True, "redis": True}, 200), + # Case 7: Both services not used + (False, False, None, None, {"status": True}, 200), + ], +) +async def test_health( + db_enabled, + redis_enabled, + db_status, + redis_status, + expected_status, + expected_code, + mocker, +): + # Mock get_db_status and get_redis_status + mocker.patch( + "reflex.utils.prerequisites.check_db_used", + return_value=db_enabled, + ) + mocker.patch( + "reflex.utils.prerequisites.check_redis_used", + return_value=redis_enabled, + ) + mocker.patch( + "reflex.app.get_db_status", + return_value={"db": db_status}, + ) + mocker.patch( + "reflex.utils.prerequisites.get_redis_status", + return_value={"redis": 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 97% rename from tests/test_model.py rename to tests/units/test_model.py index ac8187e03..0a83f39ec 100644 --- a/tests/test_model.py +++ b/tests/units/test_model.py @@ -46,7 +46,7 @@ def test_default_primary_key(model_default_primary: Model): Args: model_default_primary: Fixture. """ - assert "id" in model_default_primary.__class__.__fields__ + assert "id" in type(model_default_primary).__fields__ def test_custom_primary_key(model_custom_primary: Model): @@ -55,7 +55,7 @@ def test_custom_primary_key(model_custom_primary: Model): Args: model_custom_primary: Fixture. """ - assert "id" not in model_custom_primary.__class__.__fields__ + assert "id" not in type(model_custom_primary).__fields__ @pytest.mark.filterwarnings( 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 86% rename from tests/test_prerequisites.py rename to tests/units/test_prerequisites.py index c4f57a998..90afe0963 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"};', ), ], ) @@ -97,8 +105,8 @@ def test_initialize_requirements_txt_no_op(mocker): return_value=Mock(best=lambda: Mock(encoding="utf-8")), ) mock_fp_touch = mocker.patch("pathlib.Path.touch") - open_mock = mock_open(read_data="reflex==0.2.9") - mocker.patch("builtins.open", open_mock) + open_mock = mock_open(read_data="reflex==0.6.7") + mocker.patch("pathlib.Path.open", open_mock) initialize_requirements_txt() assert open_mock.call_count == 1 assert open_mock.call_args.kwargs["encoding"] == "utf-8" @@ -114,7 +122,7 @@ def test_initialize_requirements_txt_missing_reflex(mocker): return_value=Mock(best=lambda: Mock(encoding="utf-8")), ) open_mock = mock_open(read_data="random-package=1.2.3") - mocker.patch("builtins.open", open_mock) + mocker.patch("pathlib.Path.open", open_mock) initialize_requirements_txt() # Currently open for read, then open for append assert open_mock.call_count == 2 @@ -130,7 +138,7 @@ def test_initialize_requirements_txt_not_exist(mocker): # File does not exist, create file with reflex mocker.patch("pathlib.Path.exists", return_value=False) open_mock = mock_open() - mocker.patch("builtins.open", open_mock) + mocker.patch("pathlib.Path.open", open_mock) initialize_requirements_txt() assert open_mock.call_count == 2 # By default, use utf-8 encoding @@ -162,7 +170,7 @@ def test_requirements_txt_other_encoding(mocker): ) initialize_requirements_txt() open_mock = mock_open(read_data="random-package=1.2.3") - mocker.patch("builtins.open", open_mock) + mocker.patch("pathlib.Path.open", open_mock) initialize_requirements_txt() # Currently open for read, then open for append assert open_mock.call_count == 2 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/test_sqlalchemy.py b/tests/units/test_sqlalchemy.py similarity index 97% rename from tests/test_sqlalchemy.py rename to tests/units/test_sqlalchemy.py index b18799e0c..23e315785 100644 --- a/tests/test_sqlalchemy.py +++ b/tests/units/test_sqlalchemy.py @@ -127,8 +127,8 @@ def test_automigration( assert result[0].b == 4.2 # No-op - # assert Model.migrate(autogenerate=True) - # assert len(list(versions.glob("*.py"))) == 4 + # assert Model.migrate(autogenerate=True) #noqa: ERA001 + # assert len(list(versions.glob("*.py"))) == 4 #noqa: ERA001 # drop table (AlembicSecond) model_registry.get_metadata().clear() diff --git a/tests/test_state.py b/tests/units/test_state.py similarity index 79% rename from tests/test_state.py rename to tests/units/test_state.py index 1a014739d..39484752c 100644 --- a/tests/test_state.py +++ b/tests/units/test_state.py @@ -2,17 +2,32 @@ from __future__ import annotations import asyncio import copy +import dataclasses import datetime import functools import json import os import sys +import threading from textwrap import dedent -from typing import Any, Callable, Dict, Generator, List, Optional, Union +from typing import ( + Any, + AsyncGenerator, + Callable, + Dict, + List, + Optional, + Set, + Tuple, + Union, +) from unittest.mock import AsyncMock, Mock import pytest +import pytest_asyncio from plotly.graph_objects import Figure +from pydantic import BaseModel as BaseModelV2 +from pydantic.v1 import BaseModel as BaseModelV1 import reflex as rx import reflex.config @@ -31,6 +46,7 @@ from reflex.state import ( RouterData, State, StateManager, + StateManagerDisk, StateManagerMemory, StateManagerRedis, StateProxy, @@ -39,14 +55,22 @@ from reflex.state import ( ) from reflex.testing import chdir from reflex.utils import format, prerequisites, types +from reflex.utils.exceptions import ( + InvalidLockWarningThresholdError, + ReflexRuntimeError, + SetUndefinedStateVarError, + StateSerializationError, +) from reflex.utils.format import json_dumps -from reflex.vars import BaseVar, ComputedVar -from tests.states.mutation import MutableSQLAModel, MutableTestState +from reflex.vars.base import Var, computed_var +from tests.units.states.mutation import MutableSQLAModel, MutableTestState from .states import GenState CI = bool(os.environ.get("CI", False)) -LOCK_EXPIRATION = 2000 if CI else 300 +LOCK_EXPIRATION = 2500 if CI else 300 +LOCK_WARNING_THRESHOLD = 1000 if CI else 100 +LOCK_WARN_SLEEP = 1.5 if CI else 0.15 LOCK_EXPIRE_SLEEP = 2.5 if CI else 0.4 @@ -57,6 +81,7 @@ formatted_router = { "origin": "", "upgrade": "", "connection": "", + "cookie": "", "pragma": "", "cache_control": "", "user_agent": "", @@ -100,8 +125,10 @@ 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 + @computed_var def sum(self) -> float: """Dynamically sum the numbers. @@ -110,7 +137,7 @@ class TestState(BaseState): """ return self.num1 + self.num2 - @ComputedVar + @computed_var def upper(self) -> str: """Uppercase the key. @@ -123,6 +150,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.""" @@ -266,12 +301,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): @@ -281,7 +316,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 @@ -307,6 +342,7 @@ def test_class_vars(test_state): "upper", "fig", "dt", + "asynctest", } @@ -395,30 +431,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) == f"{{{TestState.get_name()}.array.at({TestState.get_name()}.num1)}}" - ) + assert str(prop) == f"{TestState.get_name()}.array.at({TestState.get_name()}.num1)" prop = TestState.mapping["a"][TestState.num1] assert ( str(prop) - == f'{{{TestState.get_name()}.mapping["a"].at({TestState.get_name()}.num1)}}' + == f'{TestState.get_name()}.mapping["a"].at({TestState.get_name()}.num1)' ) prop = TestState.mapping[TestState.map_key] assert ( - str(prop) - == f"{{{TestState.get_name()}.mapping[{TestState.get_name()}.map_key]}}" + 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) == f"{{{TestState.get_name()}.obj.prop1}}" + assert str(prop) == f'{TestState.get_name()}.obj["prop1"]' prop = TestState.complex[1].prop1 - assert str(prop) == f"{{{TestState.get_name()}.complex[1].prop1}}" + assert str(prop) == f'{TestState.get_name()}.complex[1]["prop1"]' def test_get_parent_state(): @@ -440,26 +473,28 @@ def test_get_substates(): def test_get_name(): """Test getting the name of a state.""" - assert TestState.get_name() == "tests___test_state____test_state" - assert ChildState.get_name() == "tests___test_state____child_state" - assert ChildState2.get_name() == "tests___test_state____child_state2" - assert GrandchildState.get_name() == "tests___test_state____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() == "tests___test_state____test_state" + assert TestState.get_full_name() == "tests___units___test_state____test_state" assert ( ChildState.get_full_name() - == "tests___test_state____test_state.tests___test_state____child_state" + == "tests___units___test_state____test_state.tests___units___test_state____child_state" ) assert ( ChildState2.get_full_name() - == "tests___test_state____test_state.tests___test_state____child_state2" + == "tests___units___test_state____test_state.tests___units___test_state____child_state2" ) assert ( GrandchildState.get_full_name() - == "tests___test_state____test_state.tests___test_state____child_state.tests___test_state____grandchild_state" + == "tests___units___test_state____test_state.tests___units___test_state____child_state.tests___units___test_state____grandchild_state" ) @@ -519,12 +554,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() @@ -651,7 +684,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: @@ -699,6 +737,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. @@ -707,6 +746,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 = { @@ -722,6 +762,8 @@ def test_reset(test_state, child_state): "map_key", "mapping", "dt", + "_backend", + "asynctest", } # The dirty vars should be reset. @@ -752,7 +794,6 @@ async def test_process_event_simple(test_state): assert test_state.num1 == 69 # The delta should contain the changes, including computed vars. - # assert update.delta == {"test_state": {"num1": 69, "sum": 72.14}} assert update.delta == { TestState.get_full_name(): {"num1": 69, "sum": 72.14, "upper": ""}, GrandchildState3.get_full_name(): {"computed": ""}, @@ -862,8 +903,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() } @@ -933,7 +976,7 @@ class InterdependentState(BaseState): """A state with 3 vars and 3 computed vars. x: a variable that no computed var depends on - v1: a varable that one computed var directly depeneds on + v1: a variable that one computed var directly depends on _v2: a backend variable that one computed var directly depends on v1x2: a computed var that depends on v1 @@ -1064,7 +1107,8 @@ def test_dirty_computed_var_from_backend_var( Args: interdependent_state: A state with varying Var dependencies. """ - assert InterdependentState._v3._backend is True + # 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}, @@ -1098,7 +1142,7 @@ def test_child_state(): v: int = 2 class ChildState(MainState): - @ComputedVar + @computed_var def rendered_var(self): return self.v @@ -1117,7 +1161,7 @@ def test_conditional_computed_vars(): t1: str = "a" t2: str = "b" - @ComputedVar + @computed_var def rendered_var(self) -> str: if self.flag: return self.t1 @@ -1276,19 +1320,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, @@ -1532,7 +1576,7 @@ def test_error_on_state_method_shadow(): assert ( err.value.args[0] - == f"The event handler name `reset` shadows a builtin State method; use a different name instead" + == "The event handler name `reset` shadows a builtin State method; use a different name instead" ) @@ -1588,8 +1632,10 @@ async def test_state_with_invalid_yield(capsys, mock_app): assert "must only return/yield: None, Events or other EventHandlers" in captured.out -@pytest.fixture(scope="function", params=["in_process", "redis"]) -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: @@ -1602,15 +1648,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() @@ -1641,7 +1690,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 @@ -1651,11 +1700,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 = type(state_manager)(state=TestState) assert sm2._state_manager_lock is state_manager._state_manager_lock assert not sm2._states_locks if state_manager._states_locks: @@ -1693,13 +1742,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: @@ -1712,7 +1761,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() @@ -1741,6 +1790,7 @@ async def test_state_manager_lock_expire( substate_token_redis: A token + substate name for looking up in state manager. """ state_manager_redis.lock_expiration = LOCK_EXPIRATION + state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD async with state_manager_redis.modify_state(substate_token_redis): await asyncio.sleep(0.01) @@ -1765,6 +1815,7 @@ async def test_state_manager_lock_expire_contend( unexp_num1 = 666 state_manager_redis.lock_expiration = LOCK_EXPIRATION + state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD order = [] @@ -1794,13 +1845,63 @@ async def test_state_manager_lock_expire_contend( assert (await state_manager_redis.get_state(substate_token_redis)).num1 == exp_num1 +@pytest.mark.asyncio +async def test_state_manager_lock_warning_threshold_contend( + state_manager_redis: StateManager, token: str, substate_token_redis: str, mocker +): + """Test that the state manager triggers a warning when lock contention exceeds the warning threshold. + + Args: + state_manager_redis: A state manager instance. + token: A token. + substate_token_redis: A token + substate name for looking up in state manager. + mocker: Pytest mocker object. + """ + console_warn = mocker.patch("reflex.utils.console.warn") + + state_manager_redis.lock_expiration = LOCK_EXPIRATION + state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD + + order = [] + + async def _coro_blocker(): + async with state_manager_redis.modify_state(substate_token_redis): + order.append("blocker") + await asyncio.sleep(LOCK_WARN_SLEEP) + + tasks = [ + asyncio.create_task(_coro_blocker()), + ] + + await tasks[0] + console_warn.assert_called() + assert console_warn.call_count == 7 + + +class CopyingAsyncMock(AsyncMock): + """An AsyncMock, but deepcopy the args and kwargs first.""" + + def __call__(self, *args, **kwargs): + """Call the mock. + + Args: + args: the arguments passed to the mock + kwargs: the keyword arguments passed to the mock + + Returns: + The result of the mock call + """ + args = copy.deepcopy(args) + kwargs = copy.deepcopy(kwargs) + return super().__call__(*args, **kwargs) + + @pytest.fixture(scope="function") -def mock_app(monkeypatch, state_manager: StateManager) -> rx.App: - """Mock app fixture. +def mock_app_simple(monkeypatch) -> rx.App: + """Simple Mock app fixture. Args: monkeypatch: Pytest monkeypatch object. - state_manager: A state manager. Returns: The app, after mocking out prerequisites.get_app() @@ -1811,8 +1912,7 @@ def mock_app(monkeypatch, state_manager: StateManager) -> rx.App: setattr(app_module, CompileVars.APP, app) app.state = TestState - app._state_manager = state_manager - app.event_namespace.emit = AsyncMock() # type: ignore + app.event_namespace.emit = CopyingAsyncMock() # type: ignore def _mock_get_app(*args, **kwargs): return app_module @@ -1821,6 +1921,21 @@ def mock_app(monkeypatch, state_manager: StateManager) -> rx.App: return app +@pytest.fixture(scope="function") +def mock_app(mock_app_simple: rx.App, state_manager: StateManager) -> rx.App: + """Mock app fixture. + + Args: + mock_app_simple: A simple mock app. + state_manager: A state manager. + + Returns: + The app, after mocking out prerequisites.get_app() + """ + mock_app_simple._state_manager = state_manager + return mock_app_simple + + @pytest.mark.asyncio async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): """Test that the state proxy works. @@ -1833,7 +1948,7 @@ async def test_state_proxy(grandchild_state: GrandchildState, mock_app: rx.App): assert child_state is not None parent_state = child_state.parent_state assert parent_state is not None - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): mock_app.state_manager.states[parent_state.router.session.client_token] = ( parent_state ) @@ -1872,7 +1987,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: @@ -1887,7 +2002,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: @@ -1901,7 +2016,7 @@ 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( + assert mcall.args[1] == StateUpdate( delta={ parent_state.get_full_name(): { "upper": "", @@ -1924,6 +2039,10 @@ class BackgroundTaskState(BaseState): order: List[str] = [] dict_list: Dict[str, List[int]] = {"foo": [1, 2, 3]} + def __init__(self, **kwargs): # noqa: D107 + super().__init__(**kwargs) + self.router_data = {"simulate": "hydrate"} + @rx.var def computed_order(self) -> List[str]: """Get the order as a computed var. @@ -1933,7 +2052,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: @@ -1970,7 +2089,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): @@ -1984,7 +2103,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. @@ -2091,51 +2210,51 @@ async def test_background_task_no_block(mock_app: rx.App, token: str): assert mock_app.event_namespace is not None emit_mock = mock_app.event_namespace.emit - first_ws_message = json.loads(emit_mock.mock_calls[0].args[1]) + first_ws_message = emit_mock.mock_calls[0].args[1] assert ( - first_ws_message["delta"][BackgroundTaskState.get_full_name()].pop("router") + first_ws_message.delta[BackgroundTaskState.get_full_name()].pop("router") is not None ) - assert first_ws_message == { - "delta": { + assert first_ws_message == StateUpdate( + delta={ BackgroundTaskState.get_full_name(): { "order": ["background_task:start"], "computed_order": ["background_task:start"], } }, - "events": [], - "final": True, - } + events=[], + final=True, + ) for call in emit_mock.mock_calls[1:5]: - assert json.loads(call.args[1]) == { - "delta": { + assert call.args[1] == StateUpdate( + delta={ BackgroundTaskState.get_full_name(): { "computed_order": ["background_task:start"], } }, - "events": [], - "final": True, - } - assert json.loads(emit_mock.mock_calls[-2].args[1]) == { - "delta": { + events=[], + final=True, + ) + assert emit_mock.mock_calls[-2].args[1] == StateUpdate( + delta={ BackgroundTaskState.get_full_name(): { "order": exp_order, "computed_order": exp_order, "dict_list": {}, } }, - "events": [], - "final": True, - } - assert json.loads(emit_mock.mock_calls[-1].args[1]) == { - "delta": { + events=[], + final=True, + ) + assert emit_mock.mock_calls[-1].args[1] == StateUpdate( + delta={ BackgroundTaskState.get_full_name(): { "computed_order": exp_order, }, }, - "events": [], - "final": True, - } + events=[], + final=True, + ) @pytest.mark.asyncio @@ -2481,13 +2600,16 @@ def test_mutable_copy_vars(mutable_state: MutableTestState, copy_func: Callable) 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): pass - class ChildTestState(TestState): # type: ignore # noqa + class ChildTestState(TestState): # type: ignore pass class ChildTestState(TestState): # type: ignore # noqa @@ -2509,7 +2631,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("'", '"') @@ -2563,7 +2685,7 @@ class Custom1(Base): self.foo = val def double_foo(self) -> str: - """Concantenate foo with foo. + """Concatenate foo with foo. Returns: foo + foo @@ -2604,15 +2726,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'{UnionState.c3!s}?.["c2"]' # type: ignore + assert str(UnionState.c3.c2.c1) == f'{UnionState.c3!s}?.["c2"]?.["c1"]' # type: ignore + assert ( + str(UnionState.c3.c2.c1.foo) == f'{UnionState.c3!s}?.["c2"]?.["c1"]?.["foo"]' # type: ignore + ) + assert ( + str(UnionState.c3.c2.c1r.foo) == f'{UnionState.c3!s}?.["c2"]?.["c1r"]["foo"]' # type: ignore + ) + assert str(UnionState.c3.c2r.c1) == f'{UnionState.c3!s}?.["c2r"]["c1"]' # type: ignore + assert ( + str(UnionState.c3.c2r.c1.foo) == f'{UnionState.c3!s}?.["c2r"]["c1"]?.["foo"]' # type: ignore + ) + assert ( + str(UnionState.c3.c2r.c1r.foo) == f'{UnionState.c3!s}?.["c2r"]["c1r"]["foo"]' # type: ignore + ) + assert str(UnionState.c3i.c2) == f'{UnionState.c3i!s}["c2"]' # type: ignore + assert str(UnionState.c3r.c2) == f'{UnionState.c3r!s}["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 @@ -2663,7 +2793,7 @@ def test_set_base_field_via_setter(): assert "c2" in bfss.dirty_vars -def exp_is_hydrated(state: State, is_hydrated: bool = True) -> Dict[str, Any]: +def exp_is_hydrated(state: BaseState, is_hydrated: bool = True) -> Dict[str, Any]: """Expected IS_HYDRATED delta that would be emitted by HydrateMiddleware. Args: @@ -2681,6 +2811,7 @@ class OnLoadState(State): num: int = 0 + @rx.event def test_handler(self): """Test handler.""" self.num += 1 @@ -2741,7 +2872,8 @@ async def test_preprocess(app_module_mock, token, test_state, expected, mocker): app = app_module_mock.app = App( state=State, load_events={"index": [test_state.test_handler]} ) - state = State() + async with app.state_manager.modify_state(_substate_key(token, State)) as state: + state.router_data = {"simulate": "hydrate"} updates = [] async for update in rx.app.process( @@ -2768,6 +2900,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): @@ -2785,7 +2920,8 @@ async def test_preprocess_multiple_load_events(app_module_mock, token, mocker): state=State, load_events={"index": [OnLoadState.test_handler, OnLoadState.test_handler]}, ) - state = State() + async with app.state_manager.modify_state(_substate_key(token, State)) as state: + state.router_data = {"simulate": "hydrate"} updates = [] async for update in rx.app.process( @@ -2815,6 +2951,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): @@ -2831,7 +2970,7 @@ async def test_get_state(mock_app: rx.App, token: str): _substate_key(token, ChildState2) ) assert isinstance(test_state, TestState) - if isinstance(mock_app.state_manager, StateManagerMemory): + if isinstance(mock_app.state_manager, (StateManagerMemory, StateManagerDisk)): # All substates are available assert tuple(sorted(test_state.substates)) == ( ChildState.get_name(), @@ -2900,7 +3039,7 @@ 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() @@ -3044,12 +3183,12 @@ def test_potentially_dirty_substates(): """ class State(RxState): - @ComputedVar + @computed_var def foo(self) -> str: return "" class C1(State): - @ComputedVar + @computed_var def bar(self) -> str: return "" @@ -3058,6 +3197,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. @@ -3083,9 +3267,9 @@ async def test_setvar(mock_app: rx.App, token: str): print(update) assert state.array == [43] - # Cannot setvar for non-existant var + # Cannot setvar for non-existent var with pytest.raises(AttributeError): - TestState.setvar("non_existant_var") + TestState.setvar("non_existent_var") # Cannot setvar for computed vars with pytest.raises(AttributeError): @@ -3096,16 +3280,53 @@ async def test_setvar(mock_app: rx.App, token: str): 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": 20000}, + ( + 20000, + constants.Expiration.TOKEN, + constants.Expiration.LOCK_WARNING_THRESHOLD, + ), + ), ( {"redis_lock_expiration": 50000, "redis_token_expiration": 5600}, - (50000, 5600), + (50000, 5600, constants.Expiration.LOCK_WARNING_THRESHOLD), + ), + ( + {"redis_token_expiration": 7600}, + ( + constants.Expiration.LOCK, + 7600, + constants.Expiration.LOCK_WARNING_THRESHOLD, + ), + ), + ( + {"redis_lock_expiration": 50000, "redis_lock_warning_threshold": 1500}, + (50000, constants.Expiration.TOKEN, 1500), + ), + ( + {"redis_token_expiration": 5600, "redis_lock_warning_threshold": 3000}, + (constants.Expiration.LOCK, 5600, 3000), + ), + ( + { + "redis_lock_expiration": 50000, + "redis_token_expiration": 5600, + "redis_lock_warning_threshold": 2000, + }, + (50000, 5600, 2000), ), - ({"redis_token_expiration": 7600}, (constants.Expiration.LOCK, 7600)), ], ) def test_redis_state_manager_config_knobs(tmp_path, expiration_kwargs, expected_values): @@ -3121,6 +3342,7 @@ import reflex as rx config = rx.Config( app_name="project1", redis_url="redis://localhost:6379", + state_manager_mode="redis", {config_items} ) """ @@ -3134,6 +3356,44 @@ config = rx.Config( 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 + assert state_manager.lock_warning_threshold == expected_values[2] # type: ignore + + +@pytest.mark.skipif("REDIS_URL" not in os.environ, reason="Test requires redis") +@pytest.mark.parametrize( + "redis_lock_expiration, redis_lock_warning_threshold", + [ + (10000, 10000), + (20000, 30000), + ], +) +def test_redis_state_manager_config_knobs_invalid_lock_warning_threshold( + tmp_path, redis_lock_expiration, redis_lock_warning_threshold +): + proj_root = tmp_path / "project1" + proj_root.mkdir() + + config_string = f""" +import reflex as rx +config = rx.Config( + app_name="project1", + redis_url="redis://localhost:6379", + state_manager_mode="redis", + redis_lock_expiration = {redis_lock_expiration}, + redis_lock_warning_threshold = {redis_lock_warning_threshold}, +) + """ + + (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 + + with pytest.raises(InvalidLockWarningThresholdError): + StateManager.create(state=State) + del sys.modules[constants.Config.MODULE] class MixinState(State, mixin=True): @@ -3141,6 +3401,16 @@ class MixinState(State, mixin=True): 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): @@ -3149,8 +3419,348 @@ class UsesMixinState(MixinState, State): pass +class ChildUsesMixinState(UsesMixinState): + """A child state that uses the mixin state.""" + + pass + + def test_mixin_state() -> None: """Test that a mixin state works correctly.""" assert "num" in UsesMixinState.base_vars assert "num" in UsesMixinState.vars - assert UsesMixinState.backend_vars == {"_backend": 0} + assert 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)) + + with pytest.raises(StateSerializationError): + _ = state3._serialize() + + +def test_typed_state() -> None: + class TypedState(rx.State): + field: rx.Field[str] = rx.field("") + + _ = TypedState(field="str") + + +class ModelV1(BaseModelV1): + """A pydantic BaseModel v1.""" + + foo: str = "bar" + + +class ModelV2(BaseModelV2): + """A pydantic BaseModel v2.""" + + foo: str = "bar" + + +@dataclasses.dataclass +class ModelDC: + """A dataclass.""" + + foo: str = "bar" + + +class PydanticState(rx.State): + """A state with pydantic BaseModel vars.""" + + v1: ModelV1 = ModelV1() + v2: ModelV2 = ModelV2() + dc: ModelDC = ModelDC() + + +def test_mutable_models(): + """Test that dataclass and pydantic BaseModel v1 and v2 use dep tracking.""" + state = PydanticState() + assert isinstance(state.v1, MutableProxy) + state.v1.foo = "baz" + assert state.dirty_vars == {"v1"} + state.dirty_vars.clear() + + assert isinstance(state.v2, MutableProxy) + state.v2.foo = "baz" + assert state.dirty_vars == {"v2"} + state.dirty_vars.clear() + + # Not yet supported ENG-4083 + # assert isinstance(state.dc, MutableProxy) #noqa: ERA001 + # state.dc.foo = "baz" #noqa: ERA001 + # assert state.dirty_vars == {"dc"} #noqa: ERA001 + # state.dirty_vars.clear() #noqa: ERA001 + + +def test_get_value(): + class GetValueState(rx.State): + foo: str = "FOO" + bar: str = "BAR" + + state = GetValueState() + + assert state.dict() == { + state.get_full_name(): { + "foo": "FOO", + "bar": "BAR", + } + } + assert state.get_delta() == {} + + state.bar = "foo" + + assert state.dict() == { + state.get_full_name(): { + "foo": "FOO", + "bar": "foo", + } + } + assert state.get_delta() == { + state.get_full_name(): { + "bar": "foo", + } + } + + +def test_init_mixin() -> None: + """Ensure that State mixins can not be instantiated directly.""" + + class Mixin(BaseState, mixin=True): + pass + + with pytest.raises(ReflexRuntimeError): + Mixin() + + class SubMixin(Mixin, mixin=True): + pass + + with pytest.raises(ReflexRuntimeError): + SubMixin() + + +class ReflexModel(rx.Model): + """A model for testing.""" + + foo: str + + +class UpcastState(rx.State): + """A state for testing upcasting.""" + + passed: bool = False + + def rx_model(self, m: ReflexModel): # noqa: D102 + assert isinstance(m, ReflexModel) + self.passed = True + + def rx_base(self, o: Object): # noqa: D102 + assert isinstance(o, Object) + self.passed = True + + def rx_base_or_none(self, o: Optional[Object]): # noqa: D102 + if o is not None: + assert isinstance(o, Object) + self.passed = True + + def rx_basemodelv1(self, m: ModelV1): # noqa: D102 + assert isinstance(m, ModelV1) + self.passed = True + + def rx_basemodelv2(self, m: ModelV2): # noqa: D102 + assert isinstance(m, ModelV2) + self.passed = True + + def rx_dataclass(self, dc: ModelDC): # noqa: D102 + assert isinstance(dc, ModelDC) + self.passed = True + + def py_set(self, s: set): # noqa: D102 + assert isinstance(s, set) + self.passed = True + + def py_Set(self, s: Set): # noqa: D102 + assert isinstance(s, Set) + self.passed = True + + def py_tuple(self, t: tuple): # noqa: D102 + assert isinstance(t, tuple) + self.passed = True + + def py_Tuple(self, t: Tuple): # noqa: D102 + assert isinstance(t, tuple) + self.passed = True + + def py_dict(self, d: dict[str, str]): # noqa: D102 + assert isinstance(d, dict) + self.passed = True + + def py_list(self, ls: list[str]): # noqa: D102 + assert isinstance(ls, list) + self.passed = True + + def py_Any(self, a: Any): # noqa: D102 + assert isinstance(a, list) + self.passed = True + + def py_unresolvable(self, u: "Unresolvable"): # noqa: D102, F821 # type: ignore + assert isinstance(u, list) + self.passed = True + + +@pytest.mark.asyncio +@pytest.mark.usefixtures("mock_app_simple") +@pytest.mark.parametrize( + ("handler", "payload"), + [ + (UpcastState.rx_model, {"m": {"foo": "bar"}}), + (UpcastState.rx_base, {"o": {"foo": "bar"}}), + (UpcastState.rx_base_or_none, {"o": {"foo": "bar"}}), + (UpcastState.rx_base_or_none, {"o": None}), + (UpcastState.rx_basemodelv1, {"m": {"foo": "bar"}}), + (UpcastState.rx_basemodelv2, {"m": {"foo": "bar"}}), + (UpcastState.rx_dataclass, {"dc": {"foo": "bar"}}), + (UpcastState.py_set, {"s": ["foo", "foo"]}), + (UpcastState.py_Set, {"s": ["foo", "foo"]}), + (UpcastState.py_tuple, {"t": ["foo", "foo"]}), + (UpcastState.py_Tuple, {"t": ["foo", "foo"]}), + (UpcastState.py_dict, {"d": {"foo": "bar"}}), + (UpcastState.py_list, {"ls": ["foo", "foo"]}), + (UpcastState.py_Any, {"a": ["foo"]}), + (UpcastState.py_unresolvable, {"u": ["foo"]}), + ], +) +async def test_upcast_event_handler_arg(handler, payload): + """Test that upcast event handler args work correctly. + + Args: + handler: The handler to test. + payload: The payload to test. + """ + state = UpcastState() + async for update in state._process_event(handler, state, payload): + assert update.delta == {UpcastState.get_full_name(): {"passed": True}} diff --git a/tests/test_state_tree.py b/tests/units/test_state_tree.py similarity index 97% rename from tests/test_state_tree.py rename to tests/units/test_state_tree.py index 7c1e13a91..ebdd877de 100644 --- a/tests/test_state_tree.py +++ b/tests/units/test_state_tree.py @@ -1,9 +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 @@ -210,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: @@ -228,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 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 87% rename from tests/test_telemetry.py rename to tests/units/test_telemetry.py index a434779d4..d8a77dfd6 100644 --- a/tests/test_telemetry.py +++ b/tests/units/test_telemetry.py @@ -34,12 +34,6 @@ def test_disable(): @pytest.mark.parametrize("event", ["init", "reinit", "run-dev", "run-prod", "export"]) def test_send(mocker, event): 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( @@ -52,4 +46,4 @@ def test_send(mocker, event): telemetry._send(event, telemetry_enabled=True) httpx_post_mock.assert_called_once() - pathlib_path_read_text_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 95% rename from tests/test_testing.py rename to tests/units/test_testing.py index b01709202..83a03ad83 100644 --- a/tests/test_testing.py +++ b/tests/units/test_testing.py @@ -29,7 +29,7 @@ def test_app_harness(tmp_path): with AppHarness.create( root=tmp_path, - app_source=BasicApp, # type: ignore + app_source=BasicApp, ) as harness: assert harness.app_instance is not None assert harness.backend is not None diff --git a/tests/test_var.py b/tests/units/test_var.py similarity index 52% rename from tests/test_var.py rename to tests/units/test_var.py index 5c67d9924..bfa8aa35a 100644 --- a/tests/test_var.py +++ b/tests/units/test_var.py @@ -1,50 +1,47 @@ import json import math +import sys import typing -from typing import Dict, List, Set, Tuple, Union +from typing import Dict, List, Optional, Set, Tuple, Union, cast import pytest from pandas import DataFrame +import reflex as rx from reflex.base import Base from reflex.constants.base import REFLEX_VAR_CLOSING_TAG, REFLEX_VAR_OPENING_TAG -from reflex.experimental.vars.base import ( - ImmutableVar, +from reflex.state import BaseState +from reflex.utils.exceptions import PrimitiveUnserializableToJSON +from reflex.utils.imports import ImportVar +from reflex.vars import VarData +from reflex.vars.base import ( + ComputedVar, LiteralVar, + Var, + computed_var, var_operation, + var_operation_return, ) -from reflex.experimental.vars.function import ArgsFunctionOperation, FunctionStringVar -from reflex.experimental.vars.number import ( - LiteralBooleanVar, - LiteralNumberVar, - NumberVar, +from reflex.vars.function import ( + ArgsFunctionOperation, + DestructuredArg, + FunctionStringVar, ) -from reflex.experimental.vars.object import LiteralObjectVar -from reflex.experimental.vars.sequence import ( +from reflex.vars.number import LiteralBooleanVar, LiteralNumberVar, NumberVar +from reflex.vars.object import LiteralObjectVar, ObjectVar +from reflex.vars.sequence import ( ArrayVar, ConcatVarOperation, LiteralArrayVar, LiteralStringVar, ) -from reflex.state import BaseState -from reflex.utils.imports import ImportVar -from reflex.vars import ( - BaseVar, - ComputedVar, - ImmutableVarData, - Var, - VarData, - computed_var, -) test_vars = [ - BaseVar(_var_name="prop1", _var_type=int), - BaseVar(_var_name="key", _var_type=str), - BaseVar(_var_name="value", _var_type=str)._var_set_state("state"), - BaseVar(_var_name="local", _var_type=str, _var_is_local=True)._var_set_state( - "state" - ), - BaseVar(_var_name="local2", _var_type=str, _var_is_local=True), + Var(_js_expr="prop1", _var_type=int), + Var(_js_expr="key", _var_type=str), + Var(_js_expr="value", _var_type=str)._var_set_state("state"), + Var(_js_expr="local", _var_type=str)._var_set_state("state"), + Var(_js_expr="local2", _var_type=str), ] @@ -82,6 +79,11 @@ def ChildState(ParentState, TestObj): class ChildState(ParentState): @computed_var def var_without_annotation(self): + """This shadows ParentState.var_without_annotation. + + Returns: + TestObj: Test object. + """ return TestObj return ChildState @@ -92,6 +94,11 @@ def GrandChildState(ChildState, TestObj): class GrandChildState(ChildState): @computed_var def var_without_annotation(self): + """This shadows ChildState.var_without_annotation. + + Returns: + TestObj: Test object. + """ return TestObj return GrandChildState @@ -187,14 +194,14 @@ def test_full_name(prop, expected): prop: The var to test. expected: The expected full name. """ - assert prop._var_full_name == expected + assert str(prop) == expected @pytest.mark.parametrize( "prop,expected", zip( test_vars, - ["{prop1}", "{key}", "{state.value}", "state.local", "local2"], + ["prop1", "key", "state.value", "state.local", "local2"], ), ) def test_str(prop, expected): @@ -208,26 +215,26 @@ def test_str(prop, expected): @pytest.mark.parametrize( - "prop,expected", + ("prop", "expected"), [ - (BaseVar(_var_name="p", _var_type=int), 0), - (BaseVar(_var_name="p", _var_type=float), 0.0), - (BaseVar(_var_name="p", _var_type=str), ""), - (BaseVar(_var_name="p", _var_type=bool), False), - (BaseVar(_var_name="p", _var_type=list), []), - (BaseVar(_var_name="p", _var_type=dict), {}), - (BaseVar(_var_name="p", _var_type=tuple), ()), - (BaseVar(_var_name="p", _var_type=set), set()), + (Var(_js_expr="p", _var_type=int), 0), + (Var(_js_expr="p", _var_type=float), 0.0), + (Var(_js_expr="p", _var_type=str), ""), + (Var(_js_expr="p", _var_type=bool), False), + (Var(_js_expr="p", _var_type=list), []), + (Var(_js_expr="p", _var_type=dict), {}), + (Var(_js_expr="p", _var_type=tuple), ()), + (Var(_js_expr="p", _var_type=set), set()), ], ) -def test_default_value(prop, expected): +def test_default_value(prop: Var, 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 + assert prop._get_default_value() == expected @pytest.mark.parametrize( @@ -243,27 +250,27 @@ def test_default_value(prop, expected): ], ), ) -def test_get_setter(prop, expected): +def test_get_setter(prop: Var, 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 + 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)), + (None, Var(_js_expr="null", _var_type=None)), + (1, Var(_js_expr="1", _var_type=int)), + ("key", Var(_js_expr='"key"', _var_type=str)), + (3.14, Var(_js_expr="3.14", _var_type=float)), + ([1, 2, 3], Var(_js_expr="[1, 2, 3]", _var_type=List[int])), ( {"a": 1, "b": 2}, - BaseVar(_var_name='{"a": 1, "b": 2}', _var_type=dict, _var_is_local=True), + Var(_js_expr='({ ["a"] : 1, ["b"] : 2 })', _var_type=Dict[str, int]), ), ], ) @@ -274,11 +281,8 @@ def test_create(value, expected): value: The value to create a var from. expected: The expected name of the setter function. """ - prop = Var.create(value) - if value is None: - assert prop == expected - else: - assert prop.equals(expected) # type: ignore + prop = LiteralVar.create(value) + assert prop.equals(expected) # type: ignore def test_create_type_error(): @@ -290,17 +294,11 @@ def test_create_type_error(): value = ErrorType() with pytest.raises(TypeError): - Var.create(value) + LiteralVar.create(value) def v(value) -> Var: - val = ( - Var.create(json.dumps(value), _var_is_string=True, _var_is_local=False) - if isinstance(value, str) - else Var.create(value, _var_is_local=False) - ) - assert val is not None - return val + return LiteralVar.create(value) def test_basic_operations(TestObj): @@ -309,208 +307,184 @@ def test_basic_operations(TestObj): Args: TestObj: The test object. """ - assert str(v(1) == v(2)) == "{((1) === (2))}" - assert str(v(1) != v(2)) == "{((1) !== (2))}" - assert str(v(1) < v(2)) == "{((1) < (2))}" - assert str(v(1) <= v(2)) == "{((1) <= (2))}" - assert str(v(1) > v(2)) == "{((1) > (2))}" - assert str(v(1) >= v(2)) == "{((1) >= (2))}" - assert str(v(1) + v(2)) == "{((1) + (2))}" - assert str(v(1) - v(2)) == "{((1) - (2))}" - assert str(v(1) * v(2)) == "{((1) * (2))}" - assert str(v(1) / v(2)) == "{((1) / (2))}" - assert str(v(1) // v(2)) == "{Math.floor((1) / (2))}" - assert str(v(1) % v(2)) == "{((1) % (2))}" - assert str(v(1) ** v(2)) == "{Math.pow((1) , (2))}" - assert str(v(1) & v(2)) == "{((1) && (2))}" - assert str(v(1) | v(2)) == "{((1) || (2))}" - assert str(v([1, 2, 3])[v(0)]) == "{[1, 2, 3].at(0)}" - assert str(v({"a": 1, "b": 2})["a"]) == '{{"a": 1, "b": 2}["a"]}' - assert str(v("foo") == v("bar")) == '{(("foo") === ("bar"))}' + assert str(v(1) == v(2)) == "(1 === 2)" + assert str(v(1) != v(2)) == "(1 !== 2)" + assert str(LiteralNumberVar.create(1) < 2) == "(1 < 2)" + assert str(LiteralNumberVar.create(1) <= 2) == "(1 <= 2)" + assert str(LiteralNumberVar.create(1) > 2) == "(1 > 2)" + assert str(LiteralNumberVar.create(1) >= 2) == "(1 >= 2)" + assert str(LiteralNumberVar.create(1) + 2) == "(1 + 2)" + assert str(LiteralNumberVar.create(1) - 2) == "(1 - 2)" + assert str(LiteralNumberVar.create(1) * 2) == "(1 * 2)" + assert str(LiteralNumberVar.create(1) / 2) == "(1 / 2)" + assert str(LiteralNumberVar.create(1) // 2) == "Math.floor(1 / 2)" + assert str(LiteralNumberVar.create(1) % 2) == "(1 % 2)" + assert str(LiteralNumberVar.create(1) ** 2) == "(1 ** 2)" + assert str(LiteralNumberVar.create(1) & v(2)) == "(1 && 2)" + assert str(LiteralNumberVar.create(1) | v(2)) == "(1 || 2)" + assert str(LiteralArrayVar.create([1, 2, 3])[0]) == "[1, 2, 3].at(0)" + assert ( + str(LiteralObjectVar.create({"a": 1, "b": 2})["a"]) + == '({ ["a"] : 1, ["b"] : 2 })["a"]' + ) + assert str(v("foo") == v("bar")) == '("foo" === "bar")' + assert str(Var(_js_expr="foo") == Var(_js_expr="bar")) == "(foo === bar)" + assert ( + str(LiteralVar.create("foo") == LiteralVar.create("bar")) == '("foo" === "bar")' + ) + print(Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state")) assert ( str( - Var.create("foo", _var_is_local=False) - == Var.create("bar", _var_is_local=False) + Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar + == LiteralVar.create("bar") ) - == "{((foo) === (bar))}" + == '(state.foo["bar"] === "bar")' ) assert ( - str( - BaseVar( - _var_name="foo", _var_type=str, _var_is_string=True, _var_is_local=True - ) - == BaseVar( - _var_name="bar", _var_type=str, _var_is_string=True, _var_is_local=True - ) - ) - == "((`foo`) === (`bar`))" + str(Var(_js_expr="foo").to(ObjectVar, TestObj)._var_set_state("state").bar) + == 'state.foo["bar"]' ) + assert str(abs(LiteralNumberVar.create(1))) == "Math.abs(1)" + assert str(LiteralArrayVar.create([1, 2, 3]).length()) == "[1, 2, 3].length" assert ( - str( - BaseVar( - _var_name="foo", - _var_type=TestObj, - _var_is_string=True, - _var_is_local=False, - ) - ._var_set_state("state") - .bar - == BaseVar( - _var_name="bar", _var_type=str, _var_is_string=True, _var_is_local=True - ) - ) - == "{((state.foo.bar) === (`bar`))}" + str(LiteralArrayVar.create([1, 2]) + LiteralArrayVar.create([3, 4])) + == "[...[1, 2], ...[3, 4]]" ) - assert ( - str(BaseVar(_var_name="foo", _var_type=TestObj)._var_set_state("state").bar) - == "{state.foo.bar}" - ) - assert str(abs(v(1))) == "{Math.abs(1)}" - assert str(v([1, 2, 3]).length()) == "{[1, 2, 3].length}" - assert str(v([1, 2]) + v([3, 4])) == "{spreadArraysOrObjects(([1, 2]) , ([3, 4]))}" # Tests for reverse operation - assert str(v([1, 2, 3]).reverse()) == "{[...[1, 2, 3]].reverse()}" - assert str(v(["1", "2", "3"]).reverse()) == '{[...["1", "2", "3"]].reverse()}' assert ( - str(BaseVar(_var_name="foo", _var_type=list)._var_set_state("state").reverse()) - == "{[...state.foo].reverse()}" + str(LiteralArrayVar.create([1, 2, 3]).reverse()) + == "[1, 2, 3].slice().reverse()" ) assert ( - str(BaseVar(_var_name="foo", _var_type=list).reverse()) - == "{[...foo].reverse()}" - ) - assert str(BaseVar(_var_name="foo", _var_type=str)._type()) == "{typeof foo}" # type: ignore - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == str) # type: ignore - == "{((typeof foo) === (`string`))}" + str(LiteralArrayVar.create(["1", "2", "3"]).reverse()) + == '["1", "2", "3"].slice().reverse()' ) assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == str) # type: ignore - == "{((typeof foo) === (`string`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == int) # type: ignore - == "{((typeof foo) === (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == list) # type: ignore - == "{((typeof foo) === (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == float) # type: ignore - == "{((typeof foo) === (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == tuple) # type: ignore - == "{((typeof foo) === (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() == dict) # type: ignore - == "{((typeof foo) === (`Object`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != str) # type: ignore - == "{((typeof foo) !== (`string`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != int) # type: ignore - == "{((typeof foo) !== (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != list) # type: ignore - == "{((typeof foo) !== (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != float) # type: ignore - == "{((typeof foo) !== (`number`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != tuple) # type: ignore - == "{((typeof foo) !== (`Array`))}" - ) - assert ( - str(BaseVar(_var_name="foo", _var_type=str)._type() != dict) # type: ignore - == "{((typeof foo) !== (`Object`))}" + str(Var(_js_expr="foo")._var_set_state("state").to(list).reverse()) + == "state.foo.slice().reverse()" ) + assert str(Var(_js_expr="foo").to(list).reverse()) == "foo.slice().reverse()" + assert str(Var(_js_expr="foo", _var_type=str).js_type()) == "(typeof(foo))" @pytest.mark.parametrize( "var, expected", [ (v([1, 2, 3]), "[1, 2, 3]"), - (v(set([1, 2, 3])), "[1, 2, 3]"), + (v({1, 2, 3}), "[1, 2, 3]"), (v(["1", "2", "3"]), '["1", "2", "3"]'), - (BaseVar(_var_name="foo", _var_type=list)._var_set_state("state"), "state.foo"), - (BaseVar(_var_name="foo", _var_type=list), "foo"), + ( + Var(_js_expr="foo")._var_set_state("state").to(list), + "state.foo", + ), + (Var(_js_expr="foo").to(list), "foo"), (v((1, 2, 3)), "[1, 2, 3]"), (v(("1", "2", "3")), '["1", "2", "3"]'), ( - BaseVar(_var_name="foo", _var_type=tuple)._var_set_state("state"), + Var(_js_expr="foo")._var_set_state("state").to(tuple), "state.foo", ), - (BaseVar(_var_name="foo", _var_type=tuple), "foo"), + (Var(_js_expr="foo").to(tuple), "foo"), ], ) def test_list_tuple_contains(var, expected): - assert str(var.contains(1)) == f"{{{expected}.includes(1)}}" - assert str(var.contains("1")) == f'{{{expected}.includes("1")}}' - assert str(var.contains(v(1))) == f"{{{expected}.includes(1)}}" - assert str(var.contains(v("1"))) == f'{{{expected}.includes("1")}}' - other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state") - other_var = BaseVar(_var_name="other", _var_type=str) - assert str(var.contains(other_state_var)) == f"{{{expected}.includes(state.other)}}" - assert str(var.contains(other_var)) == f"{{{expected}.includes(other)}}" + assert str(var.contains(1)) == f"{expected}.includes(1)" + assert str(var.contains("1")) == f'{expected}.includes("1")' + assert str(var.contains(v(1))) == f"{expected}.includes(1)" + assert str(var.contains(v("1"))) == f'{expected}.includes("1")' + other_state_var = Var(_js_expr="other", _var_type=str)._var_set_state("state") + other_var = Var(_js_expr="other", _var_type=str) + assert str(var.contains(other_state_var)) == f"{expected}.includes(state.other)" + assert str(var.contains(other_var)) == f"{expected}.includes(other)" + + +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")), - (BaseVar(_var_name="foo", _var_type=str)._var_set_state("state"), "state.foo"), - (BaseVar(_var_name="foo", _var_type=str), "foo"), + (Var(_js_expr="foo")._var_set_state("state").to(str), "state.foo"), + (Var(_js_expr="foo").to(str), "foo"), ], ) def test_str_contains(var, expected): - assert str(var.contains("1")) == f'{{{expected}.includes("1")}}' - assert str(var.contains(v("1"))) == f'{{{expected}.includes("1")}}' - other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state") - other_var = BaseVar(_var_name="other", _var_type=str) - assert str(var.contains(other_state_var)) == f"{{{expected}.includes(state.other)}}" - assert str(var.contains(other_var)) == f"{{{expected}.includes(other)}}" + assert str(var.contains("1")) == f'{expected}.includes("1")' + assert str(var.contains(v("1"))) == f'{expected}.includes("1")' + other_state_var = Var(_js_expr="other")._var_set_state("state").to(str) + other_var = Var(_js_expr="other").to(str) + assert str(var.contains(other_state_var)) == f"{expected}.includes(state.other)" + assert str(var.contains(other_var)) == f"{expected}.includes(other)" assert ( - str(var.contains("1", "hello")) == f'{{{expected}.some(e=>e[`hello`]==="1")}}' + str(var.contains("1", "hello")) + == f'{expected}.some(obj => obj["hello"] === "1")' ) @pytest.mark.parametrize( "var, expected", [ - (v({"a": 1, "b": 2}), '{"a": 1, "b": 2}'), - (BaseVar(_var_name="foo", _var_type=dict)._var_set_state("state"), "state.foo"), - (BaseVar(_var_name="foo", _var_type=dict), "foo"), + (v({"a": 1, "b": 2}), '({ ["a"] : 1, ["b"] : 2 })'), + (Var(_js_expr="foo")._var_set_state("state").to(dict), "state.foo"), + (Var(_js_expr="foo").to(dict), "foo"), ], ) def test_dict_contains(var, expected): - assert str(var.contains(1)) == f"{{{expected}.hasOwnProperty(1)}}" - assert str(var.contains("1")) == f'{{{expected}.hasOwnProperty("1")}}' - assert str(var.contains(v(1))) == f"{{{expected}.hasOwnProperty(1)}}" - assert str(var.contains(v("1"))) == f'{{{expected}.hasOwnProperty("1")}}' - other_state_var = BaseVar(_var_name="other", _var_type=str)._var_set_state("state") - other_var = BaseVar(_var_name="other", _var_type=str) + assert str(var.contains(1)) == f"{expected}.hasOwnProperty(1)" + assert str(var.contains("1")) == f'{expected}.hasOwnProperty("1")' + assert str(var.contains(v(1))) == f"{expected}.hasOwnProperty(1)" + assert str(var.contains(v("1"))) == f'{expected}.hasOwnProperty("1")' + other_state_var = Var(_js_expr="other")._var_set_state("state").to(str) + other_var = Var(_js_expr="other").to(str) assert ( - str(var.contains(other_state_var)) - == f"{{{expected}.hasOwnProperty(state.other)}}" + str(var.contains(other_state_var)) == f"{expected}.hasOwnProperty(state.other)" ) - assert str(var.contains(other_var)) == f"{{{expected}.hasOwnProperty(other)}}" + assert str(var.contains(other_var)) == f"{expected}.hasOwnProperty(other)" @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="list", _var_type=List[int]), - BaseVar(_var_name="tuple", _var_type=Tuple[int, int]), - BaseVar(_var_name="str", _var_type=str), + Var(_js_expr="list", _var_type=List[int]).guess_type(), + Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(), + Var(_js_expr="str", _var_type=str).guess_type(), ], ) def test_var_indexing_lists(var): @@ -520,59 +494,62 @@ def test_var_indexing_lists(var): var : The str, list or tuple base var. """ # Test basic indexing. - assert str(var[0]) == f"{{{var._var_name}.at(0)}}" - assert str(var[1]) == f"{{{var._var_name}.at(1)}}" + assert str(var[0]) == f"{var._js_expr}.at(0)" + assert str(var[1]) == f"{var._js_expr}.at(1)" # Test negative indexing. - assert str(var[-1]) == f"{{{var._var_name}.at(-1)}}" + assert str(var[-1]) == f"{var._js_expr}.at(-1)" @pytest.mark.parametrize( "var, type_", [ - (BaseVar(_var_name="list", _var_type=List[int]), [int, int]), - (BaseVar(_var_name="tuple", _var_type=Tuple[int, str]), [int, str]), + (Var(_js_expr="list", _var_type=List[int]).guess_type(), [int, int]), + ( + Var(_js_expr="tuple", _var_type=Tuple[int, str]).guess_type(), + [int, str], + ), ], ) def test_var_indexing_types(var, type_): """Test that indexing returns valid types. Args: - var : The list, typle base var. + var : The list, tuple base var. type_ : The type on indexed object. """ - assert var[2]._var_type == type_[0] - assert var[3]._var_type == type_[1] + 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 = BaseVar(_var_name="str", _var_type=str) + str_var = Var(_js_expr="str").to(str) # Test that indexing gives a type of Var[str]. assert isinstance(str_var[0], Var) - assert str_var[0]._var_type == str + 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)}" + assert str(str_var[0]) == "str.at(0)" + assert str(str_var[1]) == "str.at(1)" # Test negative indexing. - assert str(str_var[-1]) == "{str.at(-1)}" + assert str(str_var[-1]) == "str.at(-1)" @pytest.mark.parametrize( "var", [ - (BaseVar(_var_name="foo", _var_type=int)), - (BaseVar(_var_name="bar", _var_type=float)), + (Var(_js_expr="foo", _var_type=int).guess_type()), + (Var(_js_expr="bar", _var_type=float).guess_type()), ], ) def test_var_replace_with_invalid_kwargs(var): with pytest.raises(TypeError) as excinfo: var._replace(_this_should_fail=True) - assert "Unexpected keyword arguments" in str(excinfo.value) + assert "unexpected keyword argument" in str(excinfo.value) def test_computed_var_replace_with_invalid_kwargs(): @@ -582,65 +559,71 @@ def test_computed_var_replace_with_invalid_kwargs(): with pytest.raises(TypeError) as excinfo: test_var._replace(_random_kwarg=True) - assert "Unexpected keyword arguments" in str(excinfo.value) + assert "Unexpected keyword argument" in str(excinfo.value) @pytest.mark.parametrize( "var, index", [ - (BaseVar(_var_name="lst", _var_type=List[int]), [1, 2]), - (BaseVar(_var_name="lst", _var_type=List[int]), {"name": "dict"}), - (BaseVar(_var_name="lst", _var_type=List[int]), {"set"}), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), [1, 2]), ( - BaseVar(_var_name="lst", _var_type=List[int]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + {"name": "dict"}, + ), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), {"set"}), + ( + Var(_js_expr="lst", _var_type=List[int]).guess_type(), ( 1, 2, ), ), - (BaseVar(_var_name="lst", _var_type=List[int]), 1.5), - (BaseVar(_var_name="lst", _var_type=List[int]), "str"), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), 1.5), + (Var(_js_expr="lst", _var_type=List[int]).guess_type(), "str"), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="string_var", _var_type=str), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="float_var", _var_type=float), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="list_var", _var_type=List[int]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="set_var", _var_type=Set[str]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), - (BaseVar(_var_name="str", _var_type=str), [1, 2]), - (BaseVar(_var_name="lst", _var_type=str), {"name": "dict"}), - (BaseVar(_var_name="lst", _var_type=str), {"set"}), + (Var(_js_expr="str", _var_type=str).guess_type(), [1, 2]), + (Var(_js_expr="lst", _var_type=str).guess_type(), {"name": "dict"}), + (Var(_js_expr="lst", _var_type=str).guess_type(), {"set"}), ( - BaseVar(_var_name="lst", _var_type=str), - BaseVar(_var_name="string_var", _var_type=str), + Var(_js_expr="lst", _var_type=str).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=str), - BaseVar(_var_name="float_var", _var_type=float), + Var(_js_expr="lst", _var_type=str).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), ), - (BaseVar(_var_name="str", _var_type=Tuple[str]), [1, 2]), - (BaseVar(_var_name="lst", _var_type=Tuple[str]), {"name": "dict"}), - (BaseVar(_var_name="lst", _var_type=Tuple[str]), {"set"}), + (Var(_js_expr="str", _var_type=Tuple[str]).guess_type(), [1, 2]), ( - BaseVar(_var_name="lst", _var_type=Tuple[str]), - BaseVar(_var_name="string_var", _var_type=str), + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + {"name": "dict"}, + ), + (Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), {"set"}), + ( + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + Var(_js_expr="string_var", _var_type=str).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=Tuple[str]), - BaseVar(_var_name="float_var", _var_type=float), + Var(_js_expr="lst", _var_type=Tuple[str]).guess_type(), + Var(_js_expr="float_var", _var_type=float).guess_type(), ), ], ) @@ -658,9 +641,8 @@ def test_var_unsupported_indexing_lists(var, index): @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="lst", _var_type=List[int]), - BaseVar(_var_name="tuple", _var_type=Tuple[int, int]), - BaseVar(_var_name="str", _var_type=str), + Var(_js_expr="lst", _var_type=List[int]).guess_type(), + Var(_js_expr="tuple", _var_type=Tuple[int, int]).guess_type(), ], ) def test_var_list_slicing(var): @@ -669,84 +651,105 @@ def test_var_list_slicing(var): Args: var : The str, list or tuple base var. """ - assert str(var[:1]) == f"{{{var._var_name}.slice(0, 1)}}" - assert str(var[:1]) == f"{{{var._var_name}.slice(0, 1)}}" - assert str(var[:]) == f"{{{var._var_name}.slice(0, undefined)}}" + assert str(var[:1]) == f"{var._js_expr}.slice(undefined, 1)" + assert str(var[1:]) == f"{var._js_expr}.slice(1, undefined)" + assert str(var[:]) == f"{var._js_expr}.slice(undefined, undefined)" + + +def test_str_var_slicing(): + """Test that we can slice into str vars.""" + str_var = Var(_js_expr="str").to(str) + + # Test that slicing gives a type of Var[str]. + assert isinstance(str_var[:1], Var) + assert str_var[:1]._var_type 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 = BaseVar(_var_name="dct", _var_type=Dict[str, int]) + dct = Var(_js_expr="dct").to(ObjectVar, Dict[str, str]) # Check correct indexing. - assert str(dct["a"]) == '{dct["a"]}' - assert str(dct["asdf"]) == '{dct["asdf"]}' + assert str(dct["a"]) == 'dct["a"]' + assert str(dct["asdf"]) == 'dct["asdf"]' @pytest.mark.parametrize( "var, index", [ ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), [1, 2], ), ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), {"name": "dict"}, ), ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), {"set"}, ), ( - BaseVar(_var_name="dict", _var_type=Dict[str, str]), + Var(_js_expr="dict", _var_type=Dict[str, str]).guess_type(), ( 1, 2, ), ), ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="list_var", _var_type=List[int]), + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="set_var", _var_type=Set[str]), + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - BaseVar(_var_name="lst", _var_type=Dict[str, str]), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), + Var(_js_expr="lst", _var_type=Dict[str, str]).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), [1, 2], ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), {"name": "dict"}, ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), {"set"}, ), ( - BaseVar(_var_name="df", _var_type=DataFrame), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), ( 1, 2, ), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="list_var", _var_type=List[int]), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="list_var", _var_type=List[int]).guess_type(), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="set_var", _var_type=Set[str]), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="set_var", _var_type=Set[str]).guess_type(), ), ( - BaseVar(_var_name="df", _var_type=DataFrame), - BaseVar(_var_name="dict_var", _var_type=Dict[str, str]), + Var(_js_expr="df", _var_type=DataFrame).guess_type(), + Var(_js_expr="dict_var", _var_type=Dict[str, str]).guess_type(), ), ], ) @@ -765,8 +768,6 @@ def test_var_unsupported_indexing_dicts(var, index): "fixture", [ "ParentState", - "ChildState", - "GrandChildState", "StateWithAnyVar", ], ) @@ -788,6 +789,26 @@ def test_computed_var_without_annotation_error(request, fixture): ) +@pytest.mark.parametrize( + "fixture", + [ + "ChildState", + "GrandChildState", + ], +) +def test_shadow_computed_var_error(request: pytest.FixtureRequest, fixture: str): + """Test that a name error is thrown when an attribute of a computed var is + shadowed by another attribute. + + Args: + request: Fixture Request. + fixture: The state fixture. + """ + with pytest.raises(NameError): + state = request.getfixturevalue(fixture) + state.var_without_annotation.foo + + @pytest.mark.parametrize( "fixture", [ @@ -882,7 +903,7 @@ def test_literal_var(): True, False, None, - set([1, 2, 3]), + {1, 2, 3}, ] ) assert ( @@ -892,47 +913,63 @@ def test_literal_var(): def test_function_var(): - addition_func = FunctionStringVar("((a, b) => a + b)") + 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( + manual_addition_func = ArgsFunctionOperation.create( ("a", "b"), { - "args": [ImmutableVar.create_safe("a"), ImmutableVar.create_safe("b")], - "result": ImmutableVar.create_safe("a + b"), + "args": [Var(_js_expr="a"), Var(_js_expr="b")], + "result": Var(_js_expr="a + b"), }, ) assert ( str(manual_addition_func.call(1, 2)) - == '(((a, b) => (({ ["args"] : [a, b], ["result"] : a + b })))(1, 2))' + == '(((a, b) => ({ ["args"] : [a, b], ["result"] : a + b }))(1, 2))' ) - increment_func = addition_func(1) + increment_func = addition_func.partial(1) assert ( str(increment_func.call(2)) - == "(((...args) => ((((a, b) => a + b)(1, ...args))))(2))" + == "(((...args) => (((a, b) => a + b)(1, ...args)))(2))" ) - create_hello_statement = ArgsFunctionOperation( - ("name",), f"Hello, {ImmutableVar.create_safe('name')}!" + create_hello_statement = ArgsFunctionOperation.create( + ("name",), f"Hello, {Var(_js_expr='name')}!" ) - first_name = LiteralStringVar("Steven") - last_name = LiteralStringVar("Universe") + 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")))' + == '(((name) => ("Hello, "+name+"!"))("Steven Universe"))' ) + # Test with destructured arguments + destructured_func = ArgsFunctionOperation.create( + (DestructuredArg(fields=("a", "b")),), + Var(_js_expr="a + b"), + ) + assert ( + str(destructured_func.call({"a": 1, "b": 2})) + == '((({a, b}) => a + b)(({ ["a"] : 1, ["b"] : 2 })))' + ) + + # Test with explicit return + explicit_return_func = ArgsFunctionOperation.create( + ("a", "b"), Var(_js_expr="return a + b"), explicit_return=True + ) + assert str(explicit_return_func.call(1, 2)) == "(((a, b) => {return a + b})(1, 2))" + def test_var_operation(): - @var_operation(output=NumberVar) - def add(a: Union[NumberVar, int], b: Union[NumberVar, int]) -> str: - return f"({a} + {b})" + @var_operation + def add(a: Union[NumberVar, int], b: Union[NumberVar, int]): + return var_operation_return(js_expression=f"({a} + {b})", var_type=int) assert str(add(1, 2)) == "(1 + 2)" assert str(add(a=4, b=-9)) == "(4 + -9)" - five = LiteralNumberVar(5) + five = LiteralNumberVar.create(5) seven = add(2, five) assert isinstance(seven, NumberVar) @@ -952,7 +989,7 @@ def test_string_operations(): def test_all_number_operations(): - starting_number = LiteralNumberVar(-5.4) + starting_number = LiteralNumberVar.create(-5.4) complicated_number = (((-(starting_number + 1)) * 2 / 3) // 2 % 3) ** 2 @@ -967,19 +1004,34 @@ def test_all_number_operations(): assert ( str(even_more_complicated_number) - == "!(((Math.abs(Math.floor(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2))) != 0) || (true && (Math.round(((Math.floor(((-((-5.4 + 1)) * 2) / 3) / 2) % 3) ** 2)) != 0))))" + == "!(((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(5) > False) == "(5 > 0)" - assert str(LiteralBooleanVar(False) < 5) == "((false ? 1 : 0) < 5)" + assert str(LiteralNumberVar.create(5) > False) == "(5 > 0)" + assert str(LiteralBooleanVar.create(False) < 5) == "(Number(false) < 5)" assert ( - str(LiteralBooleanVar(False) < LiteralBooleanVar(True)) - == "((false ? 1 : 0) < (true ? 1 : 0))" + 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([1, 2, 3, 4, 5]) + 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 ( @@ -988,18 +1040,34 @@ def test_index_operation(): ) assert ( str(array_var[::-1]) - == "[1, 2, 3, 4, 5].slice(0, [1, 2, 3, 4, 5].length).reverse().slice(undefined, undefined).filter((_, i) => i % 1 === 0)" + == "[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].reverse()" + 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].reverse()" + 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)" @@ -1019,7 +1087,7 @@ def test_array_operations(): def test_object_operations(): - object_var = LiteralObjectVar({"a": 1, "b": 2, "c": 3}) + object_var = LiteralObjectVar.create({"a": 1, "b": 2, "c": 3}) assert ( str(object_var.keys()) == 'Object.keys(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }))' @@ -1035,13 +1103,36 @@ def test_object_operations(): 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({"c": 4, "d": 5}))) - == 'Object.assign(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }), ({ ["c"] : 4, ["d"] : 5 }))' + 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({"a": 1, "b": 2, "c": 3}) + 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], @@ -1062,7 +1153,7 @@ def test_type_chains(): def test_nested_dict(): - arr = LiteralArrayVar([{"bar": ["foo", "bar"]}], List[Dict[str, List[str]]]) + 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)' @@ -1078,7 +1169,9 @@ def nested_base(): bar: Boo baz: int - parent_obj = LiteralVar.create(Foo(bar=Boo(foo="bar", bar=5), baz=5)) + parent_obj = LiteralObjectVar.create( + Foo(bar=Boo(foo="bar", bar=5), baz=5).dict(), Foo + ) assert ( str(parent_obj.bar.foo) @@ -1087,7 +1180,7 @@ def nested_base(): def test_retrival(): - var_without_data = ImmutableVar.create("test") + var_without_data = Var(_js_expr="test") assert var_without_data is not None original_var_data = VarData( @@ -1103,8 +1196,8 @@ def test_retrival(): assert REFLEX_VAR_OPENING_TAG in f_string assert REFLEX_VAR_CLOSING_TAG in f_string - result_var_data = Var.create_safe(f_string)._var_data - result_immutable_var_data = ImmutableVar.create_safe(f_string)._var_data + result_var_data = LiteralVar.create(f_string)._get_all_var_data() + result_immutable_var_data = Var(_js_expr=f_string)._var_data assert result_var_data is not None and result_immutable_var_data is not None assert ( result_var_data.state @@ -1113,35 +1206,23 @@ def test_retrival(): ) assert ( result_var_data.imports - == ( - result_immutable_var_data.imports - if isinstance(result_immutable_var_data.imports, dict) - else { - k: list(v) - for k, v in result_immutable_var_data.imports - if k in original_var_data.imports - } - ) + == result_immutable_var_data.imports == original_var_data.imports ) assert ( - list(result_var_data.hooks.keys()) - == ( - list(result_immutable_var_data.hooks.keys()) - if isinstance(result_immutable_var_data.hooks, dict) - else list(result_immutable_var_data.hooks) - ) - == list(original_var_data.hooks.keys()) + tuple(result_var_data.hooks) + == tuple(result_immutable_var_data.hooks) + == tuple(original_var_data.hooks) ) def test_fstring_concat(): - original_var_with_data = Var.create_safe( + original_var_with_data = LiteralVar.create( "imagination", _var_data=VarData(state="fear") ) - immutable_var_with_data = ImmutableVar.create_safe( - "consequences", + immutable_var_with_data = Var( + _js_expr="consequences", _var_data=VarData( imports={ "react": [ImportVar(tag="useRef")], @@ -1159,9 +1240,9 @@ def test_fstring_concat(): ), ) - assert str(string_concat) == '("foo"+imagination+"bar"+consequences+"baz")' + assert str(string_concat) == '("fooimaginationbar"+consequences+"baz")' assert isinstance(string_concat, ConcatVarOperation) - assert string_concat._get_all_var_data() == ImmutableVarData( + assert string_concat._get_all_var_data() == VarData( state="fear", imports={ "react": [ImportVar(tag="useRef")], @@ -1171,17 +1252,22 @@ def test_fstring_concat(): ) +var = Var(_js_expr="var", _var_type=str) +myvar = Var(_js_expr="myvar", _var_type=int)._var_set_state("state") +x = Var(_js_expr="x", _var_type=str) + + @pytest.mark.parametrize( "out, expected", [ - (f"{BaseVar(_var_name='var', _var_type=str)}", "${var}"), + (f"{var}", f"{hash(var)}var"), ( - f"testing f-string with {BaseVar(_var_name='myvar', _var_type=int)._var_set_state('state')}", - 'testing f-string with ${"state": "state", "interpolations": [], "imports": {"/utils/context": [{"tag": "StateContexts", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}], "react": [{"tag": "useContext", "is_default": false, "alias": null, "install": true, "render": true, "transpile": false}]}, "hooks": {"const state = useContext(StateContexts.state)": null}, "string_length": 13}{state.myvar}', + f"testing f-string with {myvar}", + f"testing f-string with {hash(myvar)}state.myvar", ), ( - f"testing local f-string {BaseVar(_var_name='x', _var_is_local=True, _var_type=str)}", - "testing local f-string x", + f"testing local f-string {x}", + f"testing local f-string {hash(x)}x", ), ], ) @@ -1194,8 +1280,8 @@ def test_fstrings(out, expected): [ ([1], ""), ({"a": 1}, ""), - ([Var.create_safe(1)._var_set_state("foo")], "foo"), - ({"a": Var.create_safe(1)._var_set_state("foo")}, "foo"), + ([LiteralVar.create(1)._var_set_state("foo")], "foo"), + ({"a": LiteralVar.create(1)._var_set_state("foo")}, "foo"), ], ) def test_extract_state_from_container(value, expect_state): @@ -1205,7 +1291,9 @@ def test_extract_state_from_container(value, expect_state): value: The value to create a var from. expect_state: The expected state. """ - assert Var.create_safe(value)._var_state == expect_state + var_data = LiteralVar.create(value)._get_all_var_data() + var_state = var_data.state if var_data else "" + assert var_state == expect_state @pytest.mark.parametrize( @@ -1221,25 +1309,20 @@ def test_fstring_roundtrip(value): Args: value: The value to create a Var from. """ - var = BaseVar.create_safe(value)._var_set_state("state") - rt_var = Var.create_safe(f"{var}") + var = Var(_js_expr=value)._var_set_state("state") + rt_var = LiteralVar.create(f"{var}") assert var._var_state == rt_var._var_state - assert var._var_full_name_needs_state_prefix - assert not rt_var._var_full_name_needs_state_prefix - assert rt_var._var_name == var._var_full_name + assert str(rt_var) == str(var) @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="var", _var_type=int), - BaseVar(_var_name="var", _var_type=float), - BaseVar(_var_name="var", _var_type=str), - BaseVar(_var_name="var", _var_type=bool), - BaseVar(_var_name="var", _var_type=dict), - BaseVar(_var_name="var", _var_type=tuple), - BaseVar(_var_name="var", _var_type=set), - BaseVar(_var_name="var", _var_type=None), + Var(_js_expr="var", _var_type=int).guess_type(), + Var(_js_expr="var", _var_type=float).guess_type(), + Var(_js_expr="var", _var_type=str).guess_type(), + Var(_js_expr="var", _var_type=bool).guess_type(), + Var(_js_expr="var", _var_type=None).guess_type(), ], ) def test_unsupported_types_for_reverse(var): @@ -1250,19 +1333,19 @@ def test_unsupported_types_for_reverse(var): """ with pytest.raises(TypeError) as err: var.reverse() - assert err.value.args[0] == f"Cannot reverse non-list var var." + assert err.value.args[0] == "Cannot reverse non-list var." @pytest.mark.parametrize( "var", [ - BaseVar(_var_name="var", _var_type=int), - BaseVar(_var_name="var", _var_type=float), - BaseVar(_var_name="var", _var_type=bool), - BaseVar(_var_name="var", _var_type=None), + Var(_js_expr="var", _var_type=int).guess_type(), + Var(_js_expr="var", _var_type=float).guess_type(), + Var(_js_expr="var", _var_type=bool).guess_type(), + Var(_js_expr="var", _var_type=type(None)).guess_type(), ], ) -def test_unsupported_types_for_contains(var): +def test_unsupported_types_for_contains(var: Var): """Test that unsupported types for contains throw a type error. Args: @@ -1272,34 +1355,34 @@ def test_unsupported_types_for_contains(var): assert var.contains(1) assert ( err.value.args[0] - == f"Var var of type {var._var_type} does not support contains check." + == f"Var of type {var._var_type} does not support contains check." ) @pytest.mark.parametrize( "other", [ - BaseVar(_var_name="other", _var_type=int), - BaseVar(_var_name="other", _var_type=float), - BaseVar(_var_name="other", _var_type=bool), - BaseVar(_var_name="other", _var_type=list), - BaseVar(_var_name="other", _var_type=dict), - BaseVar(_var_name="other", _var_type=tuple), - BaseVar(_var_name="other", _var_type=set), + Var(_js_expr="other", _var_type=int).guess_type(), + Var(_js_expr="other", _var_type=float).guess_type(), + Var(_js_expr="other", _var_type=bool).guess_type(), + Var(_js_expr="other", _var_type=list).guess_type(), + Var(_js_expr="other", _var_type=dict).guess_type(), + Var(_js_expr="other", _var_type=tuple).guess_type(), + Var(_js_expr="other", _var_type=set).guess_type(), ], ) def test_unsupported_types_for_string_contains(other): with pytest.raises(TypeError) as err: - assert BaseVar(_var_name="var", _var_type=str).contains(other) + assert Var(_js_expr="var").to(str).contains(other) assert ( err.value.args[0] - == f"'in ' requires string as left operand, not {other._var_type}" + == f"Unsupported Operand type(s) for contains: ToStringOperation, {type(other).__name__}" ) def test_unsupported_default_contains(): with pytest.raises(TypeError) as err: - assert 1 in BaseVar(_var_name="var", _var_type=str) + assert 1 in Var(_js_expr="var", _var_type=str).guess_type() assert ( err.value.args[0] == "'in' operator not supported for Var types, use Var.contains() instead." @@ -1310,8 +1393,8 @@ def test_unsupported_default_contains(): "operand1_var,operand2_var,operators", [ ( - Var.create(10), - Var.create(5), + LiteralVar.create(10), + LiteralVar.create(5), [ "+", "-", @@ -1329,13 +1412,13 @@ def test_unsupported_default_contains(): ], ), ( - Var.create(10.5), - Var.create(5), + LiteralVar.create(10.5), + LiteralVar.create(5), ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], ), ( - Var.create(5), - Var.create(True), + LiteralVar.create(5), + LiteralVar.create(True), [ "+", "-", @@ -1353,22 +1436,26 @@ def test_unsupported_default_contains(): ], ), ( - Var.create(10.5), - Var.create(5.5), + LiteralVar.create(10.5), + LiteralVar.create(5.5), ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], ), ( - Var.create(10.5), - Var.create(True), + LiteralVar.create(10.5), + LiteralVar.create(True), ["+", "-", "/", "//", "*", "%", "**", ">", "<", "<=", ">="], ), - (Var.create("10"), Var.create("5"), ["+", ">", "<", "<=", ">="]), - (Var.create([10, 20]), Var.create([5, 6]), ["+", ">", "<", "<=", ">="]), - (Var.create([10, 20]), Var.create(5), ["*"]), - (Var.create([10, 20]), Var.create(True), ["*"]), + (LiteralVar.create("10"), LiteralVar.create("5"), ["+", ">", "<", "<=", ">="]), ( - Var.create(True), - Var.create(True), + LiteralVar.create([10, 20]), + LiteralVar.create([5, 6]), + ["+", ">", "<", "<=", ">="], + ), + (LiteralVar.create([10, 20]), LiteralVar.create(5), ["*"]), + (LiteralVar.create([10, 20]), LiteralVar.create(True), ["*"]), + ( + LiteralVar.create(True), + LiteralVar.create(True), [ "+", "-", @@ -1396,16 +1483,26 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s operators: list of supported operators. """ for operator in operators: - operand1_var.operation(op=operator, other=operand2_var) - operand1_var.operation(op=operator, other=operand2_var, flip=True) + print( + "testing", + operator, + "on", + operand1_var, + operand2_var, + " of types", + type(operand1_var), + type(operand2_var), + ) + eval(f"operand1_var {operator} operand2_var") + eval(f"operand2_var {operator} operand1_var") @pytest.mark.parametrize( "operand1_var,operand2_var,operators", [ ( - Var.create(10), - Var.create(5), + LiteralVar.create(10), + LiteralVar.create(5), [ "^", "<<", @@ -1413,41 +1510,35 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s ], ), ( - Var.create(10.5), - Var.create(5), + LiteralVar.create(10.5), + LiteralVar.create(5), [ - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create(10.5), - Var.create(True), + LiteralVar.create(10.5), + LiteralVar.create(True), [ - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create(10.5), - Var.create(5.5), + LiteralVar.create(10.5), + LiteralVar.create(5.5), [ - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create("10"), - Var.create("5"), + LiteralVar.create("10"), + LiteralVar.create("5"), [ "-", "/", @@ -1455,16 +1546,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "*", "%", "**", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create([5, 6]), + LiteralVar.create([10, 20]), + LiteralVar.create([5, 6]), [ "-", "/", @@ -1472,16 +1561,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "*", "%", "**", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create(5), + LiteralVar.create([10, 20]), + LiteralVar.create(5), [ "+", "-", @@ -1493,16 +1580,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create(True), + LiteralVar.create([10, 20]), + LiteralVar.create(True), [ "+", "-", @@ -1514,16 +1599,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create("5"), + LiteralVar.create([10, 20]), + LiteralVar.create("5"), [ "+", "-", @@ -1536,16 +1619,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create({"key": "value"}), + LiteralVar.create([10, 20]), + LiteralVar.create({"key": "value"}), [ "+", "-", @@ -1558,16 +1639,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create([10, 20]), - Var.create(5.5), + LiteralVar.create([10, 20]), + LiteralVar.create(5.5), [ "+", "-", @@ -1580,16 +1659,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create({"another_key": "another_value"}), + LiteralVar.create({"key": "value"}), + LiteralVar.create({"another_key": "another_value"}), [ "+", "-", @@ -1602,16 +1679,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create(5), + LiteralVar.create({"key": "value"}), + LiteralVar.create(5), [ "+", "-", @@ -1624,16 +1699,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create(True), + LiteralVar.create({"key": "value"}), + LiteralVar.create(True), [ "+", "-", @@ -1646,16 +1719,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create(5.5), + LiteralVar.create({"key": "value"}), + LiteralVar.create(5.5), [ "+", "-", @@ -1668,16 +1739,14 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ( - Var.create({"key": "value"}), - Var.create("5"), + LiteralVar.create({"key": "value"}), + LiteralVar.create("5"), [ "+", "-", @@ -1690,44 +1759,46 @@ def test_valid_var_operations(operand1_var: Var, operand2_var, operators: List[s "<", "<=", ">=", - "|", "^", "<<", ">>", - "&", ], ), ], ) def test_invalid_var_operations(operand1_var: Var, operand2_var, operators: List[str]): for operator in operators: + print(f"testing {operator} on {operand1_var!s} and {operand2_var!s}") with pytest.raises(TypeError): - operand1_var.operation(op=operator, other=operand2_var) + print(eval(f"operand1_var {operator} operand2_var")) with pytest.raises(TypeError): - operand1_var.operation(op=operator, other=operand2_var, flip=True) + print(eval(f"operand2_var {operator} operand1_var")) @pytest.mark.parametrize( "var, expected", [ - (Var.create("string_value", _var_is_string=True), "`string_value`"), - (Var.create(1), "1"), - (Var.create([1, 2, 3]), "[1, 2, 3]"), - (Var.create({"foo": "bar"}), '{"foo": "bar"}'), + (LiteralVar.create("string_value"), '"string_value"'), + (LiteralVar.create(1), "1"), + (LiteralVar.create([1, 2, 3]), "[1, 2, 3]"), + (LiteralVar.create({"foo": "bar"}), '({ ["foo"] : "bar" })'), ( - Var.create(ATestState.value, _var_is_string=True), + LiteralVar.create(ATestState.value), f"{ATestState.get_full_name()}.value", ), ( - Var.create(f"{ATestState.value} string", _var_is_string=True), - f"`${{{ATestState.get_full_name()}.value}} string`", + 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", ), - (Var.create(ATestState.dict_val), f"{ATestState.get_full_name()}.dict_val"), ], ) def test_var_name_unwrapped(var, expected): - assert var._var_name_unwrapped == expected + assert str(var) == expected def cv_fget(state: BaseState) -> int: @@ -1770,3 +1841,24 @@ def test_invalid_computed_var_deps(deps: List): ) def test_var(state) -> int: return 1 + + +def test_to_string_operation(): + class Email(str): ... + + class TestState(BaseState): + optional_email: Optional[Email] = None + email: Email = Email("test@reflex.dev") + + assert ( + str(TestState.optional_email) == f"{TestState.get_full_name()}.optional_email" + ) + my_state = TestState() + assert my_state.optional_email is None + assert my_state.email == "test@reflex.dev" + + assert cast(Var, TestState.email)._var_type == Email + assert cast(Var, TestState.optional_email)._var_type == Optional[Email] + + single_var = Var.create(Email()) + assert single_var._var_type == Email diff --git a/tests/utils/__init__.py b/tests/units/utils/__init__.py similarity index 100% rename from tests/utils/__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 68% rename from tests/utils/test_format.py rename to tests/units/utils/test_format.py index 95ebc047b..2a2aa8259 100644 --- a/tests/utils/test_format.py +++ b/tests/units/utils/test_format.py @@ -1,18 +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.utils.serializers import serialize_figure -from reflex.vars import BaseVar, Var -from tests.test_state import ( +from reflex.vars.base import LiteralVar, Var +from reflex.vars.object import ObjectVar +from tests.units.test_state import ( ChildState, ChildState2, ChildState3, @@ -260,7 +262,7 @@ def test_to_kebab_case(input: str, output: str): ], ) def test_format_string(input: str, output: str): - """Test formating the input as JS string literal. + """Test formatting the input as JS string literal. Args: input: the input string. @@ -272,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( @@ -312,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): " - 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;};})()", + 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. @@ -456,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: [], ), - '{(...args) => addEvents([Event("mock_event", {})], args, {})}', + '((...args) => (addEvents([(Event("mock_event", ({ }), ({ })))], args, ({ }))))', ), ( EventChain( @@ -486,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 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( @@ -505,7 +403,19 @@ def test_format_match( args_spec=lambda: [], event_actions={"stopPropagation": True}, ), - '{(...args) => addEvents([Event("mock_event", {})], args, {"stopPropagation": true})}', + '((...args) => (addEvents([(Event("mock_event", ({ }), ({ })))], args, ({ ["stopPropagation"] : true }))))', + ), + ( + EventChain( + events=[ + EventSpec( + handler=EventHandler(fn=mock_event), + event_actions={"stopPropagation": True}, + ) + ], + args_spec=lambda: [], + ), + '((...args) => (addEvents([(Event("mock_event", ({ }), ({ ["stopPropagation"] : true })))], args, ({ }))))', ), ( EventChain( @@ -513,35 +423,41 @@ def test_format_match( args_spec=lambda: [], event_actions={"preventDefault": True}, ), - '{(...args) => addEvents([Event("mock_event", {})], args, {"preventDefault": true})}', + '((...args) => (addEvents([(Event("mock_event", ({ }), ({ })))], args, ({ ["preventDefault"] : true }))))', ), - ({"a": "red", "b": "blue"}, '{{"a": "red", "b": "blue"}}'), - (BaseVar(_var_name="var", _var_type="int"), "{var}"), + ({"a": "red", "b": "blue"}, '({ ["a"] : "red", ["b"] : "blue" })'), + (Var(_js_expr="var", _var_type=int).guess_type(), "var"), ( - BaseVar( - _var_name="_", + Var( + _js_expr="_", _var_type=Any, - _var_is_local=True, - _var_is_string=False, ), - "{_}", + "_", ), ( - BaseVar(_var_name='state.colors["a"]', _var_type="str"), - '{state.colors["a"]}', + Var(_js_expr='state.colors["a"]', _var_type=str).guess_type(), + 'state.colors["a"]', ), - ({"a": BaseVar(_var_name="val", _var_type="str")}, '{{"a": val}}'), - ({"a": BaseVar(_var_name='"val"', _var_type="str")}, '{{"a": "val"}}'), ( - {"a": BaseVar(_var_name='state.colors["val"]', _var_type="str")}, - '{{"a": state.colors["val"]}}', + {"a": Var(_js_expr="val", _var_type=str).guess_type()}, + '({ ["a"] : val })', + ), + ( + {"a": Var(_js_expr='"val"', _var_type=str).guess_type()}, + '({ ["a"] : "val" })', + ), + ( + {"a": Var(_js_expr='state.colors["val"]', _var_type=str).guess_type()}, + '({ ["a"] : state.colors["val"] })', ), # tricky real-world case from markdown component ( { - "h1": f"{{({{node, ...props}}) => }}" + "h1": Var( + _js_expr=f"(({{node, ...props}}) => )" + ), }, - '{{"h1": ({node, ...props}) => }}', + '({ ["h1"] : (({node, ...props}) => ) })', ), ], ) @@ -552,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): @@ -609,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( @@ -663,6 +557,7 @@ formatted_router = { "origin": "", "upgrade": "", "connection": "", + "cookie": "", "pragma": "", "cache_control": "", "user_agent": "", @@ -706,6 +601,7 @@ formatted_router = { "sum": 3.14, "upper": "", "router": formatted_router, + "asynctest": 0, }, ChildState.get_full_name(): { "count": 23, @@ -739,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( @@ -766,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", [ @@ -799,7 +680,7 @@ def test_format_breadcrumbs(input, output): ], ) def test_format_library_name(input: str, output: str): - """Test formating a library name to remove the @version part. + """Test formatting a library name to remove the @version part. Args: input: the input string. diff --git a/tests/utils/test_imports.py b/tests/units/utils/test_imports.py similarity index 88% rename from tests/utils/test_imports.py rename to tests/units/utils/test_imports.py index e9be5c1be..c30d1d85c 100644 --- a/tests/utils/test_imports.py +++ b/tests/units/utils/test_imports.py @@ -54,17 +54,21 @@ def test_import_var(import_var, expected_name): ( {"react": {"Component"}}, {"react": {"Component"}, "react-dom": {"render"}}, - {"react": {"Component"}, "react-dom": {"render"}}, + {"react": {ImportVar("Component")}, "react-dom": {ImportVar("render")}}, ), ( {"react": {"Component"}, "next/image": {"Image"}}, {"react": {"Component"}, "react-dom": {"render"}}, - {"react": {"Component"}, "react-dom": {"render"}, "next/image": {"Image"}}, + { + "react": {ImportVar("Component")}, + "react-dom": {ImportVar("render")}, + "next/image": {ImportVar("Image")}, + }, ), ( {"react": {"Component"}}, {"": {"some/custom.css"}}, - {"react": {"Component"}, "": {"some/custom.css"}}, + {"react": {ImportVar("Component")}, "": {ImportVar("some/custom.css")}}, ), ], ) diff --git a/tests/utils/test_serializers.py b/tests/units/utils/test_serializers.py similarity index 66% rename from tests/utils/test_serializers.py rename to tests/units/utils/test_serializers.py index b516f5eb3..e5a47abaa 100644 --- a/tests/utils/test_serializers.py +++ b/tests/units/utils/test_serializers.py @@ -1,24 +1,25 @@ import datetime +import json from enum import Enum from pathlib import Path -from typing import Any, Dict, List, Type +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. - Args: type_: The type to check. expected: The expected result. @@ -29,27 +30,16 @@ 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), ], ) def test_get_serializer(type_: Type, expected: serializers.Serializer): """Test that get_serializer returns the correct value. - Args: type_: The type to check. expected: The expected result. @@ -104,7 +94,7 @@ class StrEnum(str, Enum): BAR = "bar" -class TestEnum(Enum): +class FooBarEnum(Enum): """A lone enum class.""" FOO = "foo" @@ -133,48 +123,59 @@ class BaseSubclass(Base): "value,expected", [ ("test", "test"), - (1, "1"), - (1.0, "1.0"), - (True, "true"), - (False, "false"), - (None, "null"), - ([1, 2, 3], "[1, 2, 3]"), - ([1, "2", 3.0], '[1, "2", 3.0]'), - ([{"key": 1}, {"key": 2}], '[{"key": 1}, {"key": 2}]'), + (1, 1), + (1.0, 1.0), + (True, True), + (False, False), + (None, None), + ([1, 2, 3], [1, 2, 3]), + ([1, "2", 3.0], [1, "2", 3.0]), + ([{"key": 1}, {"key": 2}], [{"key": 1}, {"key": 2}]), (StrEnum.FOO, "foo"), - ([StrEnum.FOO, StrEnum.BAR], '["foo", "bar"]'), + ([StrEnum.FOO, StrEnum.BAR], ["foo", "bar"]), ( {"key1": [1, 2, 3], "key2": [StrEnum.FOO, StrEnum.BAR]}, - '{"key1": [1, 2, 3], "key2": ["foo", "bar"]}', + { + "key1": [1, 2, 3], + "key2": ["foo", "bar"], + }, ), (EnumWithPrefix.FOO, "prefix_foo"), - ([EnumWithPrefix.FOO, EnumWithPrefix.BAR], '["prefix_foo", "prefix_bar"]'), + ([EnumWithPrefix.FOO, EnumWithPrefix.BAR], ["prefix_foo", "prefix_bar"]), ( {"key1": EnumWithPrefix.FOO, "key2": EnumWithPrefix.BAR}, - '{"key1": "prefix_foo", "key2": "prefix_bar"}', + { + "key1": "prefix_foo", + "key2": "prefix_bar", + }, ), - (TestEnum.FOO, "foo"), - ([TestEnum.FOO, TestEnum.BAR], '["foo", "bar"]'), + (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"), @@ -182,7 +183,7 @@ class BaseSubclass(Base): (datetime.timedelta(1, 1, 1), "1 day, 0:00:01.000001"), ( [datetime.timedelta(1, 1, 1), datetime.timedelta(1, 1, 2)], - '["1 day, 0:00:01.000001", "1 day, 0:00:01.000002"]', + ["1 day, 0:00:01.000001", "1 day, 0:00:01.000002"], ), (Color(color="slate", shade=1), "var(--slate-1)"), (Color(color="orange", shade=1, alpha=True), "var(--orange-a1)"), @@ -192,35 +193,39 @@ class BaseSubclass(Base): def test_serialize(value: Any, expected: str): """Test that serialize returns the correct value. - Args: 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), + ("test", '"test"', False), (1, "1", False), (1.0, "1.0", False), (True, "true", False), (False, "false", False), ([1, 2, 3], "[1, 2, 3]", False), - ([{"key": 1}, {"key": 2}], '[{"key": 1}, {"key": 2}]', False), - (StrEnum.FOO, "foo", False), + ([{"key": 1}, {"key": 2}], '[({ ["key"] : 1 }), ({ ["key"] : 2 })]', False), + (StrEnum.FOO, '"foo"', False), ([StrEnum.FOO, StrEnum.BAR], '["foo", "bar"]', False), ( BaseSubclass(ts=datetime.timedelta(1, 1, 1)), - '{"ts": "1 day, 0:00:01.000001"}', + '({ ["ts"] : "1 day, 0:00:01.000001" })', False, ), - (datetime.datetime(2021, 1, 1, 1, 1, 1, 1), "2021-01-01 01:01:01.000001", True), - (Color(color="slate", shade=1), "var(--slate-1)", True), - (BaseSubclass, "BaseSubclass", True), - (Path("."), ".", True), + ( + datetime.datetime(2021, 1, 1, 1, 1, 1, 1), + '"2021-01-01 01:01:01.000001"', + True, + ), + (datetime.date(2021, 1, 1), '"2021-01-01"', True), + (Color(color="slate", shade=1), '"var(--slate-1)"', True), + (BaseSubclass, '"BaseSubclass"', True), + (Path(), '"."', True), ], ) def test_serialize_var_to_str(value: Any, expected: str, exp_var_is_string: bool): @@ -231,6 +236,5 @@ def test_serialize_var_to_str(value: Any, expected: str, exp_var_is_string: bool expected: The expected result. exp_var_is_string: The expected value of _var_is_string. """ - v = Var.create_safe(value) - assert v._var_full_name == expected - assert v._var_is_string == exp_var_is_string + v = LiteralVar.create(value) + assert str(v) == expected diff --git a/tests/utils/test_types.py b/tests/units/utils/test_types.py similarity index 56% rename from tests/utils/test_types.py rename to tests/units/utils/test_types.py index fc9261e04..87790e979 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 @@ -17,7 +17,7 @@ def test_validate_literal_error_msg(params, allowed_value_str, value_str): types.validate_literal(*params) assert ( - err.value.args[0] == f"prop value for {str(params[0])} of the `{params[-1]}` " + err.value.args[0] == f"prop value for {params[0]!s} of the `{params[-1]}` " f"component should be one of the following: {allowed_value_str}. Got {value_str} instead" ) @@ -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 84% rename from tests/utils/test_utils.py rename to tests/units/utils/test_utils.py index e905ff587..f8573111c 100644 --- a/tests/utils/test_utils.py +++ b/tests/units/utils/test_utils.py @@ -2,7 +2,7 @@ import os import typing from functools import cached_property from pathlib import Path -from typing import Any, ClassVar, List, Literal, Type, Union +from typing import Any, ClassVar, Dict, List, Literal, Type, Union import pytest import typer @@ -10,16 +10,13 @@ from packaging import version from reflex import constants from reflex.base import Base +from reflex.config import environment from reflex.event import EventHandler from reflex.state import BaseState -from reflex.utils import ( - build, - prerequisites, - types, -) +from reflex.utils import build, prerequisites, 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, SystemPackageMissingError +from reflex.vars.base import Var def mock_event(arg): @@ -77,6 +74,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. @@ -117,7 +155,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() @@ -232,7 +270,7 @@ def test_unsupported_literals(cls: type): ("appname2.io", "AppnameioConfig"), ], ) -def test_create_config(app_name, expected_config_name, mocker): +def test_create_config(app_name: str, expected_config_name: str, mocker): """Test templates.RXCONFIG is formatted with correct app name and config class name. Args: @@ -240,7 +278,7 @@ def test_create_config(app_name, expected_config_name, mocker): expected_config_name: Expected config name. mocker: Mocker object. """ - mocker.patch("builtins.open") + mocker.patch("pathlib.Path.write_text") tmpl_mock = mocker.patch("reflex.compiler.templates.RXCONFIG") prerequisites.create_config(app_name) tmpl_mock.render.assert_called_with( @@ -260,7 +298,7 @@ def tmp_working_dir(tmp_path): Yields: subdirectory of tmp_path which is now the current working directory. """ - old_pwd = Path(".").resolve() + old_pwd = Path.cwd() working_dir = tmp_path / "working_dir" working_dir.mkdir() os.chdir(working_dir) @@ -426,7 +464,7 @@ def test_node_install_unix(tmp_path, mocker, machine, system): mocker.patch("httpx.stream", return_value=Resp()) download = mocker.patch("reflex.utils.prerequisites.download_and_extract_fnm_zip") process = mocker.patch("reflex.utils.processes.new_process") - chmod = mocker.patch("reflex.utils.prerequisites.os.chmod") + chmod = mocker.patch("pathlib.Path.chmod") mocker.patch("reflex.utils.processes.stream_logs") prerequisites.install_node() @@ -458,10 +496,10 @@ 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): + with pytest.raises(SystemPackageMissingError): prerequisites.install_bun() @@ -476,7 +514,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), @@ -538,11 +576,25 @@ 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 + ) + + +def test_is_prod_mode() -> None: + """Test that the prod mode is correctly determined.""" + environment.REFLEX_ENV_MODE.set(constants.Env.PROD) + assert utils_exec.is_prod_mode() + environment.REFLEX_ENV_MODE.set(None) + assert not utils_exec.is_prod_mode() 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/units/vars/test_object.py b/tests/units/vars/test_object.py new file mode 100644 index 000000000..efcb21166 --- /dev/null +++ b/tests/units/vars/test_object.py @@ -0,0 +1,102 @@ +import pytest +from typing_extensions import assert_type + +import reflex as rx +from reflex.utils.types import GenericType +from reflex.vars.base import Var +from reflex.vars.object import LiteralObjectVar, ObjectVar + + +class Bare: + """A bare class with a single attribute.""" + + quantity: int = 0 + + +@rx.serializer +def serialize_bare(obj: Bare) -> dict: + """A serializer for the bare class. + + Args: + obj: The object to serialize. + + Returns: + A dictionary with the quantity attribute. + """ + return {"quantity": obj.quantity} + + +class Base(rx.Base): + """A reflex base class with a single attribute.""" + + quantity: int = 0 + + +class ObjectState(rx.State): + """A reflex state with bare and base objects.""" + + bare: rx.Field[Bare] = rx.field(Bare()) + base: rx.Field[Base] = rx.field(Base()) + + +@pytest.mark.parametrize("type_", [Base, Bare]) +def test_var_create(type_: GenericType) -> None: + my_object = type_() + var = Var.create(my_object) + assert var._var_type is type_ + + quantity = var.quantity + assert quantity._var_type is int + + +@pytest.mark.parametrize("type_", [Base, Bare]) +def test_literal_create(type_: GenericType) -> None: + my_object = type_() + var = LiteralObjectVar.create(my_object) + assert var._var_type is type_ + + quantity = var.quantity + assert quantity._var_type is int + + +@pytest.mark.parametrize("type_", [Base, Bare]) +def test_guess(type_: GenericType) -> None: + my_object = type_() + var = Var.create(my_object) + var = var.guess_type() + assert var._var_type is type_ + + quantity = var.quantity + assert quantity._var_type is int + + +@pytest.mark.parametrize("type_", [Base, Bare]) +def test_state(type_: GenericType) -> None: + attr_name = type_.__name__.lower() + var = getattr(ObjectState, attr_name) + assert var._var_type is type_ + + quantity = var.quantity + assert quantity._var_type is int + + +@pytest.mark.parametrize("type_", [Base, Bare]) +def test_state_to_operation(type_: GenericType) -> None: + attr_name = type_.__name__.lower() + original_var = getattr(ObjectState, attr_name) + + var = original_var.to(ObjectVar, type_) + assert var._var_type is type_ + + var = original_var.to(ObjectVar) + assert var._var_type is type_ + + +def test_typing() -> None: + # Bare + var = ObjectState.bare.to(ObjectVar) + _ = assert_type(var, ObjectVar[Bare]) + + # Base + var = ObjectState.base + _ = assert_type(var, ObjectVar[Base])