diff --git a/.github/workflows/dispatch_release.yml b/.github/workflows/dispatch_release.yml index e11adc81957..91107ea316f 100644 --- a/.github/workflows/dispatch_release.yml +++ b/.github/workflows/dispatch_release.yml @@ -139,6 +139,10 @@ on: description: "reflex-components-sonner" type: boolean default: false + reflex_components_ui: + description: "reflex-components-ui" + type: boolean + default: false reflex_docgen: description: "reflex-docgen" type: boolean @@ -207,6 +211,7 @@ jobs: ${{ inputs.reflex_components_react_player && 'reflex-components-react-player' || '' }} ${{ inputs.reflex_components_recharts && 'reflex-components-recharts' || '' }} ${{ inputs.reflex_components_sonner && 'reflex-components-sonner' || '' }} + ${{ inputs.reflex_components_ui && 'reflex-components-ui' || '' }} ${{ inputs.reflex_docgen && 'reflex-docgen' || '' }} ${{ inputs.reflex_hosting_cli && 'reflex-hosting-cli' || '' }} ${{ inputs.reflex_otel && 'reflex-otel' || '' }} diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 23ddd7ef686..9a7daf90057 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -349,7 +349,83 @@ jobs: - name: Run Playwright integration tests env: REFLEX_REDIS_URL: ${{ matrix.state_manager == 'redis' && 'redis://localhost:6379' || '' }} - run: uv run pytest tests/integration/tests_playwright --reruns 3 -rs -v --maxfail=5 --splits 2 --group ${{ matrix.split_index }} + # The rx.ui parity harness has jobs of its own below: it compares + # pixels, which a rerun must not paper over. + run: uv run pytest tests/integration/tests_playwright --ignore=tests/integration/tests_playwright/test_ui_parity.py --reruns 3 -rs -v --maxfail=5 --splits 2 --group ${{ matrix.split_index }} + + # The look of every rx.ui component against the Radix one it replaces: + # pixels, computed styles and accessibility tree, cell by cell. + ui-parity: + needs: changes + if: needs.changes.outputs.run == 'true' + timeout-minutes: 30 + runs-on: ubuntu-22.04 + env: + UI_PARITY_REPORT: ui-parity-report + # The build and every matrix together, in seconds: the run fails above. + UI_PARITY_BUDGET_SECONDS: "900" + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-tags: true + fetch-depth: 0 + persist-credentials: false + - uses: ./.github/actions/setup_build_env + with: + python-version: "3.14" + run-uv-sync: true + - name: Install Playwright Chromium + run: uv run playwright install chromium --only-shell + - name: Compare every matrix with Radix Themes + run: uv run pytest tests/integration/tests_playwright/test_ui_parity.py -k "not test_contract" -rs -v + - name: Report the run time + if: always() + run: | + if [ -f "$UI_PARITY_REPORT/timings.json" ]; then + { + echo '### rx.ui parity run time' + echo '```json' + cat "$UI_PARITY_REPORT/timings.json" + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + fi + - name: Upload the report + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: ui-parity-report + path: ui-parity-report + if-no-files-found: warn + + # The behaviour contract of every rx.ui component, and of the Radix one it + # replaces, in each browser engine. + ui-contracts: + needs: changes + if: needs.changes.outputs.run == 'true' + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + engine: [chromium, firefox, webkit] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-tags: true + fetch-depth: 0 + persist-credentials: false + - uses: ./.github/actions/setup_build_env + with: + python-version: "3.14" + run-uv-sync: true + - name: Install Playwright ${{ matrix.engine }} + env: + ENGINE: ${{ matrix.engine }} + run: uv run playwright install --with-deps "$ENGINE" + - name: Run every contract in ${{ matrix.engine }} + env: + ENGINE: ${{ matrix.engine }} + run: uv run pytest tests/integration/tests_playwright/test_ui_parity.py --browser "$ENGINE" -k test_contract -rs -v bun-only-startup: needs: changes @@ -413,6 +489,8 @@ jobs: reflex-docs-macos, app-harness, app-harness-playwright, + ui-parity, + ui-contracts, bun-only-startup, ] if: always() diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 27e27303b6a..004885ccfad 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -191,6 +191,34 @@ jobs: if-no-files-found: error retention-days: 7 + ui-js-checks: + # Checks the javascript reflex-components-ui embeds: its lint rules (no + # components, no barrels, StyleX), the type check, the generated files and + # the tests. + needs: changes + if: needs.changes.outputs.run == 'true' + timeout-minutes: 10 + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/reflex-components-ui/js + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: 22 + cache: npm + cache-dependency-path: packages/reflex-components-ui/js/package-lock.json + - run: npm ci + - run: npm run lint + - run: npm run typecheck + - run: npm run generate:check + # The tests of the tokens and themes read computed styles in a browser. + - run: npx playwright install --with-deps --only-shell chromium + - run: npm test + unit-tests-macos: timeout-minutes: 30 if: github.event_name == 'push' && github.ref == 'refs/heads/main' @@ -224,7 +252,7 @@ jobs: # jobs above directly does not survive: check names follow the matrix and the # display names, and a job that a filter skips must not block the merge. unit-tests-gate: - needs: [changes, unit-tests, js-unit-tests, unit-tests-macos] + needs: [changes, unit-tests, js-unit-tests, ui-js-checks, unit-tests-macos] if: always() runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 85354828f2b..2a8220b8fd5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,9 @@ reflex.db .env.* node_modules package-lock.json -# ...except the frontend package, which CI installs with `npm ci`. +# ...except the javascript packages, which CI installs with `npm ci`. !packages/reflex-frontend/package-lock.json +!packages/reflex-components-ui/js/package-lock.json *.pyi .pre-commit-config.yaml .claude/.worktrees diff --git a/AGENTS.md b/AGENTS.md index 9bc22def8d8..2dbd53f2dca 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,6 +25,8 @@ uv run reflex-release sync # regenerate th uv run python scripts/make_pyi.py # regenerate .pyi stubs uv run pre-commit run --all-files # all pre-commit hooks npm --prefix packages/reflex-frontend ci && npm --prefix packages/reflex-frontend run check # frontend package: lint, type-check (JSDoc) and unit tests +npm --prefix packages/reflex-components-ui/js ci && npm --prefix packages/reflex-components-ui/js run check # rx.ui javascript: lint, type-check (JSDoc), generated files and unit tests +uv run python scripts/ui_parity.py [component] # rx.ui parity harness: look and behaviour against the Radix components, in Chromium (--all-engines adds Firefox and WebKit) ``` ## Layout diff --git a/docs/api-reference/plugins.md b/docs/api-reference/plugins.md index 3374544c415..3066cc9c7ab 100644 --- a/docs/api-reference/plugins.md +++ b/docs/api-reference/plugins.md @@ -203,6 +203,10 @@ class Plugin: """Get paths to stylesheets required by the plugin.""" return [] + def get_vite_plugins(self, **context) -> Sequence[VitePluginEntry]: + """Get Vite plugins to add to the generated vite.config.js.""" + return [] + def register_route(self, **context) -> None: """Contribute pages before the app's first compilation.""" pass @@ -295,6 +299,70 @@ during collection, while the framework owns the final batch commit. The public API but are intentionally not dispatched during a staged plugin batch, so an override cannot make the batch commit partially. +### Adding Vite Plugins + +Reflex generates the app's `vite.config.js` and rewrites it on every compile. A +plugin adds a Vite plugin to it by overriding `get_vite_plugins`, which returns +`VitePluginEntry` objects. Each entry carries JavaScript source: the import +statements it needs, and the expression to place in the `plugins` array. + +```python +from reflex.plugins import Plugin, VitePluginEntry + + +class InspectPlugin(Plugin): + def get_frontend_development_dependencies(self, **context): + return ["vite-plugin-inspect"] + + def get_vite_plugins(self, **context): + return [ + VitePluginEntry( + imports=['import inspect from "vite-plugin-inspect"'], + call="inspect({ build: true })", + ) + ] +``` + +This renders as: + +```javascript +import inspect from "vite-plugin-inspect"; + +export default defineConfig((config) => ({ + plugins: [ + alwaysUseReactDomServerNode(), + inspect({ build: true }), + reactRouter(), + // ... + ], +})); +``` + +- `imports` is a sequence of import statements, one per string, with or without + the closing semicolon. An entry may need several. A statement that several + entries share is written once, so two plugins can import the same name from + the same package; importing one name from two different modules is a syntax + error in the generated file. +- `call` is any JavaScript expression: usually a call, possibly spanning + several lines. It may evaluate to one Vite plugin or to an array of them. +- Module specifiers resolve from `.web`. Import an npm package by name, and a + file the plugin writes with `get_static_assets` by its relative path, such as + `"./my-vite-plugin.js"`. +- Entries are placed ahead of `reactRouter()` (and after React Compiler, when + `react_compiler` is enabled), in the order of the plugins in `rxconfig.py` + and then in the order each plugin returns them. Vite's own `enforce: "pre"` + and `enforce: "post"` still apply within that order. +- A Vite plugin only runs at build time, so declare its npm packages in + `get_frontend_development_dependencies`. Packages returned from + `get_frontend_dependencies` are also bundled into the app. + +A malformed entry stops the compile with an `InvalidVitePluginError` that names +the plugin and the entry, for example: + +```text +InspectPlugin.get_vite_plugins() returned an invalid entry: entry 0 has 'vite-plugin-inspect' in imports, which is not an import statement. +``` + ### Looking Up Configured Plugins Use `rx.plugins.get_plugin(PluginType)` when runtime behavior needs the plugin diff --git a/docs/app/.github/workflows/unit_tests.yml b/docs/app/.github/workflows/unit_tests.yml index 191ab754e4b..be62b49d41d 100644 --- a/docs/app/.github/workflows/unit_tests.yml +++ b/docs/app/.github/workflows/unit_tests.yml @@ -64,7 +64,8 @@ jobs: --upgrade-package reflex-components-radix \ --upgrade-package reflex-components-react-player \ --upgrade-package reflex-components-recharts \ - --upgrade-package reflex-components-sonner + --upgrade-package reflex-components-sonner \ + --upgrade-package reflex-components-ui - name: Install custom reflex version (if specified) if: github.event.inputs.reflex_dep diff --git a/docs/library/overlay/toast.md b/docs/library/overlay/toast.md index 5991f5b585b..18cd0ae5b9c 100644 --- a/docs/library/overlay/toast.md +++ b/docs/library/overlay/toast.md @@ -114,5 +114,11 @@ Using the `rx.toast` function require to have a toast provider in your app. `rx.toast.provider` is a component that provides a context for displaying toasts. It should be placed at the root of your app. ```md alert warning -# In most case you will not need to include this component directly, as it is already included in `rx.app` as the `overlay_component` for displaying connections errors. +# In most case you will not need to include this component directly, as `rx.App` puts one at the root of the app. +``` + +The toaster is only bundled with an app that sends a toast: a page that calls `rx.toast`, an event handler that refers to it, or an `on_load` toast. An app with state that sends none shows connection errors, and any toast the compiler could not foresee, as plain notices. To bundle the toaster in every case, or to configure it, pass one to the app: + +```python +app = rx.App(toaster=rx.toast.provider(position="top-center")) ``` diff --git a/examples/ruff.toml b/examples/ruff.toml index 41393b91a35..338c7ea5a8c 100644 --- a/examples/ruff.toml +++ b/examples/ruff.toml @@ -31,6 +31,7 @@ reflex_components_radix.msg = "Examples import Reflex only as `import reflex as reflex_components_react_player.msg = "Examples import Reflex only as `import reflex as rx`." reflex_components_recharts.msg = "Examples import Reflex only as `import reflex as rx`." reflex_components_sonner.msg = "Examples import Reflex only as `import reflex as rx`." +reflex_components_ui.msg = "Examples import Reflex only as `import reflex as rx`." reflex_docgen.msg = "Examples import Reflex only as `import reflex as rx`." reflex_otel.msg = "Examples import Reflex only as `import reflex as rx`." reflex_release.msg = "Examples import Reflex only as `import reflex as rx`." diff --git a/news/+lazy-dynamic-libraries.performance.md b/news/+lazy-dynamic-libraries.performance.md new file mode 100644 index 00000000000..6a3699cf8af --- /dev/null +++ b/news/+lazy-dynamic-libraries.performance.md @@ -0,0 +1 @@ +Apps that render no dynamic component (a component held in state) no longer build or ship the libraries registered for them, and apps that do fetch each library on first use instead of on every page. Libraries an app registers itself with `rx.bundle_library` always stay loadable through `window.__reflex_load`. diff --git a/news/+rx-ui-extra.feature.md b/news/+rx-ui-extra.feature.md new file mode 100644 index 00000000000..8a35dab38ea --- /dev/null +++ b/news/+rx-ui-extra.feature.md @@ -0,0 +1 @@ +Add the `ui` extra. `pip install 'reflex[ui]'` installs `reflex-components-ui`, a pre-release package of components that compile to plain HTML and static CSS, and exposes it as `rx.ui`. Without the extra, `rx.ui` raises an error that says what to install. The package has no components yet. diff --git a/news/+state-runtime-on-demand.performance.md b/news/+state-runtime-on-demand.performance.md new file mode 100644 index 00000000000..b1d9763de01 --- /dev/null +++ b/news/+state-runtime-on-demand.performance.md @@ -0,0 +1,3 @@ +An app without state no longer bundles Socket.io, the cookie library or the code that connects to the backend, and no app bundles the toaster unless it sends a toast: a static page ships about 28 kB less gzipped JavaScript, and an app with state that sends no toast about 8 kB less. + +The toaster is bundled when a toast call is compiled into a page, when an event handler refers to `rx.toast`, or when `rx.App` is given a `toaster`. A toast the compiler could not foresee, and a connection error, show as a plain notice in an app with state; pass `toaster=rx.toast.provider()` to `rx.App` to always bundle the toaster. diff --git a/news/+ui-plugin.feature.md b/news/+ui-plugin.feature.md new file mode 100644 index 00000000000..dab4dda3d78 --- /dev/null +++ b/news/+ui-plugin.feature.md @@ -0,0 +1 @@ +Add `rx.plugins.UIPlugin`, which compiles the styles of the `rx.ui` components. It comes with the `ui` extra: `pip install 'reflex[ui]'`. diff --git a/news/+vite-plugin-hook.feature.md b/news/+vite-plugin-hook.feature.md new file mode 100644 index 00000000000..a2175f9b013 --- /dev/null +++ b/news/+vite-plugin-hook.feature.md @@ -0,0 +1 @@ +Plugins can add Vite plugins to the app's `vite.config.js` through the new `Plugin.get_vite_plugins()` hook, which returns `rx.plugins.VitePluginEntry` objects. A malformed entry stops the compile with an error naming the plugin. See [Adding Vite Plugins](https://reflex.dev/docs/api-reference/plugins/#adding-vite-plugins). diff --git a/packages/reflex-base/news/+lazy-dynamic-libraries.breaking.md b/packages/reflex-base/news/+lazy-dynamic-libraries.breaking.md new file mode 100644 index 00000000000..024d40cde62 --- /dev/null +++ b/packages/reflex-base/news/+lazy-dynamic-libraries.breaking.md @@ -0,0 +1 @@ +`frontend_lazy_bundled_libraries` now defaults to `True`: `window.__reflex` holds React and the Reflex runtime, and gains each other registered library only once it has been loaded. Custom scripts that read a library from `window.__reflex` must first `await window.__reflex_load([""])`, or the app can set `frontend_lazy_bundled_libraries=False` to keep importing every registered library up front. Dynamic components and `rx.bundle_library` need no change. diff --git a/packages/reflex-base/news/+lazy-dynamic-libraries.performance.md b/packages/reflex-base/news/+lazy-dynamic-libraries.performance.md new file mode 100644 index 00000000000..64fdeb41bfc --- /dev/null +++ b/packages/reflex-base/news/+lazy-dynamic-libraries.performance.md @@ -0,0 +1 @@ +Stop shipping whole libraries to every page for dynamic components. A library registered for dynamic components (such as `@radix-ui/themes`, or one passed to `rx.bundle_library`) is now built as a chunk of its own and fetched the first time a dynamic component needs it, so pages only load the parts of it they use. A blank app's JavaScript drops from about 240 KB to 171 KB gzipped. diff --git a/packages/reflex-base/news/+pyi-overwrite-types.misc.md b/packages/reflex-base/news/+pyi-overwrite-types.misc.md new file mode 100644 index 00000000000..fc0d4d5fcee --- /dev/null +++ b/packages/reflex-base/news/+pyi-overwrite-types.misc.md @@ -0,0 +1 @@ +A component class can set `_pyi_overwrite_types` and `_pyi_imports` to give a prop a narrower annotation in its generated `.pyi` stub. diff --git a/packages/reflex-base/news/+pyi-ui-subpackage.misc.md b/packages/reflex-base/news/+pyi-ui-subpackage.misc.md new file mode 100644 index 00000000000..b682e3ad12f --- /dev/null +++ b/packages/reflex-base/news/+pyi-ui-subpackage.misc.md @@ -0,0 +1 @@ +The stub generator resolves the `ui` component subpackage to `reflex-components-ui`. diff --git a/packages/reflex-base/news/+rendering-dynamic-component.feature.md b/packages/reflex-base/news/+rendering-dynamic-component.feature.md new file mode 100644 index 00000000000..31e31fe49d1 --- /dev/null +++ b/packages/reflex-base/news/+rendering-dynamic-component.feature.md @@ -0,0 +1 @@ +Add `reflex_base.components.dynamic.is_rendering_dynamic_component()`, which a component can call while it renders to learn that its code will be evaluated in the browser at runtime and skip what depends on the frontend build. diff --git a/packages/reflex-base/news/+scripts-after-first-paint.performance.md b/packages/reflex-base/news/+scripts-after-first-paint.performance.md new file mode 100644 index 00000000000..e698cafd17a --- /dev/null +++ b/packages/reflex-base/news/+scripts-after-first-paint.performance.md @@ -0,0 +1 @@ +Prerendered pages show up sooner: a production page no longer preloads its scripts ahead of the stylesheet it needs to paint, and starts them once it has painted. On a blank app, mobile Lighthouse LCP drops from about 2.9 s to 1.2 s (simulated slow 4G). Hydration starts later by the same design, and the window `load` event no longer waits for it. A click that comes before the page is hydrated starts the scripts right away and is dispatched again once its handler is attached; so does a hidden tab or a browser without paint timing, and a page that paints nothing starts them after one second. Dev mode and pages rendered in the browser are unchanged. diff --git a/packages/reflex-base/news/+state-runtime-on-demand.performance.md b/packages/reflex-base/news/+state-runtime-on-demand.performance.md new file mode 100644 index 00000000000..a700f364cb5 --- /dev/null +++ b/packages/reflex-base/news/+state-runtime-on-demand.performance.md @@ -0,0 +1 @@ +The connection to the backend moved out of `utils/state.js` into `utils/socket.js`, which only the compiled context of an app with state imports, so an app without state bundles neither it nor Socket.io and the cookie library. Every name `$/utils/state` exported is still exported from there. diff --git a/packages/reflex-base/news/+vite-plugin-hook.feature.md b/packages/reflex-base/news/+vite-plugin-hook.feature.md new file mode 100644 index 00000000000..bc834222090 --- /dev/null +++ b/packages/reflex-base/news/+vite-plugin-hook.feature.md @@ -0,0 +1,11 @@ +A plugin can add Vite plugins to the generated `vite.config.js` by overriding `Plugin.get_vite_plugins()`, instead of rewriting the file in `pre_compile`. Each `VitePluginEntry` gives the import statements it needs and the expression placed in the `plugins` array, ahead of `reactRouter()`: + +```python +def get_vite_plugins(self, **context): + return [ + VitePluginEntry( + imports=['import inspect from "vite-plugin-inspect"'], + call="inspect({ build: true })", + ) + ] +``` diff --git a/packages/reflex-base/src/reflex_base/compiler/templates.py b/packages/reflex-base/src/reflex_base/compiler/templates.py index 77f28862881..52447e4928c 100644 --- a/packages/reflex-base/src/reflex_base/compiler/templates.py +++ b/packages/reflex-base/src/reflex_base/compiler/templates.py @@ -15,6 +15,7 @@ if TYPE_CHECKING: from reflex.compiler.utils import _ImportDict from reflex_base.components.component import Component + from reflex_base.plugins.base import VitePluginEntry _STATE_HOOK = re.compile( @@ -201,7 +202,7 @@ def app_root_template( render: The dictionary of render functions. dynamic_imports: The set of dynamic imports. hydrate_fallback_export: The exported name of the hydrate-fallback memo module to re-export as ``HydrateFallback``, or None for no fallback. - lazy_window_libraries: Optional libraries loaded before evaluating a dynamic component. + lazy_window_libraries: Optional libraries loaded before evaluating a dynamic component, each from the module `dynamic_library_template` renders for it. Returns: Rendered App root component as string. @@ -236,11 +237,15 @@ def app_root_template( lazy_imports_setup = "" if lazy_window_libraries: loaders = "\n".join( - f" {json.dumps(lib_path)}: () => import({json.dumps(lib_path)})," - for _, lib_path in lazy_window_libraries + f" {json.dumps(lib_path)}: () => " + f'import("$/{constants.Dirs.DYNAMIC_LIBRARIES_PATH}/{lib_alias}")' + ".then((module) => module.default)," + for lib_alias, lib_path in lazy_window_libraries ) # Register before child effects run, including an initially mounted - # dynamic component. Optional namespaces stay out of the initial graph. + # dynamic component. Each namespace is imported through a module of its + # own: importing the library here would pull every export into the + # chunks pages load, a separate module becomes a chunk fetched on demand. window_imports_effect = "" lazy_imports_setup = f""" if (typeof window !== "undefined") {{ @@ -311,6 +316,20 @@ def app_root_template( """ +def dynamic_library_template(lib_path: str) -> str: + """Template for the module that exposes a library to dynamic components. + + Args: + lib_path: The module path of the library. + + Returns: + Rendered module code as string. + """ + return f"""import * as library from {json.dumps(lib_path)}; +export default library; +""" + + def theme_template(theme: str): """Template for the theme file. @@ -429,6 +448,15 @@ def context_template( """ ) + # Only an app with state imports the connection to the backend, so an app + # without state bundles neither it nor socket.io and the cookie library. + state_imports_str = ( + 'import { applyDelta, ReflexEvent, refs } from "$/utils/state"\n' + 'import { hydrateClientStorage, useEventLoop } from "$/utils/socket"' + if state_name + else 'import { applyDelta, useEventLoop, refs } from "$/utils/state"' + ) + disable_owner_stacks_str = ( r""" // Disable React dev-build owner-stack capture: the per-element Error() @@ -458,7 +486,7 @@ def context_template( ) return rf"""import {"React, " if disable_react_owner_stacks else ""}{{ useContext, useMemo, useState, createElement, useEffect }} from "react" -import {{ applyDelta, ReflexEvent, hydrateClientStorage, useEventLoop, refs }} from "$/utils/state" +{state_imports_str} import {{ ColorModeContext, UploadFilesContext, DispatchContext, EventLoopContext, StateStoreContext, registerApp, eventLoop }} from "$/utils/context-registry" import {{ jsx }} from "@emotion/react"; {disable_owner_stacks_str} @@ -772,6 +800,7 @@ def vite_config_template( prod_react: bool = False, warmup_routes: bool = False, react_compiler: bool = False, + vite_plugins: Sequence[VitePluginEntry] = (), ): """Template for vite.config.js. @@ -788,6 +817,9 @@ def vite_config_template( warmup_routes: Pre-transform every route module when the dev server starts, so the first visit to a page does not wait on Vite. react_compiler: Enable React Compiler for generated components. + vite_plugins: Vite plugins contributed by Reflex plugins, placed ahead + of ``reactRouter()`` in the order given. An import statement that + several entries share is written once. Returns: Rendered vite.config.js content as string. @@ -890,11 +922,22 @@ def vite_config_template( else "" ) react_compiler_plugin = " reactCompiler(),\n" if react_compiler else "" + vite_plugin_imports = "".join( + f"{statement};\n" + for statement in dict.fromkeys( + statement.strip().rstrip(";").rstrip() + for entry in vite_plugins + for statement in entry.imports + ) + ) + vite_plugin_calls = "".join( + f" {entry.call.strip()},\n" for entry in vite_plugins + ) return rf"""import {{ fileURLToPath, URL }} from "url"; import {{ reactRouter }} from "@react-router/dev/vite"; import {{ defineConfig }} from "vite"; import safariCacheBustPlugin from "./vite-plugin-safari-cachebust.js"; -{react_compiler_import} +{react_compiler_import}{vite_plugin_imports} // Ensure that bun always uses the react-dom/server.node functions. function alwaysUseReactDomServerNode() {{ return {{ @@ -961,7 +1004,7 @@ def vite_config_template( base: "{base}", plugins: [ alwaysUseReactDomServerNode(), -{react_compiler_plugin} reactRouter(), +{react_compiler_plugin}{vite_plugin_calls} reactRouter(), patchReactRouterHmrRuntime(), safariCacheBustPlugin(), ].concat({"[fullReload()]" if force_full_reload else "[]"}), diff --git a/packages/reflex-base/src/reflex_base/components/dynamic.py b/packages/reflex-base/src/reflex_base/components/dynamic.py index a32e4cddff1..d6e22830038 100644 --- a/packages/reflex-base/src/reflex_base/components/dynamic.py +++ b/packages/reflex-base/src/reflex_base/components/dynamic.py @@ -1,5 +1,6 @@ """Components that are dynamically generated on the backend.""" +import contextvars import dataclasses import json from typing import TYPE_CHECKING, Any, Union @@ -17,6 +18,24 @@ if TYPE_CHECKING: from reflex_base.components.component import Component +# Set while the code of a dynamic component is generated. +_RENDERING_DYNAMIC_COMPONENT: contextvars.ContextVar[bool] = contextvars.ContextVar( + "rendering_dynamic_component", default=False +) + + +def is_rendering_dynamic_component() -> bool: + """Whether the code being generated is evaluated in the browser at runtime. + + The code of a dynamic component never passes through the frontend build, so + a component whose output relies on a build step checks this to render + something that works without one. + + Returns: + True while a dynamic component is being serialized. + """ + return _RENDERING_DYNAMIC_COMPONENT.get() + def __getattr__(name: str) -> Any: """Provide the module-level globals that moved onto `RegistrationContext`. @@ -166,6 +185,21 @@ def load_dynamic_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 + """ + token = _RENDERING_DYNAMIC_COMPONENT.set(True) + try: + return generate_component_code(component) + finally: + _RENDERING_DYNAMIC_COMPONENT.reset(token) + + def generate_component_code(component: Component) -> str: + """Generate the module a dynamic component is evaluated from. + Args: component: The component to generate code for. diff --git a/packages/reflex-base/src/reflex_base/config.py b/packages/reflex-base/src/reflex_base/config.py index cb23d019170..2a71a28f84e 100644 --- a/packages/reflex-base/src/reflex_base/config.py +++ b/packages/reflex-base/src/reflex_base/config.py @@ -186,7 +186,7 @@ class BaseConfig: auto_memoize: Wrap stateful page components in generated memo components. Disable only together with react_compiler, which then memoizes whole pages; without it, every state change re-renders the whole page. Defaults to True. frontend_compression_formats: Pre-compressed frontend asset formats to generate for production builds. Supported values are "gzip", "brotli", and "zstd". Use an empty list to disable build-time pre-compression. frontend_packages: Additional frontend packages to install. - frontend_lazy_bundled_libraries: Load optional dynamic-component libraries when a dynamic component is first evaluated, rather than importing their full namespaces on every page. Defaults to False for compatibility with scripts that read window.__reflex directly. + frontend_lazy_bundled_libraries: Load optional dynamic-component libraries when a dynamic component is first evaluated, rather than importing their full namespaces on every page. Set to False for scripts that read these libraries from window.__reflex without awaiting window.__reflex_load(). state_manager_mode: Indicate which type of state manager to use. redis_lock_expiration: Maximum expiration lock time for redis state manager. redis_lock_warning_threshold: Maximum lock time before warning for redis state manager. @@ -264,7 +264,7 @@ class BaseConfig: frontend_packages: list[str] = dataclasses.field(default_factory=list) - frontend_lazy_bundled_libraries: bool = False + frontend_lazy_bundled_libraries: bool = True state_manager_mode: constants.StateManagerMode = constants.StateManagerMode.DISK diff --git a/packages/reflex-base/src/reflex_base/constants/base.py b/packages/reflex-base/src/reflex_base/constants/base.py index 5add4115098..c617d29fb7e 100644 --- a/packages/reflex-base/src/reflex_base/constants/base.py +++ b/packages/reflex-base/src/reflex_base/constants/base.py @@ -40,6 +40,8 @@ class Dirs(SimpleNamespace): CONTEXTS_PATH = UTILS + "/context" # The name of the client state file. CLIENT_STATE_PATH = UTILS + "/client_state" + # The directory of the modules that expose a library to dynamic components. + DYNAMIC_LIBRARIES_PATH = UTILS + "/dynamic_libraries" # The name of the output directory. BUILD_DIR = "build" # The name of the static files directory. diff --git a/packages/reflex-base/src/reflex_base/plugins/__init__.py b/packages/reflex-base/src/reflex_base/plugins/__init__.py index c82a36d559f..9e0b2da1fda 100644 --- a/packages/reflex-base/src/reflex_base/plugins/__init__.py +++ b/packages/reflex-base/src/reflex_base/plugins/__init__.py @@ -23,6 +23,7 @@ PostCompileContext, PreCompileContext, RegisterRouteContext, + VitePluginEntry, get_plugin, ) from .compiler import ( @@ -55,6 +56,7 @@ "SitemapPlugin", "TailwindV3Plugin", "TailwindV4Plugin", + "VitePluginEntry", "_ScreenshotPlugin", "embed", "get_plugin", @@ -83,6 +85,7 @@ "PostCompileContext", "PreCompileContext", "RegisterRouteContext", + "VitePluginEntry", "get_plugin", ], "compiler": [ diff --git a/packages/reflex-base/src/reflex_base/plugins/base.py b/packages/reflex-base/src/reflex_base/plugins/base.py index 3f52afe48ee..ddec296d65b 100644 --- a/packages/reflex-base/src/reflex_base/plugins/base.py +++ b/packages/reflex-base/src/reflex_base/plugins/base.py @@ -1,5 +1,6 @@ """Base class for all plugins.""" +import dataclasses from collections.abc import Callable, Mapping, Sequence from enum import Enum from pathlib import Path @@ -118,6 +119,37 @@ class PostBuildContext(CommonContext): static_dir: Path +@dataclasses.dataclass(frozen=True, kw_only=True) +class VitePluginEntry: + """A Vite plugin that a Reflex plugin adds to the generated ``vite.config.js``. + + Both fields are JavaScript source, written to the file as given. A module + specifier resolves from ``.web``, where the file lives: an npm package by + name, a file the plugin wrote with ``get_static_assets`` by its relative + path (``"./my-plugin.js"``). + + Example: + >>> VitePluginEntry( + ... imports=[ + ... 'import myPlugin from "./my-plugin.js"', + ... 'import { Features } from "lightningcss"', + ... ], + ... call="myPlugin({ exclude: Features.LightDark })", + ... ) + + Attributes: + call: The expression placed in the ``plugins`` array, usually a call + such as ``"myPlugin({ fast: true })"``. It may evaluate to one + plugin or to an array of plugins, and may span several lines. + imports: The import statements ``call`` needs, one statement per + string, with or without the closing semicolon. A statement that + several entries share is written once. + """ + + call: str + imports: Sequence[str] = () + + class Plugin: """Base class for all plugins.""" @@ -178,6 +210,28 @@ def get_stylesheet_paths(self, **context: Unpack[CommonContext]) -> Sequence[str """ return [] + def get_vite_plugins( + self, **context: Unpack[CommonContext] + ) -> Sequence[VitePluginEntry]: + """Get the Vite plugins to add to the generated ``vite.config.js``. + + Entries are placed in the ``plugins`` array ahead of ``reactRouter()``, + in the order of the plugins in ``rxconfig.py`` and then in the order + each plugin returns them. The npm packages they import are build-time + only, so declare them in ``get_frontend_development_dependencies``. + + The hook runs each time the file is rendered, on ``reflex init`` and on + every compile, so it must return the same entries for the same + configuration. + + Args: + context: The context for the plugin. + + Returns: + The Vite plugins required by the plugin. + """ + return [] + def register_route(self, **context: Unpack[RegisterRouteContext]) -> None: """Contribute pages before the app's first compilation. diff --git a/packages/reflex-base/src/reflex_base/utils/exceptions.py b/packages/reflex-base/src/reflex_base/utils/exceptions.py index 9a9884b58c6..70b58654971 100644 --- a/packages/reflex-base/src/reflex_base/utils/exceptions.py +++ b/packages/reflex-base/src/reflex_base/utils/exceptions.py @@ -20,6 +20,10 @@ class InvalidPluginConfigError(ConfigError): """Raised when ``Config.plugins`` contains a plugin that could not be loaded.""" +class InvalidVitePluginError(ReflexError, ValueError): + """Raised when a plugin's ``get_vite_plugins`` returns a malformed entry.""" + + class InvalidStateManagerModeError(ReflexError, ValueError): """Raised when an invalid state manager mode is provided.""" diff --git a/packages/reflex-base/src/reflex_base/utils/pyi_generator.py b/packages/reflex-base/src/reflex_base/utils/pyi_generator.py index 06280c42e84..9cb51fe725b 100644 --- a/packages/reflex-base/src/reflex_base/utils/pyi_generator.py +++ b/packages/reflex-base/src/reflex_base/utils/pyi_generator.py @@ -502,19 +502,27 @@ def _get_class_event_triggers(target_class: type) -> frozenset[str]: def _generate_imports( typing_imports: Iterable[str], + extra_imports: Mapping[str, Iterable[str]] | None = None, ) -> list[ast.ImportFrom | ast.Import]: """Generate the import statements for the stub file. Args: typing_imports: The typing imports to include. + extra_imports: The names the classes of the module ask for, by module, + for the types they overwrite. Returns: The list of import statements. """ return [ *[ - ast.ImportFrom(module=name, names=[ast.alias(name=val) for val in values]) # pyright: ignore [reportCallIssue] - for name, values in DEFAULT_IMPORTS.items() + ast.ImportFrom( + module=name, names=[ast.alias(name=val) for val in sorted(values)] + ) # pyright: ignore [reportCallIssue] + for name, values in ( + *DEFAULT_IMPORTS.items(), + *sorted((extra_imports or {}).items()), + ) ], ast.Import([ast.alias("reflex")]), ] @@ -598,6 +606,22 @@ def _extract_func_kwargs_as_ast_nodes( return kwargs +def _class_overwrite_types(clz: type) -> dict[str, str]: + """Get the annotations a class gives its props in place of the declared ones. + + A component class sets ``_pyi_overwrite_types`` to a dict from the name of + a prop to its annotation in the stub, and ``_pyi_imports`` to the names + those annotations need, by module. Both are inherited. + + Args: + clz: The class a ``create`` stub is generated for. + + Returns: + The annotation of each overwritten prop. + """ + return getattr(clz, "_pyi_overwrite_types", {}) + + def _extract_class_props_as_ast_nodes( func: Callable, clzs: list[type], @@ -618,6 +642,8 @@ def _extract_class_props_as_ast_nodes( """ spec = _get_full_argspec(func) func_kwonlyargs = set(spec.kwonlyargs) + # The class the stub is for may type a prop more narrowly than its parents. + overwrite_types = {**OVERWRITE_TYPES, **_class_overwrite_types(clzs[0])} all_props: set[str] = set() kwargs = deque() for target_class in reversed(clzs): @@ -657,7 +683,7 @@ def _extract_class_props_as_ast_nodes( ast.arg( arg=name, annotation=ast.Name( - id=OVERWRITE_TYPES.get( + id=overwrite_types.get( name, _get_type_hint( value, @@ -1214,7 +1240,11 @@ def visit_Import( ] if not self.inserted_imports: self.inserted_imports = True - default_imports = _generate_imports(self.typing_imports) + extra_imports: dict[str, set[str]] = {} + for clz in self.classes.values(): + for module, names in getattr(clz, "_pyi_imports", {}).items(): + extra_imports.setdefault(module, set()).update(names) + default_imports = _generate_imports(self.typing_imports, extra_imports) return [*default_imports, *([node] if node.names else ())] if not node.names: return [] @@ -1500,6 +1530,7 @@ def _write_pyi_file(module_path: Path, source: str) -> None: "react_router": "reflex_components_core.react_router", "recharts": "reflex_components_recharts", "sonner": "reflex_components_sonner", + "ui": "reflex_components_ui", } diff --git a/packages/reflex-components-core/news/+connection-toaster-request.performance.md b/packages/reflex-components-core/news/+connection-toaster-request.performance.md new file mode 100644 index 00000000000..89e3c958ce7 --- /dev/null +++ b/packages/reflex-components-core/news/+connection-toaster-request.performance.md @@ -0,0 +1 @@ +The connection toaster no longer makes an app bundle the toaster: in an app that sends no toast, a connection error shows as a plain notice instead. diff --git a/packages/reflex-components-core/news/+scripts-after-first-paint.performance.md b/packages/reflex-components-core/news/+scripts-after-first-paint.performance.md new file mode 100644 index 00000000000..7bedd5a67df --- /dev/null +++ b/packages/reflex-components-core/news/+scripts-after-first-paint.performance.md @@ -0,0 +1 @@ +The document's `Scripts` component now renders Reflex's own `$/utils/scripts`, which wraps react-router's `` to start a prerendered page's scripts after its first paint. diff --git a/packages/reflex-components-core/src/reflex_components_core/base/document.py b/packages/reflex-components-core/src/reflex_components_core/base/document.py index 42fbdabf4a0..9fbd139850a 100644 --- a/packages/reflex-components-core/src/reflex_components_core/base/document.py +++ b/packages/reflex-components-core/src/reflex_components_core/base/document.py @@ -33,7 +33,13 @@ class Outlet(ReactRouterLib): tag = "Outlet" -class Scripts(ReactRouterLib): - """The document main scripts.""" +class Scripts(Component): + """The document main scripts. + + Renders react-router's scripts, started after the first paint on a + prerendered page. + """ + + library = "$/utils/scripts" tag = "Scripts" diff --git a/packages/reflex-components-core/src/reflex_components_core/core/banner.py b/packages/reflex-components-core/src/reflex_components_core/core/banner.py index 6cf4e97a58b..13ccf0cf27e 100644 --- a/packages/reflex-components-core/src/reflex_components_core/core/banner.py +++ b/packages/reflex-components-core/src/reflex_components_core/core/banner.py @@ -16,7 +16,7 @@ from reflex_base.vars.number import BooleanVar from reflex_base.vars.sequence import LiteralArrayVar from reflex_components_lucide.icon import Icon -from reflex_components_sonner.toast import ToastProps, toast_ref +from reflex_components_sonner.toast import ToastProps from reflex_components_core import el from reflex_components_core.base.fragment import Fragment @@ -145,7 +145,15 @@ def add_hooks(self) -> list[str | Var]: ) individual_hooks = [ - Var(f"const toast = {toast_ref};"), + # Whichever toast function the app installed. Unlike ``toast_ref`` + # this does not ask the app for its toaster: a connection error is + # no reason to bundle it, and shows as a plain notice without it. + Var( + "const toast = refs['__toast'];", + _var_data=VarData( + imports={f"$/{Dirs.STATE_PATH}": [ImportVar(tag="refs")]} + ), + ), f"const toast_props = {LiteralVar.create(props)!s};", "const [userDismissed, setUserDismissed] = useState(false);", "const [waitedForBackend, setWaitedForBackend] = useState(false);", diff --git a/packages/reflex-components-sonner/news/+toaster-request.feature.md b/packages/reflex-components-sonner/news/+toaster-request.feature.md new file mode 100644 index 00000000000..67874272c6b --- /dev/null +++ b/packages/reflex-components-sonner/news/+toaster-request.feature.md @@ -0,0 +1 @@ +A toast call now carries a `ToasterRequest` app wrap in its var data, which tells the compiler that the app sends a toast and needs its toaster bundled. diff --git a/packages/reflex-components-sonner/src/reflex_components_sonner/toast.py b/packages/reflex-components-sonner/src/reflex_components_sonner/toast.py index ff6bece4b13..af711f0874c 100644 --- a/packages/reflex-components-sonner/src/reflex_components_sonner/toast.py +++ b/packages/reflex-components-sonner/src/reflex_components_sonner/toast.py @@ -30,9 +30,25 @@ "bottom-right", ] + +class ToasterRequest(Component): + """An empty app wrap that asks the app for its toaster. + + A toast call carries it in its var data, so compiling the call into a page + tells the compiler that the app sends a toast. It renders an empty fragment + wherever it is left in place. + """ + + library = "react" + tag = "Fragment" + + toast_ref = Var( _js_expr="refs['__toast']", - _var_data=VarData(imports={f"$/{Dirs.STATE_PATH}": [ImportVar(tag="refs")]}), + _var_data=VarData( + imports={f"$/{Dirs.STATE_PATH}": [ImportVar(tag="refs")]}, + app_wraps=[(44, ToasterRequest.create())], + ), ) _TOAST_STYLE_PROP_ALIASES = ( diff --git a/packages/reflex-components-ui/CHANGELOG.md b/packages/reflex-components-ui/CHANGELOG.md new file mode 100644 index 00000000000..8cf66aa33c9 --- /dev/null +++ b/packages/reflex-components-ui/CHANGELOG.md @@ -0,0 +1 @@ + diff --git a/packages/reflex-components-ui/README.md b/packages/reflex-components-ui/README.md new file mode 100644 index 00000000000..354b6d51e9b --- /dev/null +++ b/packages/reflex-components-ui/README.md @@ -0,0 +1,670 @@ +# reflex-components-ui + +Reflex components that compile to plain HTML elements with static class names. +The styles are compiled by [StyleX](https://stylexjs.com) in the app's own Vite +build, and behaviour comes from the browser and a few small hooks, so no +component library ships to the browser. + +The package is a pre-release. It is an optional extra of Reflex, exposed as +`rx.ui`, and its components need the plugin that compiles their styles: + +``` +pip install 'reflex[ui]' +``` + +```python +# rxconfig.py +config = rx.Config(app_name="shop", plugins=[rx.plugins.UIPlugin()]) +``` + +Without the plugin a compile stops with `rx.ui components need +rx.plugins.UIPlugin() in rxconfig.py plugins.` + +## Layout + +``` +src/reflex_components_ui/ the python package: the rx.ui namespace + plugin.py UIPlugin: the build wiring of an app, and its theme + base.py UIComponent: a plain element and its StyleX source + themes.py Theme: the options of a theme and the StyleX themes they apply + tokens.py rx.ui.tokens: the design tokens as style values + style/lower.py, merge.py the styles a user writes to the ones StyleX compiles + style/emit.py merged styles to the statements of a module + styles/ the look of each component, one table per module + layout/ the components, rx.ui.theme among them + _radix_tokens.py generated: the modules below and what they define +js/ the javascript package, with its own tooling + src/ what ships: copied into an app at .web/reflex-ui/ + base.css the cascade layer order and the color scheme switch + class-name.js joins the class names of compiled styles: a theme's + vite-plugin-stylex.js the StyleX Vite plugin, fitted to the Reflex build + colors/ generated: one module for each Radix color scale + tokens/ generated: space, radius, typography, shadow, ... + themes/ generated: accent/, gray/, radius, scaling, ... + tests/ vitest + harness/ the pages the live tests build and open in Chromium + scripts/generate.js writes and checks the generated files + scripts/radix-tokens.js the generator of the colors, tokens and themes +parity/ the parity harness: is a component the Radix one? Not shipped + ui_parity/components/ the matrix and the contract of each component + allowlist.toml every intended difference from Radix, with its reason +hatch_build.py embeds js/src in the wheel +``` + +`js/` is not published to npm. A wheel embeds `js/src` as +`reflex_components_ui/js/src`; in a checkout +`reflex_components_ui.constants.JS_SRC` resolves to `js/src` directly, so an +edit needs no rebuild. A change under `js/src` is a change to this package: its +news fragment goes in `news/`. + +## How a component reaches the browser + +`rx.ui.box("hello", style={"top": "4px"})` compiles to a `div`, with its style +declared in the module that renders it: + +```js +import * as stylex from "@stylexjs/stylex" + +const sx_3debd41bb2 = stylex.create({ s: {"boxSizing": "border-box", "display": "block", "top": "4px"} }); +const sx_3debd41bb2_c = stylex.props(sx_3debd41bb2.s).className; + +jsx("div",{className:sx_3debd41bb2_c},"hello") +``` + +StyleX folds the second statement into the string `"x9f619 x1lliihq xndqk7f"` +and appends the three rules to the app's stylesheet. It only does so for a +call it can evaluate while compiling, on a style declared in the same module, +so everything the compiler emits has that shape and **no page ships the StyleX +runtime**: + +| You write | It becomes | +| --- | --- | +| A literal value | An atomic class in the module's constant | +| A state `Var` value | `var(--v0)` in the declaration, and `style={{"--v0": state.width ?? "initial"}}` on the element | +| A `_hover` or `:focus-visible` block | A condition on each property inside | +| A responsive list or `rx.breakpoints(...)` | Media-query conditions on the app's breakpoints | +| `rx.color("ruby", 9)` or a token | `var(--ruby-9)`, and `import "$/reflex-ui/colors/ruby.stylex.js"` in the module | +| Layout props (`gap`, `p`, `m`, `columns`, `direction`) | Styles, lowered like any other | +| `variant=State.kind` | One style per value of that prop, folded into a table of class names the element indexes: `sx_…_c + " " + (sx_…_0[state.kind] ?? sx_…_0d)` | +| `style=State.style_dict` | The inline `style` of the element; conditions are not available | +| `margin="0 auto"` | Its longhands | +| `"& > div": {...}`, `paddng="1em"` | A `StyleError` where the component is created | + +What follows from it: + +- A component is a subclass of `UIComponent` with a `styles` table. It imports + nothing: `add_custom_code` emits the declaration and `add_imports` the token + modules, which the compiler places in whichever module renders the element + (a page, an auto-memoized element, an `rx.memo` component). +- A declaration is named after its content, so equal styles on many elements + are declared once per module and the elements share one string. +- A value bound to state is a custom property, so the declaration stays + literal. A number is given `px` unless the property takes bare numbers, as + StyleX does for a literal. The browser recomputes the style of each element + whose custom property changes: a thousand rows bound to one value that + changes cost more than they do with Emotion, which swaps one class. Rows + bound to a value of their own cost less. +- A prop bound to state gets, for each of its values, the whole value of the + properties it changes, so a value replaces the others instead of overriding + them. Props that a compound style combines, or that set the same property, + are indexed together: `table[kind]?.[size]`. A value the table does not list + gets the style of the element without the prop. +- The element's own `class_name` is joined to the constant: `"p-8 " + sx_…_c`. +- A component held in state is evaluated in the browser and never reaches + StyleX: its literal styles fall back to an inline `style`, and anything + conditional or bound to state there is a `StyleError` that says to render + the component in a page. + +`base.css` declares the cascade order once: the resets (Reflex, Tailwind's +`theme` and `base`), then `reflex-ui` (a component's styles merged with the +element's `style`), then Tailwind's `components` and `utilities`. Unlayered +CSS, such as an app's stylesheet, Emotion and Radix Themes, beats all of them. + +It also holds what Radix Themes styles through a selector that a class on an +element cannot express: the selection color inside a theme, in the layer +`reflex-ui.base` so that a component's own style beats it, and the +`@font-face` rules of the system fonts whose metrics Radix adjusts, which +`js/tests/base-css.test.js` keeps equal to the ones of `@radix-ui/themes`. +`-webkit-text-size-adjust` is not there: the build adds the prefixed property +beside the one `themes/theme.js` sets. + +`vite-plugin-stylex.js` hands StyleX only the statements above, not the module +around them, and compiles a module once per build although React Router +transforms it several times. A module that uses StyleX in any other way is +compiled whole. + +## Writing a component + +```python +BUTTON: ComponentStyles = { + "base": {"display": "inline-flex", "border_radius": "var(--radius-2)"}, + "variants": { + "variant": {"solid": {"color": "white"}, "soft": {"opacity": 0.8}}, + "size": {"1": {"height": "var(--space-5)"}, "2": {"height": "var(--space-6)"}}, + }, + "compound": [ + {"props": {"variant": "solid", "size": "2"}, "style": {"font_weight": 700}} + ], + "parts": { + "icon": { + "base": {"width": "1em"}, + "variants": {"size": {"2": {"width": "1.25em"}}}, + } + }, +} + + +class Button(UIComponent): + """A button.""" + + tag = "button" + + styles: ClassVar[ComponentStyles] = BUTTON + + # Which look the button has. + variant: Var[Literal["solid", "soft"]] = field(default=LiteralVar.create("solid")) + + # How large the button is. + size: Var[Literal["1", "2"]] + + # The space between the children. + gap: Var[Responsive[Literal["1", "2", "3"]]] + + # Whether the button can be pressed. + disabled: Var[bool] + + @classmethod + def create(cls, *children, **props) -> Component: + return super().create(Part.create(part="icon", tag="span"), *children, **props) +``` + +- **Props** are fields, as on any component, and reach the element as + attributes. A keyword argument that is not a field, an event trigger, or a + `data_*` or `aria_*` attribute is a CSS property, and an unknown one is an + error: `rx.ui.button: unknown CSS property "paddng". Did you mean "padding"?` +- **Variants**: a field named in `variants` or in the `props` of a `compound` + style selects styles and is not rendered as an attribute. Its default is the + default of the field. Bound to state, it is indexed in the browser. +- **Layout props**: a field named after one of `LAYOUT_PROPS` (`p`, `m`, `gap`, + `columns`, `direction`…) is lowered to styles before the element's own, and + is not rendered either. Declare only those the component should take: on a + component without a `columns` field, `columns` is the CSS property. +- **Parts**: an inner element is a `Part` named after an entry of `parts`, + created as a child of the component or of another part. It reads the props + of the component, takes no styles of its own, and is a `StyleError` anywhere + else. Subclass `Part` for an inner element with fields of its own. +- **Order**: base, variants, compound styles, layout props, the styles of the + app for the component (`rx.App(style={Button: {...}})`), then the element's + `style` with its CSS keyword arguments written over it key by key, as in any + Reflex component. +- The stubs type `style` as `Sequence[StyleProps] | StyleProps | + Var[Mapping[str, Any]] | Breakpoints` through `UIComponent._pyi_overwrite_types`, + so a misspelt property or keyword in a `style` is a type error. Keyword + arguments stay open, as `data_*` and `aria_*` come through them: a misspelt + one is caught by the compile. + +## Styles + +`reflex_components_ui.style` holds what turns the styles a user writes into +the style objects StyleX compiles. Nothing in it depends on a component. + +- `StyleProps` types one style: the CSS properties under the snake_case names + Reflex users write, the keywords of each one, and blocks under a condition + such as `_hover` or `":focus-visible"`. `style/_css_props.py` is generated + from the type definitions of the pinned StyleX by `js/scripts/css-props.js`. + At runtime the name is a plain `dict`: only a type checker reads the table. +- `ComponentStyles` types the look of a component: `base`, `variants` by prop + and value, `compound` styles for a combination of props, and `parts` for + inner elements. +- `lower(name, style, layout)` returns a `Lowered`: `style` maps a camelCase + CSS property to a literal, a `Var` or a condition map such as + `{"default": v, ":hover": v, "@media ...": v}`; `imports` names the modules + whose CSS the values need, such as a color scale; `inline` carries a `Var` + that holds a whole dict of styles. +- `merge(name, styles, props, style, layout)` returns a `Merged`: the `style` + of the element with every prop known at compile time resolved, `dynamic` + alternatives for the props bound to state, and the `Merged` of each part. + The table is lowered once and kept by identity, so it is a module constant. +- `emit(merged)` returns an `Emitted`: the statements the module declares, the + constant and the lookups that give the element its class names, the custom + properties of its inline style, and the modules to import. + +Both results are hashable and equal when they compile to the same +declarations. Errors are `StyleError`s that start with the display name passed +as `name`, such as `rx.ui.card: unknown CSS property "paddng". Did you mean +"padding"?`. + +What lowering does to each input: + +| Input | Lowered form | +| --- | --- | +| A literal | The literal | +| A `Var`, or a string with one inside | The `Var` | +| `_hover`, `":hover"`, `"[data-open]"`, `"@media ..."` blocks | A condition on each property inside | +| A list or `rx.breakpoints(...)` | Conditions `@media screen and (min-width: ...)` on the app's breakpoints | +| `rx.color("ruby", 9)` | `var(--ruby-9)`, and the ruby module in `imports` | +| `margin`, `padding`, `inset`, `gap`, `overflow`, `border_width`, `border_radius`... | Their longhands | +| `border`, `border_top`..., `background` | Their longhands always: StyleX compiles neither | +| `padding_x`, `margin_y`, `bg`, `bg_color` | The properties they stand for | +| Layout props (`p`, `m`, `gap`, `columns`, `direction`...) | Styles, with steps of the space scale as `var(--space-N)` | +| A shorthand bound to state, or holding `var(...)` | Kept whole; it removes its longhands from the styles before it | +| `None` | The property is unset | +| A nested selector, an unknown property, `animation` | `StyleError` | + +Styles merge by property and the last one wins: base, variants, compound +styles, layout props, then the user's style. A style that sets a property only +under a condition, as a `_hover` block does, keeps the earlier value everywhere +else; one that sets it outright replaces the earlier conditions too. +`style` may be a list of styles, each merged over the ones before it. + +StyleX silently drops `border`, `border_top` and its siblings, `background` +and `animation`, which is why the first two are always split and the third is +refused. A split needs the value while compiling, so `background=State.color` +is an error that says to bind `background_color`, and a `background` with more +than a color or an image is one that names its longhands. + +## Themes and tokens + +The plugin takes the theme of the app. Every option has the values and, the +accent aside, the default of the `Theme` of Radix Themes: + +```python +# rxconfig.py +config = rx.Config( + app_name="shop", + plugins=[ + rx.plugins.UIPlugin(theme=rx.ui.Theme(accent_color="indigo", radius="large")) + ], +) +``` + +| Option | Values | Default | +| --- | --- | --- | +| `accent_color` | the 26 accents, `"gray"` among them | `"blue"`, as `rx.theme` has in Reflex (Radix Themes has `"indigo"`) | +| `gray_color` | `"auto"`, `"gray"`, `"mauve"`, `"slate"`, `"sage"`, `"olive"`, `"sand"` | `"auto"`: the gray that matches the accent | +| `radius` | `"none"`, `"small"`, `"medium"`, `"large"`, `"full"` | `"medium"` | +| `scaling` | `"90%"`, `"95%"`, `"100%"`, `"105%"`, `"110%"` | `"100%"` | +| `appearance` | `"inherit"`, `"light"`, `"dark"` | `"inherit"`: the color mode of the app | +| `panel_background` | `"solid"`, `"translucent"` | `"translucent"` | +| `has_background` | `True`, `False` | `True` | + +A value an option does not take stops the app where `rxconfig.py` is loaded: +`rx.ui.Theme: unknown accent_color "indgo". Did you mean "indigo"? The values +are "tomato", "red", ...`. The types are `Literal`s, so a type checker says the +same. + +The plugin wraps every page in one element that carries the theme, inside the +`Theme` of Radix Themes when the app has both, so a page with components of +both follows this one. It is a `div` with the class of a StyleX theme for each +option, and the only thing imported for an accent is the module of that accent: + +```js +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentIndigo} from "$/reflex-ui/themes/accent/indigo.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {graySlate} from "$/reflex-ui/themes/gray/slate.js" +... +const sx_c1c0436182 = stylex.create({ s: {"position": "relative", "zIndex": 0, "minHeight": {...}} }); +const sx_c1c0436182_c = stylex.props(sx_c1c0436182.s).className; +const sx_c1c0436182_o = sx_c1c0436182.s; +const reflexUIClasses_48dbd5f3d5 = "reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, accentIndigo, graySlate, radiusLarge, scaling100, panelTranslucent, reflexUITheme.root, reflexUITheme.background, sx_c1c0436182_o); + +jsx("div",{className:reflexUIClasses_48dbd5f3d5}, ...) +``` + +StyleX folds `stylex.props(...)` into a string only when every argument is +declared in the module that makes the call, and a theme is declared in a +module of its own. So the classes of a theme are joined when the module +loads, by `class-name.js`: what `stylex.props(...).className` does, a later +style winning a property, without the rest of the StyleX runtime, which no +page ships. The theme of the app adds 0.6 kB of gzipped javascript to the +chunk every page already loads, and no chunk. The element's own style is last, +through `sx_..._o`, the style before it is folded: it wins where a theme +element sets the same property, such as the text color. + +`rx.ui.theme(...)` is the same element around part of a page. It takes the +same options, each one optional: what it leaves out is inherited. + +```python +rx.ui.theme(card(), accent_color="red", radius="full") +rx.ui.theme(sidebar(), appearance="dark") +rx.ui.theme(preview(), accent_color=Settings.accent) +``` + +- An accent keeps the gray around it. `gray_color="auto"` with an accent is + the gray that matches it. +- The cascade does not tell an element what it inherits, so where that matters + a nested theme takes the theme of the app to be what is around it: + `gray_color="auto"` without an accent matches the accent of the app, and a + gray without an accent names the gray accent again when the app has it. + Inside another nested theme, give both options. +- A theme with an appearance paints its background, unless + `has_background=False`. The classes `light` and `dark`, which Tailwind and + Radix Themes select on, go on an element around it that has no box + (`display: contents`), so their components inside follow the appearance. + Beside Radix Themes, give such a theme its `gray_color` too: the Radix + stylesheet sets its plain gray wherever one of the two classes is. +- An option bound to state imports every theme it could name and chooses among + them in the browser. For the accent that is all 26 scales: about 21 kB of + gzipped CSS and 0.5 kB of gzipped javascript more than a literal accent, + where the theme of the app, one accent and one gray, is 4.6 kB of gzipped + CSS. The theme of the app is compiled ahead of time and takes literals only. +- The appearance of the theme of the app pins the page to it. It does not + change the color mode the app starts in, which `default_color_mode` sets. +- A theme held in state is a compile error: its code never reaches StyleX. + +`rx.ui.tokens` names every design token. A token is the `var()` of a custom +property, as a plain `str`, so it goes wherever a CSS value does, in the +`style` of any component and in a style table: + +```python +tokens = rx.ui.tokens + +tokens.space[4] # "var(--space-4)", steps 1 to 9 +tokens.radius[3] # steps 1 to 6, and .full, .thumb, .factor +tokens.shadow[3] # steps 1 to 6 +tokens.font_size[2] # steps 1 to 9, as line_height and letter_spacing +tokens.font_weight.bold # light, regular, medium, bold +tokens.accent[9] # steps 1 to 12 of the accent of the theme +tokens.accent.a[3] # its translucent steps +tokens.accent.contrast # and .surface, .indicator, .track +tokens.gray[11] # the gray of the theme, like the accent +tokens.focus[8] # the focus ring, and tokens.focus.a +tokens.color.panel # background, overlay, surface, panel_solid, ... +tokens.cursor.button # checkbox, disabled, link, menu_item, radio, ... +tokens.scale("ruby")[9] # a scale by name, whatever the theme +tokens.black.a[6] # and tokens.white.a +tokens.default.font_family # and heading, code, strong, em, quote, tab +tokens.scaling # "var(--scaling)" +``` + +A step or a name that does not exist is an error to a type checker, and a +`TokenError` that says what exists: `rx.ui.tokens.space has no step 10. Its +steps are 1 to 9.` + +`lower` reads a token like any other string. It names the module that defines +the custom property in `Lowered.imports`: `VAR_MODULES` has the module of each +of the 1,070 custom properties by its whole name, built from the generated +list, and a `var()` of any other custom property, such as one an app defines, +is left alone and imports nothing. A shorthand gives a token that holds one value to its +longhands, as it does with `rx.color(...)`: `{"padding": f"{tokens.space[2]} +{tokens.space[4]}"}` becomes four paddings. A shadow and a font family are +lists, and keep the shorthand whole. + +For a component: + +- Write the style table with tokens, never with the color of a named scale: + `"background_color": tokens.accent[9]`, `"color": tokens.accent.contrast`, + `"border_radius": tokens.radius[2]`, `"height": tokens.space[6]`. +- `color_scheme` is an accent on the element itself. Declare the field, + `color_scheme: Var[LiteralAccentColor]` from `reflex_components_ui.themes`, + and `UIComponent` does the rest: the tokens of the table resolve against + the accent of the element. A literal color imports its accent and + `focusScope` and joins their classes in a constant; `"gray"` imports + `accentGray` alone, and keeps the focus colors of the theme; a color bound + to state imports all 26 and indexes a table of their class names, built + when the module loads. On a component without the field, `color_scheme` is + the CSS property. `themes.color_scheme_styles(name, value)` is what + `UIComponent` calls. +- The space, radius, typography, shadow and `--color-*` tokens, the accent, the + gray and the focus colors are defined wherever a theme is, which in an app is + everywhere. A cursor, a white, and a scale named with `tokens.scale` or + `rx.color` are defined by the module `Lowered.imports` names, which the + module that renders the element imports. +- A color is one `light-dark()` value: `getPropertyValue("--accent-9")` in the + browser returns the pair, and a computed `color` the one in use. + +## Working on it + +From the repository root: + +``` +uv run pytest tests/units/reflex_components_ui tests/units/test_init.py tests/units/test_build_config.py # python tests +uv run python scripts/make_pyi.py # regenerate the .pyi stubs +npm --prefix packages/reflex-components-ui/js ci # install the javascript tooling +npm --prefix packages/reflex-components-ui/js run check # lint, type-check, generated files, tests: what CI runs +npm --prefix packages/reflex-components-ui/js run generate # rewrite the generated files +uv run pytest tests/integration/tests_playwright/test_ui_components.py # a real app in dev and prod: needs network for the npm packages +npm --prefix packages/reflex-components-ui/js run sweep # the whole token sweep against Radix Themes, about four minutes +``` + +The integration test builds one shared app (`UIComponentsApp`) with Tailwind +beside the plugin and reads computed styles, the prerendered page with +JavaScript off, and the files of the production build. Add a page or an +element to that app for a new component rather than a new app. + +`run check` is `run lint` (ESLint), `run typecheck` (`tsc` over the JSDoc, +nothing emitted), `run generate:check` and `test` (vitest), which also run on +their own. + +## The parity harness + +`rx.button(...)` becomes `rx.ui.button(...)` with the same arguments, the same +look and the same behaviour. `parity/` checks that by machine: + +``` +uv run python scripts/ui_parity.py box # one component, in Chromium +uv run python scripts/ui_parity.py # every component, in Chromium +uv run python scripts/ui_parity.py --all-engines # and in Firefox and WebKit +uv run python scripts/ui_parity.py differences # the intended differences, as markdown +uv run pytest tests/units/reflex_components_ui # the API parity test, and the harness's own tests +``` + +Other arguments go to pytest (`-x`, `-k`), and `--engine firefox` picks one +engine. The browsers come from `uv run playwright install chromium firefox webkit`. +The command builds one production app from the declarations in +`parity/ui_parity/components/` and runs +`tests/integration/tests_playwright/test_ui_parity.py` against it: + +- **Look** (`test_matrix`). A page per component renders every element of its + matrix twice, the Radix component beside the rx.ui one, each in a frame of a + fixed size. Per cell the harness compares the pixels (anti-aliasing ignored), + the computed style on a list of properties, and the accessibility tree. +- **Behaviour** (`test_contract`). Each step of a component's contract runs on a + page of its own, against the Radix component and against the rx.ui one, in + each engine asked for. +- **API** (`tests/units/reflex_components_ui/test_api_parity.py`). The props, + their types and literal values, and the event triggers of every name in + `rx.ui` are those of the same name in `rx`. + +A failure names what differed, by how much, and where to look: + +``` +box [chromium] cell base@hover: + - 712 of 10304 pixels differ (6.91%, 0.00% allowed) + - padding-top: rx '0px', rx.ui '3px' + images: .../parity/report/chromium/box/base@hover.{reference,candidate,diff}.png +box [rx.ui, webkit] step "Space toggles" failed: AssertionError: ... +``` + +The run writes a report to `parity/report/` (or `--report DIR`): `index.html` +shows the reference, the candidate and the diff of every cell with its numbers, +grouped by component, `results.json` holds the same numbers and `timings.json` +the run time. The directory is self-contained: zip it or publish it for review. +CI uploads it as the `ui-parity-report` artifact of the `ui-parity` job. + +To look at the pages by hand, `cd packages/reflex-components-ui/parity` and +`uv run reflex run`: `/parity/` and `/contract//`. + +### Adding a component + +A component wave adds, beside the wrapper and its style table, one module: +`parity/ui_parity/components/.py`. It is found by its place; nothing +registers it. + +1. Declare the matrix. Dimensions are props, or `appearance`, `state` and + `viewport`, which the runner provides. `cross` takes every combination, + `sweep` varies one dimension at a time from `base`, and `groups` adds + further small cross products. Cross what interacts (variant with size), and + sweep the rest (32 colors, radius, contrast): a full product does not fit + the run-time budget. + + ```python + MATRIX = Matrix( + component="button", + render=lambda namespace, props: namespace.button("Save", **props), + base={"variant": "solid", "size": "2"}, + cross={"variant": ["solid", "soft", "outline"], "size": ["1", "2", "3"]}, + sweep={ + "color_scheme": ["tomato", "indigo", "gray"], + "high_contrast": [True], + "disabled": [True], + "size": {"responsive": {"initial": "1", "md": "3"}}, + "appearance": [DARK], + "state": [HOVER, FOCUS_VISIBLE, ACTIVE], + "viewport": [520], + }, + groups=[{"variant": ["soft", "outline"], "state": [HOVER], "appearance": [DARK]}], + ) + ``` + + A cell is named after what differs from the base: `size-1_variant-soft`, + `base@dark@hover`. `target` and `parts` name the elements whose computed + style is read when it is not the first element, `stage` sizes the frame, + `crop="stage"` compares the whole frame for what is drawn outside the + element, and `states` adds a driver for a state the runner does not know, + such as `open`. + +2. Declare the contract: what `render` shows, then one step per requirement. + A step runs on the server's HTML (`SERVER`), on the page with scripts off + (`NO_JAVASCRIPT`) or on the hydrated page (the default), and is a plain + function that drives `run.page` and asserts. Every contract already has the + step "hydrates with no warnings". + + ```python + CONTRACT = Contract( + component="switch", + render=lambda namespace: namespace.switch(id="switch"), + ) + + + @CONTRACT.step("Space toggles") + def _space(run: Run) -> None: + switch = run.page.locator("#switch") + switch.focus() + run.page.keyboard.press("Space") + assert switch.get_attribute("aria-checked") == "true" + ``` + +3. Run `uv run python scripts/ui_parity.py ` and open + `parity/report/index.html`. Fix every difference, or, when it is intended, + list it in `parity/allowlist.toml` with a reason written for a user: under + `[[api]]`, `[[contract]]` (per system, per engine where needed) or + `[[look]]`. A listed difference passes; an entry nothing matches any more + fails, so the file stays the complete list, and the migration guide is + generated from it. + +4. Run `--all-engines` before the wave is reviewed, and add the wave's run + time to the table below. + +### What keeps a pixel from flaking + +Both systems are on one page, in frames on the pixel grid, and are cropped by +the same rectangle relative to their frame. The device scale factor and the +viewport are fixed, the page is hydrated (an effect of the first render has +run, so the root committed) and its fonts loaded before it is read, a style +or script tag beside a component is never taken for it, transitions and animations are off, and the "Built with Reflex" badge is +not rendered. Hover, focus and active are driven through the pointer and the +keyboard, never by a class, and the run stops if an element does not match +`:hover`, `:focus-visible` or `:active` when it should. The CI jobs do not +rerun a failure. + +A pixel differs when its color is off by more than `threshold` (0.01 of the +distance from black to white, about two steps of a channel: the browser +dithers by position) and it is not on an anti-aliased edge; a cell fails above +`tolerance` (0.5% of its pixels). A matrix may tighten both, as the box does. + +### Run time + +The build and every matrix together must take under 15 minutes +(`UI_PARITY_BUDGET_SECONDS`), or `test_run_time_is_within_budget` fails. The +cells at rest of a page load are read from one screenshot and one script +call; an interactive cell is driven on its own. Measured in Chromium on the +development container, with boxes: + +| cells at rest | interactive cells | page loads | build | matrix | +| --- | --- | --- | --- | --- | +| 100 | 0 | 1 | 6 s | 1.1 s | +| 1000 | 0 | 1 | 14 s | 15.6 s | +| 100 | 100 | 1 | 6 s | 14.5 s | +| 1000 | 300 | 1 | 18 s | 58.5 s | + +So a cell at rest costs 11 to 16 ms (growing with the length of the page), an +interactive cell about 0.14 s, and a page load (one per viewport and +appearance) about 0.3 s. Keep interactive states to a sweep or a small group. + +| wave | components | cells | Chromium, build + matrices | +| --- | --- | --- | --- | +| harness | box | 8 | 5 s + 1.1 s | + +## Rules the tooling enforces + +- **No React components in `js/src`.** Markup comes from the Python wrappers. + JSX fails the lint everywhere except `js/tests/behaviors/`, and so do the + imports that build a component without it. +- **No barrel files in `js/src`.** A re-export makes the CSS of everything it + names part of whatever imports one name from it. +- **StyleX's lint rules** apply to `js/src`, and its packages are pinned to one + exact version: StyleX is 0.x and has broken its output in a patch release. + `tests/units/reflex_components_ui/test_js_package.py` fails when a pin moves + alone. +- **Generated files are committed.** Each has an entry in `GENERATED` in + `js/scripts/generate.js`; CI fails when a committed file is not what its + generator produces. +- A lint rule in `js/src` cannot be switched off with a comment. + +## The modules behind the tokens and themes + +Every design token is a CSS custom property with the name and the value +[Radix Themes](https://www.radix-ui.com/themes) gives it, so that a page can +mix these components with the Radix ones and show one palette. +`js/scripts/radix-tokens.js` generates them from the token stylesheet of the +`@radix-ui/themes` the Radix components install, as StyleX modules: a module +adds its CSS to an app only when something imports it. + +- `colors/.stylex.js` defines a color scale. A color is one + `light-dark()` value, with a display-P3 one for the screens that have it. +- `tokens/*.stylex.js` define the other tokens, and the variables a theme sets: + `accent`, `gray`, `focus`, `scaling`, `radiusFactor` and `panel`. No accent + and no gray is defined outside a theme. +- `themes/accent/.js`, `themes/gray/.js`, `themes/radius.js`, + `themes/scaling.js` and `themes/panel.js` export a StyleX theme for each value + of a prop of the Radix `Theme`. They are `.js` and not `.stylex.js`: StyleX + keeps that extension for modules that only define variables. +- `themes/scope.js` and `themes/focus.js` are what make an element a theme. A + token such as `--space-1` reads `--scaling`, and a custom property takes the + value it reads from the element it is declared on. A StyleX theme declares + its whole group again on its element, so a scope theme overrides nothing and + is applied wherever a theme changes what the group reads. An accent on a + single element needs `focusScope` only. +- `themes/theme.js` holds the styles of a theme element itself: `root`, + `background`, and `light` and `dark`, which set `color-scheme`. + +An appearance is the `color-scheme` of an element. `base.css` sets it for +`html.light` and `html.dark`, the classes of the color mode of an app, as +`js/tests/harness/base.css` does for the tests; a nested appearance is +`theme.light` or `theme.dark` on its element. Nothing else changes between the +two, and nothing here depends on being at the root: a popover or a dialog in +the top layer inherits from where it is declared. + +Two things differ from Radix, both by construction: + +- `--shadow-1` to `--shadow-6` list the layers of both appearances, and a layer + the current appearance does not have is `transparent`. It paints the same. +- A nested theme that sets a gray while it inherits the gray accent has to name + the gray accent again. Radix knows what a nested `Theme` inherits; the + cascade does not. + +`npm test` reads every custom property Radix defines under both, in headless +Chromium, for each value of each theme prop. `npm run sweep` does it for the +whole product of accent, gray, appearance, radius and scaling: 10,556 themes on +an sRGB screen and on a display-P3 one. A value that is allowed to differ is +listed with its reason in `js/tests/harness/exceptions.js`. The tests need +Chromium: `npx playwright install chromium` in `js/`. + +To move to another version of Radix Themes, change `RADIX_THEMES_PACKAGE` in +`reflex-components-radix` and the pin in `js/package.json` together, then run +`npm run generate` and `npm run sweep`. + +`js/tests/lint.test.js` lints a file that breaks each rule, so a rule that stops +matching fails a test. diff --git a/packages/reflex-components-ui/hatch_build.py b/packages/reflex-components-ui/hatch_build.py new file mode 100644 index 00000000000..3bf940e7c3c --- /dev/null +++ b/packages/reflex-components-ui/hatch_build.py @@ -0,0 +1,41 @@ +"""Build hook that embeds the javascript package in reflex-components-ui.""" + +from pathlib import Path +from typing import Any + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + +# Where the javascript lands inside the reflex_components_ui package. +JS_SRC = "reflex_components_ui/js/src" + + +class JavascriptBuildHook(BuildHookInterface): + """Embed ``js/src`` in the wheel. + + The javascript package lives beside the python source rather than inside + it. An sdist carries ``js/src`` where the repository has it, so a wheel + built from the sdist finds it the same way a wheel built from a checkout + does. + """ + + PLUGIN_NAME = "custom" + + def initialize(self, version: str, build_data: dict[str, Any]) -> None: + """Add the javascript source to a wheel. + + Args: + version: The kind of build: ``standard`` or ``editable``. + build_data: Additional build data. + + Raises: + FileNotFoundError: If there is no javascript to embed. + """ + # An sdist includes js/src as it is. An editable install resolves + # reflex_components_ui to the checkout, which reads js/src in place. + if self.target_name != "wheel" or version == "editable": + return + js_src = Path(self.root) / "js" / "src" + if not js_src.is_dir(): + msg = f"No javascript to embed: {js_src} does not exist." + raise FileNotFoundError(msg) + build_data["force_include"][str(js_src)] = JS_SRC diff --git a/packages/reflex-components-ui/js/eslint.config.js b/packages/reflex-components-ui/js/eslint.config.js new file mode 100644 index 00000000000..2cde2c36264 --- /dev/null +++ b/packages/reflex-components-ui/js/eslint.config.js @@ -0,0 +1,110 @@ +import js from "@eslint/js"; +import stylex from "@stylexjs/eslint-plugin"; +import globals from "globals"; + +// `src` holds no React components: the markup of every component comes from +// its Python wrapper. JSX is allowed only where the tests of the behaviour +// hooks mount one. +const NO_JSX = [ + { + selector: ":matches(JSXElement, JSXFragment)", + message: + "No JSX here: the markup of an rx.ui component comes from its Python wrapper. Only tests/behaviors may render JSX.", + }, +]; + +// A barrel makes every stylesheet behind it part of whatever imports one name +// from it, so a module is imported from the file that defines it. +const NO_BARREL = [ + { + selector: ":matches(ExportAllDeclaration, ExportNamedDeclaration[source])", + message: + "No barrel files: a re-export leaks the CSS of everything it names. Import from the module that defines the name.", + }, +]; + +// What builds a component without JSX. Hooks are imported by name, so a +// default or namespace import of react has no use here either. +const NO_COMPONENTS = { + paths: [ + { + name: "react", + importNames: [ + "default", + "createElement", + "cloneElement", + "forwardRef", + "memo", + "lazy", + "Component", + "PureComponent", + ], + message: "No React components in src: import the hooks you need by name.", + }, + ...[ + "react-dom", + "react-dom/client", + "react/jsx-runtime", + "react/jsx-dev-runtime", + ].map((name) => ({ + name, + message: "No React components in src: nothing here renders.", + })), + ], +}; + +export default [ + js.configs.recommended, + { + files: ["**/*.js", "**/*.jsx"], + languageOptions: { + // Parsed everywhere, so that JSX is reported by the rule below rather + // than as a syntax error. + parserOptions: { ecmaFeatures: { jsx: true } }, + globals: globals.node, + }, + linterOptions: { reportUnusedDisableDirectives: "error" }, + rules: { + "no-restricted-syntax": ["error", ...NO_JSX], + }, + }, + { + // What ships: copied verbatim into an app, where StyleX compiles it. + files: ["src/**/*.js", "src/**/*.jsx"], + plugins: { "@stylexjs": stylex }, + languageOptions: { globals: globals.browser }, + // A rule here cannot be switched off from inside the file it rejects. + linterOptions: { noInlineConfig: true }, + rules: { + "no-restricted-syntax": ["error", ...NO_JSX, ...NO_BARREL], + "no-restricted-imports": ["error", NO_COMPONENTS], + // Left off: `sort-keys` is a style preference, `no-conflicting-props` + // only reads JSX, which is not allowed here, and + // `no-lookahead-selectors` is a browser support policy on `:has()`. + "@stylexjs/enforce-extension": "error", + "@stylexjs/no-legacy-contextual-styles": "error", + "@stylexjs/no-nonstandard-styles": "error", + "@stylexjs/no-unused": "error", + "@stylexjs/valid-shorthands": "error", + "@stylexjs/valid-styles": "error", + }, + }, + { + // The build files at the top of `src` run in node. + files: ["src/*.js"], + languageOptions: { globals: globals.node }, + }, + { + // The pages the live tests build and open in a browser, and the test + // whose callbacks run in them. + files: ["tests/harness/**", "tests/themes.test.js"], + languageOptions: { globals: { ...globals.node, ...globals.browser } }, + }, + { + files: ["tests/behaviors/**"], + languageOptions: { globals: globals.browser }, + rules: { + "no-restricted-syntax": "off", + }, + }, +]; diff --git a/packages/reflex-components-ui/js/package-lock.json b/packages/reflex-components-ui/js/package-lock.json new file mode 100644 index 00000000000..d44c6bf6b0d --- /dev/null +++ b/packages/reflex-components-ui/js/package-lock.json @@ -0,0 +1,5360 @@ +{ + "name": "reflex-components-ui-js", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "reflex-components-ui-js", + "version": "0.0.0", + "license": "Apache-2.0", + "dependencies": { + "@stylexjs/stylex": "0.19.2", + "@stylexjs/unplugin": "0.19.2" + }, + "devDependencies": { + "@eslint/js": "10.0.1", + "@radix-ui/themes": "3.3.0", + "@stylexjs/eslint-plugin": "0.19.2", + "@types/node": "22.20.5", + "@types/react": "19.3.0", + "@types/react-dom": "19.3.0", + "eslint": "10.15.0", + "globals": "17.14.0", + "jsdom": "^26.1.0", + "lightningcss": "1.33.0", + "playwright": "1.63.0", + "postcss": "8.5.33", + "react": "19.3.1", + "react-dom": "19.3.1", + "typescript": "5.9.3", + "vite": "8.3.4", + "vitest": "^5.1.0" + } + }, + "node_modules/@asamuzakjp/css-color": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-3.2.0.tgz", + "integrity": "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^2.1.3", + "@csstools/css-color-parser": "^3.0.9", + "@csstools/css-parser-algorithms": "^3.0.4", + "@csstools/css-tokenizer": "^3.0.3", + "lru-cache": "^10.4.3" + } + }, + "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.13.tgz", + "integrity": "sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.13", + "@babel/helper-compilation-targets": "^7.29.13", + "@babel/helper-module-transforms": "^7.29.13", + "@babel/helpers": "^7.29.13", + "@babel/parser": "^7.29.13", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.13", + "@babel/types": "^7.29.11", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.15.tgz", + "integrity": "sha512-gNWJUX0FlevflramOkaInywOMhU1lkln38gAC7TFZv2tsWbLYbN/2WZFGcq8zbX0Z55e4vGa27IB/NaeZoauWQ==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.15", + "@babel/types": "^7.29.15", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.13.tgz", + "integrity": "sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==", + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.14.tgz", + "integrity": "sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.14" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.15.tgz", + "integrity": "sha512-C2FuapQ2Kh1OnVHAoLi5rD3GBJ8COb9Q609T6HEpLqaBAo560PDP5OxBE5dCI/h951MBO/+bCUYU5SZ+8ZlV+w==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.15.tgz", + "integrity": "sha512-l+ezV2czw3t2d2ELq+3CwPL4WLKK5O8IywBXb9/gpmbCOVZFmRYJPmHVqSCv2k+8iKbE30Zf54siOoIZ52XOxA==", + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.15" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.15.tgz", + "integrity": "sha512-RpKWyisHoP81twtSCgmE02iU0RnPcq1DN5bBEbpUePrjA9Q3wXhufnCJrrayPpoZieqFh3zyZQqwtSK0gGccRA==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.15" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-flow": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.29.7.tgz", + "integrity": "sha512-ajMX6QPcyomotqwpzhkYGxcK2i/us0rs1Qo9QvUpa+Fca0FTmqrzKrctoIYLMxcOhGZldGT/BAVkRGTWBiR8gQ==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.29.7.tgz", + "integrity": "sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.29.7.tgz", + "integrity": "sha512-ngr+82Sh0xMz25TPCZi+nC2iTzjfCdWS2ONXTp/PtSCHCgaCNBpdMqgvJ2ccdLlClVZ7sisIgB914j/JFe+RZA==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.15.tgz", + "integrity": "sha512-ZfawBo2i8vvt+BTt37dWDKBPjUfm/H+bw+ltwsCRhW7gPtyNVwUXuNo54eO2Xo+P4VXpalPFfFISbBTRKC8SOQ==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.15", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.15", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.15", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.15.tgz", + "integrity": "sha512-/XKpKDakL//LZ66bq1XsZOswuqeI5MZqPLDu18o3XdkU1fNJ7bdPtzgnc4ZNS+bBGHV0FJG8jjb8SwcC3nNVQQ==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.15", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@cacheable/memory": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", + "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/utils": "^2.5.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@cacheable/utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.5.0.tgz", + "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.5.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz", + "integrity": "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@csstools/css-calc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz", + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz", + "integrity": "sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^5.1.0", + "@csstools/css-calc": "^2.1.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz", + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz", + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@dual-bundle/import-meta-resolve": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@dual-bundle/import-meta-resolve/-/import-meta-resolve-4.2.1.tgz", + "integrity": "sha512-id+7YRUgoUX6CgV0DtuhirQWodeeA7Lf4i2x71JS/vtA5pRb/hIGWlw+G6MeXvsM+MXrz0VAydTGElX1rAfgPg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/JounQin" + } + }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.3", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.3.tgz", + "integrity": "sha512-R76UKbvsqI68DJJVTVyqFKqU98CN4+B+acxNfEA2IFarSzP0SjtKf/3+fFiXzTyv5Fj3PxLkGHe2wnVWWMxobQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.6", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.6.tgz", + "integrity": "sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^3.0.5", + "debug": "^4.3.1", + "minimatch": "^11.0.5" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz", + "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/js": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-10.0.1.tgz", + "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "eslint": "^10.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/@eslint/object-schema": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.5.tgz", + "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz", + "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@floating-ui/core": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", + "integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz", + "integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.8.0", + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.9.tgz", + "integrity": "sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.8.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz", + "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", + "dev": true, + "license": "MIT" + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@keyv/bigmap": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.4.0", + "hookified": "^1.15.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "keyv": "^5.6.0" + } + }, + "node_modules/@keyv/serialize": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.1.1.tgz", + "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@radix-ui/colors": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@radix-ui/colors/-/colors-3.0.0.tgz", + "integrity": "sha512-FUOsGBkHrYJwCSEtWRCIfQbZG7q1e6DgxCIOe1SUQzDe/7rXXeA47s8yCn6fuTNQAj1Zq4oTFi9Yjp3wzElcxg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@radix-ui/number": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.3.tgz", + "integrity": "sha512-Road2bidD0uu/1BGDOWNdPI06g0lIRy6IF9GZcIrDK2KGItfor8IQwQa+yM2ERgHM1MmHxaxpTzk0/Jp42lNfA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@radix-ui/primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.2.0.tgz", + "integrity": "sha512-KABY+VMIRPJL+Vyzv/335FEhXXD/xDv8BMb1kl48/aXJZMH0LtHCTx5ga5RnxaEP3nZHtmTLf1P9vanmFX46bw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@radix-ui/react-accessible-icon": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-accessible-icon/-/react-accessible-icon-1.2.0.tgz", + "integrity": "sha512-BB4+HHkFl3HipEAhm/mLhrpXV+2kRX7MvY4AaImUcQVeWQt5KhV1JEByNs8NGfJOcr95RcQGijt9+OrCo68xGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-visually-hidden": "1.2.13" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-accordion": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.3.1.tgz", + "integrity": "sha512-lCZ6sbGS/7WO0j84yx4srIgOf0MRJ/sZ13RonADXxvKBym8xrxNCq5f6DibGcr38sIlwPk8/52uYdXeOPsbEDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collapsible": "1.2.1", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-alert-dialog": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.2.1.tgz", + "integrity": "sha512-MWC4N7RY+qsbNrFNo7yQ9ZbdoZEW+B5DtpWxJfUnVCqcQxxqqg3qis3RMPTDbCNaTIdHJSn5XDkl9ZdVWXknLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-dialog": "1.3.1", + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-arrow": { + "version": "1.1.17", + "resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.17.tgz", + "integrity": "sha512-67jjcVvxjXCCStnTW3Z+M7jmaFMuMR7M2JgpDzH4w7JSRrikmzhjfYgP/09ECb8n7whnsgh1ifJ+Ie96qEj+pQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-aspect-ratio": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-aspect-ratio/-/react-aspect-ratio-1.2.0.tgz", + "integrity": "sha512-gHEU+Lx8DlT/FYIjZQvvBJrFSwUngXTjh7FeL9QvJaNALDLez6pgDj2axCUihBjtPBy82LN0gNb25+sTcSXNmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-avatar": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-avatar/-/react-avatar-1.3.1.tgz", + "integrity": "sha512-ssZOkfQNkFpYVmCPQlr978xSaU7moSrGXdwg4j2Xs2WlGl/1KsSZtfpK+WnLnx0Rwll1BAh6oUrAy/uR31SBvQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-checkbox": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.4.1.tgz", + "integrity": "sha512-KWtwhh+98ML3seZ9vO9yRY2OwaQG90dCiDAxjpSNY2AaZ3Hik3B0dsk6m0ILywo/no3A9/SozadyPMNweVT8yw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-collapsible": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.2.1.tgz", + "integrity": "sha512-fSzLb/qy1wuZSxQBcxpW0hNXYHDMWiIXDGyJGdA4+FSLknOWZsNRrTCUavxb4PI8b8lvHo/CysO6NVi5zLpo5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-collection": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.2.0.tgz", + "integrity": "sha512-+yiQzqcc7Sy7/5s0jrMCjpPRFB3538VNrXPWdTLZhE/SCfgEws4aI6lHWN/vvcnyhHndROWBzqmqB4QBrITZ9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-compose-refs": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.5.tgz", + "integrity": "sha512-+48PbAAbq3didjJxa+OaWY2ZwgAKsNiRGyeHKszblZMQ+kcpd9pAaT11cMkGEie0vsOi3QdeTE6d5Fe3Gn61kA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-context": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.3.0.tgz", + "integrity": "sha512-v5AYEocMISkbJ+1fTXzZpiFv7NRr3D2WiYbLIKf+FkmJ8VkP6d503eV2n34MFussHXY1pcoq3yfJiQH77dc4Mg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-context-menu": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-context-menu/-/react-context-menu-2.4.1.tgz", + "integrity": "sha512-Pddn3Z8lio3/ChxyXaEP3jHTTo1LTHCWwF8+mG1chQlWijP+ttVHBKwezrQTiV6Mj670ojvumqvuGh+mdv33iQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-menu": "2.2.1", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-dialog": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.3.1.tgz", + "integrity": "sha512-+0E4qvVTwjAWra9sEhJ+9BTsvHE00zkUuNw1VGh7S+Gc13dfYk+S1PVQdchWDj+XYHhAai7Z7IpzXVDCGsDplg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-focus-guards": "1.2.0", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-direction": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-direction/-/react-direction-1.2.0.tgz", + "integrity": "sha512-FtRA52a/r+LKStFT+neLUm+8vSe7wbzkbQGGeU8ixFiwC8NU14Evoq9ATECqL3eGbcUzJR4fyfA4KkK/q6dfqg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-dismissable-layer": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.2.1.tgz", + "integrity": "sha512-KIfDcAsx+oVylFZ4xryVKusJUrLLhTQmfnJW4kwk4Km5myvhHCrj04hnWWUC166+xD4DHdH8tQGylwYX1h6+Pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-effect-event": "0.0.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-dropdown-menu": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dropdown-menu/-/react-dropdown-menu-2.2.1.tgz", + "integrity": "sha512-XsHcmYG2AcqnvTqrOXXWcMrhquEIlqucizuDH1MV/qMRW+DndpBCMvNeTRXOxqmG1H5j89M/+I0/34Zdd+zDcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-menu": "2.2.1", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-focus-guards": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-focus-guards/-/react-focus-guards-1.2.0.tgz", + "integrity": "sha512-MPm5R0iRGUDrDnPNxmLBkv+X7pN4XKzt+MbWJEuJQsH3NFH4omrbpXpucyYCCKTSt+na/ZxGhEWQrWTZ0285cA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-focus-scope": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-focus-scope/-/react-focus-scope-1.3.1.tgz", + "integrity": "sha512-ugeMhbXt4y5S2T1GnIqbWDKEN962PDwnX1fN0eKOOgf5f63Dh2mn8F1FUySlgW0iF6GiVsRF32DzuDIWTUyQJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-callback-ref": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-form": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-form/-/react-form-0.3.0.tgz", + "integrity": "sha512-KnmrCM27m7Jo1R8S6cFDPrEeq20Jfn5dqde0SZrJr2lVXlj6/QZSUCyFoYh1d8ti0uUrMNK5Lx6dUDuINT+f4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-label": "2.1.17", + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-hover-card": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-hover-card/-/react-hover-card-1.2.1.tgz", + "integrity": "sha512-4QooHxgmpCKRjj1Pft+hETKidYcrbPKcVwMGtk2Oa5DcWY2IH1fHuQt9LG6q5hUQBBV2MhQxSvtx6B/C1xfiTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-popper": "1.4.0", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-id": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.4.tgz", + "integrity": "sha512-TMQp2llA+RYn7JcjnrMnz7wN4pcVttPZnRZo52PLQsoLVKzNlVwUeHmfePgTgRluXFvlD3GD5g5MOVVTJCO0qA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-label": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.1.17.tgz", + "integrity": "sha512-xmj7MN/drx1oUAXkfiFIvyDmGNUIN/omGobvA5oAoNqu9zO2MkISYGZOkBcqSzs/UZXXwV+/3ACRE7q7mGcmkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-menu": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.2.1.tgz", + "integrity": "sha512-G34BsU90SBj5foYpz8pQqq/Q0Dlfyyl6KitWEfRwXC0QvfwhWNAwS49DWP2+rRJ0iwv20Z2Qx7Sk+T03bGo5JA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-focus-guards": "1.2.0", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.4.0", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-menubar": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-menubar/-/react-menubar-1.2.1.tgz", + "integrity": "sha512-bRTYtS9JITV2dUYqYZb7+N5SooQBkZrNRejfmyrSKe3Y57aXhKgx//kBUP0kY7pEpsWR/U1AHsAJRzjwCrK3PA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-menu": "2.2.1", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-navigation-menu": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.4.1.tgz", + "integrity": "sha512-XPPZjkeyCSMNNvt0FyDv/PUauG7Ow4GwHQ/XZSwW36F/TS7rR4HFTsXH8ewLnXTOLn3x96/pmTPNQIVoTX/86g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-previous": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.13" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-one-time-password-field": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-one-time-password-field/-/react-one-time-password-field-0.2.1.tgz", + "integrity": "sha512-KtHdcgnaAK6rohQ/MMJoGYcbgSRJsIuGBdHrFeTB1/9SaKlDs14oSOniW6BL6M43HqvgCO3u4WuVdFLkuc6sqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-password-toggle-field": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-password-toggle-field/-/react-password-toggle-field-0.2.1.tgz", + "integrity": "sha512-vu4+ZoJAaFjdI7l1lDSZRs+4dEv83Jmu7lyzajPrAeQzX74y84n0rUNWbWSgN9XB5NE8IY86Z02kGH6oRrzR+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-is-hydrated": "0.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-popover": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.3.1.tgz", + "integrity": "sha512-ZNxvXRx5W2Wos4fXCXb5lpdqN0Z5chf+mStOUOTr4ik7d+62MRvoe9rzCA/eGNg36lxXqSrKEKmwuZEcUrIstw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-focus-guards": "1.2.0", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.4.0", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-popper": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.4.0.tgz", + "integrity": "sha512-yCWRvLeGv9Pz3+efwHqGPp70mZ56r3kfIgQVF56Oj2aAa4uP/Tb+IE59wNcc+758rctqbCKx4LbK8II/r7Bn0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "^2.0.0", + "@radix-ui/react-arrow": "1.1.17", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-rect": "1.1.4", + "@radix-ui/react-use-size": "1.1.5", + "@radix-ui/rect": "1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-portal": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.2.0.tgz", + "integrity": "sha512-StX7xXnaRU41VvFtMm9zlhVGz8XF6GmWWTXftkQaY+tqVkbs/R9UmAp5mLzHHapk5hM9RMZQvO/3usyIP/g42g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-presence": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/@radix-ui/react-presence/-/react-presence-1.1.11.tgz", + "integrity": "sha512-Z7/atlkab36Z8hm+V8zYc79r0W+tiOB1o0tun1By94JyadkekLQmtEAnBSP9XKXBNQsStoStS4+gX10JpS5akA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-primitive": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.2.0.tgz", + "integrity": "sha512-HCTSPMNqv55Qk0IX4geJbpyXazmqulcimwuyjxTkKi29v+QZbG2Zho9BnbBq4YS2PF+KlNb2CXoLz66uUmblkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-slot": "1.5.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-progress": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-progress/-/react-progress-1.2.1.tgz", + "integrity": "sha512-yQBiM6J3YM8Ums1orkEFpbznK47geKxa0igikzcaS1xHgdba3DdAQBsGbCTt5BVfR8zhEvgxQ0poGcINaD3lvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-radio-group": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.5.1.tgz", + "integrity": "sha512-QbyVT1ddnjqB9H+CUYKkNWdU9fIK3QHCYtjf7mS6ekSqiuXkWtWn5UZW9mhA8qtl3vrVyIsmR9gePstAtKrqkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-roving-focus": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.2.1.tgz", + "integrity": "sha512-UwraORzVUeEPMclhO1p0vz0qI+TbdDLO9i+FiOqhJyHKwdpCRCck9yVEscUnAMIzCiuNoQa8D4A9bIpOPXGt6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-scroll-area": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.4.0.tgz", + "integrity": "sha512-CFrLqHNejWq5FhKAcj9V/WPGRsol76HBQto81NdOBVFEOqIEkJkKIJt0Z824A/9hHLCtoiR/Kw3euRgzXP2pxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-select": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.4.1.tgz", + "integrity": "sha512-888ZwW0Md6GyptuqYABRX9nLKgoYfcooCyBBvVaX5Jp3e+8Jp2i4Zo/Uy50Hm+Ysn2JfloQXstW4U36w8teVtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-focus-guards": "1.2.0", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.4.0", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.13", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.7.2" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-separator": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.2.0.tgz", + "integrity": "sha512-1jUAap0wZEqVP05Ou7kJgRxe/W+Qftng+rUNWGa0qkKbv9r5pWTG3E7a3ELKo2eJoHKMECnzuYrZpSyO1YgcYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-slider": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slider/-/react-slider-1.6.1.tgz", + "integrity": "sha512-IRNRR90moPqxfwCJ0XbMJIxo70W0/1ZExT/sNCxEHMaPx0SF9HoQrcPEC75+H28cFKa0b+KH63anfLYJmwKacw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.3", + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-slot": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.5.0.tgz", + "integrity": "sha512-tyYd9ddPXAysAbdbD9eYxgwpCSv6f3PncqVSNKQFSR5lcJVLz3cb/pANDoYrLiHBpXv7skortyUgGUWsYuPPFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-compose-refs": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-switch": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.4.1.tgz", + "integrity": "sha512-NpBGwc40rY02ZmSvuyeKk0Bvc8ZsNeTMi4qHvJ+ZH4EiYCv0zIXEgdCW4bVdzgIUeP9xxbLJSxKOUfqITYNmkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-size": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-tabs": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.2.1.tgz", + "integrity": "sha512-hRoJlode+hg5ZNlR+3tkfkUliIybdTpD5lkAvHQ9yaXseGf7XVO9Ib2GPEIOuaJJbo7YWYbNpDDRfo8Dhf6/xA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toast": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toast/-/react-toast-1.3.1.tgz", + "integrity": "sha512-iQvL0J7XK4HtJNGkkWMyYrboNseI7vtotFeUkIno8YNxVA9oM7B6//fh0Mc6TSKI96+zioLWi98lQLso88yJmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.13" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toggle": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle/-/react-toggle-1.2.1.tgz", + "integrity": "sha512-+3MUq+WyiBplXYqQ0EIYlq8R4sLQ0T5NbOK7DMdDLCKO93pe2uE0DUJTWWfTBprpJJXxfoF3eMW0xpakVZrYsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toggle-group": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle-group/-/react-toggle-group-1.2.1.tgz", + "integrity": "sha512-O8Ldx5ao4p4KoW+DO8/PmkOe5mdKNi3F2SseqjVj88wvDGDHe60cUmO0Zm/uHsKrvNgQGV8Efpuh95Tht/h4vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-toggle": "1.2.1", + "@radix-ui/react-use-controllable-state": "1.3.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-toolbar": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-toolbar/-/react-toolbar-1.2.1.tgz", + "integrity": "sha512-Cm8m7JTEeUdbfA6T9xgyu8HfOpyvSx8pB/wj0DlEuWaJe9FilIs4Az9wci/lU9RbthV/UkltszMw5WnnD+m/Ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-separator": "1.2.0", + "@radix-ui/react-toggle-group": "1.2.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-tooltip": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.4.1.tgz", + "integrity": "sha512-NxLFGSFtZ78zVfcoOhTwR1xwqo5qx1Jh8Pw6FMZ9McCaqfRzz7/gIRahs2Oy5XlPgQ+8QkUcKbN5B0U44J/kCg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-id": "1.1.4", + "@radix-ui/react-popper": "1.4.0", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-visually-hidden": "1.2.13" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-callback-ref": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.5.tgz", + "integrity": "sha512-Y5GBf4NKeADoXI1geiMlMuMoURT3k9MizzzKhGb/m55H94aGigZ01PIpkvsO6lML13BA6XYAXSJ6gza7vTn5nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-controllable-state": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.3.0.tgz", + "integrity": "sha512-TAcBI7bw2ljYCbv4+zuTSd6zICu8pRt6SDN2vJ/Z06K2MXh6I9WYFe/A9ovlFDtR5HVHGm5iDxDoABm/++dbKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-effect-event": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-effect-event/-/react-use-effect-event-0.0.5.tgz", + "integrity": "sha512-7cshFL8HGS/7HEiHH+9kL9HBwp2sa9yX18Knwek6KYWmXwM7pegMgta2AXMQKI+rq3JnfSj9x8wYqFMTdG1Jgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-escape-keydown": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-escape-keydown/-/react-use-escape-keydown-1.1.6.tgz", + "integrity": "sha512-9cRullnQRv+kqnRmFlmh0WC3kAPuGmHiQ9VwsXdrYk//sBhgCKEttcpPEPgIQbyx6TGUmooVEHYTyohwz/lSJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-callback-ref": "1.1.5" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-is-hydrated": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-is-hydrated/-/react-use-is-hydrated-0.1.3.tgz", + "integrity": "sha512-umO/aJ+82CpOnhDZUTbILCQf7kU/g0iv+oGs/Q8jw7IkhWBzaEP4sA268PhFAJTFetbwp3ICc6ktpI4TqtxcIw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-layout-effect": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.1.4.tgz", + "integrity": "sha512-K20DkRkUwDnxEYMBPcg3Y6voLkEy5p5QQmszZgLngKKiC7dzBR/aEuK3w1qlx2JWDUNH6FluahYdgR3BP+QbYw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-previous": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.4.tgz", + "integrity": "sha512-XoSLhbRbqxFtgJoi2fNHA3C6pDlY34x508vUpUGoFZfvePfHXHbE1lC4FYFMnJWgiCRroSTw6fOsXQoVS9RwZg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-rect": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.4.tgz", + "integrity": "sha512-cSOCh6JlkmfjLyNcLiu2nB4v+nm+dkZ+Q5KHWk/soo4U7ZLiEQFKHK9/YmtBHjfCEaU43IBKQOc4/uJmCaiCTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/rect": "1.1.3" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-use-size": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-size/-/react-use-size-1.1.5.tgz", + "integrity": "sha512-V1McDQkMGzgivwqdu7u96APs7oi0Jvj9LTzgq3WWrDZqxWdAqU9yZnZQqk5OizGFR8badUQwZsrlao7MOlWYOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-use-layout-effect": "1.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@radix-ui/react-visually-hidden": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.2.13.tgz", + "integrity": "sha512-feijiN1oPk4rck4u9Dm9tsU4mT6Wp9oeEEhaz1WUEs1VuqLf8xzsFG+Qk+uWq6TnMH9O+WRECRg0NftyP9E4Fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.2.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@radix-ui/rect": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@radix-ui/rect/-/rect-1.1.3.tgz", + "integrity": "sha512-JtyZR+mqgBibTo8xea3B6ZRmzZiM/YeVBtUkas6zMuXjAlfIFIW2FgqeM9eLyvEaYX66vr6DJMK+4U6LV0KhNw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@radix-ui/themes": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@radix-ui/themes/-/themes-3.3.0.tgz", + "integrity": "sha512-I0/h2CRNTpYNB7Mi3xFIvSsQq5a108d7kK8dTO5zp5b9HR5QJXKag6B8tjpz2ITkVYkFdkGk45doNkSr7OxwNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/colors": "^3.0.0", + "classnames": "^2.3.2", + "radix-ui": "^1.1.3", + "react-remove-scroll-bar": "^2.3.8" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@stylexjs/babel-plugin": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@stylexjs/babel-plugin/-/babel-plugin-0.19.2.tgz", + "integrity": "sha512-R6cB7Ym+IAvySNfmtRJ6CZ+83rjZ82Uw4wmG3YtwYY8vrnliUrYy9fOLvZ1nX407zeHNkCnE5AodEnjXXfOSYg==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.26.8", + "@babel/helper-module-imports": "^7.25.9", + "@babel/traverse": "^7.26.8", + "@babel/types": "^7.26.8", + "@dual-bundle/import-meta-resolve": "^4.1.0", + "@stylexjs/shared": "0.19.2", + "@stylexjs/stylex": "0.19.2", + "postcss-value-parser": "^4.1.0" + } + }, + "node_modules/@stylexjs/eslint-plugin": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@stylexjs/eslint-plugin/-/eslint-plugin-0.19.2.tgz", + "integrity": "sha512-Oynwwe3grD/H1cHOZeUQgodjmhe2CAEhf4MqdWNO95nDw5kANP9Vso/AKifhOrl5za7wpItHCW9bGef5RTl1UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-tokenizer": "^3.0.3", + "@stylexjs/shared": "0.19.2", + "micromatch": "^4.0.5", + "postcss-value-parser": "^4.2.0" + } + }, + "node_modules/@stylexjs/shared": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@stylexjs/shared/-/shared-0.19.2.tgz", + "integrity": "sha512-xjTZ/6T/1FV103F2bspmXoDRDy1gM/ZKYEHpQlUC0h4R5q7PqUV6k+DJbrayRAMwALIdzTf7zSTqteRde0ZXWQ==", + "license": "MIT" + }, + "node_modules/@stylexjs/stylex": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@stylexjs/stylex/-/stylex-0.19.2.tgz", + "integrity": "sha512-l0fRhOBZ4rFiZ0GntYSlp4lYO5dPT11F3mLb7O4ShK6eE1WOjHtv9GHGQZuzHJbQkjcEaRjPSpBn6itI7yXc3Q==", + "license": "MIT", + "dependencies": { + "styleq": "0.2.1" + } + }, + "node_modules/@stylexjs/unplugin": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@stylexjs/unplugin/-/unplugin-0.19.2.tgz", + "integrity": "sha512-kyHrLCVyKNmycPl+WnjVGJmPgKGAYbtVPasuCe3UgQllennwj2himUKQncG98zt+66nDuGpy7Sx2xCYM03nr3Q==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.26.8", + "@babel/plugin-syntax-flow": "^7.26.0", + "@babel/plugin-syntax-jsx": "^7.25.9", + "@babel/plugin-syntax-typescript": "^7.25.9", + "@stylexjs/babel-plugin": "0.19.2", + "browserslist": "^4.24.0", + "lightningcss": "^1.29.1" + }, + "peerDependencies": { + "unplugin": "^2.3.11" + } + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", + "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.11.tgz", + "integrity": "sha512-YBdNe5JcjYR0sPhJW1QIeRCmI11YhYvaRuGCs9+WCeTTb+Yhb2BE2XMe5/wAqF10FK5g3+q1PDhQABfT7aX0gg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", + "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.3.0" + } + }, + "node_modules/@vitest/mocker": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.2.tgz", + "integrity": "sha512-UGc97wUIy0Ji2+9GxzHEJiOhiwkaukgE7VYcUNnjpX3sWnwQ8XogmNXX4WyOukxYgKb8Nh2XFa7KId0ZjpmVhQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.1.2", + "estree-walker": "^3.0.3", + "magic-string": "^1.4.5" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9 || ^3.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/spy": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.2.tgz", + "integrity": "sha512-PQl0/3+p9GaY71+MHywN6oyHfLhVDD5kcbm7oNRldA2F0ExMU3S8RQdnpteJ9gFAdK5P6KCgE6LqCpUgy57KzA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/aria-hidden": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/aria-hidden/-/aria-hidden-1.2.6.tgz", + "integrity": "sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.40", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.40.tgz", + "integrity": "sha512-WJhaQ3kW5+5BpOduI64ewvykhCyK/IHHG5jCIzivmW2nkYPRowUjs0DbBXY4CAr1LLrN7QEzZGL9727aXH9sJA==", + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/brace-expansion": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.1.0.tgz", + "integrity": "sha512-aa11Dv491GKnYqxaul3aRJ0szew7yMJMfZPnqD44NjGrZXoj62l41OEDDpdpC4eE2P88vBFfLuSyRhpG91NUvg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.29.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.6.tgz", + "integrity": "sha512-CmVVIQ3RVc5HxYEc9X84GvxK/C8C1wH8TlKAiO7uTxF8PDwt7r8t9Qk3J9NkMOVzX5O/HbLv3yzxZg9HPrnI9w==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.37", + "caniuse-lite": "^1.0.30001826", + "electron-to-chromium": "^1.5.486", + "node-releases": "^2.0.64", + "update-browserslist-db": "^1.4.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/cacheable": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.5.0.tgz", + "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/memory": "^2.2.0", + "@cacheable/utils": "^2.5.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.10.1" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001828", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001828.tgz", + "integrity": "sha512-7MWeT+3DlrpuDybTWHl4Zb1Z80Z1fLLnOXuBjDXebzDVcqnEWUlV8JcbASg8B8BhcW8QT2UiR1KAtzYFIZHZYA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/classnames": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz", + "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cssstyle": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.6.0.tgz", + "integrity": "sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^3.2.0", + "rrweb-cssom": "^0.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/csstype": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz", + "integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/data-urls": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", + "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/detect-node-es": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", + "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.495", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.495.tgz", + "integrity": "sha512-dZcmtNbDI5oeT9uP9Z+D7h/H5C1mvBewDTLgZgo9WgyPmqOXSt2cmoCK99evPygUOn9lyXZ4w0Eb8APrkBjqBA==", + "license": "ISC" + }, + "node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.15.0.tgz", + "integrity": "sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==", + "dev": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.2", + "@eslint/config-array": "^0.23.6", + "@eslint/config-helpers": "^0.7.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.3", + "@humanfs/node": "^0.16.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^9.1.2", + "eslint-visitor-keys": "^5.0.1", + "espree": "^11.2.0", + "esquery": "^1.7.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "11.1.5 || >11.1.6 <12", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "minimatch": "^11.0.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", + "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@types/esrecurse": "^4.3.1", + "@types/estree": "^1.0.8", + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", + "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.16.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^5.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/file-entry-cache": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.5.tgz", + "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^6.1.23" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "6.1.23", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.23.tgz", + "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cacheable": "^2.5.0", + "flatted": "^3.4.2", + "hookified": "^1.15.0" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-nonce": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz", + "integrity": "sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "17.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.14.0.tgz", + "integrity": "sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hashery": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^1.15.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/hookified": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-encoding-sniffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", + "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-encoding": "^3.1.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, + "node_modules/jsdom": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.1.0.tgz", + "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssstyle": "^4.2.1", + "data-urls": "^5.0.0", + "decimal.js": "^10.5.0", + "html-encoding-sniffer": "^4.0.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.6", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.16", + "parse5": "^7.2.1", + "rrweb-cssom": "^0.8.0", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^5.1.1", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^3.1.1", + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.1.1", + "ws": "^8.18.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "canvas": "^3.0.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/keyv": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@keyv/serialize": "^1.1.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/minimatch": { + "version": "11.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", + "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.66", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.66.tgz", + "integrity": "sha512-uSMWN9/XtWzxaE0d9ZNHe00Hda6028AXH3WRjTsK71neiPCSeL5nGSD9MXTQX/6Qx0k7Op1AyyinmIUw9fBzrg==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/nwsapi": { + "version": "2.2.28", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.28.tgz", + "integrity": "sha512-IlVB7OS7qrOsVYlpnFIkETjMwT9jwvmocJmmM+GZU/PAB3uGi9Ezd7vcWhWBUnSc0ya4ppmQITOyP1ez9gg8cg==", + "dev": true, + "license": "MIT" + }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/playwright": { + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.63.0.tgz", + "integrity": "sha512-+7ziBLidS4NaNCdt57SUDT+wYmmd5fmiQejUic/kb+YsYSCPyOOE9sebzMjNmQrsnNpDJqd4WHvV/8lfKfUDUg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.63.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.63.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.63.0.tgz", + "integrity": "sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "license": "MIT" + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qified": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz", + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^2.1.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/qified/node_modules/hookified": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz", + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==", + "dev": true, + "license": "MIT" + }, + "node_modules/radix-ui": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/radix-ui/-/radix-ui-1.8.1.tgz", + "integrity": "sha512-HPfpVGizO9xANlsFSauruLhRe/3+iOt3vPX0MXYle/UQi3gorQrSYtBcdiv0BZYewcl2rvL59qrIuLFMGAmUrw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.2.0", + "@radix-ui/react-accessible-icon": "1.2.0", + "@radix-ui/react-accordion": "1.3.1", + "@radix-ui/react-alert-dialog": "1.2.1", + "@radix-ui/react-arrow": "1.1.17", + "@radix-ui/react-aspect-ratio": "1.2.0", + "@radix-ui/react-avatar": "1.3.1", + "@radix-ui/react-checkbox": "1.4.1", + "@radix-ui/react-collapsible": "1.2.1", + "@radix-ui/react-collection": "1.2.0", + "@radix-ui/react-compose-refs": "1.1.5", + "@radix-ui/react-context": "1.3.0", + "@radix-ui/react-context-menu": "2.4.1", + "@radix-ui/react-dialog": "1.3.1", + "@radix-ui/react-direction": "1.2.0", + "@radix-ui/react-dismissable-layer": "1.2.1", + "@radix-ui/react-dropdown-menu": "2.2.1", + "@radix-ui/react-focus-guards": "1.2.0", + "@radix-ui/react-focus-scope": "1.3.1", + "@radix-ui/react-form": "0.3.0", + "@radix-ui/react-hover-card": "1.2.1", + "@radix-ui/react-label": "2.1.17", + "@radix-ui/react-menu": "2.2.1", + "@radix-ui/react-menubar": "1.2.1", + "@radix-ui/react-navigation-menu": "1.4.1", + "@radix-ui/react-one-time-password-field": "0.2.1", + "@radix-ui/react-password-toggle-field": "0.2.1", + "@radix-ui/react-popover": "1.3.1", + "@radix-ui/react-popper": "1.4.0", + "@radix-ui/react-portal": "1.2.0", + "@radix-ui/react-presence": "1.1.11", + "@radix-ui/react-primitive": "2.2.0", + "@radix-ui/react-progress": "1.2.1", + "@radix-ui/react-radio-group": "1.5.1", + "@radix-ui/react-roving-focus": "1.2.1", + "@radix-ui/react-scroll-area": "1.4.0", + "@radix-ui/react-select": "2.4.1", + "@radix-ui/react-separator": "1.2.0", + "@radix-ui/react-slider": "1.6.1", + "@radix-ui/react-slot": "1.5.0", + "@radix-ui/react-switch": "1.4.1", + "@radix-ui/react-tabs": "1.2.1", + "@radix-ui/react-toast": "1.3.1", + "@radix-ui/react-toggle": "1.2.1", + "@radix-ui/react-toggle-group": "1.2.1", + "@radix-ui/react-toolbar": "1.2.1", + "@radix-ui/react-tooltip": "1.4.1", + "@radix-ui/react-use-callback-ref": "1.1.5", + "@radix-ui/react-use-controllable-state": "1.3.0", + "@radix-ui/react-use-effect-event": "0.0.5", + "@radix-ui/react-use-escape-keydown": "1.1.6", + "@radix-ui/react-use-is-hydrated": "0.1.3", + "@radix-ui/react-use-layout-effect": "1.1.4", + "@radix-ui/react-use-size": "1.1.5", + "@radix-ui/react-visually-hidden": "1.2.13" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/react": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "scheduler": "^0.28.0" + }, + "peerDependencies": { + "react": "^19.3.1" + } + }, + "node_modules/react-remove-scroll": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.7.2.tgz", + "integrity": "sha512-Iqb9NjCCTt6Hf+vOdNIZGdTiH1QSqr27H/Ek9sv/a97gfueI/5h1s3yRi1nngzMUaOOToin5dI1dXKdXiF+u0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "react-remove-scroll-bar": "^2.3.7", + "react-style-singleton": "^2.2.3", + "tslib": "^2.1.0", + "use-callback-ref": "^1.3.3", + "use-sidecar": "^1.1.3" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-remove-scroll-bar": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.8.tgz", + "integrity": "sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "react-style-singleton": "^2.2.2", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/react-style-singleton": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.3.tgz", + "integrity": "sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-nonce": "^1.0.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/rolldown": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" + } + }, + "node_modules/rrweb-cssom": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz", + "integrity": "sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/scheduler": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", + "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", + "dev": true, + "license": "MIT" + }, + "node_modules/semver": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map-js": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", + "integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, + "node_modules/styleq": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/styleq/-/styleq-0.2.1.tgz", + "integrity": "sha512-L0TR0NQb+X4/ktDEKmjWyp27gla+LUYi/by5k5SjKXf6/pvZP7wbwEB5J+tqxdFVPgzbsuz+d4RTScO/QZquBw==", + "license": "MIT" + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "6.2.5", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.5.tgz", + "integrity": "sha512-b/8GRMdnY4cqkfCLyaFpTGIv1qwfi3oT0mWaepwT++6Z/ZrYehNfZZ2JDKVLKGhNoEkS3IIB1ELtCT0XS5DtOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.4.0.tgz", + "integrity": "sha512-PV6lIcJQh57aFeJDwx16JNHmgFRh5xguzallrDW1qe8nAghYgr5MKz2K5k7wEyV/ygZhdnIAP8+HZSarHPBCsg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/tldts": { + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz", + "integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^6.1.86" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz", + "integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tough-cookie": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz", + "integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^6.1.32" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD" + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/unplugin": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-2.3.11.tgz", + "integrity": "sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==", + "license": "MIT", + "peer": true, + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "acorn": "^8.15.0", + "picomatch": "^4.0.3", + "webpack-virtual-modules": "^0.6.2" + }, + "engines": { + "node": ">=18.12.0" + } + }, + "node_modules/unplugin/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.4.0.tgz", + "integrity": "sha512-WPJuOnjI9FWDct4fB+ej4Mz8opLaw5CDcZ2t44tFZ0vIQVYWzBhWR3mkixuUj/A7+vY4V9+ApOZ2YYLwdgq46w==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/use-callback-ref": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", + "integrity": "sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/use-sidecar": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", + "integrity": "sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "detect-node-es": "^1.1.0", + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/react": "*", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/vite": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.4.tgz", + "integrity": "sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.29", + "rolldown": "~1.2.12", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vitest": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.2.tgz", + "integrity": "sha512-VIa2wXV208WraXUbzH+dQUrGcFpPuaiRA8HlhXS8R6/sy9cynw6OMqGj8fmAlH1hot7huTCtWUE14+FdXU3eLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.1.2", + "chai": "^6.3.0", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.4.5", + "obug": "^3.0.0", + "picomatch": "^4.0.7", + "std-env": "^4.3.0", + "tinybench": "^6.2.3", + "tinyexec": "^1.3.1", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.1.2", + "@vitest/browser-preview": "5.1.2", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.1.2", + "@vitest/coverage-v8": "5.1.2", + "@vitest/ui": "5.1.2", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/vitest/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz", + "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==", + "license": "MIT", + "peer": true + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation", + "dev": true, + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ws": { + "version": "8.23.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz", + "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "license": "ISC" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/packages/reflex-components-ui/js/package.json b/packages/reflex-components-ui/js/package.json new file mode 100644 index 00000000000..ea73a6f24d6 --- /dev/null +++ b/packages/reflex-components-ui/js/package.json @@ -0,0 +1,45 @@ +{ + "name": "reflex-components-ui-js", + "version": "0.0.0", + "private": true, + "type": "module", + "description": "The javascript the rx.ui components are compiled against: design tokens, themes and behaviour hooks.", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/reflex-dev/reflex.git", + "directory": "packages/reflex-components-ui/js" + }, + "scripts": { + "lint": "eslint --max-warnings 0", + "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.node.json", + "test": "vitest run", + "generate": "node scripts/generate.js", + "generate:check": "node scripts/generate.js --check", + "sweep": "node tests/harness/sweep.js", + "check": "npm run lint && npm run typecheck && npm run generate:check && npm test" + }, + "dependencies": { + "@stylexjs/stylex": "0.19.2", + "@stylexjs/unplugin": "0.19.2" + }, + "devDependencies": { + "@eslint/js": "10.0.1", + "@radix-ui/themes": "3.3.0", + "@stylexjs/eslint-plugin": "0.19.2", + "@types/node": "22.20.5", + "@types/react": "19.3.0", + "@types/react-dom": "19.3.0", + "eslint": "10.15.0", + "globals": "17.14.0", + "jsdom": "^26.1.0", + "lightningcss": "1.33.0", + "playwright": "1.63.0", + "postcss": "8.5.33", + "react": "19.3.1", + "react-dom": "19.3.1", + "typescript": "5.9.3", + "vite": "8.3.4", + "vitest": "^5.1.0" + } +} diff --git a/packages/reflex-components-ui/js/scripts/css-props.js b/packages/reflex-components-ui/js/scripts/css-props.js new file mode 100644 index 00000000000..6608771269b --- /dev/null +++ b/packages/reflex-components-ui/js/scripts/css-props.js @@ -0,0 +1,304 @@ +// Renders `style/_css_props.py`: the CSS properties an rx.ui style accepts and +// the values each one takes, read from the type definitions of the pinned +// `@stylexjs/stylex` package. + +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; + +import ts from "typescript"; + +const TYPES_DIR = fileURLToPath( + new URL("../node_modules/@stylexjs/stylex/lib/es/types/", import.meta.url), +); + +// Keys of StyleX's `CSSProperties` that are not CSS properties. +const NOT_CSS = new Set(["theme"]); + +// The pseudo-classes a style can be conditioned on with an underscore key, +// such as `_hover`. StyleX types them as `:${string}`, so the list is kept +// here. Any other one, and every functional one, is written with its colon. +export const PSEUDO_CLASSES = [ + "active", + "any-link", + "autofill", + "checked", + "default", + "disabled", + "empty", + "enabled", + "first-child", + "first-of-type", + "focus", + "focus-visible", + "focus-within", + "fullscreen", + "hover", + "in-range", + "indeterminate", + "invalid", + "last-child", + "last-of-type", + "link", + "modal", + "only-child", + "only-of-type", + "open", + "optional", + "out-of-range", + "placeholder-shown", + "popover-open", + "read-only", + "read-write", + "required", + "target", + "user-invalid", + "user-valid", + "valid", + "visited", +]; + +// The style keys Reflex adds to CSS, and the kind of value each takes. +const REFLEX_KEYS = [ + ["bg", "_Color"], + ["bg_color", "_Color"], + ["margin_x", "_Size"], + ["margin_y", "_Size"], + ["padding_x", "_Size"], + ["padding_y", "_Size"], +]; + +/** + * What one CSS property accepts. + * + * @typedef {object} Property + * @property {string} name The name StyleX gives it, such as `alignItems`. + * @property {string} key The name a Reflex user writes, such as `align_items`. + * @property {string[]} literals The keywords it takes, when it takes nothing + * else. + * @property {"_Color" | "_Size" | "_Str" | null} open The kind of free-form + * value it takes, or null when only `literals` are accepted. + */ + +/** + * Convert a StyleX property name to the name a Reflex user writes. + * + * @param {string} name A camelCase name, capitalised when it has a vendor + * prefix. + * @returns {string} The snake_case name. + */ +export function snakeCase(name) { + return name.replace( + /[A-Z]/g, + (letter, index) => (index ? "_" : "") + letter.toLowerCase(), + ); +} + +/** + * Collect the names of the type aliases a type is built from. + * + * @param {ts.Node} node The type to walk. + * @param {Map} aliases The aliases of the file by name. + * @param {Set} seen The names found so far, added to in place. + */ +function collectAliases(node, aliases, seen) { + if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName)) { + const name = node.typeName.text; + const alias = aliases.get(name); + if (alias && !seen.has(name)) { + seen.add(name); + collectAliases(alias, aliases, seen); + } + } + ts.forEachChild(node, (child) => collectAliases(child, aliases, seen)); +} + +/** + * Read the properties of StyleX's `CSSProperties` type. + * + * @returns {Property[]} The properties, sorted by the key a user writes. + */ +export function readProperties() { + const file = `${TYPES_DIR}StyleXCSSTypes.d.ts`; + const program = ts.createProgram([file], { strict: true, noEmit: true }); + const checker = program.getTypeChecker(); + const source = program.getSourceFile(file); + if (!source) throw new Error(`Cannot read ${file}`); + + /** @type {Map} */ + const aliases = new Map(); + for (const statement of source.statements) { + if (ts.isTypeAliasDeclaration(statement)) { + aliases.set(statement.name.text, statement.type); + } + } + const declared = aliases.get("CSSProperties"); + if (!declared) throw new Error("StyleX no longer declares CSSProperties"); + + /** @type {Property[]} */ + const properties = []; + const type = checker.getTypeFromTypeNode(declared); + for (const symbol of checker.getPropertiesOfType(type)) { + const name = symbol.getName(); + if (NOT_CSS.has(name)) continue; + const valueType = checker.getTypeOfSymbol(symbol); + const members = valueType.isUnion() ? valueType.types : [valueType]; + /** @type {string[]} */ + const literals = []; + let anyString = false; + let anyNumber = false; + for (const member of members) { + if (member.isStringLiteral()) literals.push(member.value); + else if (member.flags & ts.TypeFlags.String) anyString = true; + else if (member.flags & ts.TypeFlags.NumberLike) anyNumber = true; + } + const used = new Set(); + for (const declaration of symbol.getDeclarations() ?? []) { + collectAliases(declaration, aliases, used); + } + /** @type {Property["open"]} */ + let open = null; + if (used.has("color")) open = "_Color"; + else if (anyNumber) open = "_Size"; + else if (anyString || literals.length === 0) open = "_Str"; + properties.push({ + name, + key: snakeCase(name), + literals: open ? [] : literals.sort(), + open, + }); + } + return properties.sort((a, b) => (a.key < b.key ? -1 : 1)); +} + +/** + * Read the pseudo-elements StyleX types. + * + * @returns {string[]} Their names without the colons, sorted. + */ +export function readPseudoElements() { + const text = readFileSync(`${TYPES_DIR}StyleXTypes.d.ts`, "utf8"); + return [...text.matchAll(/^\s*'::([a-z-]+)'\??:/gm)] + .map((match) => match[1]) + .sort(); +} + +/** + * Render a python collection with one item per line, as the formatter does. + * + * @param {string} open The text up to and including the opening bracket. + * @param {string[]} items The items, already rendered. + * @param {string} close The closing bracket and what follows it. + * @param {string} [indent] The indentation of the opening line. + * @returns {string} The lines, ending in a newline. + */ +function block(open, items, close, indent = "") { + return `${indent}${open}\n${items.map((item) => `${indent} ${item},\n`).join("")}${indent}${close}\n`; +} + +/** + * Render the python module. + * + * @param {Property[]} properties The CSS properties. + * @param {string[]} pseudoElements The pseudo-elements, without their colons. + * @returns {string} The whole file. + */ +export function renderCssProps(properties, pseudoElements) { + // Properties with the same keywords share one alias, named after the first. + /** @type {Map} */ + const aliasOf = new Map(); + let aliases = ""; + let fields = ""; + for (const { name, key, literals, open } of properties) { + /** @type {string | null} */ + let value = open; + if (!value) { + const signature = literals.join("|"); + let alias = aliasOf.get(signature); + if (!alias) { + alias = `_${name[0].toUpperCase()}${name.slice(1)}`; + aliasOf.set(signature, alias); + aliases += `\n${block( + `${alias}: TypeAlias = Literal[`, + literals.map((literal) => JSON.stringify(literal)), + "]", + " ", + )}`; + } + value = `${alias} | _StrVar`; + } + fields += ` ${key}: _Value[${value}]\n`; + } + for (const [key, kind] of REFLEX_KEYS) { + fields += ` ${key}: _Value[${kind}]\n`; + } + + const plainElements = pseudoElements.filter((name) => !name.startsWith("-")); + const underscored = [...PSEUDO_CLASSES, ...plainElements] + .sort() + .map((name) => ` _${name.replaceAll("-", "_")}: StyleProps\n`) + .join(""); + const selectors = [ + ...PSEUDO_CLASSES.map((name) => `":${name}": "StyleProps"`), + ...pseudoElements.map((name) => `"::${name}": "StyleProps"`), + ]; + + return `"""The CSS properties of an rx.ui style and the values each one takes. + +Generated by js/scripts/css-props.js from the type definitions of the pinned +@stylexjs/stylex package. Do not edit: run \`npm run generate\` in js/. +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from collections.abc import Mapping, Sequence + from typing import Any, Literal, TypeAlias, TypedDict, TypeVar + + from reflex_base.breakpoints import Breakpoints + from reflex_base.constants.colors import Color + from reflex_base.vars.base import Var + + _T = TypeVar("_T") + + # A value, one per breakpoint, or one per condition such as ":hover". + _Value: TypeAlias = ( + _T | Sequence[_T] | Breakpoints[Any, Any] | Mapping[str, _T | Mapping[str, _T]] + ) + _StrVar: TypeAlias = Var[str] + _Str: TypeAlias = str | Var[str] + _Size: TypeAlias = str | int | float | Var[str | int | float] + _Color: TypeAlias = str | Color | Var[str] | Var[Color] +${aliases} +${block("_Selectors = TypedDict(", ['"_Selectors"', `{\n${selectors.map((item) => ` ${item},\n`).join("")} }`, "total=False"], ")", " ")} + class StyleProps(_Selectors, total=False): + """The styles of one element: CSS properties and conditional blocks of them.""" + +${fields}${underscored} +else: + # A TypedDict of this size takes milliseconds to build, and nothing reads + # it at runtime, where a style is a plain dict. + StyleProps = dict + +${block("CSS_PROPS: dict[str, str] = {", [...properties.map(({ key, name }) => `"${key}": "${name}"`)], "}")} +${block( + "PSEUDO_CLASSES: frozenset[str] = frozenset({", + PSEUDO_CLASSES.map((name) => `"${name}"`), + "})", +)} +${block( + "PSEUDO_ELEMENTS: frozenset[str] = frozenset({", + pseudoElements.map((name) => `"${name}"`), + "})", +)}`; +} + +/** + * Render `_css_props.py` from the installed StyleX package. + * + * @returns {string} The whole file. + */ +export function render() { + return renderCssProps(readProperties(), readPseudoElements()); +} diff --git a/packages/reflex-components-ui/js/scripts/generate.js b/packages/reflex-components-ui/js/scripts/generate.js new file mode 100644 index 00000000000..9411d779e93 --- /dev/null +++ b/packages/reflex-components-ui/js/scripts/generate.js @@ -0,0 +1,112 @@ +// Writes the generated files of the package, or with `--check` fails when a +// committed one is not what its generator produces. + +import { readFileSync } from "node:fs"; +import { mkdir, readFile, writeFile } from "node:fs/promises"; +import { createRequire } from "node:module"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +import { getMatchingGrayColor } from "@radix-ui/themes/helpers"; +import { themePropDefs } from "@radix-ui/themes/props"; + +import { render as renderCssProps } from "./css-props.js"; +import { radixTokens } from "./radix-tokens.js"; + +const require = createRequire(import.meta.url); + +/** + * The colors, tokens and themes, from the stylesheet of the Radix Themes + * this package installs. + * + * @returns {Generated[]} The StyleX modules and the python module listing them. + */ +function radixThemes() { + const { version } = require("@radix-ui/themes/package.json"); + const { radius, scaling, panelBackground, accentColor, grayColor } = + themePropDefs; + return radixTokens( + readFileSync(require.resolve("@radix-ui/themes/tokens.css"), "utf8"), + { + version, + defaults: { + radius: radius.default, + scaling: scaling.default, + panelBackground: panelBackground.default, + accentColor: accentColor.default, + grayColor: grayColor.default, + }, + matchingGray: (accent) => + getMatchingGrayColor( + /** @type {(typeof accentColor.values)[number]} */ (accent), + ), + }, + ); +} + +/** + * A committed file that a generator owns. + * + * @typedef {object} Generated + * @property {string} path Where the file goes, relative to the python package's + * root (`packages/reflex-components-ui`). + * @property {() => string | Promise} render Produces the whole file. + */ + +/** + * Every generated file. A generator is added here, so that `npm run generate` + * writes its output and the check in CI covers it. + * + * @type {Generated[]} + */ +export const GENERATED = [ + { + path: "src/reflex_components_ui/style/_css_props.py", + render: renderCssProps, + }, + ...radixThemes(), +]; + +const PACKAGE_ROOT = fileURLToPath(new URL("../../", import.meta.url)); + +/** + * Write the generated files, or find the ones that have drifted. + * + * @param {Generated[]} generated The files to produce. + * @param {string} root The directory their paths are relative to. + * @param {boolean} check Compare with what is on disk instead of writing. + * @returns {Promise} The paths written, or with `check` the paths + * whose file is missing or differs from what its generator produces. + */ +export async function generate(generated, root, check) { + const paths = []; + for (const { path, render } of generated) { + const target = resolve(root, path); + const content = await render(); + if (check) { + const current = await readFile(target, "utf8").catch(() => null); + if (current !== content) paths.push(path); + } else { + await mkdir(dirname(target), { recursive: true }); + await writeFile(target, content); + paths.push(path); + } + } + return paths; +} + +if (process.argv[1] === fileURLToPath(import.meta.url)) { + const check = process.argv.includes("--check"); + const paths = await generate(GENERATED, PACKAGE_ROOT, check); + if (check && paths.length > 0) { + console.error( + `Generated files are out of date:\n${paths.map((path) => ` ${path}`).join("\n")}\nRun \`npm run generate\` and commit the result.`, + ); + process.exit(1); + } + console.log( + check + ? `${GENERATED.length} generated files are up to date.` + : `Wrote ${paths.length} generated files.`, + ); +} diff --git a/packages/reflex-components-ui/js/scripts/radix-tokens.js b/packages/reflex-components-ui/js/scripts/radix-tokens.js new file mode 100644 index 00000000000..ec708ed6008 --- /dev/null +++ b/packages/reflex-components-ui/js/scripts/radix-tokens.js @@ -0,0 +1,803 @@ +// Turns the token stylesheet of @radix-ui/themes into the StyleX modules of +// `src/colors`, `src/tokens` and `src/themes`, and into the python module that +// lists them. Every custom property keeps the name and the value Radix gives +// it; what changes is where the value is decided: +// +// - Radix defines a color once under `.light` and once under `.dark`. Here it is +// one `light-dark()` value, picked by the `color-scheme` of the element that +// uses it, so an appearance is one CSS property and not a second stylesheet. +// - Radix repeats every derived token on each `.radix-themes` element, so that +// `--space-1` follows the `--scaling` of the nearest theme. Here the tokens +// are defined on `:root`, and a StyleX theme defines every variable of its +// group again on the element it is applied to. The scope themes override +// nothing and exist for that: they are what makes an element a theme. + +import { dirname, posix } from "node:path"; + +import postcss from "postcss"; + +/** + * The value of a custom property in each context Radix defines it for. + * + * @typedef {object} Token + * @property {string} [light] In the light appearance. + * @property {string} [dark] In the dark appearance. + * @property {string} [p3Light] On a display-P3 screen, when it differs. + * @property {string} [p3Dark] On a display-P3 screen, when it differs. + */ + +/** + * A value as StyleX takes it: one string, or a default with the one a + * display-P3 screen gets. + * + * @typedef {string | { default: string, p3: string }} Value + */ + +/** + * What the stylesheet says, before any of it is arranged into modules. + * + * @typedef {object} Model + * @property {Map} tokens The custom properties defined outside a + * theme attribute. + * @property {Record>>} themes The + * declarations of each value of each theme attribute, such as + * `themes["accent-color"].get("red")`. + * @property {Record} element The properties Radix + * sets on a theme element itself, by the key they get in `themes/theme.js`. + */ + +/** + * What the generator needs that the stylesheet does not say. + * + * @typedef {object} Options + * @property {string} version The version of Radix Themes that was read. + * @property {{ radius: string, scaling: string, panelBackground: string, accentColor: string, grayColor: string }} defaults + * The props of a Radix `Theme` that is given none. + * @property {(accent: string) => string} matchingGray The gray an accent is + * paired with when the gray is `auto`. + */ + +/** @typedef {import("./generate.js").Generated} Generated */ + +const P3_SUPPORTS = "@supports (color: color(display-p3 1 1 1))"; +const P3_MEDIA = "@media (color-gamut: p3)"; + +// The conditions a rule may sit in. Every browser with `light-dark()` has +// `color-mix()`, so the value Radix gives the ones that do is the only value. +const CONDITIONS = new Map([ + ["", false], + ["@supports (color: color-mix(in oklab, white, black))", false], + [`${P3_SUPPORTS} > ${P3_MEDIA}`, true], +]); + +const DARK = ":is(.dark, .dark-theme)"; + +// The appearance a rule outside a theme attribute applies to. +const TOKEN_SELECTORS = new Map([ + [":root", "both"], + [":root, .light, .light-theme", "light"], + [".dark, .dark-theme", "dark"], + [".radix-themes", "both"], + [":where(.radix-themes)", "both"], + [`${DARK}, ${DARK} :where(.radix-themes:not(.light, .light-theme))`, "dark"], + ["[data-radius]", "both"], + [ + ".radix-themes, [data-accent-color]:where(:not([data-accent-color=''], [data-accent-color='gray']))", + "both", + ], +]); + +// The attributes a Radix `Theme` puts its props in. +const ATTRIBUTES = [ + "accent-color", + "gray-color", + "radius", + "scaling", + "panel-background", +]; + +const THEME_SELECTOR = new RegExp( + `^(?:\\.radix-themes:where\\()?\\[data-(${ATTRIBUTES.join("|")})='([^']+)'\\]\\)?$`, +); + +/** + * The selector that forces an appearance on a theme element. + * + * @param {string} appearance `light` or `dark`. + * @returns {string} The selector as Radix writes it. + */ +function appearanceSelector(appearance) { + const forced = `:where(.${appearance}, .${appearance}-theme)`; + return `.radix-themes${forced}, :root:where(:has(.radix-themes[data-is-root-theme='true']${forced}))`; +} + +// The rules that style a theme element, by their key in `themes/theme.js`. +const ELEMENT_SELECTORS = new Map([ + [".radix-themes", "root"], + [".radix-themes:where([data-has-background='true'])", "background"], + [appearanceSelector("light"), "light"], + [appearanceSelector("dark"), "dark"], +]); + +// Rules that reach below the theme element, which a class on it cannot do. They +// belong to the stylesheet every page loads. +const GLOBAL_SELECTORS = new Set([".radix-themes ::selection"]); + +// The variable groups that are not a color scale: the name they are exported +// under, their module and the custom properties they hold. The first match +// wins. +const GROUPS = /** @type {const} */ ([ + ["space", "tokens/space.stylex.js", /^--space-/], + ["scaling", "tokens/scaling.stylex.js", /^--scaling$/], + ["radiusFactor", "tokens/radius.stylex.js", /^--radius-(factor|full|thumb)$/], + ["radius", "tokens/radius.stylex.js", /^--radius-/], + ["shadow", "tokens/shadow.stylex.js", /^--shadow-/], + ["cursor", "tokens/cursor.stylex.js", /^--cursor-/], + [ + "panel", + "tokens/panel.stylex.js", + /^--(panel-solid|backdrop-filter-panel)$/, + ], + ["color", "tokens/color.stylex.js", /^--color-/], + ["accent", "tokens/accent.stylex.js", /^--accent-/], + ["focus", "tokens/focus.stylex.js", /^--focus-/], + ["gray", "tokens/gray.stylex.js", /^--gray-/], + [ + "typography", + "tokens/typography.stylex.js", + /^--(font|line-height|letter-spacing|default|heading|code|strong|em|quote|tab)-/, + ], +]); + +// The groups with tokens that read another variable, which a scope theme +// defines again on a theme element. `focus` has a module of its own, because an +// accent on a single element needs it without the rest. +const SCOPED = ["space", "radius", "typography", "shadow", "color"]; + +/** + * Read the custom properties and the theme element's styles from a stylesheet. + * + * @param {string} css The token stylesheet of Radix Themes. + * @returns {Model} What it defines. + */ +export function parseTokens(css) { + /** @type {Model} */ + const model = { tokens: new Map(), themes: {}, element: {} }; + postcss.parse(css).walkRules((rule) => { + const conditions = []; + for ( + let parent = rule.parent; + parent?.type === "atrule"; + parent = parent.parent + ) { + const atRule = /** @type {import("postcss").AtRule} */ (parent); + conditions.unshift(`@${atRule.name} ${atRule.params}`); + } + const p3 = CONDITIONS.get(conditions.join(" > ")); + const selector = rule.selector.replace(/\s+/g, " "); + if (p3 === undefined) { + throw new Error( + `Unknown condition on ${selector}: ${conditions.join(" > ")}`, + ); + } + const appearance = TOKEN_SELECTORS.get(selector); + const theme = THEME_SELECTOR.exec(selector); + const element = ELEMENT_SELECTORS.get(selector); + if (!appearance && !theme && !element && !GLOBAL_SELECTORS.has(selector)) { + throw new Error(`Unknown selector: ${selector}`); + } + rule.walkDecls((decl) => { + const value = decl.value.replace(/\s+/g, " "); + if (!decl.prop.startsWith("--")) { + // A prefixed copy of a property the rule also sets is the work of + // Radix's build, and StyleX takes the standard name only. + const standard = decl.prop.replace(/^-(webkit|moz)-/, ""); + const prefixed = + standard !== decl.prop && + rule.some((node) => node.type === "decl" && node.prop === standard); + if (element && !prefixed) { + (model.element[element] ??= []).push([decl.prop, value]); + } + } else if (theme) { + const values = (model.themes[theme[1]] ??= new Map()); + let declarations = values.get(theme[2]); + if (!declarations) values.set(theme[2], (declarations = new Map())); + declarations.set(decl.prop, value); + } else if (appearance) { + let token = model.tokens.get(decl.prop); + if (!token) model.tokens.set(decl.prop, (token = {})); + if (appearance !== "dark") token[p3 ? "p3Light" : "light"] = value; + if (appearance !== "light") token[p3 ? "p3Dark" : "dark"] = value; + } else { + throw new Error(`${decl.prop} is set by ${selector}`); + } + }); + }); + return model; +} + +/** + * Split a value at the separators that are not inside parentheses. + * + * @param {string} value The value to split. + * @param {string} separator One character. + * @returns {string[]} The trimmed parts. + */ +function splitTopLevel(value, separator) { + const parts = []; + let depth = 0; + let start = 0; + for (let index = 0; index < value.length; index++) { + const character = value[index]; + if (character === "(") depth++; + else if (character === ")") depth--; + else if (character === separator && depth === 0) { + parts.push(value.slice(start, index).trim()); + start = index + 1; + } + } + parts.push(value.slice(start).trim()); + return parts.filter(Boolean); +} + +/** + * One value for both appearances of a color. + * + * @param {string} light The color in the light appearance. + * @param {string} dark The color in the dark appearance. + * @returns {string} The color, or a `light-dark()` of the two. + */ +export function lightDark(light, dark) { + return light === dark ? light : `light-dark(${light}, ${dark})`; +} + +/** + * One shadow list for both appearances. + * + * `light-dark()` only chooses between colors, and the two appearances of a + * Radix shadow differ in geometry too. Layers that share their geometry keep + * it and choose their color; a layer only one appearance has is transparent in + * the other, where it paints nothing. Both appearances keep their paint order. + * + * @param {string} light The `box-shadow` value of the light appearance. + * @param {string} dark The `box-shadow` value of the dark appearance. + * @returns {string} A `box-shadow` value that paints as `light` or as `dark` + * according to the color scheme. + */ +export function mergeShadows(light, dark) { + if (light === dark) return light; + const [lights, darks] = [light, dark].map((shadow) => + splitTopLevel(shadow, ",").map((layer) => { + const parts = splitTopLevel(layer, " "); + const color = parts.findIndex( + (part) => part !== "inset" && !/^-?[\d.]+(px)?$/.test(part), + ); + return { + color: parts[color], + geometry: parts.toSpliced(color, 1).join(" "), + }; + }), + ); + // The longest common subsequence of the two lists of geometries. + const common = lights.map(() => new Array(darks.length + 1).fill(0)); + common.push(new Array(darks.length + 1).fill(0)); + for (let l = lights.length - 1; l >= 0; l--) { + for (let d = darks.length - 1; d >= 0; d--) { + common[l][d] = + lights[l].geometry === darks[d].geometry + ? common[l + 1][d + 1] + 1 + : Math.max(common[l + 1][d], common[l][d + 1]); + } + } + const layers = []; + let l = 0; + let d = 0; + while (l < lights.length || d < darks.length) { + if ( + l < lights.length && + d < darks.length && + lights[l].geometry === darks[d].geometry + ) { + const color = lightDark(lights[l].color, darks[d++].color); + layers.push(`${lights[l++].geometry} ${color}`); + } else if ( + d === darks.length || + (l < lights.length && common[l + 1][d] >= common[l][d + 1]) + ) { + const { geometry, color } = lights[l++]; + layers.push(`${geometry} light-dark(${color}, transparent)`); + } else { + const { geometry, color } = darks[d++]; + layers.push(`${geometry} light-dark(transparent, ${color})`); + } + } + return layers.join(", "); +} + +/** + * The single value of a token. + * + * @param {string} name The custom property. + * @param {Token} token Its value in each context. + * @returns {Value} The value for every appearance, and the one a display-P3 + * screen gets when Radix has one. + */ +function resolve(name, { light, dark, p3Light, p3Dark }) { + if (light === undefined || dark === undefined) { + throw new Error(`${name} has no value in one appearance.`); + } + const merge = name.startsWith("--shadow-") ? mergeShadows : lightDark; + const value = merge(light, dark); + if (p3Light === undefined && p3Dark === undefined) return value; + return { default: value, p3: merge(p3Light ?? light, p3Dark ?? dark) }; +} + +/** + * The name a theme is exported under. + * + * @param {string} prefix What the theme sets, such as `accent`. + * @param {string} name The value of the theme prop, such as `red` or `90%`. + * @returns {string} A javascript identifier, such as `accentRed`. + */ +function themeExport(prefix, name) { + const word = name.replace(/\W/g, ""); + return prefix + word[0].toUpperCase() + word.slice(1); +} + +/** + * The property name StyleX takes for a CSS property. + * + * @param {string} property A CSS property, such as `-webkit-font-smoothing`. + * @returns {string} Its camel case name, such as `WebkitFontSmoothing`. + */ +function camelCase(property) { + return property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()); +} + +/** + * A property of an object literal, laid out the way the repository's formatter + * leaves it: a string that does not fit on the line of its key goes below it. + * + * @param {string} indent The indentation of the property. + * @param {string} key The key, as it is written. + * @param {string} expression The javascript of the value. + * @returns {string} The lines of the property. + */ +function property(indent, key, expression) { + const line = `${indent}${key}: ${expression},`; + return line.length > 80 && expression.startsWith('"') + ? `${indent}${key}:\n${indent} ${expression},\n` + : `${line}\n`; +} + +/** + * Builds the modules, remembering which module defines each custom property so + * that a value which reads one imports it. + */ +class Modules { + /** + * @param {string} version The version of Radix Themes that was read. + */ + constructor(version) { + this.header = `// Generated by scripts/generate.js from @radix-ui/themes ${version}. Do not edit.\n`; + /** @type {Map} */ + this.owners = new Map(); + /** @type {Map} */ + this.groups = new Map(); + /** @type {Map} */ + this.groupModules = new Map(); + /** @type {Generated[]} */ + this.files = []; + } + + /** + * Add a group of variables to the module that defines it. + * + * @param {string} module The module, relative to `src`. + * @param {string} name The name the group is exported under. + * @param {[string, Value][]} vars The custom properties and their values. + */ + define(module, name, vars) { + const groups = this.groups.get(module) ?? []; + this.groups.set(module, groups); + groups.push({ name, vars }); + this.groupModules.set(name, module); + for (const [variable] of vars) this.owners.set(variable, { module, name }); + } + + /** + * The javascript for a value, reading the variables other modules define + * through an import, which is what makes their CSS part of the build. + * + * @param {string} value The CSS value. + * @param {string} module The module the value is written in. + * @param {Map>} imports The names to import, by module. + * @returns {string} A string literal, a member of an imported group or a + * template literal of both. + */ + expression(value, module, imports) { + const parts = value.split(/var\((--[\w-]+)\)/); + let foreign = false; + for (let index = 1; index < parts.length; index += 2) { + const owner = this.owners.get(parts[index]); + if (!owner || owner.module === module) { + parts[index] = `var(${parts[index]})`; + continue; + } + foreign = true; + if (!imports.has(owner.module)) imports.set(owner.module, new Set()); + /** @type {Set} */ (imports.get(owner.module)).add(owner.name); + parts[index] = `\${${owner.name}["${parts[index]}"]}`; + } + if (!foreign) return JSON.stringify(parts.join("")); + if (parts.length === 3 && parts[0] === "" && parts[2] === "") { + return parts[1].slice(2, -1); + } + return `\`${parts.join("")}\``; + } + + /** + * The properties of an object literal of variables. + * + * @param {[string, Value][]} vars The custom properties and their values. + * @param {string} module The module the object is written in. + * @param {Map>} imports The names to import, by module. + * @param {string} [none] The expression for a level that has no value. + * @returns {string} One property a line, indented. + */ + properties(vars, module, imports, none = "null") { + /** @type {(value: string) => string} */ + const expression = (value) => this.expression(value, module, imports); + return vars + .map(([name, value]) => + typeof value === "string" + ? property(" ", `"${name}"`, expression(value)) + : ` "${name}": {\n` + + property(" ", "default", expression(value.default)) + + ` "${P3_SUPPORTS}": {\n` + + property(" ", "default", none) + + property(" ", `"${P3_MEDIA}"`, expression(value.p3)) + + ` },\n` + + ` },\n`, + ) + .join(""); + } + + /** + * Add a module to the generated files. + * + * @param {string} module The module, relative to `src`. + * @param {Map>} imports The names it imports, by module. + * @param {string[]} statements The exports of the module. + */ + write(module, imports, statements) { + const lines = [...imports] + .map(([from, names]) => { + let path = posix.relative(dirname(module), from); + if (!path.startsWith(".")) path = `./${path}`; + return `import { ${[...names].sort().join(", ")} } from "${path}";\n`; + }) + .sort(); + const content = `${this.header}\nimport * as stylex from "@stylexjs/stylex";\n\n${lines.join("")}${lines.length ? "\n" : ""}${statements.join("\n")}`; + this.files.push({ path: `js/src/${module}`, render: () => content }); + } + + /** + * Write every module of variables that was defined. + */ + writeGroups() { + for (const [module, groups] of this.groups) { + /** @type {Map>} */ + const imports = new Map(); + const statements = groups.map( + ({ name, vars }) => + `export const ${name} = stylex.defineVars({\n${this.properties(vars, module, imports)}});\n`, + ); + this.write(module, imports, statements); + } + } + + /** + * Write a module of themes. + * + * @param {string} module The module, relative to `src`. + * @param {[name: string, group: string, vars: [string, Value][]][]} themes + * The name each theme is exported under, the group of variables it + * overrides and the values it gives them. + * @returns {[string, string][]} The module and the name of each theme. + */ + writeThemes(module, themes) { + /** @type {Map>} */ + const imports = new Map(); + let conditional = false; + const statements = themes.map(([name, group, vars]) => { + conditional ||= vars.some(([, value]) => typeof value !== "string"); + const from = /** @type {string} */ (this.groupModules.get(group)); + if (!imports.has(from)) imports.set(from, new Set()); + /** @type {Set} */ (imports.get(from)).add(group); + const overrides = this.properties(vars, module, imports, "NONE"); + return `export const ${name} = stylex.createTheme(${group}, {${overrides && "\n"}${overrides}});\n`; + }); + if (conditional) { + statements.unshift( + "// StyleX leaves a null level out, which the type of a string token does\n// not say.\nconst NONE = /** @type {string} */ (/** @type {unknown} */ (null));\n", + ); + } + this.write(module, imports, statements); + return themes.map(([name]) => [module, name]); + } +} + +/** + * Order entries by their name. + * + * @param {[string, unknown]} a An entry. + * @param {[string, unknown]} b Another. + * @returns {number} Negative when `a` goes first. + */ +function byName([a], [b]) { + return a < b ? -1 : a > b ? 1 : 0; +} + +/** + * The declarations of a value of a theme attribute. + * + * @param {Map>} values The values of the attribute. + * @param {string} name The value. + * @returns {Map} What it declares. + */ +function required(values, name) { + const declarations = values.get(name); + if (!declarations) throw new Error(`Radix has no rule for ${name}.`); + return declarations; +} + +/** + * A python literal, laid out the way `ruff format` leaves it. + * + * @param {unknown} value Strings, arrays (written as tuples) and plain objects + * (written as dicts). + * @param {string} indent The indentation of the line the literal starts on. + * @returns {string} The literal. + */ +function python(value, indent = "") { + if (typeof value === "string") return JSON.stringify(value); + const inner = `${indent} `; + if (Array.isArray(value)) { + const flat = `(${value.map((item) => python(item)).join(", ")}${value.length === 1 ? "," : ""})`; + if (value.every((item) => typeof item === "string") && value.length <= 2) { + return flat; + } + return `(\n${value.map((item) => `${inner}${python(item, inner)},\n`).join("")}${indent})`; + } + const entries = Object.entries(/** @type {object} */ (value)); + return `{\n${entries.map(([key, item]) => `${inner}${JSON.stringify(key)}: ${python(item, inner)},\n`).join("")}${indent}}`; +} + +/** + * The generated files for a token stylesheet. + * + * @param {string} css The token stylesheet of Radix Themes. + * @param {Options} options What the stylesheet does not say. + * @returns {Generated[]} The StyleX modules under `js/src` and the python + * module that lists them. + */ +export function radixTokens(css, { version, defaults, matchingGray }) { + const { tokens, themes, element } = parseTokens(css); + for (const attribute of ATTRIBUTES) { + if (!themes[attribute]) { + throw new Error(`Radix has no rule for data-${attribute}.`); + } + } + const modules = new Modules(version); + const accents = themes["accent-color"]; + const panels = themes["panel-background"]; + + // The solid panel is a space toggle: `--color-panel` has to choose between + // two variables that follow the gray scale of the element it is used on, so + // a theme cannot hand it either of them as a value. + for (const [name, panel] of panels) { + if (panel.get("--color-panel") !== `var(--color-panel-${name})`) { + throw new Error(`The ${name} panel is not --color-panel-${name}.`); + } + panel.delete("--color-panel"); + panel.set("--panel-solid", name === "solid" ? " " : "initial"); + } + /** @type {Map} */ + const values = new Map( + [...tokens].map(([name, token]) => [name, resolve(name, token)]), + ); + const defaultTheme = [ + ...required(themes.scaling, defaults.scaling), + ...required(themes.radius, defaults.radius), + ...required(panels, defaults.panelBackground), + ["--color-panel-if-solid", "var(--panel-solid) var(--color-panel-solid)"], + [ + "--color-panel", + "var(--color-panel-if-solid, var(--color-panel-translucent))", + ], + ]; + for (const [name, value] of defaultTheme) values.set(name, value); + + // Radix defines its pure gray as `--gray-*` on `:root` and lets a gray theme + // replace it. Here it is the `gray` gray theme, and no accent or gray is + // defined outside a theme, so that an app pays for the scales it uses. + /** @type {[string, Value][]} */ + const pureGray = []; + for (const [name, value] of values) { + if (GROUPS.find(([, , pattern]) => pattern.test(name))?.[0] === "gray") { + pureGray.push([name, value]); + values.set(name, "initial"); + } + } + for (const name of required(accents, defaults.accentColor).keys()) { + values.set(name, "initial"); + } + + /** @type {Map} */ + const grouped = new Map(); + /** @type {Map} */ + const scales = new Map(); + for (const entry of values) { + const group = GROUPS.find(([, , pattern]) => pattern.test(entry[0]))?.[0]; + const scale = /^--([a-z]+)-/.exec(entry[0])?.[1] ?? ""; + if (!group && !values.has(`--${scale}-a9`)) { + throw new Error(`${entry[0]} is in no group and in no color scale.`); + } + const target = group ? grouped : scales; + if (!target.has(group ?? scale)) target.set(group ?? scale, []); + /** @type {[string, Value][]} */ (target.get(group ?? scale)).push(entry); + } + for (const [scale, vars] of [...scales].sort(byName)) { + modules.define(`colors/${scale}.stylex.js`, scale, vars); + } + for (const [name, module] of GROUPS) { + modules.define(module, name, grouped.get(name) ?? []); + } + modules.writeGroups(); + + /** + * Write one module for each value of a theme attribute. + * + * @param {string} attribute The attribute, such as `accent-color`. + * @param {string} prefix What the names of its themes start with. + * @param {string} group The group its themes override. + * @param {(name: string) => string} module The module of a value. + * @param {[string, [string, Value][]][]} [extra] Themes Radix has no rule for. + * @returns {Record} The module and the export of + * the theme of each value. + */ + const themeModules = (attribute, prefix, group, module, extra = []) => { + /** @type {Record} */ + const written = {}; + /** @type {[string, [string, Value][]][]} */ + const all = [ + ...extra, + ...[...themes[attribute]].map( + ([name, vars]) => + /** @type {[string, [string, Value][]]} */ ([name, [...vars]]), + ), + ]; + /** @type {Map} */ + const byModule = new Map(); + for (const [name, vars] of all.sort(byName)) { + const path = module(name); + if (!byModule.has(path)) byModule.set(path, []); + /** @type {[string, string, [string, Value][]][]} */ ( + byModule.get(path) + ).push([themeExport(prefix, name), group, vars]); + written[name] = [path, themeExport(prefix, name)]; + } + for (const [path, list] of byModule) modules.writeThemes(path, list); + return written; + }; + + const accentThemes = themeModules( + "accent-color", + "accent", + "accent", + (name) => `themes/accent/${name}.js`, + ); + const grayThemes = themeModules( + "gray-color", + "gray", + "gray", + (name) => `themes/gray/${name}.js`, + [["gray", pureGray]], + ); + const radiusThemes = themeModules( + "radius", + "radius", + "radiusFactor", + () => "themes/radius.js", + ); + const scalingThemes = themeModules( + "scaling", + "scaling", + "scaling", + () => "themes/scaling.js", + ); + const panelThemes = themeModules( + "panel-background", + "panel", + "panel", + () => "themes/panel.js", + ); + + for (const [group, vars] of grouped) { + const derived = vars.some(([, value]) => + (typeof value === "string" ? value : value.default).includes("var("), + ); + if (derived && group !== "focus" && !SCOPED.includes(group)) { + throw new Error(`${group} reads a variable and has no scope theme.`); + } + } + const [focusTheme] = modules.writeThemes("themes/focus.js", [ + ["focusScope", "focus", []], + ]); + const scopeThemes = modules.writeThemes( + "themes/scope.js", + SCOPED.map((group) => [`${group}Scope`, group, []]), + ); + + /** @type {Map>} */ + const imports = new Map(); + const styles = Object.entries(element).map( + ([key, declarations]) => + ` ${key}: {\n${declarations.map(([name, value]) => property(" ", camelCase(name), modules.expression(value, "themes/theme.js", imports))).join("")} },\n`, + ); + modules.write("themes/theme.js", imports, [ + `export const theme = stylex.create({\n${styles.join("")}});\n`, + ]); + + /** @type {Record} */ + const varGroups = {}; + for (const [module, groups] of modules.groups) { + for (const { name, vars } of groups) { + varGroups[name] = [module, vars.map(([variable]) => variable)]; + } + } + const data = [ + ["RADIX_THEMES_VERSION", "str", version], + ["VAR_GROUPS", "dict[str, tuple[str, tuple[str, ...]]]", varGroups], + ["ACCENT_THEMES", "dict[str, tuple[str, str]]", accentThemes], + ["GRAY_THEMES", "dict[str, tuple[str, str]]", grayThemes], + ["RADIUS_THEMES", "dict[str, tuple[str, str]]", radiusThemes], + ["SCALING_THEMES", "dict[str, tuple[str, str]]", scalingThemes], + ["PANEL_BACKGROUND_THEMES", "dict[str, tuple[str, str]]", panelThemes], + ["SCOPE_THEMES", "tuple[tuple[str, str], ...]", scopeThemes], + ["FOCUS_THEME", "tuple[str, str]", focusTheme], + [ + "THEME_STYLES", + "tuple[str, str, tuple[str, ...]]", + ["themes/theme.js", "theme", Object.keys(element)], + ], + [ + "MATCHING_GRAY", + "dict[str, str]", + Object.fromEntries( + Object.keys(accentThemes).map((accent) => [ + accent, + matchingGray(accent), + ]), + ), + ], + [ + "DEFAULTS", + "dict[str, str]", + { + accent_color: defaults.accentColor, + gray_color: defaults.grayColor, + radius: defaults.radius, + scaling: defaults.scaling, + panel_background: defaults.panelBackground, + }, + ], + ]; + modules.files.push({ + path: "src/reflex_components_ui/_radix_tokens.py", + render: () => + `"""The StyleX modules generated from @radix-ui/themes, and what they define.\n\nGenerated by js/scripts/generate.js. Do not edit.\n"""\n\n${data.map(([name, type, value]) => `${name}: ${type} = ${python(value)}\n`).join("\n")}`, + }); + return modules.files; +} diff --git a/packages/reflex-components-ui/js/src/README.md b/packages/reflex-components-ui/js/src/README.md new file mode 100644 index 00000000000..00144678adf --- /dev/null +++ b/packages/reflex-components-ui/js/src/README.md @@ -0,0 +1,19 @@ +# reflex-ui + +The javascript `rx.ui` components are compiled against. `rx.plugins.UIPlugin` +copies this directory into an app's `.web/reflex-ui/` from the +`reflex-components-ui` package on every compile, so an edit made here in an app +is overwritten. + +- `base.css` is imported first by the app's stylesheet: it orders the cascade + layers, switches the color scheme, and holds the selection color of a theme + and the font faces the typography tokens name. +- `class-name.js` joins the class names of compiled styles where StyleX + cannot fold them into a string: on an element that carries a theme. +- `colors/`, `tokens/` and `themes/` are the design tokens and the themes, as + StyleX modules: a module adds its CSS when a page imports it. +- `vite-plugin-stylex.js` is the plugin `vite.config.js` loads to compile the + styles. + +The source, its tests and its rules live in +[`packages/reflex-components-ui/js`](https://github.com/reflex-dev/reflex/tree/main/packages/reflex-components-ui/js). diff --git a/packages/reflex-components-ui/js/src/base.css b/packages/reflex-components-ui/js/src/base.css new file mode 100644 index 00000000000..27641ea20b1 --- /dev/null +++ b/packages/reflex-components-ui/js/src/base.css @@ -0,0 +1,198 @@ +/* + * The cascade order of an app that uses rx.ui, declared once so that it does + * not depend on which stylesheet loads first. Later layers win: + * + * __reflex_base, theme, base resets: Reflex's own, Tailwind's theme and preflight + * reflex-ui the components, then the `style` of an element + * components, utilities Tailwind, so a `class_name` utility overrides a component + * + * Unlayered CSS (an app's stylesheets, Emotion, Radix Themes) beats every layer. + */ +@layer __reflex_base, theme, base, reflex-ui, components, utilities; + +/* + * Reflex's color mode provider sets one of these classes on the root element. + * Without either, as in a page read with JavaScript off, the page is light: + * the default has no specificity, so any rule of an app is written over it. + */ +:where(html) { + color-scheme: light; +} + +html.light { + color-scheme: light; +} + +html.dark { + color-scheme: dark; +} + +/* + * What Radix Themes styles through a selector that a class on the element + * cannot express. A theme element carries the class `reflex-ui-theme`. + */ +@layer reflex-ui.base { + .reflex-ui-theme ::selection { + background-color: var(--focus-a5); + } +} + +/* + * The system fonts Radix Themes adjusts the metrics of, which the font + * families of the typography tokens name. Copied from the `tokens.css` of + * @radix-ui/themes: `tests/base-css.test.js` fails when they differ. + */ +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 300; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Semilight'), local('Segoe UI'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 300; + font-style: italic; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Semilight Italic'), local('Segoe UI Italic'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 400; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 400; + font-style: italic; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Italic'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 500; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Semibold'), local('Segoe UI'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 500; + font-style: italic; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Semibold Italic'), local('Segoe UI Italic'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 700; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Bold'); +} +@font-face { + font-family: 'Segoe UI (Custom)'; + font-weight: 700; + font-style: italic; + size-adjust: 103%; + descent-override: 35%; + ascent-override: 105%; + src: local('Segoe UI Bold Italic'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 300; + descent-override: 35%; + src: local('Open Sans Light'), local('Open Sans Regular'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 300; + font-style: italic; + descent-override: 35%; + src: local('Open Sans Light Italic'), local('Open Sans Italic'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 400; + descent-override: 35%; + src: local('Open Sans Regular'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 400; + font-style: italic; + descent-override: 35%; + src: local('Open Sans Italic'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 500; + descent-override: 35%; + src: local('Open Sans Medium'), local('Open Sans Regular'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 500; + font-style: italic; + descent-override: 35%; + src: local('Open Sans Medium Italic'), local('Open Sans Italic'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 700; + descent-override: 35%; + src: local('Open Sans Bold'); +} +@font-face { + font-family: 'Open Sans (Custom)'; + font-weight: 700; + font-style: italic; + descent-override: 35%; + src: local('Open Sans Bold Italic'); +} +@font-face { + font-family: 'Consolas (Custom)'; + font-weight: 400; + size-adjust: 110%; + ascent-override: 85%; + descent-override: 22%; + src: local('Consolas'); +} +@font-face { + font-family: 'Consolas (Custom)'; + font-weight: 400; + font-style: italic; + size-adjust: 110%; + ascent-override: 85%; + descent-override: 22%; + src: local('Consolas Italic'); +} +@font-face { + font-family: 'Consolas (Custom)'; + font-weight: 700; + size-adjust: 110%; + ascent-override: 85%; + descent-override: 22%; + src: local('Consolas Bold'); +} +@font-face { + font-family: 'Consolas (Custom)'; + font-weight: 700; + font-style: italic; + size-adjust: 110%; + ascent-override: 85%; + descent-override: 22%; + src: local('Consolas Bold Italic'); +} diff --git a/packages/reflex-components-ui/js/src/class-name.js b/packages/reflex-components-ui/js/src/class-name.js new file mode 100644 index 00000000000..decdbb67bc4 --- /dev/null +++ b/packages/reflex-components-ui/js/src/class-name.js @@ -0,0 +1,36 @@ +// The class names of compiled StyleX styles: what `stylex.props(...).className` +// gives, without the rest of the StyleX runtime. +// +// StyleX folds that call into a string only when every argument is declared +// in the module that makes it. A theme is declared in a module of its own, so +// the element that carries one joins its classes when the page loads. + +/** + * A compiled style: a class name for each property it sets, and a marker. + * + * @typedef {Readonly>} CompiledStyle + */ + +/** + * Join the class names of compiled styles, a later style winning a property + * that an earlier one also sets. + * + * @param {...(CompiledStyle | false | null | undefined)} styles The styles, + * and anything falsy for a style that does not apply. + * @returns {string} The class names of what is left of each style. + */ +export function className(...styles) { + /** @type {Record} */ + const merged = {}; + for (const style of styles) { + if (style) Object.assign(merged, style); + } + const names = []; + for (const key in merged) { + const name = merged[key]; + // The marker of a compiled style is no class, and neither is a property + // a style unsets. + if (key !== "$$css" && typeof name === "string") names.push(name); + } + return names.join(" "); +} diff --git a/packages/reflex-components-ui/js/src/colors/amber.stylex.js b/packages/reflex-components-ui/js/src/colors/amber.stylex.js new file mode 100644 index 00000000000..1c48e05927e --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/amber.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const amber = stylex.defineVars({ + "--amber-1": { + default: "light-dark(#fefdfb, #16120c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.992 0.985), color(display-p3 0.082 0.07 0.05))", + }, + }, + "--amber-2": { + default: "light-dark(#fefbe9, #1d180f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.994 0.986 0.921), color(display-p3 0.111 0.094 0.064))", + }, + }, + "--amber-3": { + default: "light-dark(#fff7c2, #302008)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.994 0.969 0.782), color(display-p3 0.178 0.128 0.049))", + }, + }, + "--amber-4": { + default: "light-dark(#ffee9c, #3f2700)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.989 0.937 0.65), color(display-p3 0.239 0.156 0))", + }, + }, + "--amber-5": { + default: "light-dark(#fbe577, #4d3000)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.97 0.902 0.527), color(display-p3 0.29 0.193 0))", + }, + }, + "--amber-6": { + default: "light-dark(#f3d673, #5c3d05)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.936 0.844 0.506), color(display-p3 0.344 0.245 0.076))", + }, + }, + "--amber-7": { + default: "light-dark(#e9c162, #714f19)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.89 0.762 0.443), color(display-p3 0.422 0.314 0.141))", + }, + }, + "--amber-8": { + default: "light-dark(#e2a336, #8f6424)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.85 0.65 0.3), color(display-p3 0.535 0.399 0.189))", + }, + }, + "--amber-9": { + default: "#ffc53d", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 0.77 0.26)", + }, + }, + "--amber-10": { + default: "light-dark(#ffba18, #ffd60a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.959 0.741 0.274), color(display-p3 1 0.87 0.15))", + }, + }, + "--amber-11": { + default: "light-dark(#ab6400, #ffca16)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.64 0.4 0), color(display-p3 1 0.8 0.29))", + }, + }, + "--amber-12": { + default: "light-dark(#4f3422, #ffe7b3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.294 0.208 0.145), color(display-p3 0.984 0.909 0.726))", + }, + }, + "--amber-a1": { + default: "light-dark(#c0800004, #e63c0006)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.757 0.514 0.024 / 0.016), color(display-p3 0.992 0.298 0 / 0.017))", + }, + }, + "--amber-a2": { + default: "light-dark(#f4d10016, #fd9b000d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.902 0.804 0.008 / 0.079), color(display-p3 0.988 0.651 0 / 0.047))", + }, + }, + "--amber-a3": { + default: "light-dark(#ffde003d, #fa820022)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.965 0.859 0.004 / 0.22), color(display-p3 1 0.6 0 / 0.118))", + }, + }, + "--amber-a4": { + default: "light-dark(#ffd40063, #fc820032)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.969 0.82 0.004 / 0.35), color(display-p3 1 0.557 0 / 0.185))", + }, + }, + "--amber-a5": { + default: "light-dark(#f8cf0088, #fd8b0041)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.933 0.796 0.004 / 0.475), color(display-p3 1 0.592 0 / 0.24))", + }, + }, + "--amber-a6": { + default: "light-dark(#eab5008c, #fd9b0051)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.875 0.682 0.004 / 0.495), color(display-p3 1 0.659 0.094 / 0.299))", + }, + }, + "--amber-a7": { + default: "light-dark(#dc9b009d, #ffab2567)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.804 0.573 0 / 0.557), color(display-p3 1 0.714 0.263 / 0.383))", + }, + }, + "--amber-a8": { + default: "light-dark(#da8a00c9, #ffae3587)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.788 0.502 0 / 0.699), color(display-p3 0.996 0.729 0.306 / 0.5))", + }, + }, + "--amber-a9": { + default: "light-dark(#ffb300c2, #ffc53d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.686 0 / 0.742), color(display-p3 1 0.769 0.259))", + }, + }, + "--amber-a10": { + default: "light-dark(#ffb300e7, #ffd60a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.945 0.643 0 / 0.726), color(display-p3 1 0.871 0.149))", + }, + }, + "--amber-a11": { + default: "light-dark(#ab6400, #ffca16)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.64 0.4 0), color(display-p3 1 0.8 0.29))", + }, + }, + "--amber-a12": { + default: "light-dark(#341500dd, #ffe7b3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.294 0.208 0.145), color(display-p3 0.984 0.909 0.726))", + }, + }, + "--amber-surface": { + default: "light-dark(#fefae4cc, #271f1380)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9922 0.9843 0.902 / 0.8), color(display-p3 0.1412 0.1176 0.0784 / 0.5))", + }, + }, + "--amber-indicator": "var(--amber-9)", + "--amber-track": + "light-dark(var(--amber-9), color-mix(in oklab, var(--amber-8), var(--amber-9) 75%))", + "--amber-contrast": "#21201c", +}); diff --git a/packages/reflex-components-ui/js/src/colors/black.stylex.js b/packages/reflex-components-ui/js/src/colors/black.stylex.js new file mode 100644 index 00000000000..0b72ded3023 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/black.stylex.js @@ -0,0 +1,90 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const black = stylex.defineVars({ + "--black-a1": { + default: "rgba(0, 0, 0, 0.05)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.05)", + }, + }, + "--black-a2": { + default: "rgba(0, 0, 0, 0.1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.1)", + }, + }, + "--black-a3": { + default: "rgba(0, 0, 0, 0.15)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.15)", + }, + }, + "--black-a4": { + default: "rgba(0, 0, 0, 0.2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.2)", + }, + }, + "--black-a5": { + default: "rgba(0, 0, 0, 0.3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.3)", + }, + }, + "--black-a6": { + default: "rgba(0, 0, 0, 0.4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.4)", + }, + }, + "--black-a7": { + default: "rgba(0, 0, 0, 0.5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.5)", + }, + }, + "--black-a8": { + default: "rgba(0, 0, 0, 0.6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.6)", + }, + }, + "--black-a9": { + default: "rgba(0, 0, 0, 0.7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.7)", + }, + }, + "--black-a10": { + default: "rgba(0, 0, 0, 0.8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.8)", + }, + }, + "--black-a11": { + default: "rgba(0, 0, 0, 0.9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.9)", + }, + }, + "--black-a12": { + default: "rgba(0, 0, 0, 0.95)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0.95)", + }, + }, +}); diff --git a/packages/reflex-components-ui/js/src/colors/blue.stylex.js b/packages/reflex-components-ui/js/src/colors/blue.stylex.js new file mode 100644 index 00000000000..2b8ecf5161b --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/blue.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const blue = stylex.defineVars({ + "--blue-1": { + default: "light-dark(#fbfdff, #0d1520)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.986 0.992 0.999), color(display-p3 0.057 0.081 0.122))", + }, + }, + "--blue-2": { + default: "light-dark(#f4faff, #111927)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.96 0.979 0.998), color(display-p3 0.072 0.098 0.147))", + }, + }, + "--blue-3": { + default: "light-dark(#e6f4fe, #0d2847)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.912 0.956 0.991), color(display-p3 0.078 0.154 0.27))", + }, + }, + "--blue-4": { + default: "light-dark(#d5efff, #003362)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.853 0.932 1), color(display-p3 0.033 0.197 0.37))", + }, + }, + "--blue-5": { + default: "light-dark(#c2e5ff, #004074)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.788 0.894 0.998), color(display-p3 0.08 0.245 0.441))", + }, + }, + "--blue-6": { + default: "light-dark(#acd8fc, #104d87)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.709 0.843 0.976), color(display-p3 0.14 0.298 0.511))", + }, + }, + "--blue-7": { + default: "light-dark(#8ec8f6, #205d9e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.606 0.777 0.947), color(display-p3 0.195 0.361 0.6))", + }, + }, + "--blue-8": { + default: "light-dark(#5eb1ef, #2870bd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.451 0.688 0.917), color(display-p3 0.239 0.434 0.72))", + }, + }, + "--blue-9": { + default: "#0090ff", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.247 0.556 0.969)", + }, + }, + "--blue-10": { + default: "light-dark(#0588f0, #3b9eff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.234 0.523 0.912), color(display-p3 0.344 0.612 0.973))", + }, + }, + "--blue-11": { + default: "light-dark(#0d74ce, #70b8ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.15 0.44 0.84), color(display-p3 0.49 0.72 1))", + }, + }, + "--blue-12": { + default: "light-dark(#113264, #c2e6ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.102 0.193 0.379), color(display-p3 0.788 0.898 0.99))", + }, + }, + "--blue-a1": { + default: "light-dark(#0080ff04, #004df211)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.514 1 / 0.016), color(display-p3 0 0.333 1 / 0.059))", + }, + }, + "--blue-a2": { + default: "light-dark(#008cff0b, #1166fb18)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.514 0.906 / 0.04), color(display-p3 0.114 0.435 0.988 / 0.085))", + }, + }, + "--blue-a3": { + default: "light-dark(#008ff519, #0077ff3a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.506 0.914 / 0.087), color(display-p3 0.122 0.463 1 / 0.219))", + }, + }, + "--blue-a4": { + default: "light-dark(#009eff2a, #0075ff57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.545 1 / 0.146), color(display-p3 0 0.467 1 / 0.324))", + }, + }, + "--blue-a5": { + default: "light-dark(#0093ff3d, #0081fd6b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.502 0.984 / 0.212), color(display-p3 0.098 0.51 1 / 0.4))", + }, + }, + "--blue-a6": { + default: "light-dark(#0088f653, #0f89fd7f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.463 0.922 / 0.291), color(display-p3 0.224 0.557 1 / 0.475))", + }, + }, + "--blue-a7": { + default: "light-dark(#0083eb71, #2a91fe98)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.431 0.863 / 0.393), color(display-p3 0.294 0.584 1 / 0.572))", + }, + }, + "--blue-a8": { + default: "light-dark(#0084e6a1, #3094feb9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.427 0.851 / 0.55), color(display-p3 0.314 0.592 1 / 0.702))", + }, + }, + "--blue-a9": { + default: "#0090ff", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.412 0.961 / 0.753), color(display-p3 0.251 0.573 0.996 / 0.967))", + }, + }, + "--blue-a10": { + default: "light-dark(#0086f0fa, #3b9eff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.376 0.886 / 0.765), color(display-p3 0.357 0.631 1 / 0.971))", + }, + }, + "--blue-a11": { + default: "light-dark(#006dcbf2, #70b8ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.15 0.44 0.84), color(display-p3 0.49 0.72 1))", + }, + }, + "--blue-a12": { + default: "light-dark(#002359ee, #c2e6ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.102 0.193 0.379), color(display-p3 0.788 0.898 0.99))", + }, + }, + "--blue-surface": { + default: "light-dark(#f1f9ffcc, #11213d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9529 0.9765 0.9961 / 0.8), color(display-p3 0.0706 0.1255 0.2196 / 0.5))", + }, + }, + "--blue-indicator": "var(--blue-9)", + "--blue-track": "var(--blue-9)", + "--blue-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/bronze.stylex.js b/packages/reflex-components-ui/js/src/colors/bronze.stylex.js new file mode 100644 index 00000000000..6659b95ac2f --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/bronze.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const bronze = stylex.defineVars({ + "--bronze-1": { + default: "light-dark(#fdfcfc, #141110)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.991 0.988 0.988), color(display-p3 0.076 0.067 0.063))", + }, + }, + "--bronze-2": { + default: "light-dark(#fdf7f5, #1c1917)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.989 0.97 0.961), color(display-p3 0.106 0.097 0.093))", + }, + }, + "--bronze-3": { + default: "light-dark(#f6edea, #262220)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.958 0.932 0.919), color(display-p3 0.147 0.132 0.125))", + }, + }, + "--bronze-4": { + default: "light-dark(#efe4df, #302a27)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.929 0.894 0.877), color(display-p3 0.185 0.166 0.156))", + }, + }, + "--bronze-5": { + default: "light-dark(#e7d9d3, #3b3330)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.898 0.853 0.832), color(display-p3 0.227 0.202 0.19))", + }, + }, + "--bronze-6": { + default: "light-dark(#dfcdc5, #493e3a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.861 0.805 0.778), color(display-p3 0.278 0.246 0.23))", + }, + }, + "--bronze-7": { + default: "light-dark(#d3bcb3, #5a4c47)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.812 0.739 0.706), color(display-p3 0.343 0.302 0.281))", + }, + }, + "--bronze-8": { + default: "light-dark(#c2a499, #6f5f58)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.741 0.647 0.606), color(display-p3 0.426 0.374 0.347))", + }, + }, + "--bronze-9": { + default: "#a18072", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.611 0.507 0.455)", + }, + }, + "--bronze-10": { + default: "light-dark(#957468, #ae8c7e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.563 0.461 0.414), color(display-p3 0.66 0.556 0.504))", + }, + }, + "--bronze-11": { + default: "light-dark(#7d5e54, #d4b3a5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.471 0.373 0.336), color(display-p3 0.81 0.707 0.655))", + }, + }, + "--bronze-12": { + default: "light-dark(#43302b, #ede0d9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.251 0.191 0.172), color(display-p3 0.921 0.88 0.854))", + }, + }, + "--bronze-a1": { + default: "light-dark(#55000003, #d1110004)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.349 0.024 0.024 / 0.012), color(display-p3 0.941 0.067 0 / 0.009))", + }, + }, + "--bronze-a2": { + default: "light-dark(#cc33000a, #fbbc910c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.71 0.22 0.024 / 0.04), color(display-p3 0.98 0.8 0.706 / 0.043))", + }, + }, + "--bronze-a3": { + default: "light-dark(#92250015, #faceb817)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.482 0.2 0.008 / 0.083), color(display-p3 0.988 0.851 0.761 / 0.085))", + }, + }, + "--bronze-a4": { + default: "light-dark(#80280020, #facdb622)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.424 0.133 0.004 / 0.122), color(display-p3 0.996 0.839 0.78 / 0.127))", + }, + }, + "--bronze-a5": { + default: "light-dark(#7423002c, #ffd2c12d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.4 0.145 0.004 / 0.169), color(display-p3 0.996 0.863 0.773 / 0.173))", + }, + }, + "--bronze-a6": { + default: "light-dark(#7324003a, #ffd1c03c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.388 0.125 0.004 / 0.224), color(display-p3 1 0.863 0.796 / 0.227))", + }, + }, + "--bronze-a7": { + default: "light-dark(#6c1f004c, #fdd0c04f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.365 0.11 0.004 / 0.295), color(display-p3 1 0.867 0.8 / 0.295))", + }, + }, + "--bronze-a8": { + default: "light-dark(#671c0066, #ffd6c565)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.341 0.102 0.004 / 0.393), color(display-p3 1 0.859 0.788 / 0.387))", + }, + }, + "--bronze-a9": { + default: "light-dark(#551a008d, #fec7b09b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.29 0.094 0 / 0.546), color(display-p3 1 0.82 0.733 / 0.585))", + }, + }, + "--bronze-a10": { + default: "light-dark(#4c150097, #fecab5a9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.255 0.082 0 / 0.585), color(display-p3 1 0.839 0.761 / 0.635))", + }, + }, + "--bronze-a11": { + default: "light-dark(#3d0f00ab, #ffd7c6d1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.471 0.373 0.336), color(display-p3 0.81 0.707 0.655))", + }, + }, + "--bronze-a12": { + default: "light-dark(#1d0600d4, #fff1e9ec)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.251 0.191 0.172), color(display-p3 0.921 0.88 0.854))", + }, + }, + "--bronze-surface": { + default: "light-dark(#fdf5f3cc, #27211d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9843 0.9608 0.9529 / 0.8), color(display-p3 0.1412 0.1255 0.1176 / 0.5))", + }, + }, + "--bronze-indicator": "var(--bronze-9)", + "--bronze-track": "var(--bronze-9)", + "--bronze-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/brown.stylex.js b/packages/reflex-components-ui/js/src/colors/brown.stylex.js new file mode 100644 index 00000000000..66972b307e9 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/brown.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const brown = stylex.defineVars({ + "--brown-1": { + default: "light-dark(#fefdfc, #12110f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.992 0.989), color(display-p3 0.071 0.067 0.059))", + }, + }, + "--brown-2": { + default: "light-dark(#fcf9f6, #1c1816)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.987 0.976 0.964), color(display-p3 0.107 0.095 0.087))", + }, + }, + "--brown-3": { + default: "light-dark(#f6eee7, #28211d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.959 0.936 0.909), color(display-p3 0.151 0.13 0.115))", + }, + }, + "--brown-4": { + default: "light-dark(#f0e4d9, #322922)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.934 0.897 0.855), color(display-p3 0.191 0.161 0.138))", + }, + }, + "--brown-5": { + default: "light-dark(#ebdaca, #3e3128)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.909 0.856 0.798), color(display-p3 0.235 0.194 0.162))", + }, + }, + "--brown-6": { + default: "light-dark(#e4cdb7, #4d3c2f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.88 0.808 0.73), color(display-p3 0.291 0.237 0.192))", + }, + }, + "--brown-7": { + default: "light-dark(#dcbc9f, #614a39)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.841 0.742 0.639), color(display-p3 0.365 0.295 0.232))", + }, + }, + "--brown-8": { + default: "light-dark(#cea37e, #7c5f46)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.782 0.647 0.514), color(display-p3 0.469 0.377 0.287))", + }, + }, + "--brown-9": { + default: "#ad7f58", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.651 0.505 0.368)", + }, + }, + "--brown-10": { + default: "light-dark(#a07553, #b88c67)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.601 0.465 0.344), color(display-p3 0.697 0.557 0.423))", + }, + }, + "--brown-11": { + default: "light-dark(#815e46, #dbb594)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.485 0.374 0.288), color(display-p3 0.835 0.715 0.597))", + }, + }, + "--brown-12": { + default: "light-dark(#3e332e, #f2e1ca)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.236 0.202 0.183), color(display-p3 0.938 0.885 0.802))", + }, + }, + "--brown-a1": { + default: "light-dark(#aa550003, #91110002)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.349 0.024 / 0.012), color(display-p3 0.855 0.071 0 / 0.005))", + }, + }, + "--brown-a2": { + default: "light-dark(#aa550009, #fba67c0c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.349 0.024 / 0.036), color(display-p3 0.98 0.706 0.525 / 0.043))", + }, + }, + "--brown-a3": { + default: "light-dark(#a04b0018, #fcb58c19)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.573 0.314 0.012 / 0.091), color(display-p3 0.996 0.745 0.576 / 0.093))", + }, + }, + "--brown-a4": { + default: "light-dark(#9b4a0026, #fbbb8a24)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.545 0.302 0.008 / 0.146), color(display-p3 1 0.765 0.592 / 0.135))", + }, + }, + "--brown-a5": { + default: "light-dark(#9f4d0035, #fcb88931)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.561 0.29 0.004 / 0.204), color(display-p3 1 0.761 0.588 / 0.181))", + }, + }, + "--brown-a6": { + default: "light-dark(#a04e0048, #fdba8741)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.553 0.294 0.004 / 0.271), color(display-p3 1 0.773 0.592 / 0.24))", + }, + }, + "--brown-a7": { + default: "light-dark(#a34e0060, #ffbb8856)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.557 0.286 0.004 / 0.361), color(display-p3 0.996 0.776 0.58 / 0.32))", + }, + }, + "--brown-a8": { + default: "light-dark(#9f4a0081, #ffbe8773)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.549 0.275 0.004 / 0.487), color(display-p3 1 0.78 0.573 / 0.433))", + }, + }, + "--brown-a9": { + default: "light-dark(#823c00a7, #feb87da8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.447 0.22 0 / 0.632), color(display-p3 1 0.769 0.549 / 0.627))", + }, + }, + "--brown-a10": { + default: "light-dark(#723300ac, #ffc18cb3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.388 0.188 0 / 0.655), color(display-p3 1 0.792 0.596 / 0.677))", + }, + }, + "--brown-a11": { + default: "light-dark(#522100b9, #fed1aad9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.485 0.374 0.288), color(display-p3 0.835 0.715 0.597))", + }, + }, + "--brown-a12": { + default: "light-dark(#140600d1, #feecd4f2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.236 0.202 0.183), color(display-p3 0.938 0.885 0.802))", + }, + }, + "--brown-surface": { + default: "light-dark(#fbf8f4cc, #271f1b80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9843 0.9725 0.9569 / 0.8), color(display-p3 0.1412 0.1176 0.102 / 0.5))", + }, + }, + "--brown-indicator": "var(--brown-9)", + "--brown-track": "var(--brown-9)", + "--brown-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/crimson.stylex.js b/packages/reflex-components-ui/js/src/colors/crimson.stylex.js new file mode 100644 index 00000000000..295be72940e --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/crimson.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const crimson = stylex.defineVars({ + "--crimson-1": { + default: "light-dark(#fffcfd, #191114)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.998 0.989 0.992), color(display-p3 0.093 0.068 0.078))", + }, + }, + "--crimson-2": { + default: "light-dark(#fef7f9, #201318)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.991 0.969 0.976), color(display-p3 0.117 0.078 0.095))", + }, + }, + "--crimson-3": { + default: "light-dark(#ffe9f0, #381525)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.987 0.917 0.941), color(display-p3 0.203 0.091 0.143))", + }, + }, + "--crimson-4": { + default: "light-dark(#fedce7, #4d122f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.975 0.866 0.904), color(display-p3 0.277 0.087 0.182))", + }, + }, + "--crimson-5": { + default: "light-dark(#facedd, #5c1839)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.953 0.813 0.864), color(display-p3 0.332 0.115 0.22))", + }, + }, + "--crimson-6": { + default: "light-dark(#f3bed1, #6d2545)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.921 0.755 0.817), color(display-p3 0.394 0.162 0.268))", + }, + }, + "--crimson-7": { + default: "light-dark(#eaacc3, #873356)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.88 0.683 0.761), color(display-p3 0.489 0.222 0.336))", + }, + }, + "--crimson-8": { + default: "light-dark(#e093b2, #b0436e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.834 0.592 0.694), color(display-p3 0.638 0.289 0.429))", + }, + }, + "--crimson-9": { + default: "#e93d82", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.843 0.298 0.507)", + }, + }, + "--crimson-10": { + default: "light-dark(#df3478, #ee518a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.807 0.266 0.468), color(display-p3 0.864 0.364 0.539))", + }, + }, + "--crimson-11": { + default: "light-dark(#cb1d63, #ff92ad)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.731 0.195 0.388), color(display-p3 1 0.56 0.66))", + }, + }, + "--crimson-12": { + default: "light-dark(#621639, #fdd3e8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.352 0.111 0.221), color(display-p3 0.966 0.834 0.906))", + }, + }, + "--crimson-a1": { + default: "light-dark(#ff005503, #f4126709)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 0.349 / 0.012), color(display-p3 0.984 0.071 0.463 / 0.03))", + }, + }, + "--crimson-a2": { + default: "light-dark(#e0004008, #f22f7a11)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.757 0.02 0.267 / 0.032), color(display-p3 0.996 0.282 0.569 / 0.055))", + }, + }, + "--crimson-a3": { + default: "light-dark(#ff005216, #fe2a8b2a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.859 0.008 0.294 / 0.083), color(display-p3 0.996 0.227 0.573 / 0.148))", + }, + }, + "--crimson-a4": { + default: "light-dark(#f8005123, #fd158741)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.827 0.008 0.298 / 0.134), color(display-p3 1 0.157 0.569 / 0.227))", + }, + }, + "--crimson-a5": { + default: "light-dark(#e5004f31, #fd278f51)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.753 0.008 0.275 / 0.189), color(display-p3 1 0.231 0.604 / 0.286))", + }, + }, + "--crimson-a6": { + default: "light-dark(#d0004b41, #fe459763)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.682 0.004 0.247 / 0.244), color(display-p3 1 0.337 0.643 / 0.349))", + }, + }, + "--crimson-a7": { + default: "light-dark(#bf004753, #fd559b7f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.62 0.004 0.251 / 0.318), color(display-p3 1 0.416 0.663 / 0.454))", + }, + }, + "--crimson-a8": { + default: "light-dark(#b6004a6c, #fe5b9bab)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.6 0.004 0.251 / 0.408), color(display-p3 0.996 0.427 0.651 / 0.614))", + }, + }, + "--crimson-a9": { + default: "light-dark(#e2005bc2, #fe418de8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.776 0 0.298 / 0.702), color(display-p3 1 0.345 0.596 / 0.832))", + }, + }, + "--crimson-a10": { + default: "light-dark(#d70056cb, #ff5693ed)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.737 0 0.275 / 0.734), color(display-p3 1 0.42 0.62 / 0.853))", + }, + }, + "--crimson-a11": { + default: "light-dark(#c4004fe2, #ff92ad)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.731 0.195 0.388), color(display-p3 1 0.56 0.66))", + }, + }, + "--crimson-a12": { + default: "light-dark(#530026e9, #ffd5eafd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.352 0.111 0.221), color(display-p3 0.966 0.834 0.906))", + }, + }, + "--crimson-surface": { + default: "light-dark(#fef5f8cc, #2f151f80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9922 0.9608 0.9725 / 0.8), color(display-p3 0.1647 0.0863 0.1176 / 0.5))", + }, + }, + "--crimson-indicator": "var(--crimson-9)", + "--crimson-track": "var(--crimson-9)", + "--crimson-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/cyan.stylex.js b/packages/reflex-components-ui/js/src/colors/cyan.stylex.js new file mode 100644 index 00000000000..37f9d06178f --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/cyan.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const cyan = stylex.defineVars({ + "--cyan-1": { + default: "light-dark(#fafdfe, #0b161a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.982 0.992 0.996), color(display-p3 0.053 0.085 0.098))", + }, + }, + "--cyan-2": { + default: "light-dark(#f2fafb, #101b20)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.955 0.981 0.984), color(display-p3 0.072 0.105 0.122))", + }, + }, + "--cyan-3": { + default: "light-dark(#def7f9, #082c36)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.888 0.965 0.975), color(display-p3 0.073 0.168 0.209))", + }, + }, + "--cyan-4": { + default: "light-dark(#caf1f6, #003848)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.821 0.941 0.959), color(display-p3 0.063 0.216 0.277))", + }, + }, + "--cyan-5": { + default: "light-dark(#b5e9f0, #004558)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.751 0.907 0.935), color(display-p3 0.091 0.267 0.336))", + }, + }, + "--cyan-6": { + default: "light-dark(#9ddde7, #045468)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.671 0.862 0.9), color(display-p3 0.137 0.324 0.4))", + }, + }, + "--cyan-7": { + default: "light-dark(#7dcedc, #12677e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.564 0.8 0.854), color(display-p3 0.186 0.398 0.484))", + }, + }, + "--cyan-8": { + default: "light-dark(#3db9cf, #11809c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.388 0.715 0.798), color(display-p3 0.23 0.496 0.6))", + }, + }, + "--cyan-9": { + default: "#00a2c7", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.282 0.627 0.765)", + }, + }, + "--cyan-10": { + default: "light-dark(#0797b9, #23afd0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.264 0.583 0.71), color(display-p3 0.331 0.675 0.801))", + }, + }, + "--cyan-11": { + default: "light-dark(#107d98, #4ccce6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.08 0.48 0.63), color(display-p3 0.446 0.79 0.887))", + }, + }, + "--cyan-12": { + default: "light-dark(#0d3c48, #b6ecf7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.108 0.232 0.277), color(display-p3 0.757 0.919 0.962))", + }, + }, + "--cyan-a1": { + default: "light-dark(#0099cc05, #0091f70a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.608 0.804 / 0.02), color(display-p3 0 0.647 0.992 / 0.034))", + }, + }, + "--cyan-a2": { + default: "light-dark(#009db10d, #02a7f211)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.557 0.647 / 0.044), color(display-p3 0.133 0.733 1 / 0.059))", + }, + }, + "--cyan-a3": { + default: "light-dark(#00c2d121, #00befd28)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.694 0.796 / 0.114), color(display-p3 0.122 0.741 0.996 / 0.152))", + }, + }, + "--cyan-a4": { + default: "light-dark(#00bcd435, #00baff3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.678 0.784 / 0.181), color(display-p3 0.051 0.725 1 / 0.227))", + }, + }, + "--cyan-a5": { + default: "light-dark(#01b4cc4a, #00befd4d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.624 0.733 / 0.248), color(display-p3 0.149 0.757 1 / 0.29))", + }, + }, + "--cyan-a6": { + default: "light-dark(#00a7c162, #00c7fd5e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.584 0.706 / 0.33), color(display-p3 0.267 0.792 1 / 0.358))", + }, + }, + "--cyan-a7": { + default: "light-dark(#009fbb82, #14cdff75)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.541 0.667 / 0.436), color(display-p3 0.333 0.808 1 / 0.446))", + }, + }, + "--cyan-a8": { + default: "light-dark(#00a3c0c2, #11cfff95)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.533 0.667 / 0.612), color(display-p3 0.357 0.816 1 / 0.572))", + }, + }, + "--cyan-a9": { + default: "light-dark(#00a2c7, #00cfffc3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.482 0.675 / 0.718), color(display-p3 0.357 0.82 1 / 0.748))", + }, + }, + "--cyan-a10": { + default: "light-dark(#0094b7f8, #28d6ffcd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.435 0.608 / 0.738), color(display-p3 0.4 0.839 1 / 0.786))", + }, + }, + "--cyan-a11": { + default: "light-dark(#007491ef, #52e1fee5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.08 0.48 0.63), color(display-p3 0.446 0.79 0.887))", + }, + }, + "--cyan-a12": { + default: "light-dark(#00323ef2, #bbf3fef7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.108 0.232 0.277), color(display-p3 0.757 0.919 0.962))", + }, + }, + "--cyan-surface": { + default: "light-dark(#eff9facc, #11252d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9412 0.9765 0.9804 / 0.8), color(display-p3 0.0784 0.1412 0.1725 / 0.5))", + }, + }, + "--cyan-indicator": "var(--cyan-9)", + "--cyan-track": "var(--cyan-9)", + "--cyan-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/gold.stylex.js b/packages/reflex-components-ui/js/src/colors/gold.stylex.js new file mode 100644 index 00000000000..d0140c60a35 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/gold.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const gold = stylex.defineVars({ + "--gold-1": { + default: "light-dark(#fdfdfc, #121211)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.992 0.989), color(display-p3 0.071 0.071 0.067))", + }, + }, + "--gold-2": { + default: "light-dark(#faf9f2, #1b1a17)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.98 0.976 0.953), color(display-p3 0.104 0.101 0.09))", + }, + }, + "--gold-3": { + default: "light-dark(#f2f0e7, #24231f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.947 0.94 0.909), color(display-p3 0.141 0.136 0.122))", + }, + }, + "--gold-4": { + default: "light-dark(#eae6db, #2d2b26)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.914 0.904 0.865), color(display-p3 0.177 0.17 0.152))", + }, + }, + "--gold-5": { + default: "light-dark(#e1dccf, #38352e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.88 0.865 0.816), color(display-p3 0.217 0.207 0.185))", + }, + }, + "--gold-6": { + default: "light-dark(#d8d0bf, #444039)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.84 0.818 0.756), color(display-p3 0.265 0.252 0.225))", + }, + }, + "--gold-7": { + default: "light-dark(#cbc0aa, #544f46)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.788 0.753 0.677), color(display-p3 0.327 0.31 0.277))", + }, + }, + "--gold-8": { + default: "light-dark(#b9a88d, #696256)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.715 0.66 0.565), color(display-p3 0.407 0.384 0.342))", + }, + }, + "--gold-9": { + default: "#978365", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.579 0.517 0.41)", + }, + }, + "--gold-10": { + default: "light-dark(#8c7a5e, #a39073)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.538 0.479 0.38), color(display-p3 0.628 0.566 0.463))", + }, + }, + "--gold-11": { + default: "light-dark(#71624b, #cbb99f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.433 0.386 0.305), color(display-p3 0.784 0.728 0.635))", + }, + }, + "--gold-12": { + default: "light-dark(#3b352b, #e8e2d9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.227 0.209 0.173), color(display-p3 0.906 0.887 0.855))", + }, + }, + "--gold-a1": { + default: "light-dark(#55550003, #91911102)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.349 0.349 0.024 / 0.012), color(display-p3 0.855 0.855 0.071 / 0.005))", + }, + }, + "--gold-a2": { + default: "light-dark(#9d8a000d, #f9e29d0b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.592 0.514 0.024 / 0.048), color(display-p3 0.98 0.89 0.616 / 0.043))", + }, + }, + "--gold-a3": { + default: "light-dark(#75600018, #f8ecbb15)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.4 0.357 0.012 / 0.091), color(display-p3 1 0.949 0.753 / 0.08))", + }, + }, + "--gold-a4": { + default: "light-dark(#6b4e0024, #ffeec41e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.357 0.298 0.008 / 0.134), color(display-p3 1 0.933 0.8 / 0.118))", + }, + }, + "--gold-a5": { + default: "light-dark(#60460030, #feecc22a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.345 0.282 0.004 / 0.185), color(display-p3 1 0.949 0.804 / 0.16))", + }, + }, + "--gold-a6": { + default: "light-dark(#64440040, #feebcb37)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.341 0.263 0.004 / 0.244), color(display-p3 1 0.925 0.8 / 0.215))", + }, + }, + "--gold-a7": { + default: "light-dark(#63420055, #ffedcd48)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.345 0.235 0.004 / 0.322), color(display-p3 1 0.945 0.831 / 0.278))", + }, + }, + "--gold-a8": { + default: "light-dark(#633d0072, #fdeaca5f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.345 0.22 0.004 / 0.436), color(display-p3 1 0.937 0.82 / 0.366))", + }, + }, + "--gold-a9": { + default: "light-dark(#5332009a, #ffdba690)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.286 0.18 0 / 0.589), color(display-p3 0.996 0.882 0.69 / 0.551))", + }, + }, + "--gold-a10": { + default: "light-dark(#492d00a1, #fedfb09d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.255 0.161 0 / 0.62), color(display-p3 1 0.894 0.725 / 0.601))", + }, + }, + "--gold-a11": { + default: "light-dark(#362100b4, #fee7c6c8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.433 0.386 0.305), color(display-p3 0.784 0.728 0.635))", + }, + }, + "--gold-a12": { + default: "light-dark(#130c00d4, #fef7ede7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.227 0.209 0.173), color(display-p3 0.906 0.887 0.855))", + }, + }, + "--gold-surface": { + default: "light-dark(#f9f8efcc, #25231d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9765 0.9725 0.9412 / 0.8), color(display-p3 0.1412 0.1333 0.1098 / 0.5))", + }, + }, + "--gold-indicator": "var(--gold-9)", + "--gold-track": "var(--gold-9)", + "--gold-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/grass.stylex.js b/packages/reflex-components-ui/js/src/colors/grass.stylex.js new file mode 100644 index 00000000000..a5445b0b4ea --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/grass.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const grass = stylex.defineVars({ + "--grass-1": { + default: "light-dark(#fbfefb, #0e1511)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.986 0.996 0.985), color(display-p3 0.062 0.083 0.067))", + }, + }, + "--grass-2": { + default: "light-dark(#f5fbf5, #141a15)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.966 0.983 0.964), color(display-p3 0.083 0.103 0.085))", + }, + }, + "--grass-3": { + default: "light-dark(#e9f6e9, #1b2a1e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.923 0.965 0.917), color(display-p3 0.118 0.163 0.122))", + }, + }, + "--grass-4": { + default: "light-dark(#daf1db, #1d3a24)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.872 0.94 0.865), color(display-p3 0.142 0.225 0.15))", + }, + }, + "--grass-5": { + default: "light-dark(#c9e8ca, #25482d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.811 0.908 0.802), color(display-p3 0.178 0.279 0.186))", + }, + }, + "--grass-6": { + default: "light-dark(#b2ddb5, #2d5736)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.733 0.864 0.724), color(display-p3 0.217 0.337 0.224))", + }, + }, + "--grass-7": { + default: "light-dark(#94ce9a, #366740)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.628 0.803 0.622), color(display-p3 0.258 0.4 0.264))", + }, + }, + "--grass-8": { + default: "light-dark(#65ba74, #3e7949)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.477 0.72 0.482), color(display-p3 0.302 0.47 0.305))", + }, + }, + "--grass-9": { + default: "#46a758", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.38 0.647 0.378)", + }, + }, + "--grass-10": { + default: "light-dark(#3e9b4f, #53b365)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.344 0.598 0.342), color(display-p3 0.426 0.694 0.426))", + }, + }, + "--grass-11": { + default: "light-dark(#2a7e3b, #71d083)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.263 0.488 0.261), color(display-p3 0.535 0.807 0.542))", + }, + }, + "--grass-12": { + default: "light-dark(#203c25, #c2f0c2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.151 0.233 0.153), color(display-p3 0.797 0.936 0.776))", + }, + }, + "--grass-a1": { + default: "light-dark(#00c00004, #00de1205)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.757 0.024 / 0.016), color(display-p3 0 0.992 0.071 / 0.017))", + }, + }, + "--grass-a2": { + default: "light-dark(#0099000a, #5ef7780a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.565 0.024 / 0.036), color(display-p3 0.482 0.996 0.584 / 0.038))", + }, + }, + "--grass-a3": { + default: "light-dark(#00970016, #70fe8c1b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.059 0.576 0.008 / 0.083), color(display-p3 0.549 0.992 0.588 / 0.106))", + }, + }, + "--grass-a4": { + default: "light-dark(#009f0725, #57ff802c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.035 0.565 0.008 / 0.134), color(display-p3 0.51 0.996 0.557 / 0.169))", + }, + }, + "--grass-a5": { + default: "light-dark(#00930536, #68ff8b3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.047 0.545 0.008 / 0.197), color(display-p3 0.553 1 0.588 / 0.227))", + }, + }, + "--grass-a6": { + default: "light-dark(#008f0a4d, #71ff8f4b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.031 0.502 0.004 / 0.275), color(display-p3 0.584 1 0.608 / 0.29))", + }, + }, + "--grass-a7": { + default: "light-dark(#018b0f6b, #77fd925d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.482 0.004 / 0.377), color(display-p3 0.604 1 0.616 / 0.358))", + }, + }, + "--grass-a8": { + default: "light-dark(#008d199a, #77fd9070)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.467 0.008 / 0.522), color(display-p3 0.608 1 0.62 / 0.433))", + }, + }, + "--grass-a9": { + default: "light-dark(#008619b9, #65ff82a1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.435 0 / 0.624), color(display-p3 0.573 1 0.569 / 0.622))", + }, + }, + "--grass-a10": { + default: "light-dark(#007b17c1, #72ff8dae)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.388 0 / 0.659), color(display-p3 0.6 0.996 0.6 / 0.673))", + }, + }, + "--grass-a11": { + default: "light-dark(#006514d5, #89ff9fcd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.263 0.488 0.261), color(display-p3 0.535 0.807 0.542))", + }, + }, + "--grass-a12": { + default: "light-dark(#002006df, #ceffceef)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.151 0.233 0.153), color(display-p3 0.797 0.936 0.776))", + }, + }, + "--grass-surface": { + default: "light-dark(#f3faf3cc, #19231b80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9569 0.9804 0.9569 / 0.8), color(display-p3 0.102 0.1333 0.102 / 0.5))", + }, + }, + "--grass-indicator": "var(--grass-9)", + "--grass-track": "var(--grass-9)", + "--grass-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/green.stylex.js b/packages/reflex-components-ui/js/src/colors/green.stylex.js new file mode 100644 index 00000000000..daa03e9e9da --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/green.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const green = stylex.defineVars({ + "--green-1": { + default: "light-dark(#fbfefc, #0e1512)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.986 0.996 0.989), color(display-p3 0.062 0.083 0.071))", + }, + }, + "--green-2": { + default: "light-dark(#f4fbf6, #121b17)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.963 0.983 0.967), color(display-p3 0.079 0.106 0.09))", + }, + }, + "--green-3": { + default: "light-dark(#e6f6eb, #132d21)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.913 0.964 0.925), color(display-p3 0.1 0.173 0.133))", + }, + }, + "--green-4": { + default: "light-dark(#d6f1df, #113b29)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.859 0.94 0.879), color(display-p3 0.115 0.229 0.166))", + }, + }, + "--green-5": { + default: "light-dark(#c4e8d1, #174933)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.796 0.907 0.826), color(display-p3 0.147 0.282 0.206))", + }, + }, + "--green-6": { + default: "light-dark(#adddc0, #20573e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.718 0.863 0.761), color(display-p3 0.185 0.338 0.25))", + }, + }, + "--green-7": { + default: "light-dark(#8eceaa, #28684a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.61 0.801 0.675), color(display-p3 0.227 0.403 0.298))", + }, + }, + "--green-8": { + default: "light-dark(#5bb98b, #2f7c57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.451 0.715 0.559), color(display-p3 0.27 0.479 0.351))", + }, + }, + "--green-9": { + default: "#30a46c", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.332 0.634 0.442)", + }, + }, + "--green-10": { + default: "light-dark(#2b9a66, #33b074)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.308 0.595 0.417), color(display-p3 0.357 0.682 0.474))", + }, + }, + "--green-11": { + default: "light-dark(#218358, #3dd68c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.19 0.5 0.32), color(display-p3 0.434 0.828 0.573))", + }, + }, + "--green-12": { + default: "light-dark(#193b2d, #b1f1cb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.132 0.228 0.18), color(display-p3 0.747 0.938 0.807))", + }, + }, + "--green-a1": { + default: "light-dark(#00c04004, #00de4505)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.757 0.267 / 0.016), color(display-p3 0 0.992 0.298 / 0.017))", + }, + }, + "--green-a2": { + default: "light-dark(#00a32f0b, #29f99d0b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.565 0.129 / 0.036), color(display-p3 0.341 0.98 0.616 / 0.043))", + }, + }, + "--green-a3": { + default: "light-dark(#00a43319, #22ff991e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.596 0.145 / 0.087), color(display-p3 0.376 0.996 0.655 / 0.114))", + }, + }, + "--green-a4": { + default: "light-dark(#00a83829, #11ff992d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.588 0.145 / 0.142), color(display-p3 0.341 0.996 0.635 / 0.173))", + }, + }, + "--green-a5": { + default: "light-dark(#019c393b, #2bffa23c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.541 0.157 / 0.204), color(display-p3 0.408 1 0.678 / 0.232))", + }, + }, + "--green-a6": { + default: "light-dark(#00963c52, #44ffaa4b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.518 0.157 / 0.283), color(display-p3 0.475 1 0.706 / 0.29))", + }, + }, + "--green-a7": { + default: "light-dark(#00914071, #50fdac5e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.486 0.165 / 0.389), color(display-p3 0.514 1 0.706 / 0.362))", + }, + }, + "--green-a8": { + default: "light-dark(#00924ba4, #54ffad73)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.478 0.2 / 0.55), color(display-p3 0.529 1 0.718 / 0.442))", + }, + }, + "--green-a9": { + default: "light-dark(#008f4acf, #44ffa49e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.455 0.165 / 0.667), color(display-p3 0.502 0.996 0.682 / 0.61))", + }, + }, + "--green-a10": { + default: "light-dark(#008647d4, #43fea4ab)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.416 0.153 / 0.691), color(display-p3 0.506 1 0.682 / 0.66))", + }, + }, + "--green-a11": { + default: "light-dark(#00713fde, #46fea5d4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.19 0.5 0.32), color(display-p3 0.434 0.828 0.573))", + }, + }, + "--green-a12": { + default: "light-dark(#002616e6, #bbffd7f0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.132 0.228 0.18), color(display-p3 0.747 0.938 0.807))", + }, + }, + "--green-surface": { + default: "light-dark(#f1faf4cc, #15251d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9569 0.9804 0.9608 / 0.8), color(display-p3 0.0941 0.1412 0.1098 / 0.5))", + }, + }, + "--green-indicator": "var(--green-9)", + "--green-track": "var(--green-9)", + "--green-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/indigo.stylex.js b/packages/reflex-components-ui/js/src/colors/indigo.stylex.js new file mode 100644 index 00000000000..8737deb9e18 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/indigo.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const indigo = stylex.defineVars({ + "--indigo-1": { + default: "light-dark(#fdfdfe, #11131f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.992 0.996), color(display-p3 0.068 0.074 0.118))", + }, + }, + "--indigo-2": { + default: "light-dark(#f7f9ff, #141726)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.971 0.977 0.998), color(display-p3 0.081 0.089 0.144))", + }, + }, + "--indigo-3": { + default: "light-dark(#edf2fe, #182449)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.933 0.948 0.992), color(display-p3 0.105 0.141 0.275))", + }, + }, + "--indigo-4": { + default: "light-dark(#e1e9ff, #1d2e62)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.885 0.914 1), color(display-p3 0.129 0.18 0.369))", + }, + }, + "--indigo-5": { + default: "light-dark(#d2deff, #253974)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.831 0.87 1), color(display-p3 0.163 0.22 0.439))", + }, + }, + "--indigo-6": { + default: "light-dark(#c1d0ff, #304384)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.767 0.814 0.995), color(display-p3 0.203 0.262 0.5))", + }, + }, + "--indigo-7": { + default: "light-dark(#abbdf9, #3a4f97)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.685 0.74 0.957), color(display-p3 0.245 0.309 0.575))", + }, + }, + "--indigo-8": { + default: "light-dark(#8da4ef, #435db1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.569 0.639 0.916), color(display-p3 0.285 0.362 0.674))", + }, + }, + "--indigo-9": { + default: "#3e63dd", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.276 0.384 0.837)", + }, + }, + "--indigo-10": { + default: "light-dark(#3358d4, #5472e4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.234 0.343 0.801), color(display-p3 0.354 0.445 0.866))", + }, + }, + "--indigo-11": { + default: "light-dark(#3a5bc7, #9eb1ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.256 0.354 0.755), color(display-p3 0.63 0.69 1))", + }, + }, + "--indigo-12": { + default: "light-dark(#1f2d5c, #d6e1ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.133 0.175 0.348), color(display-p3 0.848 0.881 0.99))", + }, + }, + "--indigo-a1": { + default: "light-dark(#00008002, #1133ff0f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.02 0.51 / 0.008), color(display-p3 0.071 0.212 0.996 / 0.055))", + }, + }, + "--indigo-a2": { + default: "light-dark(#0040ff08, #3354fa17)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.161 0.863 / 0.028), color(display-p3 0.251 0.345 0.988 / 0.085))", + }, + }, + "--indigo-a3": { + default: "light-dark(#0047f112, #2f62ff3c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.239 0.886 / 0.067), color(display-p3 0.243 0.404 1 / 0.223))", + }, + }, + "--indigo-a4": { + default: "light-dark(#0044ff1e, #3566ff57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.247 1 / 0.114), color(display-p3 0.263 0.42 1 / 0.324))", + }, + }, + "--indigo-a5": { + default: "light-dark(#0044ff2d, #4171fd6b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.235 1 / 0.169), color(display-p3 0.314 0.451 1 / 0.4))", + }, + }, + "--indigo-a6": { + default: "light-dark(#003eff3e, #5178fd7c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.208 0.984 / 0.232), color(display-p3 0.361 0.49 1 / 0.467))", + }, + }, + "--indigo-a7": { + default: "light-dark(#0037ed54, #5a7fff90)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.176 0.863 / 0.314), color(display-p3 0.388 0.51 1 / 0.547))", + }, + }, + "--indigo-a8": { + default: "light-dark(#0034dc72, #5b81feac)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.165 0.812 / 0.432), color(display-p3 0.404 0.518 1 / 0.652))", + }, + }, + "--indigo-a9": { + default: "light-dark(#0031d2c1, #4671ffdb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.153 0.773 / 0.726), color(display-p3 0.318 0.451 1 / 0.824))", + }, + }, + "--indigo-a10": { + default: "light-dark(#002ec9cc, #5c7efee3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.137 0.737 / 0.765), color(display-p3 0.404 0.506 1 / 0.858))", + }, + }, + "--indigo-a11": { + default: "light-dark(#002bb7c5, #9eb1ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.256 0.354 0.755), color(display-p3 0.63 0.69 1))", + }, + }, + "--indigo-a12": { + default: "light-dark(#001046e0, #d6e1ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.133 0.175 0.348), color(display-p3 0.848 0.881 0.99))", + }, + }, + "--indigo-surface": { + default: "light-dark(#f5f8ffcc, #171d3b80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9647 0.9725 0.9961 / 0.8), color(display-p3 0.0941 0.1098 0.2196 / 0.5))", + }, + }, + "--indigo-indicator": "var(--indigo-9)", + "--indigo-track": "var(--indigo-9)", + "--indigo-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/iris.stylex.js b/packages/reflex-components-ui/js/src/colors/iris.stylex.js new file mode 100644 index 00000000000..208c19bf463 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/iris.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const iris = stylex.defineVars({ + "--iris-1": { + default: "light-dark(#fdfdff, #13131e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.992 0.999), color(display-p3 0.075 0.075 0.114))", + }, + }, + "--iris-2": { + default: "light-dark(#f8f8ff, #171625)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.972 0.973 0.998), color(display-p3 0.089 0.086 0.14))", + }, + }, + "--iris-3": { + default: "light-dark(#f0f1fe, #202248)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.943 0.945 0.992), color(display-p3 0.128 0.134 0.272))", + }, + }, + "--iris-4": { + default: "light-dark(#e6e7ff, #262a65)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.902 0.906 1), color(display-p3 0.153 0.165 0.382))", + }, + }, + "--iris-5": { + default: "light-dark(#dadcff, #303374)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.857 0.861 1), color(display-p3 0.192 0.201 0.44))", + }, + }, + "--iris-6": { + default: "light-dark(#cbcdff, #3d3e82)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.799 0.805 0.987), color(display-p3 0.239 0.241 0.491))", + }, + }, + "--iris-7": { + default: "light-dark(#b8baf8, #4a4a95)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.721 0.727 0.955), color(display-p3 0.291 0.289 0.565))", + }, + }, + "--iris-8": { + default: "light-dark(#9b9ef0, #5958b1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.61 0.619 0.918), color(display-p3 0.35 0.345 0.673))", + }, + }, + "--iris-9": { + default: "#5b5bd6", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.357 0.357 0.81)", + }, + }, + "--iris-10": { + default: "light-dark(#5151cd, #6e6ade)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.318 0.318 0.774), color(display-p3 0.428 0.416 0.843))", + }, + }, + "--iris-11": { + default: "light-dark(#5753c6, #b1a9ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.337 0.326 0.748), color(display-p3 0.685 0.662 1))", + }, + }, + "--iris-12": { + default: "light-dark(#272962, #e0dffe)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.154 0.161 0.371), color(display-p3 0.878 0.875 0.986))", + }, + }, + "--iris-a1": { + default: "light-dark(#0000ff02, #3636fe0e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.02 1 / 0.008), color(display-p3 0.224 0.224 0.992 / 0.051))", + }, + }, + "--iris-a2": { + default: "light-dark(#0000ff07, #564bf916)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.024 0.863 / 0.028), color(display-p3 0.361 0.314 1 / 0.08))", + }, + }, + "--iris-a3": { + default: "light-dark(#0011ee0f, #525bff3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.071 0.871 / 0.059), color(display-p3 0.357 0.373 1 / 0.219))", + }, + }, + "--iris-a4": { + default: "light-dark(#000bff19, #4d58ff5a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.051 1 / 0.099), color(display-p3 0.325 0.361 1 / 0.337))", + }, + }, + "--iris-a5": { + default: "light-dark(#000eff25, #5b62fd6b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.035 1 / 0.142), color(display-p3 0.38 0.4 1 / 0.4))", + }, + }, + "--iris-a6": { + default: "light-dark(#000aff34, #6d6ffd7a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.02 0.941 / 0.2), color(display-p3 0.447 0.447 1 / 0.454))", + }, + }, + "--iris-a7": { + default: "light-dark(#0008e647, #7777fe8e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.02 0.847 / 0.279), color(display-p3 0.486 0.486 1 / 0.534))", + }, + }, + "--iris-a8": { + default: "light-dark(#0008d964, #7b7afeac)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.024 0.788 / 0.389), color(display-p3 0.502 0.494 1 / 0.652))", + }, + }, + "--iris-a9": { + default: "light-dark(#0000c0a4, #6a6afed4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0.706 / 0.644), color(display-p3 0.431 0.431 1 / 0.799))", + }, + }, + "--iris-a10": { + default: "light-dark(#0000b6ae, #7d79ffdc)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0.667 / 0.683), color(display-p3 0.502 0.486 1 / 0.832))", + }, + }, + "--iris-a11": { + default: "light-dark(#0600abac, #b1a9ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.337 0.326 0.748), color(display-p3 0.685 0.662 1))", + }, + }, + "--iris-a12": { + default: "light-dark(#000246d8, #e1e0fffe)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.154 0.161 0.371), color(display-p3 0.878 0.875 0.986))", + }, + }, + "--iris-surface": { + default: "light-dark(#f6f6ffcc, #1d1b3980)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9647 0.9647 0.9961 / 0.8), color(display-p3 0.1098 0.102 0.2118 / 0.5))", + }, + }, + "--iris-indicator": "var(--iris-9)", + "--iris-track": "var(--iris-9)", + "--iris-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/jade.stylex.js b/packages/reflex-components-ui/js/src/colors/jade.stylex.js new file mode 100644 index 00000000000..ee703544f9a --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/jade.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const jade = stylex.defineVars({ + "--jade-1": { + default: "light-dark(#fbfefd, #0d1512)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.986 0.996 0.992), color(display-p3 0.059 0.083 0.071))", + }, + }, + "--jade-2": { + default: "light-dark(#f4fbf7, #121c18)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.962 0.983 0.969), color(display-p3 0.078 0.11 0.094))", + }, + }, + "--jade-3": { + default: "light-dark(#e6f7ed, #0f2e22)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.912 0.965 0.932), color(display-p3 0.091 0.176 0.138))", + }, + }, + "--jade-4": { + default: "light-dark(#d6f1e3, #0b3b2c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.858 0.941 0.893), color(display-p3 0.102 0.228 0.177))", + }, + }, + "--jade-5": { + default: "light-dark(#c3e9d7, #114837)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.795 0.909 0.847), color(display-p3 0.133 0.279 0.221))", + }, + }, + "--jade-6": { + default: "light-dark(#acdec8, #1b5745)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.715 0.864 0.791), color(display-p3 0.174 0.334 0.273))", + }, + }, + "--jade-7": { + default: "light-dark(#8bceb6, #246854)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.603 0.802 0.718), color(display-p3 0.219 0.402 0.335))", + }, + }, + "--jade-8": { + default: "light-dark(#56ba9f, #2a7e68)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.44 0.72 0.629), color(display-p3 0.263 0.488 0.411))", + }, + }, + "--jade-9": { + default: "#29a383", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.319 0.63 0.521)", + }, + }, + "--jade-10": { + default: "light-dark(#26997b, #27b08b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.299 0.592 0.488), color(display-p3 0.338 0.68 0.555))", + }, + }, + "--jade-11": { + default: "light-dark(#208368, #1fd8a4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.15 0.5 0.37), color(display-p3 0.4 0.835 0.656))", + }, + }, + "--jade-12": { + default: "light-dark(#1d3b31, #adf0d4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.142 0.229 0.194), color(display-p3 0.734 0.934 0.838))", + }, + }, + "--jade-a1": { + default: "light-dark(#00c08004, #00de4505)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.757 0.514 / 0.016), color(display-p3 0 0.992 0.298 / 0.017))", + }, + }, + "--jade-a2": { + default: "light-dark(#00a3460b, #27fba60c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.612 0.22 / 0.04), color(display-p3 0.318 0.988 0.651 / 0.047))", + }, + }, + "--jade-a3": { + default: "light-dark(#00ae4819, #02f99920)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.596 0.235 / 0.087), color(display-p3 0.267 1 0.667 / 0.118))", + }, + }, + "--jade-a4": { + default: "light-dark(#00a85129, #00ffaa2d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.588 0.255 / 0.142), color(display-p3 0.275 0.996 0.702 / 0.173))", + }, + }, + "--jade-a5": { + default: "light-dark(#00a2553c, #11ffb63b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.561 0.251 / 0.204), color(display-p3 0.361 1 0.741 / 0.227))", + }, + }, + "--jade-a6": { + default: "light-dark(#009a5753, #34ffc24b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.525 0.278 / 0.287), color(display-p3 0.439 1 0.796 / 0.286))", + }, + }, + "--jade-a7": { + default: "light-dark(#00945f74, #45fdc75e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.506 0.29 / 0.397), color(display-p3 0.49 1 0.804 / 0.362))", + }, + }, + "--jade-a8": { + default: "light-dark(#00976ea9, #48ffcf75)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.506 0.337 / 0.561), color(display-p3 0.506 1 0.835 / 0.45))", + }, + }, + "--jade-a9": { + default: "light-dark(#00916bd6, #38feca9d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.459 0.298 / 0.683), color(display-p3 0.478 0.996 0.816 / 0.606))", + }, + }, + "--jade-a10": { + default: "light-dark(#008764d9, #31fec7ab)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.42 0.271 / 0.702), color(display-p3 0.478 1 0.816 / 0.656))", + }, + }, + "--jade-a11": { + default: "light-dark(#007152df, #21fec0d6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.15 0.5 0.37), color(display-p3 0.4 0.835 0.656))", + }, + }, + "--jade-a12": { + default: "light-dark(#002217e2, #b8ffe1ef)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.142 0.229 0.194), color(display-p3 0.734 0.934 0.838))", + }, + }, + "--jade-surface": { + default: "light-dark(#f1faf5cc, #13271f80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9529 0.9804 0.9608 / 0.8), color(display-p3 0.0863 0.149 0.1176 / 0.5))", + }, + }, + "--jade-indicator": "var(--jade-9)", + "--jade-track": "var(--jade-9)", + "--jade-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/lime.stylex.js b/packages/reflex-components-ui/js/src/colors/lime.stylex.js new file mode 100644 index 00000000000..fb2b9f367c5 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/lime.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const lime = stylex.defineVars({ + "--lime-1": { + default: "light-dark(#fcfdfa, #11130c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.989 0.992 0.981), color(display-p3 0.067 0.073 0.048))", + }, + }, + "--lime-2": { + default: "light-dark(#f8faf3, #151a10)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.975 0.98 0.954), color(display-p3 0.086 0.1 0.067))", + }, + }, + "--lime-3": { + default: "light-dark(#eef6d6, #1f2917)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.939 0.965 0.851), color(display-p3 0.13 0.16 0.099))", + }, + }, + "--lime-4": { + default: "light-dark(#e2f0bd, #29371d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.896 0.94 0.76), color(display-p3 0.172 0.214 0.126))", + }, + }, + "--lime-5": { + default: "light-dark(#d3e7a6, #334423)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.843 0.903 0.678), color(display-p3 0.213 0.266 0.153))", + }, + }, + "--lime-6": { + default: "light-dark(#c2da91, #3d522a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.778 0.852 0.599), color(display-p3 0.257 0.321 0.182))", + }, + }, + "--lime-7": { + default: "light-dark(#abc978, #496231)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.694 0.784 0.508), color(display-p3 0.307 0.383 0.215))", + }, + }, + "--lime-8": { + default: "light-dark(#8db654, #577538)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.585 0.707 0.378), color(display-p3 0.365 0.456 0.25))", + }, + }, + "--lime-9": { + default: "#bdee63", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.78 0.928 0.466)", + }, + }, + "--lime-10": { + default: "light-dark(#b0e64c, #d4ff70)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.734 0.896 0.397), color(display-p3 0.865 0.995 0.519))", + }, + }, + "--lime-11": { + default: "light-dark(#5c7c2f, #bde56c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.386 0.482 0.227), color(display-p3 0.771 0.893 0.485))", + }, + }, + "--lime-12": { + default: "light-dark(#37401c, #e3f7ba)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.222 0.25 0.128), color(display-p3 0.905 0.966 0.753))", + }, + }, + "--lime-a1": { + default: "light-dark(#66990005, #11bb0003)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.412 0.608 0.02 / 0.02), color(display-p3 0.067 0.941 0 / 0.009))", + }, + }, + "--lime-a2": { + default: "light-dark(#6b95000c, #78f7000a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.514 0.592 0.024 / 0.048), color(display-p3 0.584 0.996 0.071 / 0.038))", + }, + }, + "--lime-a3": { + default: "light-dark(#96c80029, #9bfd4c1a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.584 0.765 0.008 / 0.15), color(display-p3 0.69 1 0.38 / 0.101))", + }, + }, + "--lime-a4": { + default: "light-dark(#8fc60042, #a7fe5c29)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.561 0.757 0.004 / 0.24), color(display-p3 0.729 1 0.435 / 0.16))", + }, + }, + "--lime-a5": { + default: "light-dark(#81bb0059, #affe6537)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.514 0.698 0.004 / 0.322), color(display-p3 0.745 1 0.471 / 0.215))", + }, + }, + "--lime-a6": { + default: "light-dark(#72aa006e, #b2fe6d46)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.443 0.627 0 / 0.4), color(display-p3 0.769 1 0.482 / 0.274))", + }, + }, + "--lime-a7": { + default: "light-dark(#61990087, #b6ff6f57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.376 0.561 0.004 / 0.491), color(display-p3 0.769 1 0.506 / 0.341))", + }, + }, + "--lime-a8": { + default: "light-dark(#559200ab, #b6fd6d6c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.333 0.529 0 / 0.624), color(display-p3 0.784 1 0.51 / 0.416))", + }, + }, + "--lime-a9": { + default: "light-dark(#93e4009c, #caff69ed)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.588 0.867 0 / 0.534), color(display-p3 0.839 1 0.502 / 0.925))", + }, + }, + "--lime-a10": { + default: "light-dark(#8fdc00b3, #d4ff70)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.561 0.827 0 / 0.604), color(display-p3 0.871 1 0.522 / 0.996))", + }, + }, + "--lime-a11": { + default: "light-dark(#375f00d0, #d1fe77e4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.386 0.482 0.227), color(display-p3 0.771 0.893 0.485))", + }, + }, + "--lime-a12": { + default: "light-dark(#1e2900e3, #e9febff7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.222 0.25 0.128), color(display-p3 0.905 0.966 0.753))", + }, + }, + "--lime-surface": { + default: "light-dark(#f6f9f0cc, #1b211580)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9725 0.9765 0.9412 / 0.8), color(display-p3 0.1098 0.1255 0.0784 / 0.5))", + }, + }, + "--lime-indicator": "var(--lime-9)", + "--lime-track": + "light-dark(var(--lime-9), color-mix(in oklab, var(--lime-8), var(--lime-9) 65%))", + "--lime-contrast": "#1d211c", +}); diff --git a/packages/reflex-components-ui/js/src/colors/mauve.stylex.js b/packages/reflex-components-ui/js/src/colors/mauve.stylex.js new file mode 100644 index 00000000000..5486c849cd8 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/mauve.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const mauve = stylex.defineVars({ + "--mauve-1": { + default: "light-dark(#fdfcfd, #121113)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.991 0.988 0.992), color(display-p3 0.07 0.067 0.074))", + }, + }, + "--mauve-2": { + default: "light-dark(#faf9fb, #1a191b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.98 0.976 0.984), color(display-p3 0.101 0.098 0.105))", + }, + }, + "--mauve-3": { + default: "light-dark(#f2eff3, #232225)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.946 0.938 0.952), color(display-p3 0.138 0.134 0.144))", + }, + }, + "--mauve-4": { + default: "light-dark(#eae7ec, #2b292d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.915 0.906 0.925), color(display-p3 0.167 0.161 0.175))", + }, + }, + "--mauve-5": { + default: "light-dark(#e3dfe6, #323035)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.886 0.876 0.901), color(display-p3 0.196 0.189 0.206))", + }, + }, + "--mauve-6": { + default: "light-dark(#dbd8e0, #3c393f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.856 0.846 0.875), color(display-p3 0.232 0.225 0.245))", + }, + }, + "--mauve-7": { + default: "light-dark(#d0cdd7, #49474e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.814 0.804 0.84), color(display-p3 0.286 0.277 0.302))", + }, + }, + "--mauve-8": { + default: "light-dark(#bcbac7, #625f69)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.735 0.728 0.777), color(display-p3 0.383 0.373 0.408))", + }, + }, + "--mauve-9": { + default: "light-dark(#8e8c99, #6f6d78)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.555 0.549 0.596), color(display-p3 0.434 0.428 0.467))", + }, + }, + "--mauve-10": { + default: "light-dark(#84828e, #7c7a85)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.514 0.508 0.552), color(display-p3 0.487 0.48 0.519))", + }, + }, + "--mauve-11": { + default: "light-dark(#65636d, #b5b2bc)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.395 0.388 0.424), color(display-p3 0.707 0.7 0.735))", + }, + }, + "--mauve-12": { + default: "light-dark(#211f26, #eeeef0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.128 0.122 0.147), color(display-p3 0.933 0.933 0.94))", + }, + }, + "--mauve-a1": { + default: "light-dark(#55005503, #00000000)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.349 0.024 0.349 / 0.012), color(display-p3 0 0 0 / 0))", + }, + }, + "--mauve-a2": { + default: "light-dark(#2b005506, #f5f4f609)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.184 0.024 0.349 / 0.024), color(display-p3 0.996 0.992 1 / 0.034))", + }, + }, + "--mauve-a3": { + default: "light-dark(#30004010, #ebeaf814)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.129 0.008 0.255 / 0.063), color(display-p3 0.937 0.933 0.992 / 0.077))", + }, + }, + "--mauve-a4": { + default: "light-dark(#20003618, #eee5f81d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.094 0.012 0.216 / 0.095), color(display-p3 0.957 0.918 0.996 / 0.111))", + }, + }, + "--mauve-a5": { + default: "light-dark(#20003820, #efe6fe25)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.098 0.008 0.224 / 0.126), color(display-p3 0.937 0.906 0.996 / 0.145))", + }, + }, + "--mauve-a6": { + default: "light-dark(#14003527, #f1e6fd30)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.055 0.004 0.18 / 0.153), color(display-p3 0.953 0.925 0.996 / 0.183))", + }, + }, + "--mauve-a7": { + default: "light-dark(#10003332, #eee9ff40)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.067 0.008 0.184 / 0.197), color(display-p3 0.945 0.929 1 / 0.246))", + }, + }, + "--mauve-a8": { + default: "light-dark(#08003145, #eee7ff5d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.004 0.176 / 0.271), color(display-p3 0.937 0.918 1 / 0.361))", + }, + }, + "--mauve-a9": { + default: "light-dark(#05001d73, #eae6fd6e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.004 0.106 / 0.451), color(display-p3 0.933 0.918 1 / 0.424))", + }, + }, + "--mauve-a10": { + default: "light-dark(#0500197d, #ece9fd7c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.004 0.09 / 0.491), color(display-p3 0.941 0.925 1 / 0.479))", + }, + }, + "--mauve-a11": { + default: "light-dark(#0400119c, #f5f1ffb7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.016 0 0.059 / 0.612), color(display-p3 0.965 0.961 1 / 0.712))", + }, + }, + "--mauve-a12": { + default: "light-dark(#020008e0, #fdfdffef)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0 0.027 / 0.879), color(display-p3 0.992 0.992 1 / 0.937))", + }, + }, + "--mauve-surface": { + default: "light-dark(#ffffffcc, #22212380)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 1 1 / 0.8), color(display-p3 0.1333 0.1255 0.1333 / 0.5))", + }, + }, + "--mauve-indicator": "var(--mauve-9)", + "--mauve-track": "var(--mauve-9)", + "--mauve-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/mint.stylex.js b/packages/reflex-components-ui/js/src/colors/mint.stylex.js new file mode 100644 index 00000000000..00b1c97b4e3 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/mint.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const mint = stylex.defineVars({ + "--mint-1": { + default: "light-dark(#f9fefd, #0e1515)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.98 0.995 0.992), color(display-p3 0.059 0.082 0.081))", + }, + }, + "--mint-2": { + default: "light-dark(#f2fbf9, #0f1b1b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.957 0.985 0.977), color(display-p3 0.068 0.104 0.105))", + }, + }, + "--mint-3": { + default: "light-dark(#ddf9f2, #092c2b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.888 0.972 0.95), color(display-p3 0.077 0.17 0.168))", + }, + }, + "--mint-4": { + default: "light-dark(#c8f4e9, #003a38)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.819 0.951 0.916), color(display-p3 0.068 0.224 0.22))", + }, + }, + "--mint-5": { + default: "light-dark(#b3ecde, #004744)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.747 0.918 0.873), color(display-p3 0.104 0.275 0.264))", + }, + }, + "--mint-6": { + default: "light-dark(#9ce0d0, #105650)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.668 0.87 0.818), color(display-p3 0.154 0.332 0.313))", + }, + }, + "--mint-7": { + default: "light-dark(#7ecfbd, #1e685f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.567 0.805 0.744), color(display-p3 0.207 0.403 0.373))", + }, + }, + "--mint-8": { + default: "light-dark(#4cbba5, #277f70)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.42 0.724 0.649), color(display-p3 0.258 0.49 0.441))", + }, + }, + "--mint-9": { + default: "#86ead4", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.62 0.908 0.834)", + }, + }, + "--mint-10": { + default: "light-dark(#7de0cb, #a8f5e5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.585 0.871 0.797), color(display-p3 0.725 0.954 0.898))", + }, + }, + "--mint-11": { + default: "light-dark(#027864, #58d5ba)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.203 0.463 0.397), color(display-p3 0.482 0.825 0.733))", + }, + }, + "--mint-12": { + default: "light-dark(#16433c, #c4f5e1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.136 0.259 0.236), color(display-p3 0.807 0.955 0.887))", + }, + }, + "--mint-a1": { + default: "light-dark(#00d5aa06, #00dede05)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.804 0.608 / 0.02), color(display-p3 0 0.992 0.992 / 0.017))", + }, + }, + "--mint-a2": { + default: "light-dark(#00b18a0d, #00f9f90b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.647 0.467 / 0.044), color(display-p3 0.071 0.98 0.98 / 0.043))", + }, + }, + "--mint-a3": { + default: "light-dark(#00d29e22, #00fff61d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.761 0.553 / 0.114), color(display-p3 0.176 0.996 0.996 / 0.11))", + }, + }, + "--mint-a4": { + default: "light-dark(#00cc9937, #00fff42c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.741 0.545 / 0.181), color(display-p3 0.071 0.996 0.973 / 0.169))", + }, + }, + "--mint-a5": { + default: "light-dark(#00c0914c, #00fff23a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.678 0.51 / 0.255), color(display-p3 0.243 1 0.949 / 0.223))", + }, + }, + "--mint-a6": { + default: "light-dark(#00b08663, #0effeb4a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.616 0.463 / 0.334), color(display-p3 0.369 1 0.933 / 0.286))", + }, + }, + "--mint-a7": { + default: "light-dark(#00a17d81, #34fde55e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.549 0.412 / 0.432), color(display-p3 0.459 1 0.914 / 0.362))", + }, + }, + "--mint-a8": { + default: "light-dark(#009e7fb3, #41ffdf76)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.529 0.392 / 0.581), color(display-p3 0.49 1 0.89 / 0.454))", + }, + }, + "--mint-a9": { + default: "light-dark(#00d3a579, #92ffe7e9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.765 0.569 / 0.381), color(display-p3 0.678 0.996 0.914 / 0.904))", + }, + }, + "--mint-a10": { + default: "light-dark(#00c39982, #aefeedf5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.69 0.51 / 0.416), color(display-p3 0.761 1 0.941 / 0.95))", + }, + }, + "--mint-a11": { + default: "light-dark(#007763fd, #67ffded2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.203 0.463 0.397), color(display-p3 0.482 0.825 0.733))", + }, + }, + "--mint-a12": { + default: "light-dark(#00312ae9, #cbfee9f5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.136 0.259 0.236), color(display-p3 0.807 0.955 0.887))", + }, + }, + "--mint-surface": { + default: "light-dark(#effaf8cc, #15272780)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9451 0.9804 0.9725 / 0.8), color(display-p3 0.0941 0.149 0.1412 / 0.5))", + }, + }, + "--mint-indicator": "var(--mint-9)", + "--mint-track": + "light-dark(var(--mint-9), color-mix(in oklab, var(--mint-8), var(--mint-9) 65%))", + "--mint-contrast": "#1a211e", +}); diff --git a/packages/reflex-components-ui/js/src/colors/olive.stylex.js b/packages/reflex-components-ui/js/src/colors/olive.stylex.js new file mode 100644 index 00000000000..40766aa58a1 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/olive.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const olive = stylex.defineVars({ + "--olive-1": { + default: "light-dark(#fcfdfc, #111210)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.989 0.992 0.989), color(display-p3 0.067 0.07 0.063))", + }, + }, + "--olive-2": { + default: "light-dark(#f8faf8, #181917)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.974 0.98 0.973), color(display-p3 0.095 0.098 0.091))", + }, + }, + "--olive-3": { + default: "light-dark(#eff1ef, #212220)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.939 0.945 0.937), color(display-p3 0.131 0.135 0.126))", + }, + }, + "--olive-4": { + default: "light-dark(#e7e9e7, #282a27)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.907 0.914 0.905), color(display-p3 0.158 0.163 0.153))", + }, + }, + "--olive-5": { + default: "light-dark(#dfe2df, #2f312e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.878 0.885 0.875), color(display-p3 0.186 0.192 0.18))", + }, + }, + "--olive-6": { + default: "light-dark(#d7dad7, #383a36)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.846 0.855 0.843), color(display-p3 0.221 0.229 0.215))", + }, + }, + "--olive-7": { + default: "light-dark(#cccfcc, #454843)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.803 0.812 0.8), color(display-p3 0.273 0.284 0.266))", + }, + }, + "--olive-8": { + default: "light-dark(#b9bcb8, #5c625b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.727 0.738 0.723), color(display-p3 0.365 0.382 0.359))", + }, + }, + "--olive-9": { + default: "light-dark(#898e87, #687066)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.541 0.556 0.532), color(display-p3 0.414 0.438 0.404))", + }, + }, + "--olive-10": { + default: "light-dark(#7f847d, #767d74)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.5 0.515 0.491), color(display-p3 0.467 0.49 0.458))", + }, + }, + "--olive-11": { + default: "light-dark(#60655f, #afb5ad)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.38 0.395 0.374), color(display-p3 0.69 0.709 0.682))", + }, + }, + "--olive-12": { + default: "light-dark(#1d211c, #eceeec)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.117 0.129 0.111), color(display-p3 0.927 0.933 0.926))", + }, + }, + "--olive-a1": { + default: "light-dark(#00550003, #00000000)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.349 0.024 / 0.012), color(display-p3 0 0 0 / 0))", + }, + }, + "--olive-a2": { + default: "light-dark(#00490007, #f1f2f008)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.302 0.024 / 0.028), color(display-p3 0.984 0.988 0.976 / 0.03))", + }, + }, + "--olive-a3": { + default: "light-dark(#00200010, #f4f5f312)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.129 0.008 / 0.063), color(display-p3 0.992 0.996 0.988 / 0.068))", + }, + }, + "--olive-a4": { + default: "light-dark(#00160018, #f3fef21a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.094 0.012 / 0.095), color(display-p3 0.953 0.996 0.949 / 0.102))", + }, + }, + "--olive-a5": { + default: "light-dark(#00180020, #f2fbf122)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.035 0.098 0.008 / 0.126), color(display-p3 0.969 1 0.965 / 0.131))", + }, + }, + "--olive-a6": { + default: "light-dark(#00140028, #f4faed2c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.027 0.078 0.004 / 0.157), color(display-p3 0.973 1 0.969 / 0.169))", + }, + }, + "--olive-a7": { + default: "light-dark(#000f0033, #f2fced3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.059 0 / 0.2), color(display-p3 0.98 1 0.961 / 0.228))", + }, + }, + "--olive-a8": { + default: "light-dark(#040f0047, #edfdeb57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.059 0.004 / 0.279), color(display-p3 0.961 1 0.957 / 0.334))", + }, + }, + "--olive-a9": { + default: "light-dark(#050f0078, #ebfde766)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.051 0.004 / 0.467), color(display-p3 0.949 1 0.922 / 0.397))", + }, + }, + "--olive-a10": { + default: "light-dark(#040e0082, #f0fdec74)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.047 0 / 0.51), color(display-p3 0.953 1 0.941 / 0.452))", + }, + }, + "--olive-a11": { + default: "light-dark(#020a00a0, #f6fef4b0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.039 0 / 0.628), color(display-p3 0.976 1 0.965 / 0.688))", + }, + }, + "--olive-a12": { + default: "light-dark(#010600e3, #fdfffded)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.024 0 / 0.891), color(display-p3 0.992 1 0.992 / 0.929))", + }, + }, + "--olive-surface": { + default: "light-dark(#ffffffcc, #1f201e80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 1 1 / 0.8), color(display-p3 0.1176 0.1255 0.1176 / 0.5))", + }, + }, + "--olive-indicator": "var(--olive-9)", + "--olive-track": "var(--olive-9)", + "--olive-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/orange.stylex.js b/packages/reflex-components-ui/js/src/colors/orange.stylex.js new file mode 100644 index 00000000000..ee326505781 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/orange.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const orange = stylex.defineVars({ + "--orange-1": { + default: "light-dark(#fefcfb, #17120e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.988 0.985), color(display-p3 0.088 0.07 0.057))", + }, + }, + "--orange-2": { + default: "light-dark(#fff7ed, #1e160f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.994 0.968 0.934), color(display-p3 0.113 0.089 0.061))", + }, + }, + "--orange-3": { + default: "light-dark(#ffefd6, #331e0b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.989 0.938 0.85), color(display-p3 0.189 0.12 0.056))", + }, + }, + "--orange-4": { + default: "light-dark(#ffdfb5, #462100)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.874 0.687), color(display-p3 0.262 0.132 0))", + }, + }, + "--orange-5": { + default: "light-dark(#ffd19a, #562800)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.821 0.583), color(display-p3 0.315 0.168 0.016))", + }, + }, + "--orange-6": { + default: "light-dark(#ffc182, #66350c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.975 0.767 0.545), color(display-p3 0.376 0.219 0.088))", + }, + }, + "--orange-7": { + default: "light-dark(#f5ae73, #7e451d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.919 0.693 0.486), color(display-p3 0.465 0.283 0.147))", + }, + }, + "--orange-8": { + default: "light-dark(#ec9455, #a35829)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.877 0.597 0.379), color(display-p3 0.601 0.359 0.201))", + }, + }, + "--orange-9": { + default: "#f76b15", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.9 0.45 0.2)", + }, + }, + "--orange-10": { + default: "light-dark(#ef5f00, #ff801f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.87 0.409 0.164), color(display-p3 0.98 0.51 0.23))", + }, + }, + "--orange-11": { + default: "light-dark(#cc4e00, #ffa057)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.76 0.34 0), color(display-p3 1 0.63 0.38))", + }, + }, + "--orange-12": { + default: "light-dark(#582d1d, #ffe0c2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.323 0.185 0.127), color(display-p3 0.98 0.883 0.775))", + }, + }, + "--orange-a1": { + default: "light-dark(#c0400004, #ec360007)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.757 0.267 0.024 / 0.016), color(display-p3 0.961 0.247 0 / 0.022))", + }, + }, + "--orange-a2": { + default: "light-dark(#ff8e0012, #fe6d000e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.886 0.533 0.008 / 0.067), color(display-p3 0.992 0.529 0 / 0.051))", + }, + }, + "--orange-a3": { + default: "light-dark(#ff9c0029, #fb6a0025)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.922 0.584 0.008 / 0.15), color(display-p3 0.996 0.486 0 / 0.131))", + }, + }, + "--orange-a4": { + default: "light-dark(#ff91014a, #ff590039)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.604 0.004 / 0.314), color(display-p3 0.996 0.384 0 / 0.211))", + }, + }, + "--orange-a5": { + default: "light-dark(#ff8b0065, #ff61004a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.569 0.004 / 0.416), color(display-p3 1 0.455 0 / 0.265))", + }, + }, + "--orange-a6": { + default: "light-dark(#ff81007d, #fd75045c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.949 0.494 0.004 / 0.455), color(display-p3 1 0.529 0.129 / 0.332))", + }, + }, + "--orange-a7": { + default: "light-dark(#ed6c008c, #ff832c75)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.839 0.408 0 / 0.514), color(display-p3 1 0.569 0.251 / 0.429))", + }, + }, + "--orange-a8": { + default: "light-dark(#e35f00aa, #fe84389d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.804 0.349 0 / 0.62), color(display-p3 1 0.584 0.302 / 0.572))", + }, + }, + "--orange-a9": { + default: "light-dark(#f65e00ea, #fe6d15f7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.878 0.314 0 / 0.8), color(display-p3 1 0.494 0.216 / 0.895))", + }, + }, + "--orange-a10": { + default: "light-dark(#ef5f00, #ff801f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.843 0.29 0 / 0.836), color(display-p3 1 0.522 0.235 / 0.979))", + }, + }, + "--orange-a11": { + default: "light-dark(#cc4e00, #ffa057)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.76 0.34 0), color(display-p3 1 0.63 0.38))", + }, + }, + "--orange-a12": { + default: "light-dark(#431200e2, #ffe0c2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.323 0.185 0.127), color(display-p3 0.98 0.883 0.775))", + }, + }, + "--orange-surface": { + default: "light-dark(#fff5e9cc, #271d1380)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9961 0.9608 0.9176 / 0.8), color(display-p3 0.1412 0.1098 0.0706 / 0.5))", + }, + }, + "--orange-indicator": "var(--orange-9)", + "--orange-track": "var(--orange-9)", + "--orange-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/pink.stylex.js b/packages/reflex-components-ui/js/src/colors/pink.stylex.js new file mode 100644 index 00000000000..5f03925f6ce --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/pink.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const pink = stylex.defineVars({ + "--pink-1": { + default: "light-dark(#fffcfe, #191117)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.998 0.989 0.996), color(display-p3 0.093 0.068 0.089))", + }, + }, + "--pink-2": { + default: "light-dark(#fef7fb, #21121d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.97 0.985), color(display-p3 0.121 0.073 0.11))", + }, + }, + "--pink-3": { + default: "light-dark(#fee9f5, #37172f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.981 0.917 0.96), color(display-p3 0.198 0.098 0.179))", + }, + }, + "--pink-4": { + default: "light-dark(#fbdcef, #4b143d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.963 0.867 0.932), color(display-p3 0.271 0.095 0.231))", + }, + }, + "--pink-5": { + default: "light-dark(#f6cee7, #591c47)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.939 0.815 0.899), color(display-p3 0.32 0.127 0.273))", + }, + }, + "--pink-6": { + default: "light-dark(#efbfdd, #692955)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.907 0.756 0.859), color(display-p3 0.382 0.177 0.326))", + }, + }, + "--pink-7": { + default: "light-dark(#e7acd0, #833869)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.869 0.683 0.81), color(display-p3 0.477 0.238 0.405))", + }, + }, + "--pink-8": { + default: "light-dark(#dd93c2, #a84885)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.825 0.59 0.751), color(display-p3 0.612 0.304 0.51))", + }, + }, + "--pink-9": { + default: "#d6409f", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.775 0.297 0.61)", + }, + }, + "--pink-10": { + default: "light-dark(#cf3897, #de51a8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.748 0.27 0.581), color(display-p3 0.808 0.356 0.645))", + }, + }, + "--pink-11": { + default: "light-dark(#c2298a, #ff8dcc)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.698 0.219 0.528), color(display-p3 1 0.535 0.78))", + }, + }, + "--pink-12": { + default: "light-dark(#651249, #fdd1ea)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.363 0.101 0.279), color(display-p3 0.964 0.826 0.912))", + }, + }, + "--pink-a1": { + default: "light-dark(#ff00aa03, #f412bc09)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 0.675 / 0.012), color(display-p3 0.984 0.071 0.855 / 0.03))", + }, + }, + "--pink-a2": { + default: "light-dark(#e0008008, #f420bb12)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.757 0.02 0.51 / 0.032), color(display-p3 1 0.2 0.8 / 0.059))", + }, + }, + "--pink-a3": { + default: "light-dark(#f4008c16, #fe37cc29)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.765 0.008 0.529 / 0.083), color(display-p3 1 0.294 0.886 / 0.139))", + }, + }, + "--pink-a4": { + default: "light-dark(#e2008b23, #fc1ec43f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.737 0.008 0.506 / 0.134), color(display-p3 1 0.192 0.82 / 0.219))", + }, + }, + "--pink-a5": { + default: "light-dark(#d1008331, #fd35c24e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.663 0.004 0.451 / 0.185), color(display-p3 1 0.282 0.827 / 0.274))", + }, + }, + "--pink-a6": { + default: "light-dark(#c0007840, #fd51c75f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.616 0.004 0.424 / 0.244), color(display-p3 1 0.396 0.835 / 0.337))", + }, + }, + "--pink-a7": { + default: "light-dark(#b6006f53, #fd62c87b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.596 0.004 0.412 / 0.318), color(display-p3 1 0.459 0.831 / 0.442))", + }, + }, + "--pink-a8": { + default: "light-dark(#af006f6c, #ff68c8a2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.573 0.004 0.404 / 0.412), color(display-p3 1 0.478 0.827 / 0.585))", + }, + }, + "--pink-a9": { + default: "light-dark(#c8007fbf, #fe49bcd4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.682 0 0.447 / 0.702), color(display-p3 1 0.373 0.784 / 0.761))", + }, + }, + "--pink-a10": { + default: "light-dark(#c2007ac7, #ff5cc0dc)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.655 0 0.424 / 0.73), color(display-p3 1 0.435 0.792 / 0.795))", + }, + }, + "--pink-a11": { + default: "light-dark(#b60074d6, #ff8dcc)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.698 0.219 0.528), color(display-p3 1 0.535 0.78))", + }, + }, + "--pink-a12": { + default: "light-dark(#59003bed, #ffd3ecfd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.363 0.101 0.279), color(display-p3 0.964 0.826 0.912))", + }, + }, + "--pink-surface": { + default: "light-dark(#fef5facc, #31132980)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9922 0.9608 0.9804 / 0.8), color(display-p3 0.1725 0.0784 0.149 / 0.5))", + }, + }, + "--pink-indicator": "var(--pink-9)", + "--pink-track": "var(--pink-9)", + "--pink-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/plum.stylex.js b/packages/reflex-components-ui/js/src/colors/plum.stylex.js new file mode 100644 index 00000000000..d16bbd6c6ed --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/plum.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const plum = stylex.defineVars({ + "--plum-1": { + default: "light-dark(#fefcff, #181118)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.988 0.999), color(display-p3 0.09 0.068 0.092))", + }, + }, + "--plum-2": { + default: "light-dark(#fdf7fd, #201320)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.988 0.971 0.99), color(display-p3 0.118 0.077 0.121))", + }, + }, + "--plum-3": { + default: "light-dark(#fbebfb, #351a35)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.973 0.923 0.98), color(display-p3 0.192 0.105 0.202))", + }, + }, + "--plum-4": { + default: "light-dark(#f7def8, #451d47)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.953 0.875 0.966), color(display-p3 0.25 0.121 0.271))", + }, + }, + "--plum-5": { + default: "light-dark(#f2d1f3, #512454)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.926 0.825 0.945), color(display-p3 0.293 0.152 0.319))", + }, + }, + "--plum-6": { + default: "light-dark(#e9c2ec, #5e3061)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.89 0.765 0.916), color(display-p3 0.343 0.198 0.372))", + }, + }, + "--plum-7": { + default: "light-dark(#deade3, #734079)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.84 0.686 0.877), color(display-p3 0.424 0.262 0.461))", + }, + }, + "--plum-8": { + default: "light-dark(#cf91d8, #92549c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.775 0.58 0.832), color(display-p3 0.54 0.341 0.595))", + }, + }, + "--plum-9": { + default: "#ab4aba", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.624 0.313 0.708)", + }, + }, + "--plum-10": { + default: "light-dark(#a144af, #b658c4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.587 0.29 0.667), color(display-p3 0.666 0.365 0.748))", + }, + }, + "--plum-11": { + default: "light-dark(#953ea3, #e796f3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.543 0.263 0.619), color(display-p3 0.86 0.602 0.933))", + }, + }, + "--plum-12": { + default: "light-dark(#53195d, #f4d4f4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.299 0.114 0.352), color(display-p3 0.936 0.836 0.949))", + }, + }, + "--plum-a1": { + default: "light-dark(#aa00ff03, #f112f108)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 1 / 0.012), color(display-p3 0.973 0.071 0.973 / 0.026))", + }, + }, + "--plum-a2": { + default: "light-dark(#c000c008, #f22ff211)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.58 0.024 0.58 / 0.028), color(display-p3 0.933 0.267 1 / 0.059))", + }, + }, + "--plum-a3": { + default: "light-dark(#cc00cc14, #fd4cfd27)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.655 0.008 0.753 / 0.079), color(display-p3 0.918 0.333 0.996 / 0.148))", + }, + }, + "--plum-a4": { + default: "light-dark(#c200c921, #f646ff3a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.627 0.008 0.722 / 0.126), color(display-p3 0.91 0.318 1 / 0.219))", + }, + }, + "--plum-a5": { + default: "light-dark(#b700bd2e, #f455ff48)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.58 0.004 0.69 / 0.177), color(display-p3 0.914 0.388 1 / 0.269))", + }, + }, + "--plum-a6": { + default: "light-dark(#a400b03d, #f66dff56)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.537 0.004 0.655 / 0.236), color(display-p3 0.906 0.463 1 / 0.328))", + }, + }, + "--plum-a7": { + default: "light-dark(#9900a852, #f07cfd70)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.49 0.004 0.616 / 0.314), color(display-p3 0.906 0.529 1 / 0.425))", + }, + }, + "--plum-a8": { + default: "light-dark(#9000a56e, #ee84ff95)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.471 0.004 0.6 / 0.42), color(display-p3 0.906 0.553 1 / 0.568))", + }, + }, + "--plum-a9": { + default: "light-dark(#89009eb5, #e961feb6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.451 0 0.576 / 0.687), color(display-p3 0.875 0.427 1 / 0.69))", + }, + }, + "--plum-a10": { + default: "light-dark(#7f0092bb, #ed70ffc0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.42 0 0.529 / 0.71), color(display-p3 0.886 0.471 0.996 / 0.732))", + }, + }, + "--plum-a11": { + default: "light-dark(#730086c1, #f19cfef3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.543 0.263 0.619), color(display-p3 0.86 0.602 0.933))", + }, + }, + "--plum-a12": { + default: "light-dark(#40004be6, #feddfef4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.299 0.114 0.352), color(display-p3 0.936 0.836 0.949))", + }, + }, + "--plum-surface": { + default: "light-dark(#fdf5fdcc, #2f152f80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9843 0.9647 0.9843 / 0.8), color(display-p3 0.1647 0.0863 0.1725 / 0.5))", + }, + }, + "--plum-indicator": "var(--plum-9)", + "--plum-track": "var(--plum-9)", + "--plum-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/purple.stylex.js b/packages/reflex-components-ui/js/src/colors/purple.stylex.js new file mode 100644 index 00000000000..e87723f4e5f --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/purple.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const purple = stylex.defineVars({ + "--purple-1": { + default: "light-dark(#fefcfe, #18111b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.988 0.996), color(display-p3 0.09 0.068 0.103))", + }, + }, + "--purple-2": { + default: "light-dark(#fbf7fe, #1e1523)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.983 0.971 0.993), color(display-p3 0.113 0.082 0.134))", + }, + }, + "--purple-3": { + default: "light-dark(#f7edfe, #301c3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.963 0.931 0.989), color(display-p3 0.175 0.112 0.224))", + }, + }, + "--purple-4": { + default: "light-dark(#f2e2fc, #3d224e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.937 0.888 0.981), color(display-p3 0.224 0.137 0.297))", + }, + }, + "--purple-5": { + default: "light-dark(#ead5f9, #48295c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.904 0.837 0.966), color(display-p3 0.264 0.167 0.349))", + }, + }, + "--purple-6": { + default: "light-dark(#e0c4f4, #54346b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.86 0.774 0.942), color(display-p3 0.311 0.208 0.406))", + }, + }, + "--purple-7": { + default: "light-dark(#d1afec, #664282)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.799 0.69 0.91), color(display-p3 0.381 0.266 0.496))", + }, + }, + "--purple-8": { + default: "light-dark(#be93e4, #8457aa)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.719 0.583 0.874), color(display-p3 0.49 0.349 0.649))", + }, + }, + "--purple-9": { + default: "#8e4ec6", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.523 0.318 0.751)", + }, + }, + "--purple-10": { + default: "light-dark(#8347b9, #9a5cd0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.483 0.289 0.7), color(display-p3 0.57 0.373 0.791))", + }, + }, + "--purple-11": { + default: "light-dark(#8145b5, #d19dff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.473 0.281 0.687), color(display-p3 0.8 0.62 1))", + }, + }, + "--purple-12": { + default: "light-dark(#402060, #ecd9fa)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.234 0.132 0.363), color(display-p3 0.913 0.854 0.971))", + }, + }, + "--purple-a1": { + default: "light-dark(#aa00aa03, #b412f90b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 0.675 / 0.012), color(display-p3 0.686 0.071 0.996 / 0.038))", + }, + }, + "--purple-a2": { + default: "light-dark(#8000e008, #b744f714)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.443 0.024 0.722 / 0.028), color(display-p3 0.722 0.286 0.996 / 0.072))", + }, + }, + "--purple-a3": { + default: "light-dark(#8e00f112, #c150ff2d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.506 0.008 0.835 / 0.071), color(display-p3 0.718 0.349 0.996 / 0.169))", + }, + }, + "--purple-a4": { + default: "light-dark(#8d00e51d, #bb53fd42)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.451 0.004 0.831 / 0.114), color(display-p3 0.702 0.353 1 / 0.248))", + }, + }, + "--purple-a5": { + default: "light-dark(#8000db2a, #be5cfd51)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.431 0.004 0.788 / 0.165), color(display-p3 0.718 0.404 1 / 0.303))", + }, + }, + "--purple-a6": { + default: "light-dark(#7a01d03b, #c16dfd61)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.384 0.004 0.745 / 0.228), color(display-p3 0.733 0.455 1 / 0.366))", + }, + }, + "--purple-a7": { + default: "light-dark(#6d00c350, #c378fd7a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.357 0.004 0.71 / 0.31), color(display-p3 0.753 0.506 1 / 0.458))", + }, + }, + "--purple-a8": { + default: "light-dark(#6600c06c, #c47effa4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.322 0.004 0.702 / 0.416), color(display-p3 0.749 0.522 1 / 0.622))", + }, + }, + "--purple-a9": { + default: "light-dark(#5c00adb1, #b661ffc2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.298 0 0.639 / 0.683), color(display-p3 0.686 0.408 1 / 0.736))", + }, + }, + "--purple-a10": { + default: "light-dark(#53009eb8, #bc6fffcd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.271 0 0.58 / 0.71), color(display-p3 0.71 0.459 1 / 0.778))", + }, + }, + "--purple-a11": { + default: "light-dark(#52009aba, #d19dff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.473 0.281 0.687), color(display-p3 0.8 0.62 1))", + }, + }, + "--purple-a12": { + default: "light-dark(#250049df, #f1ddfffa)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.234 0.132 0.363), color(display-p3 0.913 0.854 0.971))", + }, + }, + "--purple-surface": { + default: "light-dark(#faf5fecc, #2b173580)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9804 0.9647 0.9922 / 0.8), color(display-p3 0.149 0.0941 0.1961 / 0.5))", + }, + }, + "--purple-indicator": "var(--purple-9)", + "--purple-track": "var(--purple-9)", + "--purple-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/red.stylex.js b/packages/reflex-components-ui/js/src/colors/red.stylex.js new file mode 100644 index 00000000000..75edcef6e85 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/red.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const red = stylex.defineVars({ + "--red-1": { + default: "light-dark(#fffcfc, #191111)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.998 0.989 0.988), color(display-p3 0.093 0.068 0.067))", + }, + }, + "--red-2": { + default: "light-dark(#fff7f7, #201314)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.971 0.971), color(display-p3 0.118 0.077 0.079))", + }, + }, + "--red-3": { + default: "light-dark(#feebec, #3b1219)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.985 0.925 0.925), color(display-p3 0.211 0.081 0.099))", + }, + }, + "--red-4": { + default: "light-dark(#ffdbdc, #500f1c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.999 0.866 0.866), color(display-p3 0.287 0.079 0.113))", + }, + }, + "--red-5": { + default: "light-dark(#ffcdce, #611623)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.984 0.812 0.811), color(display-p3 0.348 0.11 0.142))", + }, + }, + "--red-6": { + default: "light-dark(#fdbdbe, #72232d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.955 0.751 0.749), color(display-p3 0.414 0.16 0.183))", + }, + }, + "--red-7": { + default: "light-dark(#f4a9aa, #8c333a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.915 0.675 0.672), color(display-p3 0.508 0.224 0.236))", + }, + }, + "--red-8": { + default: "light-dark(#eb8e90, #b54548)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.872 0.575 0.572), color(display-p3 0.659 0.298 0.297))", + }, + }, + "--red-9": { + default: "#e5484d", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.83 0.329 0.324)", + }, + }, + "--red-10": { + default: "light-dark(#dc3e42, #ec5d5e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.798 0.294 0.285), color(display-p3 0.861 0.403 0.387))", + }, + }, + "--red-11": { + default: "light-dark(#ce2c31, #ff9592)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.744 0.234 0.222), color(display-p3 1 0.57 0.55))", + }, + }, + "--red-12": { + default: "light-dark(#641723, #ffd1d9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.36 0.115 0.143), color(display-p3 0.971 0.826 0.852))", + }, + }, + "--red-a1": { + default: "light-dark(#ff000003, #f4121209)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 0.024 / 0.012), color(display-p3 0.984 0.071 0.071 / 0.03))", + }, + }, + "--red-a2": { + default: "light-dark(#ff000008, #f22f3e11)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.863 0.024 0.024 / 0.028), color(display-p3 0.996 0.282 0.282 / 0.055))", + }, + }, + "--red-a3": { + default: "light-dark(#f3000d14, #ff173f2d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.792 0.008 0.008 / 0.075), color(display-p3 1 0.169 0.271 / 0.156))", + }, + }, + "--red-a4": { + default: "light-dark(#ff000824, #fe0a3b44)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.008 0.008 / 0.134), color(display-p3 1 0.118 0.267 / 0.236))", + }, + }, + "--red-a5": { + default: "light-dark(#ff000632, #ff204756)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.918 0.008 0.008 / 0.189), color(display-p3 1 0.212 0.314 / 0.303))", + }, + }, + "--red-a6": { + default: "light-dark(#f8000442, #ff3e5668)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.831 0.02 0.004 / 0.251), color(display-p3 1 0.318 0.38 / 0.374))", + }, + }, + "--red-a7": { + default: "light-dark(#df000356, #ff536184)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.741 0.016 0.004 / 0.33), color(display-p3 1 0.4 0.424 / 0.475))", + }, + }, + "--red-a8": { + default: "light-dark(#d2000571, #ff5d61b0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.698 0.012 0.004 / 0.428), color(display-p3 1 0.431 0.431 / 0.635))", + }, + }, + "--red-a9": { + default: "light-dark(#db0007b7, #fe4e54e4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.749 0.008 0 / 0.675), color(display-p3 1 0.388 0.384 / 0.82))", + }, + }, + "--red-a10": { + default: "light-dark(#d10005c1, #ff6465eb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.714 0.012 0 / 0.714), color(display-p3 1 0.463 0.447 / 0.853))", + }, + }, + "--red-a11": { + default: "light-dark(#c40006d3, #ff9592)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.744 0.234 0.222), color(display-p3 1 0.57 0.55))", + }, + }, + "--red-a12": { + default: "light-dark(#55000de8, #ffd1d9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.36 0.115 0.143), color(display-p3 0.971 0.826 0.852))", + }, + }, + "--red-surface": { + default: "light-dark(#fff5f5cc, #2f151780)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9961 0.9647 0.9647 / 0.8), color(display-p3 0.1647 0.0863 0.0863 / 0.5))", + }, + }, + "--red-indicator": "var(--red-9)", + "--red-track": "var(--red-9)", + "--red-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/ruby.stylex.js b/packages/reflex-components-ui/js/src/colors/ruby.stylex.js new file mode 100644 index 00000000000..13172a361cd --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/ruby.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const ruby = stylex.defineVars({ + "--ruby-1": { + default: "light-dark(#fffcfd, #191113)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.998 0.989 0.992), color(display-p3 0.093 0.068 0.074))", + }, + }, + "--ruby-2": { + default: "light-dark(#fff7f8, #1e1517)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.971 0.974), color(display-p3 0.113 0.083 0.089))", + }, + }, + "--ruby-3": { + default: "light-dark(#feeaed, #3a141e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.983 0.92 0.928), color(display-p3 0.208 0.088 0.117))", + }, + }, + "--ruby-4": { + default: "light-dark(#ffdce1, #4e1325)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.987 0.869 0.885), color(display-p3 0.279 0.092 0.147))", + }, + }, + "--ruby-5": { + default: "light-dark(#ffced6, #5e1a2e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.968 0.817 0.839), color(display-p3 0.337 0.12 0.18))", + }, + }, + "--ruby-6": { + default: "light-dark(#f8bfc8, #6f2539)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.937 0.758 0.786), color(display-p3 0.401 0.166 0.223))", + }, + }, + "--ruby-7": { + default: "light-dark(#efacb8, #883447)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.897 0.685 0.721), color(display-p3 0.495 0.224 0.281))", + }, + }, + "--ruby-8": { + default: "light-dark(#e592a3, #b3445a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.851 0.588 0.639), color(display-p3 0.652 0.295 0.359))", + }, + }, + "--ruby-9": { + default: "#e54666", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.83 0.323 0.408)", + }, + }, + "--ruby-10": { + default: "light-dark(#dc3b5d, #ec5a72)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.795 0.286 0.375), color(display-p3 0.857 0.392 0.455))", + }, + }, + "--ruby-11": { + default: "light-dark(#ca244d, #ff949d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.728 0.211 0.311), color(display-p3 1 0.57 0.59))", + }, + }, + "--ruby-12": { + default: "light-dark(#64172b, #fed2e1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.36 0.115 0.171), color(display-p3 0.968 0.83 0.88))", + }, + }, + "--ruby-a1": { + default: "light-dark(#ff005503, #f4124a09)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 0.349 / 0.012), color(display-p3 0.984 0.071 0.329 / 0.03))", + }, + }, + "--ruby-a2": { + default: "light-dark(#ff002008, #fe5a7f0e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.863 0.024 0.024 / 0.028), color(display-p3 0.992 0.376 0.529 / 0.051))", + }, + }, + "--ruby-a3": { + default: "light-dark(#f3002515, #ff235d2c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.804 0.008 0.11 / 0.079), color(display-p3 0.996 0.196 0.404 / 0.152))", + }, + }, + "--ruby-a4": { + default: "light-dark(#ff002523, #fd195e42)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.91 0.008 0.125 / 0.13), color(display-p3 1 0.173 0.416 / 0.227))", + }, + }, + "--ruby-a5": { + default: "light-dark(#ff002a31, #fe2d6b53)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.831 0.004 0.133 / 0.185), color(display-p3 1 0.259 0.459 / 0.29))", + }, + }, + "--ruby-a6": { + default: "light-dark(#e4002440, #ff447665)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.745 0.004 0.118 / 0.244), color(display-p3 1 0.341 0.506 / 0.358))", + }, + }, + "--ruby-a7": { + default: "light-dark(#ce002553, #ff577d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.678 0.004 0.114 / 0.314), color(display-p3 1 0.412 0.541 / 0.458))", + }, + }, + "--ruby-a8": { + default: "light-dark(#c300286d, #ff5c7cae)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.639 0.004 0.125 / 0.412), color(display-p3 1 0.431 0.537 / 0.627))", + }, + }, + "--ruby-a9": { + default: "light-dark(#db002cb9, #fe4c70e4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.753 0 0.129 / 0.679), color(display-p3 1 0.376 0.482 / 0.82))", + }, + }, + "--ruby-a10": { + default: "light-dark(#d2002cc4, #ff617beb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.714 0 0.125 / 0.714), color(display-p3 1 0.447 0.522 / 0.849))", + }, + }, + "--ruby-a11": { + default: "light-dark(#c10030db, #ff949d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.728 0.211 0.311), color(display-p3 1 0.57 0.59))", + }, + }, + "--ruby-a12": { + default: "light-dark(#550016e8, #ffd3e2fe)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.36 0.115 0.171), color(display-p3 0.968 0.83 0.88))", + }, + }, + "--ruby-surface": { + default: "light-dark(#fff5f6cc, #2b191d80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9961 0.9647 0.9647 / 0.8), color(display-p3 0.1569 0.0941 0.1098 / 0.5))", + }, + }, + "--ruby-indicator": "var(--ruby-9)", + "--ruby-track": "var(--ruby-9)", + "--ruby-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/sage.stylex.js b/packages/reflex-components-ui/js/src/colors/sage.stylex.js new file mode 100644 index 00000000000..4f59b74a174 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/sage.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const sage = stylex.defineVars({ + "--sage-1": { + default: "light-dark(#fbfdfc, #101211)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.986 0.992 0.988), color(display-p3 0.064 0.07 0.067))", + }, + }, + "--sage-2": { + default: "light-dark(#f7f9f8, #171918)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.97 0.977 0.974), color(display-p3 0.092 0.098 0.094))", + }, + }, + "--sage-3": { + default: "light-dark(#eef1f0, #202221)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.935 0.944 0.94), color(display-p3 0.128 0.135 0.131))", + }, + }, + "--sage-4": { + default: "light-dark(#e6e9e8, #272a29)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.904 0.913 0.909), color(display-p3 0.155 0.164 0.159))", + }, + }, + "--sage-5": { + default: "light-dark(#dfe2e0, #2e3130)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.875 0.885 0.88), color(display-p3 0.183 0.193 0.188))", + }, + }, + "--sage-6": { + default: "light-dark(#d7dad9, #373b39)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.844 0.854 0.849), color(display-p3 0.218 0.23 0.224))", + }, + }, + "--sage-7": { + default: "light-dark(#cbcfcd, #444947)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.8 0.811 0.806), color(display-p3 0.269 0.285 0.277))", + }, + }, + "--sage-8": { + default: "light-dark(#b8bcba, #5b625f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.725 0.738 0.732), color(display-p3 0.362 0.382 0.373))", + }, + }, + "--sage-9": { + default: "light-dark(#868e8b, #63706b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.531 0.556 0.546), color(display-p3 0.398 0.438 0.421))", + }, + }, + "--sage-10": { + default: "light-dark(#7c8481, #717d79)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.492 0.515 0.506), color(display-p3 0.453 0.49 0.474))", + }, + }, + "--sage-11": { + default: "light-dark(#5f6563, #adb5b2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.377 0.395 0.389), color(display-p3 0.685 0.709 0.697))", + }, + }, + "--sage-12": { + default: "light-dark(#1a211e, #eceeed)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.107 0.129 0.118), color(display-p3 0.927 0.933 0.93))", + }, + }, + "--sage-a1": { + default: "light-dark(#00804004, #00000000)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.514 0.267 / 0.016), color(display-p3 0 0 0 / 0))", + }, + }, + "--sage-a2": { + default: "light-dark(#00402008, #f0f2f108)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.267 0.145 / 0.032), color(display-p3 0.976 0.988 0.984 / 0.03))", + }, + }, + "--sage-a3": { + default: "light-dark(#002d1e11, #f3f5f412)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.184 0.125 / 0.067), color(display-p3 0.992 0.945 0.941 / 0.072))", + }, + }, + "--sage-a4": { + default: "light-dark(#001f1519, #f2fefd1a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.094 0.051 / 0.095), color(display-p3 0.988 0.996 0.992 / 0.102))", + }, + }, + "--sage-a5": { + default: "light-dark(#00180820, #f1fbfa22)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.098 0.035 / 0.126), color(display-p3 0.992 1 0.996 / 0.131))", + }, + }, + "--sage-a6": { + default: "light-dark(#00140d28, #edfbf42d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.078 0.027 / 0.157), color(display-p3 0.973 1 0.976 / 0.173))", + }, + }, + "--sage-a7": { + default: "light-dark(#00140a34, #edfcf73c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.059 0.039 / 0.2), color(display-p3 0.957 1 0.976 / 0.233))", + }, + }, + "--sage-a8": { + default: "light-dark(#000f0847, #ebfdf657)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.047 0.031 / 0.275), color(display-p3 0.957 1 0.984 / 0.334))", + }, + }, + "--sage-a9": { + default: "light-dark(#00110b79, #dffdf266)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.059 0.035 / 0.471), color(display-p3 0.902 1 0.957 / 0.397))", + }, + }, + "--sage-a10": { + default: "light-dark(#00100a83, #e5fdf674)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.047 0.031 / 0.51), color(display-p3 0.929 1 0.973 / 0.452))", + }, + }, + "--sage-a11": { + default: "light-dark(#000a07a0, #f4fefbb0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.031 0.02 / 0.624), color(display-p3 0.969 1 0.988 / 0.688))", + }, + }, + "--sage-a12": { + default: "light-dark(#000805e5, #fdfffeed)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.027 0.012 / 0.895), color(display-p3 0.992 1 0.996 / 0.929))", + }, + }, + "--sage-surface": { + default: "light-dark(#ffffffcc, #1e201f80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 1 1 / 0.8), color(display-p3 0.1176 0.1255 0.1176 / 0.5))", + }, + }, + "--sage-indicator": "var(--sage-9)", + "--sage-track": "var(--sage-9)", + "--sage-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/sand.stylex.js b/packages/reflex-components-ui/js/src/colors/sand.stylex.js new file mode 100644 index 00000000000..eb2770a1063 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/sand.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const sand = stylex.defineVars({ + "--sand-1": { + default: "light-dark(#fdfdfc, #111110)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.992 0.989), color(display-p3 0.067 0.067 0.063))", + }, + }, + "--sand-2": { + default: "light-dark(#f9f9f8, #191918)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.977 0.977 0.973), color(display-p3 0.098 0.098 0.094))", + }, + }, + "--sand-3": { + default: "light-dark(#f1f0ef, #222221)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.943 0.942 0.936), color(display-p3 0.135 0.135 0.129))", + }, + }, + "--sand-4": { + default: "light-dark(#e9e8e6, #2a2a28)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.913 0.912 0.903), color(display-p3 0.164 0.163 0.156))", + }, + }, + "--sand-5": { + default: "light-dark(#e2e1de, #31312e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.885 0.883 0.873), color(display-p3 0.193 0.192 0.183))", + }, + }, + "--sand-6": { + default: "light-dark(#dad9d6, #3b3a37)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.854 0.852 0.839), color(display-p3 0.23 0.229 0.217))", + }, + }, + "--sand-7": { + default: "light-dark(#cfceca, #494844)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.813 0.81 0.794), color(display-p3 0.285 0.282 0.267))", + }, + }, + "--sand-8": { + default: "light-dark(#bcbbb5, #62605b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.738 0.734 0.713), color(display-p3 0.384 0.378 0.357))", + }, + }, + "--sand-9": { + default: "light-dark(#8d8d86, #6f6d66)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.553 0.553 0.528), color(display-p3 0.434 0.428 0.403))", + }, + }, + "--sand-10": { + default: "light-dark(#82827c, #7c7b74)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.511 0.511 0.488), color(display-p3 0.487 0.481 0.456))", + }, + }, + "--sand-11": { + default: "light-dark(#63635e, #b5b3ad)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.388 0.388 0.37), color(display-p3 0.707 0.703 0.68))", + }, + }, + "--sand-12": { + default: "light-dark(#21201c, #eeeeec)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.129 0.126 0.111), color(display-p3 0.933 0.933 0.926))", + }, + }, + "--sand-a1": { + default: "light-dark(#55550003, #00000000)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.349 0.349 0.024 / 0.012), color(display-p3 0 0 0 / 0))", + }, + }, + "--sand-a2": { + default: "light-dark(#25250007, #f4f4f309)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.161 0.161 0.024 / 0.028), color(display-p3 0.992 0.992 0.988 / 0.034))", + }, + }, + "--sand-a3": { + default: "light-dark(#20100010, #f6f6f513)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.067 0.067 0.008 / 0.063), color(display-p3 0.996 0.996 0.992 / 0.072))", + }, + }, + "--sand-a4": { + default: "light-dark(#1f150019, #fefef31b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.129 0.129 0.012 / 0.099), color(display-p3 0.992 0.992 0.953 / 0.106))", + }, + }, + "--sand-a5": { + default: "light-dark(#1f180021, #fbfbeb23)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.098 0.067 0.008 / 0.126), color(display-p3 1 1 0.965 / 0.135))", + }, + }, + "--sand-a6": { + default: "light-dark(#19130029, #fffaed2d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.102 0.075 0.004 / 0.161), color(display-p3 1 0.976 0.929 / 0.177))", + }, + }, + "--sand-a7": { + default: "light-dark(#19140035, #fffbed3c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.098 0.098 0.004 / 0.208), color(display-p3 1 0.984 0.929 / 0.236))", + }, + }, + "--sand-a8": { + default: "light-dark(#1915014a, #fff9eb57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.086 0.075 0.004 / 0.287), color(display-p3 1 0.976 0.925 / 0.341))", + }, + }, + "--sand-a9": { + default: "light-dark(#0f0f0079, #fffae965)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.051 0.051 0.004 / 0.471), color(display-p3 1 0.98 0.925 / 0.395))", + }, + }, + "--sand-a10": { + default: "light-dark(#0c0c0083, #fffdee73)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.047 0.047 0 / 0.514), color(display-p3 1 0.992 0.933 / 0.45))", + }, + }, + "--sand-a11": { + default: "light-dark(#080800a1, #fffcf4b0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.031 0.031 0 / 0.632), color(display-p3 1 0.996 0.961 / 0.685))", + }, + }, + "--sand-a12": { + default: "light-dark(#060500e3, #fffffded)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.02 0 / 0.891), color(display-p3 1 1 0.992 / 0.929))", + }, + }, + "--sand-surface": { + default: "light-dark(#ffffffcc, #21212080)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 1 1 / 0.8), color(display-p3 0.1255 0.1255 0.1255 / 0.5))", + }, + }, + "--sand-indicator": "var(--sand-9)", + "--sand-track": "var(--sand-9)", + "--sand-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/sky.stylex.js b/packages/reflex-components-ui/js/src/colors/sky.stylex.js new file mode 100644 index 00000000000..a2670da136a --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/sky.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const sky = stylex.defineVars({ + "--sky-1": { + default: "light-dark(#f9feff, #0d141f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.98 0.995 0.999), color(display-p3 0.056 0.078 0.116))", + }, + }, + "--sky-2": { + default: "light-dark(#f1fafd, #111a27)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.953 0.98 0.99), color(display-p3 0.075 0.101 0.149))", + }, + }, + "--sky-3": { + default: "light-dark(#e1f6fd, #112840)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.899 0.963 0.989), color(display-p3 0.089 0.154 0.244))", + }, + }, + "--sky-4": { + default: "light-dark(#d1f0fa, #113555)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.842 0.937 0.977), color(display-p3 0.106 0.207 0.323))", + }, + }, + "--sky-5": { + default: "light-dark(#bee7f5, #154467)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.777 0.9 0.954), color(display-p3 0.135 0.261 0.394))", + }, + }, + "--sky-6": { + default: "light-dark(#a9daed, #1b537b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.701 0.851 0.921), color(display-p3 0.17 0.322 0.469))", + }, + }, + "--sky-7": { + default: "light-dark(#8dcae3, #1f6692)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.604 0.785 0.879), color(display-p3 0.205 0.394 0.557))", + }, + }, + "--sky-8": { + default: "light-dark(#60b3d7, #197cae)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.457 0.696 0.829), color(display-p3 0.232 0.48 0.665))", + }, + }, + "--sky-9": { + default: "#7ce2fe", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.585 0.877 0.983)", + }, + }, + "--sky-10": { + default: "light-dark(#74daf8, #a8eeff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.555 0.845 0.959), color(display-p3 0.718 0.925 0.991))", + }, + }, + "--sky-11": { + default: "light-dark(#00749e, #75c7f0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.193 0.448 0.605), color(display-p3 0.536 0.772 0.924))", + }, + }, + "--sky-12": { + default: "light-dark(#1d3e56, #c2f3ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.145 0.241 0.329), color(display-p3 0.799 0.947 0.993))", + }, + }, + "--sky-a1": { + default: "light-dark(#00d5ff06, #0044ff0f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.804 1 / 0.02), color(display-p3 0 0.282 0.996 / 0.055))", + }, + }, + "--sky-a2": { + default: "light-dark(#00a4db0e, #1171fb18)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.592 0.757 / 0.048), color(display-p3 0.157 0.467 0.992 / 0.089))", + }, + }, + "--sky-a3": { + default: "light-dark(#00b3ee1e, #1184fc33)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.655 0.886 / 0.102), color(display-p3 0.192 0.522 0.996 / 0.19))", + }, + }, + "--sky-a4": { + default: "light-dark(#00ace42e, #128fff49)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.604 0.851 / 0.157), color(display-p3 0.212 0.584 1 / 0.274))", + }, + }, + "--sky-a5": { + default: "light-dark(#00a1d841, #1c9dfd5d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.565 0.792 / 0.224), color(display-p3 0.259 0.631 1 / 0.349))", + }, + }, + "--sky-a6": { + default: "light-dark(#0092ca56, #28a5ff72)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.502 0.737 / 0.299), color(display-p3 0.302 0.655 1 / 0.433))", + }, + }, + "--sky-a7": { + default: "light-dark(#0089c172, #2badfe8b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.459 0.694 / 0.397), color(display-p3 0.329 0.686 1 / 0.526))", + }, + }, + "--sky-a8": { + default: "light-dark(#0085bf9f, #1db2fea9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.435 0.682 / 0.542), color(display-p3 0.325 0.71 1 / 0.643))", + }, + }, + "--sky-a9": { + default: "light-dark(#00c7fe83, #7ce3fffe)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.71 0.965 / 0.416), color(display-p3 0.592 0.894 1 / 0.984))", + }, + }, + "--sky-a10": { + default: "light-dark(#00bcf38b, #a8eeff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.647 0.914 / 0.444), color(display-p3 0.722 0.933 1 / 0.992))", + }, + }, + "--sky-a11": { + default: "light-dark(#00749e, #7cd3ffef)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.193 0.448 0.605), color(display-p3 0.536 0.772 0.924))", + }, + }, + "--sky-a12": { + default: "light-dark(#002540e2, #c2f3ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.145 0.241 0.329), color(display-p3 0.799 0.947 0.993))", + }, + }, + "--sky-surface": { + default: "light-dark(#eef9fdcc, #13233b80)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9412 0.9765 0.9843 / 0.8), color(display-p3 0.0863 0.1333 0.2196 / 0.5))", + }, + }, + "--sky-indicator": "var(--sky-9)", + "--sky-track": + "light-dark(var(--sky-9), color-mix(in oklab, var(--sky-8), var(--sky-9) 65%))", + "--sky-contrast": "#1c2024", +}); diff --git a/packages/reflex-components-ui/js/src/colors/slate.stylex.js b/packages/reflex-components-ui/js/src/colors/slate.stylex.js new file mode 100644 index 00000000000..6b38158c63f --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/slate.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const slate = stylex.defineVars({ + "--slate-1": { + default: "light-dark(#fcfcfd, #111113)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.988 0.988 0.992), color(display-p3 0.067 0.067 0.074))", + }, + }, + "--slate-2": { + default: "light-dark(#f9f9fb, #18191b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.976 0.976 0.984), color(display-p3 0.095 0.098 0.105))", + }, + }, + "--slate-3": { + default: "light-dark(#f0f0f3, #212225)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.94 0.941 0.953), color(display-p3 0.13 0.135 0.145))", + }, + }, + "--slate-4": { + default: "light-dark(#e8e8ec, #272a2d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.908 0.909 0.925), color(display-p3 0.156 0.163 0.176))", + }, + }, + "--slate-5": { + default: "light-dark(#e0e1e6, #2e3135)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.88 0.881 0.901), color(display-p3 0.183 0.191 0.206))", + }, + }, + "--slate-6": { + default: "light-dark(#d9d9e0, #363a3f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.85 0.852 0.876), color(display-p3 0.215 0.226 0.244))", + }, + }, + "--slate-7": { + default: "light-dark(#cdced6, #43484e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.805 0.808 0.838), color(display-p3 0.265 0.28 0.302))", + }, + }, + "--slate-8": { + default: "light-dark(#b9bbc6, #5a6169)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.727 0.733 0.773), color(display-p3 0.357 0.381 0.409))", + }, + }, + "--slate-9": { + default: "light-dark(#8b8d98, #696e77)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.547 0.553 0.592), color(display-p3 0.415 0.431 0.463))", + }, + }, + "--slate-10": { + default: "light-dark(#80838d, #777b84)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.503 0.512 0.549), color(display-p3 0.469 0.483 0.514))", + }, + }, + "--slate-11": { + default: "light-dark(#60646c, #b0b4ba)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.379 0.392 0.421), color(display-p3 0.692 0.704 0.728))", + }, + }, + "--slate-12": { + default: "light-dark(#1c2024, #edeef0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.113 0.125 0.14), color(display-p3 0.93 0.933 0.94))", + }, + }, + "--slate-a1": { + default: "light-dark(#00005503, #00000000)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.024 0.349 / 0.012), color(display-p3 0 0 0 / 0))", + }, + }, + "--slate-a2": { + default: "light-dark(#00005506, #d8f4f609)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.024 0.349 / 0.024), color(display-p3 0.875 0.992 1 / 0.034))", + }, + }, + "--slate-a3": { + default: "light-dark(#0000330f, #ddeaf814)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.004 0.204 / 0.059), color(display-p3 0.882 0.933 0.992 / 0.077))", + }, + }, + "--slate-a4": { + default: "light-dark(#00002d17, #d3edf81d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.012 0.012 0.184 / 0.091), color(display-p3 0.882 0.953 0.996 / 0.111))", + }, + }, + "--slate-a5": { + default: "light-dark(#0009321f, #d9edfe25)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.039 0.2 / 0.122), color(display-p3 0.878 0.929 0.996 / 0.145))", + }, + }, + "--slate-a6": { + default: "light-dark(#00002f26, #d6ebfd30)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.008 0.165 / 0.15), color(display-p3 0.882 0.949 0.996 / 0.183))", + }, + }, + "--slate-a7": { + default: "light-dark(#00062e32, #d9edff40)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.008 0.027 0.184 / 0.197), color(display-p3 0.882 0.929 1 / 0.246))", + }, + }, + "--slate-a8": { + default: "light-dark(#00083046, #d9edff5d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.031 0.176 / 0.275), color(display-p3 0.871 0.937 1 / 0.361))", + }, + }, + "--slate-a9": { + default: "light-dark(#00051d74, #dfebfd6d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.02 0.106 / 0.455), color(display-p3 0.898 0.937 1 / 0.42))", + }, + }, + "--slate-a10": { + default: "light-dark(#00071b7f, #e5edfd7b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.027 0.098 / 0.499), color(display-p3 0.918 0.945 1 / 0.475))", + }, + }, + "--slate-a11": { + default: "light-dark(#0007149f, #f1f7feb5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.02 0.063 / 0.62), color(display-p3 0.949 0.969 0.996 / 0.708))", + }, + }, + "--slate-a12": { + default: "light-dark(#000509e3, #fcfdffef)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.012 0.031 / 0.887), color(display-p3 0.988 0.992 1 / 0.937))", + }, + }, + "--slate-surface": { + default: "light-dark(#ffffffcc, #1f212380)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 1 1 / 0.8), color(display-p3 0.1176 0.1255 0.1333 / 0.5))", + }, + }, + "--slate-indicator": "var(--slate-9)", + "--slate-track": "var(--slate-9)", + "--slate-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/teal.stylex.js b/packages/reflex-components-ui/js/src/colors/teal.stylex.js new file mode 100644 index 00000000000..88b43508b07 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/teal.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const teal = stylex.defineVars({ + "--teal-1": { + default: "light-dark(#fafefd, #0d1514)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.983 0.996 0.992), color(display-p3 0.059 0.083 0.079))", + }, + }, + "--teal-2": { + default: "light-dark(#f3fbf9, #111c1b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.958 0.983 0.976), color(display-p3 0.075 0.11 0.107))", + }, + }, + "--teal-3": { + default: "light-dark(#e0f8f3, #0d2d2a)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.895 0.971 0.952), color(display-p3 0.087 0.175 0.165))", + }, + }, + "--teal-4": { + default: "light-dark(#ccf3ea, #023b37)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.831 0.949 0.92), color(display-p3 0.087 0.227 0.214))", + }, + }, + "--teal-5": { + default: "light-dark(#b8eae0, #084843)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.761 0.914 0.878), color(display-p3 0.12 0.277 0.261))", + }, + }, + "--teal-6": { + default: "light-dark(#a1ded2, #145750)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.682 0.864 0.825), color(display-p3 0.162 0.335 0.314))", + }, + }, + "--teal-7": { + default: "light-dark(#83cdc1, #1c6961)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.581 0.798 0.756), color(display-p3 0.205 0.406 0.379))", + }, + }, + "--teal-8": { + default: "light-dark(#53b9ab, #207e73)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.433 0.716 0.671), color(display-p3 0.245 0.489 0.453))", + }, + }, + "--teal-9": { + default: "#12a594", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.297 0.637 0.581)", + }, + }, + "--teal-10": { + default: "light-dark(#0d9b8a, #0eb39e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.275 0.599 0.542), color(display-p3 0.319 0.69 0.62))", + }, + }, + "--teal-11": { + default: "light-dark(#008573, #0bd8b6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.08 0.5 0.43), color(display-p3 0.388 0.835 0.719))", + }, + }, + "--teal-12": { + default: "light-dark(#0d3d38, #adf0dd)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.11 0.235 0.219), color(display-p3 0.734 0.934 0.87))", + }, + }, + "--teal-a1": { + default: "light-dark(#00cc9905, #00deab05)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.024 0.757 0.514 / 0.016), color(display-p3 0 0.992 0.761 / 0.017))", + }, + }, + "--teal-a2": { + default: "light-dark(#00aa800c, #12fbe60c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.02 0.647 0.467 / 0.044), color(display-p3 0.235 0.988 0.902 / 0.047))", + }, + }, + "--teal-a3": { + default: "light-dark(#00c69d1f, #00ffe61e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.741 0.557 / 0.106), color(display-p3 0.235 1 0.898 / 0.118))", + }, + }, + "--teal-a4": { + default: "light-dark(#00c39633, #00ffe92d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.702 0.537 / 0.169), color(display-p3 0.18 0.996 0.929 / 0.173))", + }, + }, + "--teal-a5": { + default: "light-dark(#00b49047, #00ffea3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.643 0.494 / 0.24), color(display-p3 0.31 1 0.933 / 0.227))", + }, + }, + "--teal-a6": { + default: "light-dark(#00a6855e, #1cffe84b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.569 0.447 / 0.318), color(display-p3 0.396 1 0.933 / 0.286))", + }, + }, + "--teal-a7": { + default: "light-dark(#0099807c, #2efde85f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.004 0.518 0.424 / 0.42), color(display-p3 0.443 1 0.925 / 0.366))", + }, + }, + "--teal-a8": { + default: "light-dark(#009783ac, #32ffe775)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.506 0.424 / 0.569), color(display-p3 0.459 1 0.925 / 0.454))", + }, + }, + "--teal-a9": { + default: "light-dark(#009e8ced, #13ffe49f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.482 0.404 / 0.702), color(display-p3 0.443 0.996 0.906 / 0.61))", + }, + }, + "--teal-a10": { + default: "light-dark(#009684f2, #0dffe0ae)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0.451 0.369 / 0.726), color(display-p3 0.439 0.996 0.89 / 0.669))", + }, + }, + "--teal-a11": { + default: "light-dark(#008573, #0afed5d6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.08 0.5 0.43), color(display-p3 0.388 0.835 0.719))", + }, + }, + "--teal-a12": { + default: "light-dark(#00332df2, #b8ffebef)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.11 0.235 0.219), color(display-p3 0.734 0.934 0.87))", + }, + }, + "--teal-surface": { + default: "light-dark(#f0faf8cc, #13272580)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9451 0.9804 0.9725 / 0.8), color(display-p3 0.0863 0.149 0.1412 / 0.5))", + }, + }, + "--teal-indicator": "var(--teal-9)", + "--teal-track": "var(--teal-9)", + "--teal-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/tomato.stylex.js b/packages/reflex-components-ui/js/src/colors/tomato.stylex.js new file mode 100644 index 00000000000..91f4a30e761 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/tomato.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const tomato = stylex.defineVars({ + "--tomato-1": { + default: "light-dark(#fffcfc, #181111)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.998 0.989 0.988), color(display-p3 0.09 0.068 0.067))", + }, + }, + "--tomato-2": { + default: "light-dark(#fff8f7, #1f1513)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.994 0.974 0.969), color(display-p3 0.115 0.084 0.076))", + }, + }, + "--tomato-3": { + default: "light-dark(#feebe7, #391714)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.985 0.924 0.909), color(display-p3 0.205 0.097 0.083))", + }, + }, + "--tomato-4": { + default: "light-dark(#ffdcd3, #4e1511)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.996 0.868 0.835), color(display-p3 0.282 0.099 0.077))", + }, + }, + "--tomato-5": { + default: "light-dark(#ffcdc2, #5e1c16)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.98 0.812 0.77), color(display-p3 0.339 0.129 0.101))", + }, + }, + "--tomato-6": { + default: "light-dark(#fdbdaf, #6e2920)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.953 0.75 0.698), color(display-p3 0.398 0.179 0.141))", + }, + }, + "--tomato-7": { + default: "light-dark(#f5a898, #853a2d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.917 0.673 0.611), color(display-p3 0.487 0.245 0.194))", + }, + }, + "--tomato-8": { + default: "light-dark(#ec8e7b, #ac4d39)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.875 0.575 0.502), color(display-p3 0.629 0.322 0.248))", + }, + }, + "--tomato-9": { + default: "#e54d2e", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.831 0.345 0.231)", + }, + }, + "--tomato-10": { + default: "light-dark(#dd4425, #ec6142)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.802 0.313 0.2), color(display-p3 0.862 0.415 0.298))", + }, + }, + "--tomato-11": { + default: "light-dark(#d13415, #ff977d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.755 0.259 0.152), color(display-p3 1 0.585 0.455))", + }, + }, + "--tomato-12": { + default: "light-dark(#5c271f, #fbd3cb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.335 0.165 0.132), color(display-p3 0.959 0.833 0.802))", + }, + }, + "--tomato-a1": { + default: "light-dark(#ff000003, #f1121208)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.024 0.024 / 0.012), color(display-p3 0.973 0.071 0.071 / 0.026))", + }, + }, + "--tomato-a2": { + default: "light-dark(#ff200008, #ff55330f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.757 0.145 0.02 / 0.032), color(display-p3 0.992 0.376 0.224 / 0.051))", + }, + }, + "--tomato-a3": { + default: "light-dark(#f52b0018, #ff35232b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.831 0.184 0.012 / 0.091), color(display-p3 0.996 0.282 0.176 / 0.148))", + }, + }, + "--tomato-a4": { + default: "light-dark(#ff35002c, #fd201142)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.976 0.192 0.004 / 0.165), color(display-p3 1 0.204 0.118 / 0.232))", + }, + }, + "--tomato-a5": { + default: "light-dark(#ff2e003d, #fe332153)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.918 0.192 0.004 / 0.232), color(display-p3 1 0.286 0.192 / 0.29))", + }, + }, + "--tomato-a6": { + default: "light-dark(#f92d0050, #ff4f3864)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.847 0.173 0.004 / 0.302), color(display-p3 1 0.392 0.278 / 0.353))", + }, + }, + "--tomato-a7": { + default: "light-dark(#e7280067, #fd644a7d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.788 0.165 0.004 / 0.389), color(display-p3 1 0.459 0.349 / 0.45))", + }, + }, + "--tomato-a8": { + default: "light-dark(#db250084, #fe6d4ea7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.749 0.153 0.004 / 0.499), color(display-p3 1 0.49 0.369 / 0.601))", + }, + }, + "--tomato-a9": { + default: "light-dark(#df2600d1, #fe5431e4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.78 0.149 0 / 0.769), color(display-p3 1 0.408 0.267 / 0.82))", + }, + }, + "--tomato-a10": { + default: "light-dark(#d72400da, #ff6847eb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.757 0.141 0 / 0.8), color(display-p3 1 0.478 0.341 / 0.853))", + }, + }, + "--tomato-a11": { + default: "light-dark(#cd2200ea, #ff977d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.755 0.259 0.152), color(display-p3 1 0.585 0.455))", + }, + }, + "--tomato-a12": { + default: "light-dark(#460900e0, #ffd6cefb)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.335 0.165 0.132), color(display-p3 0.959 0.833 0.802))", + }, + }, + "--tomato-surface": { + default: "light-dark(#fff6f5cc, #2d191580)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9922 0.9647 0.9608 / 0.8), color(display-p3 0.1569 0.0941 0.0784 / 0.5))", + }, + }, + "--tomato-indicator": "var(--tomato-9)", + "--tomato-track": "var(--tomato-9)", + "--tomato-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/violet.stylex.js b/packages/reflex-components-ui/js/src/colors/violet.stylex.js new file mode 100644 index 00000000000..d37640ba998 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/violet.stylex.js @@ -0,0 +1,208 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const violet = stylex.defineVars({ + "--violet-1": { + default: "light-dark(#fdfcfe, #14121f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.991 0.988 0.995), color(display-p3 0.077 0.071 0.118))", + }, + }, + "--violet-2": { + default: "light-dark(#faf8ff, #1b1525)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.978 0.974 0.998), color(display-p3 0.101 0.084 0.141))", + }, + }, + "--violet-3": { + default: "light-dark(#f4f0fe, #291f43)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.953 0.943 0.993), color(display-p3 0.154 0.123 0.256))", + }, + }, + "--violet-4": { + default: "light-dark(#ebe4ff, #33255b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.916 0.897 1), color(display-p3 0.191 0.148 0.345))", + }, + }, + "--violet-5": { + default: "light-dark(#e1d9ff, #3c2e69)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.876 0.851 1), color(display-p3 0.226 0.182 0.396))", + }, + }, + "--violet-6": { + default: "light-dark(#d4cafe, #473876)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.825 0.793 0.981), color(display-p3 0.269 0.223 0.449))", + }, + }, + "--violet-7": { + default: "light-dark(#c2b5f5, #56468b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.752 0.712 0.943), color(display-p3 0.326 0.277 0.53))", + }, + }, + "--violet-8": { + default: "light-dark(#aa99ec, #6958ad)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.654 0.602 0.902), color(display-p3 0.399 0.346 0.656))", + }, + }, + "--violet-9": { + default: "#6e56cf", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0.417 0.341 0.784)", + }, + }, + "--violet-10": { + default: "light-dark(#654dc4, #7d66d9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.381 0.306 0.741), color(display-p3 0.477 0.402 0.823))", + }, + }, + "--violet-11": { + default: "light-dark(#6550b9, #baa7ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.383 0.317 0.702), color(display-p3 0.72 0.65 1))", + }, + }, + "--violet-12": { + default: "light-dark(#2f265f, #e2ddfe)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.179 0.15 0.359), color(display-p3 0.883 0.867 0.986))", + }, + }, + "--violet-a1": { + default: "light-dark(#5500aa03, #4422ff0f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.349 0.024 0.675 / 0.012), color(display-p3 0.282 0.141 0.996 / 0.055))", + }, + }, + "--violet-a2": { + default: "light-dark(#4900ff07, #853ff916)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.161 0.024 0.863 / 0.028), color(display-p3 0.51 0.263 1 / 0.08))", + }, + }, + "--violet-a3": { + default: "light-dark(#4400ee0f, #8354fe36)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.204 0.004 0.871 / 0.059), color(display-p3 0.494 0.337 0.996 / 0.202))", + }, + }, + "--violet-a4": { + default: "light-dark(#4300ff1b, #7d51fd50)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.196 0.004 1 / 0.102), color(display-p3 0.49 0.345 1 / 0.299))", + }, + }, + "--violet-a5": { + default: "light-dark(#3600ff26, #845ffd5f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.165 0.008 1 / 0.15), color(display-p3 0.525 0.392 1 / 0.353))", + }, + }, + "--violet-a6": { + default: "light-dark(#3100fb35, #8f6cfd6d)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.153 0.004 0.906 / 0.208), color(display-p3 0.569 0.455 1 / 0.408))", + }, + }, + "--violet-a7": { + default: "light-dark(#2d01dd4a, #9879ff83)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.141 0.004 0.796 / 0.287), color(display-p3 0.588 0.494 1 / 0.496))", + }, + }, + "--violet-a8": { + default: "light-dark(#2b00d066, #977dfea8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.133 0.004 0.753 / 0.397), color(display-p3 0.596 0.51 1 / 0.631))", + }, + }, + "--violet-a9": { + default: "light-dark(#2400b7a9, #8668ffcc)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.114 0 0.675 / 0.659), color(display-p3 0.522 0.424 1 / 0.769))", + }, + }, + "--violet-a10": { + default: "light-dark(#2300abb2, #9176fed7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.11 0 0.627 / 0.695), color(display-p3 0.576 0.482 1 / 0.811))", + }, + }, + "--violet-a11": { + default: "light-dark(#1f0099af, #baa7ff)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.383 0.317 0.702), color(display-p3 0.72 0.65 1))", + }, + }, + "--violet-a12": { + default: "light-dark(#0b0043d9, #e3defffe)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.179 0.15 0.359), color(display-p3 0.883 0.867 0.986))", + }, + }, + "--violet-surface": { + default: "light-dark(#f9f6ffcc, #25193980)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9725 0.9647 0.9961 / 0.8), color(display-p3 0.1333 0.102 0.2118 / 0.5))", + }, + }, + "--violet-indicator": "var(--violet-9)", + "--violet-track": "var(--violet-9)", + "--violet-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/colors/white.stylex.js b/packages/reflex-components-ui/js/src/colors/white.stylex.js new file mode 100644 index 00000000000..d68947c3353 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/white.stylex.js @@ -0,0 +1,90 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const white = stylex.defineVars({ + "--white-a1": { + default: "rgba(255, 255, 255, 0.05)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.05)", + }, + }, + "--white-a2": { + default: "rgba(255, 255, 255, 0.1)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.1)", + }, + }, + "--white-a3": { + default: "rgba(255, 255, 255, 0.15)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.15)", + }, + }, + "--white-a4": { + default: "rgba(255, 255, 255, 0.2)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.2)", + }, + }, + "--white-a5": { + default: "rgba(255, 255, 255, 0.3)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.3)", + }, + }, + "--white-a6": { + default: "rgba(255, 255, 255, 0.4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.4)", + }, + }, + "--white-a7": { + default: "rgba(255, 255, 255, 0.5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.5)", + }, + }, + "--white-a8": { + default: "rgba(255, 255, 255, 0.6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.6)", + }, + }, + "--white-a9": { + default: "rgba(255, 255, 255, 0.7)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.7)", + }, + }, + "--white-a10": { + default: "rgba(255, 255, 255, 0.8)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.8)", + }, + }, + "--white-a11": { + default: "rgba(255, 255, 255, 0.9)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.9)", + }, + }, + "--white-a12": { + default: "rgba(255, 255, 255, 0.95)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 1 1 / 0.95)", + }, + }, +}); diff --git a/packages/reflex-components-ui/js/src/colors/yellow.stylex.js b/packages/reflex-components-ui/js/src/colors/yellow.stylex.js new file mode 100644 index 00000000000..e1776df5d29 --- /dev/null +++ b/packages/reflex-components-ui/js/src/colors/yellow.stylex.js @@ -0,0 +1,209 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const yellow = stylex.defineVars({ + "--yellow-1": { + default: "light-dark(#fdfdf9, #14120b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.992 0.978), color(display-p3 0.078 0.069 0.047))", + }, + }, + "--yellow-2": { + default: "light-dark(#fefce9, #1b180f)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.995 0.99 0.922), color(display-p3 0.103 0.094 0.063))", + }, + }, + "--yellow-3": { + default: "light-dark(#fffab8, #2d2305)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.997 0.982 0.749), color(display-p3 0.168 0.137 0.039))", + }, + }, + "--yellow-4": { + default: "light-dark(#fff394, #362b00)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.992 0.953 0.627), color(display-p3 0.209 0.169 0))", + }, + }, + "--yellow-5": { + default: "light-dark(#ffe770, #433500)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.984 0.91 0.51), color(display-p3 0.255 0.209 0))", + }, + }, + "--yellow-6": { + default: "light-dark(#f3d768, #524202)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.934 0.847 0.474), color(display-p3 0.31 0.261 0.07))", + }, + }, + "--yellow-7": { + default: "light-dark(#e4c767, #665417)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.876 0.785 0.46), color(display-p3 0.389 0.331 0.135))", + }, + }, + "--yellow-8": { + default: "light-dark(#d5ae39, #836a21)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.811 0.689 0.313), color(display-p3 0.497 0.42 0.182))", + }, + }, + "--yellow-9": { + default: "#ffe629", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 1 0.92 0.22)", + }, + }, + "--yellow-10": { + default: "light-dark(#ffdc00, #ffff57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.977 0.868 0.291), color(display-p3 1 1 0.456))", + }, + }, + "--yellow-11": { + default: "light-dark(#9e6c00, #f5e147)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.6 0.44 0), color(display-p3 0.948 0.885 0.392))", + }, + }, + "--yellow-12": { + default: "light-dark(#473b1f, #f6eeb4)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.271 0.233 0.137), color(display-p3 0.959 0.934 0.731))", + }, + }, + "--yellow-a1": { + default: "light-dark(#aaaa0006, #d1510004)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.675 0.675 0.024 / 0.024), color(display-p3 0.973 0.369 0 / 0.013))", + }, + }, + "--yellow-a2": { + default: "light-dark(#f4dd0016, #f9b4000b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.953 0.855 0.008 / 0.079), color(display-p3 0.996 0.792 0 / 0.038))", + }, + }, + "--yellow-a3": { + default: "light-dark(#ffee0047, #ffaa001e)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.988 0.925 0.004 / 0.251), color(display-p3 0.996 0.71 0 / 0.11))", + }, + }, + "--yellow-a4": { + default: "light-dark(#ffe3016b, #fdb70028)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.98 0.875 0.004 / 0.373), color(display-p3 0.996 0.741 0 / 0.152))", + }, + }, + "--yellow-a5": { + default: "light-dark(#ffd5008f, #febb0036)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.969 0.816 0.004 / 0.491), color(display-p3 0.996 0.765 0 / 0.202))", + }, + }, + "--yellow-a6": { + default: "light-dark(#ebbc0097, #fec40046)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.875 0.71 0 / 0.526), color(display-p3 0.996 0.816 0.082 / 0.261))", + }, + }, + "--yellow-a7": { + default: "light-dark(#d2a10098, #fdcb225c)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.769 0.604 0 / 0.542), color(display-p3 1 0.831 0.263 / 0.345))", + }, + }, + "--yellow-a8": { + default: "light-dark(#c99700c6, #fdca327b)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.725 0.549 0 / 0.687), color(display-p3 1 0.831 0.314 / 0.463))", + }, + }, + "--yellow-a9": { + default: "light-dark(#ffe100d6, #ffe629)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 0.898 0 / 0.781), color(display-p3 1 0.922 0.22))", + }, + }, + "--yellow-a10": { + default: "light-dark(#ffdc00, #ffff57)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.969 0.812 0 / 0.71), color(display-p3 1 1 0.455))", + }, + }, + "--yellow-a11": { + default: "light-dark(#9e6c00, #fee949f5)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.6 0.44 0), color(display-p3 0.948 0.885 0.392))", + }, + }, + "--yellow-a12": { + default: "light-dark(#2e2000e0, #fef6baf6)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.271 0.233 0.137), color(display-p3 0.959 0.934 0.731))", + }, + }, + "--yellow-surface": { + default: "light-dark(#fefbe4cc, #231f1380)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.9961 0.9922 0.902 / 0.8), color(display-p3 0.1333 0.1176 0.0706 / 0.5))", + }, + }, + "--yellow-indicator": "light-dark(var(--yellow-10), var(--yellow-9))", + "--yellow-track": + "light-dark(var(--yellow-10), color-mix(in oklab, var(--yellow-8), var(--yellow-9) 65%))", + "--yellow-contrast": "#21201c", +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/amber.js b/packages/reflex-components-ui/js/src/themes/accent/amber.js new file mode 100644 index 00000000000..8b7183d0431 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/amber.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { amber } from "../../colors/amber.stylex.js"; + +export const accentAmber = stylex.createTheme(accent, { + "--accent-1": amber["--amber-1"], + "--accent-2": amber["--amber-2"], + "--accent-3": amber["--amber-3"], + "--accent-4": amber["--amber-4"], + "--accent-5": amber["--amber-5"], + "--accent-6": amber["--amber-6"], + "--accent-7": amber["--amber-7"], + "--accent-8": amber["--amber-8"], + "--accent-9": amber["--amber-9"], + "--accent-10": amber["--amber-10"], + "--accent-11": amber["--amber-11"], + "--accent-12": amber["--amber-12"], + "--accent-a1": amber["--amber-a1"], + "--accent-a2": amber["--amber-a2"], + "--accent-a3": amber["--amber-a3"], + "--accent-a4": amber["--amber-a4"], + "--accent-a5": amber["--amber-a5"], + "--accent-a6": amber["--amber-a6"], + "--accent-a7": amber["--amber-a7"], + "--accent-a8": amber["--amber-a8"], + "--accent-a9": amber["--amber-a9"], + "--accent-a10": amber["--amber-a10"], + "--accent-a11": amber["--amber-a11"], + "--accent-a12": amber["--amber-a12"], + "--accent-contrast": amber["--amber-contrast"], + "--accent-surface": amber["--amber-surface"], + "--accent-indicator": amber["--amber-indicator"], + "--accent-track": amber["--amber-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/blue.js b/packages/reflex-components-ui/js/src/themes/accent/blue.js new file mode 100644 index 00000000000..e03a9285c5c --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/blue.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { blue } from "../../colors/blue.stylex.js"; + +export const accentBlue = stylex.createTheme(accent, { + "--accent-1": blue["--blue-1"], + "--accent-2": blue["--blue-2"], + "--accent-3": blue["--blue-3"], + "--accent-4": blue["--blue-4"], + "--accent-5": blue["--blue-5"], + "--accent-6": blue["--blue-6"], + "--accent-7": blue["--blue-7"], + "--accent-8": blue["--blue-8"], + "--accent-9": blue["--blue-9"], + "--accent-10": blue["--blue-10"], + "--accent-11": blue["--blue-11"], + "--accent-12": blue["--blue-12"], + "--accent-a1": blue["--blue-a1"], + "--accent-a2": blue["--blue-a2"], + "--accent-a3": blue["--blue-a3"], + "--accent-a4": blue["--blue-a4"], + "--accent-a5": blue["--blue-a5"], + "--accent-a6": blue["--blue-a6"], + "--accent-a7": blue["--blue-a7"], + "--accent-a8": blue["--blue-a8"], + "--accent-a9": blue["--blue-a9"], + "--accent-a10": blue["--blue-a10"], + "--accent-a11": blue["--blue-a11"], + "--accent-a12": blue["--blue-a12"], + "--accent-contrast": blue["--blue-contrast"], + "--accent-surface": blue["--blue-surface"], + "--accent-indicator": blue["--blue-indicator"], + "--accent-track": blue["--blue-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/bronze.js b/packages/reflex-components-ui/js/src/themes/accent/bronze.js new file mode 100644 index 00000000000..9bd594d68da --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/bronze.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { bronze } from "../../colors/bronze.stylex.js"; + +export const accentBronze = stylex.createTheme(accent, { + "--accent-1": bronze["--bronze-1"], + "--accent-2": bronze["--bronze-2"], + "--accent-3": bronze["--bronze-3"], + "--accent-4": bronze["--bronze-4"], + "--accent-5": bronze["--bronze-5"], + "--accent-6": bronze["--bronze-6"], + "--accent-7": bronze["--bronze-7"], + "--accent-8": bronze["--bronze-8"], + "--accent-9": bronze["--bronze-9"], + "--accent-10": bronze["--bronze-10"], + "--accent-11": bronze["--bronze-11"], + "--accent-12": bronze["--bronze-12"], + "--accent-a1": bronze["--bronze-a1"], + "--accent-a2": bronze["--bronze-a2"], + "--accent-a3": bronze["--bronze-a3"], + "--accent-a4": bronze["--bronze-a4"], + "--accent-a5": bronze["--bronze-a5"], + "--accent-a6": bronze["--bronze-a6"], + "--accent-a7": bronze["--bronze-a7"], + "--accent-a8": bronze["--bronze-a8"], + "--accent-a9": bronze["--bronze-a9"], + "--accent-a10": bronze["--bronze-a10"], + "--accent-a11": bronze["--bronze-a11"], + "--accent-a12": bronze["--bronze-a12"], + "--accent-contrast": bronze["--bronze-contrast"], + "--accent-surface": bronze["--bronze-surface"], + "--accent-indicator": bronze["--bronze-indicator"], + "--accent-track": bronze["--bronze-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/brown.js b/packages/reflex-components-ui/js/src/themes/accent/brown.js new file mode 100644 index 00000000000..a933aeda0e0 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/brown.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { brown } from "../../colors/brown.stylex.js"; + +export const accentBrown = stylex.createTheme(accent, { + "--accent-1": brown["--brown-1"], + "--accent-2": brown["--brown-2"], + "--accent-3": brown["--brown-3"], + "--accent-4": brown["--brown-4"], + "--accent-5": brown["--brown-5"], + "--accent-6": brown["--brown-6"], + "--accent-7": brown["--brown-7"], + "--accent-8": brown["--brown-8"], + "--accent-9": brown["--brown-9"], + "--accent-10": brown["--brown-10"], + "--accent-11": brown["--brown-11"], + "--accent-12": brown["--brown-12"], + "--accent-a1": brown["--brown-a1"], + "--accent-a2": brown["--brown-a2"], + "--accent-a3": brown["--brown-a3"], + "--accent-a4": brown["--brown-a4"], + "--accent-a5": brown["--brown-a5"], + "--accent-a6": brown["--brown-a6"], + "--accent-a7": brown["--brown-a7"], + "--accent-a8": brown["--brown-a8"], + "--accent-a9": brown["--brown-a9"], + "--accent-a10": brown["--brown-a10"], + "--accent-a11": brown["--brown-a11"], + "--accent-a12": brown["--brown-a12"], + "--accent-contrast": brown["--brown-contrast"], + "--accent-surface": brown["--brown-surface"], + "--accent-indicator": brown["--brown-indicator"], + "--accent-track": brown["--brown-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/crimson.js b/packages/reflex-components-ui/js/src/themes/accent/crimson.js new file mode 100644 index 00000000000..816043536de --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/crimson.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { crimson } from "../../colors/crimson.stylex.js"; + +export const accentCrimson = stylex.createTheme(accent, { + "--accent-1": crimson["--crimson-1"], + "--accent-2": crimson["--crimson-2"], + "--accent-3": crimson["--crimson-3"], + "--accent-4": crimson["--crimson-4"], + "--accent-5": crimson["--crimson-5"], + "--accent-6": crimson["--crimson-6"], + "--accent-7": crimson["--crimson-7"], + "--accent-8": crimson["--crimson-8"], + "--accent-9": crimson["--crimson-9"], + "--accent-10": crimson["--crimson-10"], + "--accent-11": crimson["--crimson-11"], + "--accent-12": crimson["--crimson-12"], + "--accent-a1": crimson["--crimson-a1"], + "--accent-a2": crimson["--crimson-a2"], + "--accent-a3": crimson["--crimson-a3"], + "--accent-a4": crimson["--crimson-a4"], + "--accent-a5": crimson["--crimson-a5"], + "--accent-a6": crimson["--crimson-a6"], + "--accent-a7": crimson["--crimson-a7"], + "--accent-a8": crimson["--crimson-a8"], + "--accent-a9": crimson["--crimson-a9"], + "--accent-a10": crimson["--crimson-a10"], + "--accent-a11": crimson["--crimson-a11"], + "--accent-a12": crimson["--crimson-a12"], + "--accent-contrast": crimson["--crimson-contrast"], + "--accent-surface": crimson["--crimson-surface"], + "--accent-indicator": crimson["--crimson-indicator"], + "--accent-track": crimson["--crimson-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/cyan.js b/packages/reflex-components-ui/js/src/themes/accent/cyan.js new file mode 100644 index 00000000000..830edeb79d8 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/cyan.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { cyan } from "../../colors/cyan.stylex.js"; + +export const accentCyan = stylex.createTheme(accent, { + "--accent-1": cyan["--cyan-1"], + "--accent-2": cyan["--cyan-2"], + "--accent-3": cyan["--cyan-3"], + "--accent-4": cyan["--cyan-4"], + "--accent-5": cyan["--cyan-5"], + "--accent-6": cyan["--cyan-6"], + "--accent-7": cyan["--cyan-7"], + "--accent-8": cyan["--cyan-8"], + "--accent-9": cyan["--cyan-9"], + "--accent-10": cyan["--cyan-10"], + "--accent-11": cyan["--cyan-11"], + "--accent-12": cyan["--cyan-12"], + "--accent-a1": cyan["--cyan-a1"], + "--accent-a2": cyan["--cyan-a2"], + "--accent-a3": cyan["--cyan-a3"], + "--accent-a4": cyan["--cyan-a4"], + "--accent-a5": cyan["--cyan-a5"], + "--accent-a6": cyan["--cyan-a6"], + "--accent-a7": cyan["--cyan-a7"], + "--accent-a8": cyan["--cyan-a8"], + "--accent-a9": cyan["--cyan-a9"], + "--accent-a10": cyan["--cyan-a10"], + "--accent-a11": cyan["--cyan-a11"], + "--accent-a12": cyan["--cyan-a12"], + "--accent-contrast": cyan["--cyan-contrast"], + "--accent-surface": cyan["--cyan-surface"], + "--accent-indicator": cyan["--cyan-indicator"], + "--accent-track": cyan["--cyan-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/gold.js b/packages/reflex-components-ui/js/src/themes/accent/gold.js new file mode 100644 index 00000000000..55b50db820b --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/gold.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { gold } from "../../colors/gold.stylex.js"; + +export const accentGold = stylex.createTheme(accent, { + "--accent-1": gold["--gold-1"], + "--accent-2": gold["--gold-2"], + "--accent-3": gold["--gold-3"], + "--accent-4": gold["--gold-4"], + "--accent-5": gold["--gold-5"], + "--accent-6": gold["--gold-6"], + "--accent-7": gold["--gold-7"], + "--accent-8": gold["--gold-8"], + "--accent-9": gold["--gold-9"], + "--accent-10": gold["--gold-10"], + "--accent-11": gold["--gold-11"], + "--accent-12": gold["--gold-12"], + "--accent-a1": gold["--gold-a1"], + "--accent-a2": gold["--gold-a2"], + "--accent-a3": gold["--gold-a3"], + "--accent-a4": gold["--gold-a4"], + "--accent-a5": gold["--gold-a5"], + "--accent-a6": gold["--gold-a6"], + "--accent-a7": gold["--gold-a7"], + "--accent-a8": gold["--gold-a8"], + "--accent-a9": gold["--gold-a9"], + "--accent-a10": gold["--gold-a10"], + "--accent-a11": gold["--gold-a11"], + "--accent-a12": gold["--gold-a12"], + "--accent-contrast": gold["--gold-contrast"], + "--accent-surface": gold["--gold-surface"], + "--accent-indicator": gold["--gold-indicator"], + "--accent-track": gold["--gold-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/grass.js b/packages/reflex-components-ui/js/src/themes/accent/grass.js new file mode 100644 index 00000000000..8da8cc7db75 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/grass.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { grass } from "../../colors/grass.stylex.js"; + +export const accentGrass = stylex.createTheme(accent, { + "--accent-1": grass["--grass-1"], + "--accent-2": grass["--grass-2"], + "--accent-3": grass["--grass-3"], + "--accent-4": grass["--grass-4"], + "--accent-5": grass["--grass-5"], + "--accent-6": grass["--grass-6"], + "--accent-7": grass["--grass-7"], + "--accent-8": grass["--grass-8"], + "--accent-9": grass["--grass-9"], + "--accent-10": grass["--grass-10"], + "--accent-11": grass["--grass-11"], + "--accent-12": grass["--grass-12"], + "--accent-a1": grass["--grass-a1"], + "--accent-a2": grass["--grass-a2"], + "--accent-a3": grass["--grass-a3"], + "--accent-a4": grass["--grass-a4"], + "--accent-a5": grass["--grass-a5"], + "--accent-a6": grass["--grass-a6"], + "--accent-a7": grass["--grass-a7"], + "--accent-a8": grass["--grass-a8"], + "--accent-a9": grass["--grass-a9"], + "--accent-a10": grass["--grass-a10"], + "--accent-a11": grass["--grass-a11"], + "--accent-a12": grass["--grass-a12"], + "--accent-contrast": grass["--grass-contrast"], + "--accent-surface": grass["--grass-surface"], + "--accent-indicator": grass["--grass-indicator"], + "--accent-track": grass["--grass-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/gray.js b/packages/reflex-components-ui/js/src/themes/accent/gray.js new file mode 100644 index 00000000000..b5ec90d2c36 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/gray.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { gray } from "../../tokens/gray.stylex.js"; + +export const accentGray = stylex.createTheme(accent, { + "--accent-1": gray["--gray-1"], + "--accent-2": gray["--gray-2"], + "--accent-3": gray["--gray-3"], + "--accent-4": gray["--gray-4"], + "--accent-5": gray["--gray-5"], + "--accent-6": gray["--gray-6"], + "--accent-7": gray["--gray-7"], + "--accent-8": gray["--gray-8"], + "--accent-9": gray["--gray-9"], + "--accent-10": gray["--gray-10"], + "--accent-11": gray["--gray-11"], + "--accent-12": gray["--gray-12"], + "--accent-a1": gray["--gray-a1"], + "--accent-a2": gray["--gray-a2"], + "--accent-a3": gray["--gray-a3"], + "--accent-a4": gray["--gray-a4"], + "--accent-a5": gray["--gray-a5"], + "--accent-a6": gray["--gray-a6"], + "--accent-a7": gray["--gray-a7"], + "--accent-a8": gray["--gray-a8"], + "--accent-a9": gray["--gray-a9"], + "--accent-a10": gray["--gray-a10"], + "--accent-a11": gray["--gray-a11"], + "--accent-a12": gray["--gray-a12"], + "--accent-contrast": gray["--gray-contrast"], + "--accent-surface": gray["--gray-surface"], + "--accent-indicator": gray["--gray-indicator"], + "--accent-track": gray["--gray-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/green.js b/packages/reflex-components-ui/js/src/themes/accent/green.js new file mode 100644 index 00000000000..63028e6e3b5 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/green.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { green } from "../../colors/green.stylex.js"; + +export const accentGreen = stylex.createTheme(accent, { + "--accent-1": green["--green-1"], + "--accent-2": green["--green-2"], + "--accent-3": green["--green-3"], + "--accent-4": green["--green-4"], + "--accent-5": green["--green-5"], + "--accent-6": green["--green-6"], + "--accent-7": green["--green-7"], + "--accent-8": green["--green-8"], + "--accent-9": green["--green-9"], + "--accent-10": green["--green-10"], + "--accent-11": green["--green-11"], + "--accent-12": green["--green-12"], + "--accent-a1": green["--green-a1"], + "--accent-a2": green["--green-a2"], + "--accent-a3": green["--green-a3"], + "--accent-a4": green["--green-a4"], + "--accent-a5": green["--green-a5"], + "--accent-a6": green["--green-a6"], + "--accent-a7": green["--green-a7"], + "--accent-a8": green["--green-a8"], + "--accent-a9": green["--green-a9"], + "--accent-a10": green["--green-a10"], + "--accent-a11": green["--green-a11"], + "--accent-a12": green["--green-a12"], + "--accent-contrast": green["--green-contrast"], + "--accent-surface": green["--green-surface"], + "--accent-indicator": green["--green-indicator"], + "--accent-track": green["--green-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/indigo.js b/packages/reflex-components-ui/js/src/themes/accent/indigo.js new file mode 100644 index 00000000000..067bf28ee60 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/indigo.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { indigo } from "../../colors/indigo.stylex.js"; + +export const accentIndigo = stylex.createTheme(accent, { + "--accent-1": indigo["--indigo-1"], + "--accent-2": indigo["--indigo-2"], + "--accent-3": indigo["--indigo-3"], + "--accent-4": indigo["--indigo-4"], + "--accent-5": indigo["--indigo-5"], + "--accent-6": indigo["--indigo-6"], + "--accent-7": indigo["--indigo-7"], + "--accent-8": indigo["--indigo-8"], + "--accent-9": indigo["--indigo-9"], + "--accent-10": indigo["--indigo-10"], + "--accent-11": indigo["--indigo-11"], + "--accent-12": indigo["--indigo-12"], + "--accent-a1": indigo["--indigo-a1"], + "--accent-a2": indigo["--indigo-a2"], + "--accent-a3": indigo["--indigo-a3"], + "--accent-a4": indigo["--indigo-a4"], + "--accent-a5": indigo["--indigo-a5"], + "--accent-a6": indigo["--indigo-a6"], + "--accent-a7": indigo["--indigo-a7"], + "--accent-a8": indigo["--indigo-a8"], + "--accent-a9": indigo["--indigo-a9"], + "--accent-a10": indigo["--indigo-a10"], + "--accent-a11": indigo["--indigo-a11"], + "--accent-a12": indigo["--indigo-a12"], + "--accent-contrast": indigo["--indigo-contrast"], + "--accent-surface": indigo["--indigo-surface"], + "--accent-indicator": indigo["--indigo-indicator"], + "--accent-track": indigo["--indigo-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/iris.js b/packages/reflex-components-ui/js/src/themes/accent/iris.js new file mode 100644 index 00000000000..3533d30ada6 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/iris.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { iris } from "../../colors/iris.stylex.js"; + +export const accentIris = stylex.createTheme(accent, { + "--accent-1": iris["--iris-1"], + "--accent-2": iris["--iris-2"], + "--accent-3": iris["--iris-3"], + "--accent-4": iris["--iris-4"], + "--accent-5": iris["--iris-5"], + "--accent-6": iris["--iris-6"], + "--accent-7": iris["--iris-7"], + "--accent-8": iris["--iris-8"], + "--accent-9": iris["--iris-9"], + "--accent-10": iris["--iris-10"], + "--accent-11": iris["--iris-11"], + "--accent-12": iris["--iris-12"], + "--accent-a1": iris["--iris-a1"], + "--accent-a2": iris["--iris-a2"], + "--accent-a3": iris["--iris-a3"], + "--accent-a4": iris["--iris-a4"], + "--accent-a5": iris["--iris-a5"], + "--accent-a6": iris["--iris-a6"], + "--accent-a7": iris["--iris-a7"], + "--accent-a8": iris["--iris-a8"], + "--accent-a9": iris["--iris-a9"], + "--accent-a10": iris["--iris-a10"], + "--accent-a11": iris["--iris-a11"], + "--accent-a12": iris["--iris-a12"], + "--accent-contrast": iris["--iris-contrast"], + "--accent-surface": iris["--iris-surface"], + "--accent-indicator": iris["--iris-indicator"], + "--accent-track": iris["--iris-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/jade.js b/packages/reflex-components-ui/js/src/themes/accent/jade.js new file mode 100644 index 00000000000..a40749f03bf --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/jade.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { jade } from "../../colors/jade.stylex.js"; + +export const accentJade = stylex.createTheme(accent, { + "--accent-1": jade["--jade-1"], + "--accent-2": jade["--jade-2"], + "--accent-3": jade["--jade-3"], + "--accent-4": jade["--jade-4"], + "--accent-5": jade["--jade-5"], + "--accent-6": jade["--jade-6"], + "--accent-7": jade["--jade-7"], + "--accent-8": jade["--jade-8"], + "--accent-9": jade["--jade-9"], + "--accent-10": jade["--jade-10"], + "--accent-11": jade["--jade-11"], + "--accent-12": jade["--jade-12"], + "--accent-a1": jade["--jade-a1"], + "--accent-a2": jade["--jade-a2"], + "--accent-a3": jade["--jade-a3"], + "--accent-a4": jade["--jade-a4"], + "--accent-a5": jade["--jade-a5"], + "--accent-a6": jade["--jade-a6"], + "--accent-a7": jade["--jade-a7"], + "--accent-a8": jade["--jade-a8"], + "--accent-a9": jade["--jade-a9"], + "--accent-a10": jade["--jade-a10"], + "--accent-a11": jade["--jade-a11"], + "--accent-a12": jade["--jade-a12"], + "--accent-contrast": jade["--jade-contrast"], + "--accent-surface": jade["--jade-surface"], + "--accent-indicator": jade["--jade-indicator"], + "--accent-track": jade["--jade-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/lime.js b/packages/reflex-components-ui/js/src/themes/accent/lime.js new file mode 100644 index 00000000000..e0388650f91 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/lime.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { lime } from "../../colors/lime.stylex.js"; + +export const accentLime = stylex.createTheme(accent, { + "--accent-1": lime["--lime-1"], + "--accent-2": lime["--lime-2"], + "--accent-3": lime["--lime-3"], + "--accent-4": lime["--lime-4"], + "--accent-5": lime["--lime-5"], + "--accent-6": lime["--lime-6"], + "--accent-7": lime["--lime-7"], + "--accent-8": lime["--lime-8"], + "--accent-9": lime["--lime-9"], + "--accent-10": lime["--lime-10"], + "--accent-11": lime["--lime-11"], + "--accent-12": lime["--lime-12"], + "--accent-a1": lime["--lime-a1"], + "--accent-a2": lime["--lime-a2"], + "--accent-a3": lime["--lime-a3"], + "--accent-a4": lime["--lime-a4"], + "--accent-a5": lime["--lime-a5"], + "--accent-a6": lime["--lime-a6"], + "--accent-a7": lime["--lime-a7"], + "--accent-a8": lime["--lime-a8"], + "--accent-a9": lime["--lime-a9"], + "--accent-a10": lime["--lime-a10"], + "--accent-a11": lime["--lime-a11"], + "--accent-a12": lime["--lime-a12"], + "--accent-contrast": lime["--lime-contrast"], + "--accent-surface": lime["--lime-surface"], + "--accent-indicator": lime["--lime-indicator"], + "--accent-track": lime["--lime-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/mint.js b/packages/reflex-components-ui/js/src/themes/accent/mint.js new file mode 100644 index 00000000000..54fbdae09d1 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/mint.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { mint } from "../../colors/mint.stylex.js"; + +export const accentMint = stylex.createTheme(accent, { + "--accent-1": mint["--mint-1"], + "--accent-2": mint["--mint-2"], + "--accent-3": mint["--mint-3"], + "--accent-4": mint["--mint-4"], + "--accent-5": mint["--mint-5"], + "--accent-6": mint["--mint-6"], + "--accent-7": mint["--mint-7"], + "--accent-8": mint["--mint-8"], + "--accent-9": mint["--mint-9"], + "--accent-10": mint["--mint-10"], + "--accent-11": mint["--mint-11"], + "--accent-12": mint["--mint-12"], + "--accent-a1": mint["--mint-a1"], + "--accent-a2": mint["--mint-a2"], + "--accent-a3": mint["--mint-a3"], + "--accent-a4": mint["--mint-a4"], + "--accent-a5": mint["--mint-a5"], + "--accent-a6": mint["--mint-a6"], + "--accent-a7": mint["--mint-a7"], + "--accent-a8": mint["--mint-a8"], + "--accent-a9": mint["--mint-a9"], + "--accent-a10": mint["--mint-a10"], + "--accent-a11": mint["--mint-a11"], + "--accent-a12": mint["--mint-a12"], + "--accent-contrast": mint["--mint-contrast"], + "--accent-surface": mint["--mint-surface"], + "--accent-indicator": mint["--mint-indicator"], + "--accent-track": mint["--mint-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/orange.js b/packages/reflex-components-ui/js/src/themes/accent/orange.js new file mode 100644 index 00000000000..8ab839d8138 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/orange.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { orange } from "../../colors/orange.stylex.js"; + +export const accentOrange = stylex.createTheme(accent, { + "--accent-1": orange["--orange-1"], + "--accent-2": orange["--orange-2"], + "--accent-3": orange["--orange-3"], + "--accent-4": orange["--orange-4"], + "--accent-5": orange["--orange-5"], + "--accent-6": orange["--orange-6"], + "--accent-7": orange["--orange-7"], + "--accent-8": orange["--orange-8"], + "--accent-9": orange["--orange-9"], + "--accent-10": orange["--orange-10"], + "--accent-11": orange["--orange-11"], + "--accent-12": orange["--orange-12"], + "--accent-a1": orange["--orange-a1"], + "--accent-a2": orange["--orange-a2"], + "--accent-a3": orange["--orange-a3"], + "--accent-a4": orange["--orange-a4"], + "--accent-a5": orange["--orange-a5"], + "--accent-a6": orange["--orange-a6"], + "--accent-a7": orange["--orange-a7"], + "--accent-a8": orange["--orange-a8"], + "--accent-a9": orange["--orange-a9"], + "--accent-a10": orange["--orange-a10"], + "--accent-a11": orange["--orange-a11"], + "--accent-a12": orange["--orange-a12"], + "--accent-contrast": orange["--orange-contrast"], + "--accent-surface": orange["--orange-surface"], + "--accent-indicator": orange["--orange-indicator"], + "--accent-track": orange["--orange-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/pink.js b/packages/reflex-components-ui/js/src/themes/accent/pink.js new file mode 100644 index 00000000000..02c4a8f48e0 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/pink.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { pink } from "../../colors/pink.stylex.js"; + +export const accentPink = stylex.createTheme(accent, { + "--accent-1": pink["--pink-1"], + "--accent-2": pink["--pink-2"], + "--accent-3": pink["--pink-3"], + "--accent-4": pink["--pink-4"], + "--accent-5": pink["--pink-5"], + "--accent-6": pink["--pink-6"], + "--accent-7": pink["--pink-7"], + "--accent-8": pink["--pink-8"], + "--accent-9": pink["--pink-9"], + "--accent-10": pink["--pink-10"], + "--accent-11": pink["--pink-11"], + "--accent-12": pink["--pink-12"], + "--accent-a1": pink["--pink-a1"], + "--accent-a2": pink["--pink-a2"], + "--accent-a3": pink["--pink-a3"], + "--accent-a4": pink["--pink-a4"], + "--accent-a5": pink["--pink-a5"], + "--accent-a6": pink["--pink-a6"], + "--accent-a7": pink["--pink-a7"], + "--accent-a8": pink["--pink-a8"], + "--accent-a9": pink["--pink-a9"], + "--accent-a10": pink["--pink-a10"], + "--accent-a11": pink["--pink-a11"], + "--accent-a12": pink["--pink-a12"], + "--accent-contrast": pink["--pink-contrast"], + "--accent-surface": pink["--pink-surface"], + "--accent-indicator": pink["--pink-indicator"], + "--accent-track": pink["--pink-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/plum.js b/packages/reflex-components-ui/js/src/themes/accent/plum.js new file mode 100644 index 00000000000..5494f737394 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/plum.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { plum } from "../../colors/plum.stylex.js"; + +export const accentPlum = stylex.createTheme(accent, { + "--accent-1": plum["--plum-1"], + "--accent-2": plum["--plum-2"], + "--accent-3": plum["--plum-3"], + "--accent-4": plum["--plum-4"], + "--accent-5": plum["--plum-5"], + "--accent-6": plum["--plum-6"], + "--accent-7": plum["--plum-7"], + "--accent-8": plum["--plum-8"], + "--accent-9": plum["--plum-9"], + "--accent-10": plum["--plum-10"], + "--accent-11": plum["--plum-11"], + "--accent-12": plum["--plum-12"], + "--accent-a1": plum["--plum-a1"], + "--accent-a2": plum["--plum-a2"], + "--accent-a3": plum["--plum-a3"], + "--accent-a4": plum["--plum-a4"], + "--accent-a5": plum["--plum-a5"], + "--accent-a6": plum["--plum-a6"], + "--accent-a7": plum["--plum-a7"], + "--accent-a8": plum["--plum-a8"], + "--accent-a9": plum["--plum-a9"], + "--accent-a10": plum["--plum-a10"], + "--accent-a11": plum["--plum-a11"], + "--accent-a12": plum["--plum-a12"], + "--accent-contrast": plum["--plum-contrast"], + "--accent-surface": plum["--plum-surface"], + "--accent-indicator": plum["--plum-indicator"], + "--accent-track": plum["--plum-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/purple.js b/packages/reflex-components-ui/js/src/themes/accent/purple.js new file mode 100644 index 00000000000..65346307631 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/purple.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { purple } from "../../colors/purple.stylex.js"; + +export const accentPurple = stylex.createTheme(accent, { + "--accent-1": purple["--purple-1"], + "--accent-2": purple["--purple-2"], + "--accent-3": purple["--purple-3"], + "--accent-4": purple["--purple-4"], + "--accent-5": purple["--purple-5"], + "--accent-6": purple["--purple-6"], + "--accent-7": purple["--purple-7"], + "--accent-8": purple["--purple-8"], + "--accent-9": purple["--purple-9"], + "--accent-10": purple["--purple-10"], + "--accent-11": purple["--purple-11"], + "--accent-12": purple["--purple-12"], + "--accent-a1": purple["--purple-a1"], + "--accent-a2": purple["--purple-a2"], + "--accent-a3": purple["--purple-a3"], + "--accent-a4": purple["--purple-a4"], + "--accent-a5": purple["--purple-a5"], + "--accent-a6": purple["--purple-a6"], + "--accent-a7": purple["--purple-a7"], + "--accent-a8": purple["--purple-a8"], + "--accent-a9": purple["--purple-a9"], + "--accent-a10": purple["--purple-a10"], + "--accent-a11": purple["--purple-a11"], + "--accent-a12": purple["--purple-a12"], + "--accent-contrast": purple["--purple-contrast"], + "--accent-surface": purple["--purple-surface"], + "--accent-indicator": purple["--purple-indicator"], + "--accent-track": purple["--purple-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/red.js b/packages/reflex-components-ui/js/src/themes/accent/red.js new file mode 100644 index 00000000000..a68687d391d --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/red.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { red } from "../../colors/red.stylex.js"; + +export const accentRed = stylex.createTheme(accent, { + "--accent-1": red["--red-1"], + "--accent-2": red["--red-2"], + "--accent-3": red["--red-3"], + "--accent-4": red["--red-4"], + "--accent-5": red["--red-5"], + "--accent-6": red["--red-6"], + "--accent-7": red["--red-7"], + "--accent-8": red["--red-8"], + "--accent-9": red["--red-9"], + "--accent-10": red["--red-10"], + "--accent-11": red["--red-11"], + "--accent-12": red["--red-12"], + "--accent-a1": red["--red-a1"], + "--accent-a2": red["--red-a2"], + "--accent-a3": red["--red-a3"], + "--accent-a4": red["--red-a4"], + "--accent-a5": red["--red-a5"], + "--accent-a6": red["--red-a6"], + "--accent-a7": red["--red-a7"], + "--accent-a8": red["--red-a8"], + "--accent-a9": red["--red-a9"], + "--accent-a10": red["--red-a10"], + "--accent-a11": red["--red-a11"], + "--accent-a12": red["--red-a12"], + "--accent-contrast": red["--red-contrast"], + "--accent-surface": red["--red-surface"], + "--accent-indicator": red["--red-indicator"], + "--accent-track": red["--red-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/ruby.js b/packages/reflex-components-ui/js/src/themes/accent/ruby.js new file mode 100644 index 00000000000..f5216066959 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/ruby.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { ruby } from "../../colors/ruby.stylex.js"; + +export const accentRuby = stylex.createTheme(accent, { + "--accent-1": ruby["--ruby-1"], + "--accent-2": ruby["--ruby-2"], + "--accent-3": ruby["--ruby-3"], + "--accent-4": ruby["--ruby-4"], + "--accent-5": ruby["--ruby-5"], + "--accent-6": ruby["--ruby-6"], + "--accent-7": ruby["--ruby-7"], + "--accent-8": ruby["--ruby-8"], + "--accent-9": ruby["--ruby-9"], + "--accent-10": ruby["--ruby-10"], + "--accent-11": ruby["--ruby-11"], + "--accent-12": ruby["--ruby-12"], + "--accent-a1": ruby["--ruby-a1"], + "--accent-a2": ruby["--ruby-a2"], + "--accent-a3": ruby["--ruby-a3"], + "--accent-a4": ruby["--ruby-a4"], + "--accent-a5": ruby["--ruby-a5"], + "--accent-a6": ruby["--ruby-a6"], + "--accent-a7": ruby["--ruby-a7"], + "--accent-a8": ruby["--ruby-a8"], + "--accent-a9": ruby["--ruby-a9"], + "--accent-a10": ruby["--ruby-a10"], + "--accent-a11": ruby["--ruby-a11"], + "--accent-a12": ruby["--ruby-a12"], + "--accent-contrast": ruby["--ruby-contrast"], + "--accent-surface": ruby["--ruby-surface"], + "--accent-indicator": ruby["--ruby-indicator"], + "--accent-track": ruby["--ruby-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/sky.js b/packages/reflex-components-ui/js/src/themes/accent/sky.js new file mode 100644 index 00000000000..3f2c0179c71 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/sky.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { sky } from "../../colors/sky.stylex.js"; + +export const accentSky = stylex.createTheme(accent, { + "--accent-1": sky["--sky-1"], + "--accent-2": sky["--sky-2"], + "--accent-3": sky["--sky-3"], + "--accent-4": sky["--sky-4"], + "--accent-5": sky["--sky-5"], + "--accent-6": sky["--sky-6"], + "--accent-7": sky["--sky-7"], + "--accent-8": sky["--sky-8"], + "--accent-9": sky["--sky-9"], + "--accent-10": sky["--sky-10"], + "--accent-11": sky["--sky-11"], + "--accent-12": sky["--sky-12"], + "--accent-a1": sky["--sky-a1"], + "--accent-a2": sky["--sky-a2"], + "--accent-a3": sky["--sky-a3"], + "--accent-a4": sky["--sky-a4"], + "--accent-a5": sky["--sky-a5"], + "--accent-a6": sky["--sky-a6"], + "--accent-a7": sky["--sky-a7"], + "--accent-a8": sky["--sky-a8"], + "--accent-a9": sky["--sky-a9"], + "--accent-a10": sky["--sky-a10"], + "--accent-a11": sky["--sky-a11"], + "--accent-a12": sky["--sky-a12"], + "--accent-contrast": sky["--sky-contrast"], + "--accent-surface": sky["--sky-surface"], + "--accent-indicator": sky["--sky-indicator"], + "--accent-track": sky["--sky-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/teal.js b/packages/reflex-components-ui/js/src/themes/accent/teal.js new file mode 100644 index 00000000000..de7dc6e3fdb --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/teal.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { teal } from "../../colors/teal.stylex.js"; + +export const accentTeal = stylex.createTheme(accent, { + "--accent-1": teal["--teal-1"], + "--accent-2": teal["--teal-2"], + "--accent-3": teal["--teal-3"], + "--accent-4": teal["--teal-4"], + "--accent-5": teal["--teal-5"], + "--accent-6": teal["--teal-6"], + "--accent-7": teal["--teal-7"], + "--accent-8": teal["--teal-8"], + "--accent-9": teal["--teal-9"], + "--accent-10": teal["--teal-10"], + "--accent-11": teal["--teal-11"], + "--accent-12": teal["--teal-12"], + "--accent-a1": teal["--teal-a1"], + "--accent-a2": teal["--teal-a2"], + "--accent-a3": teal["--teal-a3"], + "--accent-a4": teal["--teal-a4"], + "--accent-a5": teal["--teal-a5"], + "--accent-a6": teal["--teal-a6"], + "--accent-a7": teal["--teal-a7"], + "--accent-a8": teal["--teal-a8"], + "--accent-a9": teal["--teal-a9"], + "--accent-a10": teal["--teal-a10"], + "--accent-a11": teal["--teal-a11"], + "--accent-a12": teal["--teal-a12"], + "--accent-contrast": teal["--teal-contrast"], + "--accent-surface": teal["--teal-surface"], + "--accent-indicator": teal["--teal-indicator"], + "--accent-track": teal["--teal-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/tomato.js b/packages/reflex-components-ui/js/src/themes/accent/tomato.js new file mode 100644 index 00000000000..ea55b8075c7 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/tomato.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { tomato } from "../../colors/tomato.stylex.js"; + +export const accentTomato = stylex.createTheme(accent, { + "--accent-1": tomato["--tomato-1"], + "--accent-2": tomato["--tomato-2"], + "--accent-3": tomato["--tomato-3"], + "--accent-4": tomato["--tomato-4"], + "--accent-5": tomato["--tomato-5"], + "--accent-6": tomato["--tomato-6"], + "--accent-7": tomato["--tomato-7"], + "--accent-8": tomato["--tomato-8"], + "--accent-9": tomato["--tomato-9"], + "--accent-10": tomato["--tomato-10"], + "--accent-11": tomato["--tomato-11"], + "--accent-12": tomato["--tomato-12"], + "--accent-a1": tomato["--tomato-a1"], + "--accent-a2": tomato["--tomato-a2"], + "--accent-a3": tomato["--tomato-a3"], + "--accent-a4": tomato["--tomato-a4"], + "--accent-a5": tomato["--tomato-a5"], + "--accent-a6": tomato["--tomato-a6"], + "--accent-a7": tomato["--tomato-a7"], + "--accent-a8": tomato["--tomato-a8"], + "--accent-a9": tomato["--tomato-a9"], + "--accent-a10": tomato["--tomato-a10"], + "--accent-a11": tomato["--tomato-a11"], + "--accent-a12": tomato["--tomato-a12"], + "--accent-contrast": tomato["--tomato-contrast"], + "--accent-surface": tomato["--tomato-surface"], + "--accent-indicator": tomato["--tomato-indicator"], + "--accent-track": tomato["--tomato-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/violet.js b/packages/reflex-components-ui/js/src/themes/accent/violet.js new file mode 100644 index 00000000000..8802b28994b --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/violet.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { violet } from "../../colors/violet.stylex.js"; + +export const accentViolet = stylex.createTheme(accent, { + "--accent-1": violet["--violet-1"], + "--accent-2": violet["--violet-2"], + "--accent-3": violet["--violet-3"], + "--accent-4": violet["--violet-4"], + "--accent-5": violet["--violet-5"], + "--accent-6": violet["--violet-6"], + "--accent-7": violet["--violet-7"], + "--accent-8": violet["--violet-8"], + "--accent-9": violet["--violet-9"], + "--accent-10": violet["--violet-10"], + "--accent-11": violet["--violet-11"], + "--accent-12": violet["--violet-12"], + "--accent-a1": violet["--violet-a1"], + "--accent-a2": violet["--violet-a2"], + "--accent-a3": violet["--violet-a3"], + "--accent-a4": violet["--violet-a4"], + "--accent-a5": violet["--violet-a5"], + "--accent-a6": violet["--violet-a6"], + "--accent-a7": violet["--violet-a7"], + "--accent-a8": violet["--violet-a8"], + "--accent-a9": violet["--violet-a9"], + "--accent-a10": violet["--violet-a10"], + "--accent-a11": violet["--violet-a11"], + "--accent-a12": violet["--violet-a12"], + "--accent-contrast": violet["--violet-contrast"], + "--accent-surface": violet["--violet-surface"], + "--accent-indicator": violet["--violet-indicator"], + "--accent-track": violet["--violet-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/accent/yellow.js b/packages/reflex-components-ui/js/src/themes/accent/yellow.js new file mode 100644 index 00000000000..940747c2443 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/accent/yellow.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { yellow } from "../../colors/yellow.stylex.js"; + +export const accentYellow = stylex.createTheme(accent, { + "--accent-1": yellow["--yellow-1"], + "--accent-2": yellow["--yellow-2"], + "--accent-3": yellow["--yellow-3"], + "--accent-4": yellow["--yellow-4"], + "--accent-5": yellow["--yellow-5"], + "--accent-6": yellow["--yellow-6"], + "--accent-7": yellow["--yellow-7"], + "--accent-8": yellow["--yellow-8"], + "--accent-9": yellow["--yellow-9"], + "--accent-10": yellow["--yellow-10"], + "--accent-11": yellow["--yellow-11"], + "--accent-12": yellow["--yellow-12"], + "--accent-a1": yellow["--yellow-a1"], + "--accent-a2": yellow["--yellow-a2"], + "--accent-a3": yellow["--yellow-a3"], + "--accent-a4": yellow["--yellow-a4"], + "--accent-a5": yellow["--yellow-a5"], + "--accent-a6": yellow["--yellow-a6"], + "--accent-a7": yellow["--yellow-a7"], + "--accent-a8": yellow["--yellow-a8"], + "--accent-a9": yellow["--yellow-a9"], + "--accent-a10": yellow["--yellow-a10"], + "--accent-a11": yellow["--yellow-a11"], + "--accent-a12": yellow["--yellow-a12"], + "--accent-contrast": yellow["--yellow-contrast"], + "--accent-surface": yellow["--yellow-surface"], + "--accent-indicator": yellow["--yellow-indicator"], + "--accent-track": yellow["--yellow-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/focus.js b/packages/reflex-components-ui/js/src/themes/focus.js new file mode 100644 index 00000000000..c9ce54c90b7 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/focus.js @@ -0,0 +1,7 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { focus } from "../tokens/focus.stylex.js"; + +export const focusScope = stylex.createTheme(focus, {}); diff --git a/packages/reflex-components-ui/js/src/themes/gray/gray.js b/packages/reflex-components-ui/js/src/themes/gray/gray.js new file mode 100644 index 00000000000..d2e24215df3 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/gray/gray.js @@ -0,0 +1,215 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; + +// StyleX leaves a null level out, which the type of a string token does +// not say. +const NONE = /** @type {string} */ (/** @type {unknown} */ (null)); + +export const grayGray = stylex.createTheme(gray, { + "--gray-1": { + default: "light-dark(#fcfcfc, #111111)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.988 0.988 0.988), color(display-p3 0.067 0.067 0.067))", + }, + }, + "--gray-2": { + default: "light-dark(#f9f9f9, #191919)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.975 0.975 0.975), color(display-p3 0.098 0.098 0.098))", + }, + }, + "--gray-3": { + default: "light-dark(#f0f0f0, #222222)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.939 0.939 0.939), color(display-p3 0.135 0.135 0.135))", + }, + }, + "--gray-4": { + default: "light-dark(#e8e8e8, #2a2a2a)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.908 0.908 0.908), color(display-p3 0.163 0.163 0.163))", + }, + }, + "--gray-5": { + default: "light-dark(#e0e0e0, #313131)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.88 0.88 0.88), color(display-p3 0.192 0.192 0.192))", + }, + }, + "--gray-6": { + default: "light-dark(#d9d9d9, #3a3a3a)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.849 0.849 0.849), color(display-p3 0.228 0.228 0.228))", + }, + }, + "--gray-7": { + default: "light-dark(#cecece, #484848)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.807 0.807 0.807), color(display-p3 0.283 0.283 0.283))", + }, + }, + "--gray-8": { + default: "light-dark(#bbbbbb, #606060)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.732 0.732 0.732), color(display-p3 0.375 0.375 0.375))", + }, + }, + "--gray-9": { + default: "light-dark(#8d8d8d, #6e6e6e)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.553 0.553 0.553), color(display-p3 0.431 0.431 0.431))", + }, + }, + "--gray-10": { + default: "light-dark(#838383, #7b7b7b)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.512 0.512 0.512), color(display-p3 0.484 0.484 0.484))", + }, + }, + "--gray-11": { + default: "light-dark(#646464, #b4b4b4)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.392 0.392 0.392), color(display-p3 0.706 0.706 0.706))", + }, + }, + "--gray-12": { + default: "light-dark(#202020, #eeeeee)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.125 0.125 0.125), color(display-p3 0.933 0.933 0.933))", + }, + }, + "--gray-a1": { + default: "light-dark(#00000003, #00000000)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.012), color(display-p3 0 0 0 / 0))", + }, + }, + "--gray-a2": { + default: "light-dark(#00000006, #ffffff09)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.024), color(display-p3 1 1 1 / 0.034))", + }, + }, + "--gray-a3": { + default: "light-dark(#0000000f, #ffffff12)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.063), color(display-p3 1 1 1 / 0.071))", + }, + }, + "--gray-a4": { + default: "light-dark(#00000017, #ffffff1b)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.09), color(display-p3 1 1 1 / 0.105))", + }, + }, + "--gray-a5": { + default: "light-dark(#0000001f, #ffffff22)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.122), color(display-p3 1 1 1 / 0.134))", + }, + }, + "--gray-a6": { + default: "light-dark(#00000026, #ffffff2c)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.153), color(display-p3 1 1 1 / 0.172))", + }, + }, + "--gray-a7": { + default: "light-dark(#00000031, #ffffff3b)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.192), color(display-p3 1 1 1 / 0.231))", + }, + }, + "--gray-a8": { + default: "light-dark(#00000044, #ffffff55)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.267), color(display-p3 1 1 1 / 0.332))", + }, + }, + "--gray-a9": { + default: "light-dark(#00000072, #ffffff64)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.447), color(display-p3 1 1 1 / 0.391))", + }, + }, + "--gray-a10": { + default: "light-dark(#0000007c, #ffffff72)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.486), color(display-p3 1 1 1 / 0.445))", + }, + }, + "--gray-a11": { + default: "light-dark(#0000009b, #ffffffaf)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.608), color(display-p3 1 1 1 / 0.685))", + }, + }, + "--gray-a12": { + default: "light-dark(#000000df, #ffffffed)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0 0 0 / 0.875), color(display-p3 1 1 1 / 0.929))", + }, + }, + "--gray-surface": { + default: "light-dark(#ffffffcc, #21212180)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 1 1 1 / 0.8), color(display-p3 0.1255 0.1255 0.1255 / 0.5))", + }, + }, + "--gray-indicator": gray["--gray-9"], + "--gray-track": gray["--gray-9"], + "--gray-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/src/themes/gray/mauve.js b/packages/reflex-components-ui/js/src/themes/gray/mauve.js new file mode 100644 index 00000000000..cbfc531c944 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/gray/mauve.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; +import { mauve } from "../../colors/mauve.stylex.js"; + +export const grayMauve = stylex.createTheme(gray, { + "--gray-1": mauve["--mauve-1"], + "--gray-2": mauve["--mauve-2"], + "--gray-3": mauve["--mauve-3"], + "--gray-4": mauve["--mauve-4"], + "--gray-5": mauve["--mauve-5"], + "--gray-6": mauve["--mauve-6"], + "--gray-7": mauve["--mauve-7"], + "--gray-8": mauve["--mauve-8"], + "--gray-9": mauve["--mauve-9"], + "--gray-10": mauve["--mauve-10"], + "--gray-11": mauve["--mauve-11"], + "--gray-12": mauve["--mauve-12"], + "--gray-a1": mauve["--mauve-a1"], + "--gray-a2": mauve["--mauve-a2"], + "--gray-a3": mauve["--mauve-a3"], + "--gray-a4": mauve["--mauve-a4"], + "--gray-a5": mauve["--mauve-a5"], + "--gray-a6": mauve["--mauve-a6"], + "--gray-a7": mauve["--mauve-a7"], + "--gray-a8": mauve["--mauve-a8"], + "--gray-a9": mauve["--mauve-a9"], + "--gray-a10": mauve["--mauve-a10"], + "--gray-a11": mauve["--mauve-a11"], + "--gray-a12": mauve["--mauve-a12"], + "--gray-contrast": mauve["--mauve-contrast"], + "--gray-surface": mauve["--mauve-surface"], + "--gray-indicator": mauve["--mauve-indicator"], + "--gray-track": mauve["--mauve-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/gray/olive.js b/packages/reflex-components-ui/js/src/themes/gray/olive.js new file mode 100644 index 00000000000..14ef616b389 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/gray/olive.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; +import { olive } from "../../colors/olive.stylex.js"; + +export const grayOlive = stylex.createTheme(gray, { + "--gray-1": olive["--olive-1"], + "--gray-2": olive["--olive-2"], + "--gray-3": olive["--olive-3"], + "--gray-4": olive["--olive-4"], + "--gray-5": olive["--olive-5"], + "--gray-6": olive["--olive-6"], + "--gray-7": olive["--olive-7"], + "--gray-8": olive["--olive-8"], + "--gray-9": olive["--olive-9"], + "--gray-10": olive["--olive-10"], + "--gray-11": olive["--olive-11"], + "--gray-12": olive["--olive-12"], + "--gray-a1": olive["--olive-a1"], + "--gray-a2": olive["--olive-a2"], + "--gray-a3": olive["--olive-a3"], + "--gray-a4": olive["--olive-a4"], + "--gray-a5": olive["--olive-a5"], + "--gray-a6": olive["--olive-a6"], + "--gray-a7": olive["--olive-a7"], + "--gray-a8": olive["--olive-a8"], + "--gray-a9": olive["--olive-a9"], + "--gray-a10": olive["--olive-a10"], + "--gray-a11": olive["--olive-a11"], + "--gray-a12": olive["--olive-a12"], + "--gray-contrast": olive["--olive-contrast"], + "--gray-surface": olive["--olive-surface"], + "--gray-indicator": olive["--olive-indicator"], + "--gray-track": olive["--olive-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/gray/sage.js b/packages/reflex-components-ui/js/src/themes/gray/sage.js new file mode 100644 index 00000000000..e7d062895d7 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/gray/sage.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; +import { sage } from "../../colors/sage.stylex.js"; + +export const graySage = stylex.createTheme(gray, { + "--gray-1": sage["--sage-1"], + "--gray-2": sage["--sage-2"], + "--gray-3": sage["--sage-3"], + "--gray-4": sage["--sage-4"], + "--gray-5": sage["--sage-5"], + "--gray-6": sage["--sage-6"], + "--gray-7": sage["--sage-7"], + "--gray-8": sage["--sage-8"], + "--gray-9": sage["--sage-9"], + "--gray-10": sage["--sage-10"], + "--gray-11": sage["--sage-11"], + "--gray-12": sage["--sage-12"], + "--gray-a1": sage["--sage-a1"], + "--gray-a2": sage["--sage-a2"], + "--gray-a3": sage["--sage-a3"], + "--gray-a4": sage["--sage-a4"], + "--gray-a5": sage["--sage-a5"], + "--gray-a6": sage["--sage-a6"], + "--gray-a7": sage["--sage-a7"], + "--gray-a8": sage["--sage-a8"], + "--gray-a9": sage["--sage-a9"], + "--gray-a10": sage["--sage-a10"], + "--gray-a11": sage["--sage-a11"], + "--gray-a12": sage["--sage-a12"], + "--gray-contrast": sage["--sage-contrast"], + "--gray-surface": sage["--sage-surface"], + "--gray-indicator": sage["--sage-indicator"], + "--gray-track": sage["--sage-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/gray/sand.js b/packages/reflex-components-ui/js/src/themes/gray/sand.js new file mode 100644 index 00000000000..95e4d488006 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/gray/sand.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; +import { sand } from "../../colors/sand.stylex.js"; + +export const graySand = stylex.createTheme(gray, { + "--gray-1": sand["--sand-1"], + "--gray-2": sand["--sand-2"], + "--gray-3": sand["--sand-3"], + "--gray-4": sand["--sand-4"], + "--gray-5": sand["--sand-5"], + "--gray-6": sand["--sand-6"], + "--gray-7": sand["--sand-7"], + "--gray-8": sand["--sand-8"], + "--gray-9": sand["--sand-9"], + "--gray-10": sand["--sand-10"], + "--gray-11": sand["--sand-11"], + "--gray-12": sand["--sand-12"], + "--gray-a1": sand["--sand-a1"], + "--gray-a2": sand["--sand-a2"], + "--gray-a3": sand["--sand-a3"], + "--gray-a4": sand["--sand-a4"], + "--gray-a5": sand["--sand-a5"], + "--gray-a6": sand["--sand-a6"], + "--gray-a7": sand["--sand-a7"], + "--gray-a8": sand["--sand-a8"], + "--gray-a9": sand["--sand-a9"], + "--gray-a10": sand["--sand-a10"], + "--gray-a11": sand["--sand-a11"], + "--gray-a12": sand["--sand-a12"], + "--gray-contrast": sand["--sand-contrast"], + "--gray-surface": sand["--sand-surface"], + "--gray-indicator": sand["--sand-indicator"], + "--gray-track": sand["--sand-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/gray/slate.js b/packages/reflex-components-ui/js/src/themes/gray/slate.js new file mode 100644 index 00000000000..49edc7b1244 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/gray/slate.js @@ -0,0 +1,37 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; +import { slate } from "../../colors/slate.stylex.js"; + +export const graySlate = stylex.createTheme(gray, { + "--gray-1": slate["--slate-1"], + "--gray-2": slate["--slate-2"], + "--gray-3": slate["--slate-3"], + "--gray-4": slate["--slate-4"], + "--gray-5": slate["--slate-5"], + "--gray-6": slate["--slate-6"], + "--gray-7": slate["--slate-7"], + "--gray-8": slate["--slate-8"], + "--gray-9": slate["--slate-9"], + "--gray-10": slate["--slate-10"], + "--gray-11": slate["--slate-11"], + "--gray-12": slate["--slate-12"], + "--gray-a1": slate["--slate-a1"], + "--gray-a2": slate["--slate-a2"], + "--gray-a3": slate["--slate-a3"], + "--gray-a4": slate["--slate-a4"], + "--gray-a5": slate["--slate-a5"], + "--gray-a6": slate["--slate-a6"], + "--gray-a7": slate["--slate-a7"], + "--gray-a8": slate["--slate-a8"], + "--gray-a9": slate["--slate-a9"], + "--gray-a10": slate["--slate-a10"], + "--gray-a11": slate["--slate-a11"], + "--gray-a12": slate["--slate-a12"], + "--gray-contrast": slate["--slate-contrast"], + "--gray-surface": slate["--slate-surface"], + "--gray-indicator": slate["--slate-indicator"], + "--gray-track": slate["--slate-track"], +}); diff --git a/packages/reflex-components-ui/js/src/themes/panel.js b/packages/reflex-components-ui/js/src/themes/panel.js new file mode 100644 index 00000000000..fafdcb3a87c --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/panel.js @@ -0,0 +1,15 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { panel } from "../tokens/panel.stylex.js"; + +export const panelSolid = stylex.createTheme(panel, { + "--backdrop-filter-panel": "none", + "--panel-solid": " ", +}); + +export const panelTranslucent = stylex.createTheme(panel, { + "--backdrop-filter-panel": "blur(64px)", + "--panel-solid": "initial", +}); diff --git a/packages/reflex-components-ui/js/src/themes/radius.js b/packages/reflex-components-ui/js/src/themes/radius.js new file mode 100644 index 00000000000..18eb9cdf8ff --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/radius.js @@ -0,0 +1,35 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { radiusFactor } from "../tokens/radius.stylex.js"; + +export const radiusFull = stylex.createTheme(radiusFactor, { + "--radius-factor": "1.5", + "--radius-full": "9999px", + "--radius-thumb": "9999px", +}); + +export const radiusLarge = stylex.createTheme(radiusFactor, { + "--radius-factor": "1.5", + "--radius-full": "0px", + "--radius-thumb": "9999px", +}); + +export const radiusMedium = stylex.createTheme(radiusFactor, { + "--radius-factor": "1", + "--radius-full": "0px", + "--radius-thumb": "9999px", +}); + +export const radiusNone = stylex.createTheme(radiusFactor, { + "--radius-factor": "0", + "--radius-full": "0px", + "--radius-thumb": "0.5px", +}); + +export const radiusSmall = stylex.createTheme(radiusFactor, { + "--radius-factor": "0.75", + "--radius-full": "0px", + "--radius-thumb": "0.5px", +}); diff --git a/packages/reflex-components-ui/js/src/themes/scaling.js b/packages/reflex-components-ui/js/src/themes/scaling.js new file mode 100644 index 00000000000..f2f9ca6c230 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/scaling.js @@ -0,0 +1,25 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "../tokens/scaling.stylex.js"; + +export const scaling100 = stylex.createTheme(scaling, { + "--scaling": "1", +}); + +export const scaling105 = stylex.createTheme(scaling, { + "--scaling": "1.05", +}); + +export const scaling110 = stylex.createTheme(scaling, { + "--scaling": "1.1", +}); + +export const scaling90 = stylex.createTheme(scaling, { + "--scaling": "0.9", +}); + +export const scaling95 = stylex.createTheme(scaling, { + "--scaling": "0.95", +}); diff --git a/packages/reflex-components-ui/js/src/themes/scope.js b/packages/reflex-components-ui/js/src/themes/scope.js new file mode 100644 index 00000000000..0c496e45e6d --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/scope.js @@ -0,0 +1,19 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { color } from "../tokens/color.stylex.js"; +import { radius } from "../tokens/radius.stylex.js"; +import { shadow } from "../tokens/shadow.stylex.js"; +import { space } from "../tokens/space.stylex.js"; +import { typography } from "../tokens/typography.stylex.js"; + +export const spaceScope = stylex.createTheme(space, {}); + +export const radiusScope = stylex.createTheme(radius, {}); + +export const typographyScope = stylex.createTheme(typography, {}); + +export const shadowScope = stylex.createTheme(shadow, {}); + +export const colorScope = stylex.createTheme(color, {}); diff --git a/packages/reflex-components-ui/js/src/themes/theme.js b/packages/reflex-components-ui/js/src/themes/theme.js new file mode 100644 index 00000000000..e9693fb9974 --- /dev/null +++ b/packages/reflex-components-ui/js/src/themes/theme.js @@ -0,0 +1,32 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { color } from "../tokens/color.stylex.js"; +import { gray } from "../tokens/gray.stylex.js"; +import { typography } from "../tokens/typography.stylex.js"; + +export const theme = stylex.create({ + light: { + colorScheme: "light", + }, + dark: { + colorScheme: "dark", + }, + background: { + backgroundColor: color["--color-background"], + }, + root: { + overflowWrap: "break-word", + fontFamily: typography["--default-font-family"], + fontSize: typography["--default-font-size"], + fontWeight: typography["--default-font-weight"], + fontStyle: typography["--default-font-style"], + lineHeight: typography["--default-line-height"], + letterSpacing: typography["--default-letter-spacing"], + textSizeAdjust: "none", + WebkitFontSmoothing: "antialiased", + MozOsxFontSmoothing: "grayscale", + color: gray["--gray-12"], + }, +}); diff --git a/packages/reflex-components-ui/js/src/tokens/accent.stylex.js b/packages/reflex-components-ui/js/src/tokens/accent.stylex.js new file mode 100644 index 00000000000..f7953c0a9f7 --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/accent.stylex.js @@ -0,0 +1,34 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const accent = stylex.defineVars({ + "--accent-1": "initial", + "--accent-2": "initial", + "--accent-3": "initial", + "--accent-4": "initial", + "--accent-5": "initial", + "--accent-6": "initial", + "--accent-7": "initial", + "--accent-8": "initial", + "--accent-9": "initial", + "--accent-10": "initial", + "--accent-11": "initial", + "--accent-12": "initial", + "--accent-a1": "initial", + "--accent-a2": "initial", + "--accent-a3": "initial", + "--accent-a4": "initial", + "--accent-a5": "initial", + "--accent-a6": "initial", + "--accent-a7": "initial", + "--accent-a8": "initial", + "--accent-a9": "initial", + "--accent-a10": "initial", + "--accent-a11": "initial", + "--accent-a12": "initial", + "--accent-contrast": "initial", + "--accent-surface": "initial", + "--accent-indicator": "initial", + "--accent-track": "initial", +}); diff --git a/packages/reflex-components-ui/js/src/tokens/color.stylex.js b/packages/reflex-components-ui/js/src/tokens/color.stylex.js new file mode 100644 index 00000000000..d7b54f2494a --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/color.stylex.js @@ -0,0 +1,26 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { black } from "../colors/black.stylex.js"; +import { gray } from "./gray.stylex.js"; +import { panel } from "./panel.stylex.js"; + +export const color = stylex.defineVars({ + "--color-background": `light-dark(white, ${gray["--gray-1"]})`, + "--color-overlay": `light-dark(${black["--black-a6"]}, ${black["--black-a8"]})`, + "--color-panel-solid": `light-dark(white, ${gray["--gray-2"]})`, + "--color-panel-translucent": `light-dark(rgba(255, 255, 255, 0.7), ${gray["--gray-a2"]})`, + "--color-surface": + "light-dark(rgba(255, 255, 255, 0.85), rgba(0, 0, 0, 0.25))", + "--color-transparent": { + default: "rgb(0 0 0 / 0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0)", + }, + }, + "--color-panel-if-solid": `${panel["--panel-solid"]} var(--color-panel-solid)`, + "--color-panel": + "var(--color-panel-if-solid, var(--color-panel-translucent))", +}); diff --git a/packages/reflex-components-ui/js/src/tokens/cursor.stylex.js b/packages/reflex-components-ui/js/src/tokens/cursor.stylex.js new file mode 100644 index 00000000000..671007ded78 --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/cursor.stylex.js @@ -0,0 +1,15 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const cursor = stylex.defineVars({ + "--cursor-button": "default", + "--cursor-checkbox": "default", + "--cursor-disabled": "not-allowed", + "--cursor-link": "pointer", + "--cursor-menu-item": "default", + "--cursor-radio": "default", + "--cursor-slider-thumb": "default", + "--cursor-slider-thumb-active": "default", + "--cursor-switch": "default", +}); diff --git a/packages/reflex-components-ui/js/src/tokens/focus.stylex.js b/packages/reflex-components-ui/js/src/tokens/focus.stylex.js new file mode 100644 index 00000000000..a3a92e3f495 --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/focus.stylex.js @@ -0,0 +1,32 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "./accent.stylex.js"; + +export const focus = stylex.defineVars({ + "--focus-1": accent["--accent-1"], + "--focus-2": accent["--accent-2"], + "--focus-3": accent["--accent-3"], + "--focus-4": accent["--accent-4"], + "--focus-5": accent["--accent-5"], + "--focus-6": accent["--accent-6"], + "--focus-7": accent["--accent-7"], + "--focus-8": accent["--accent-8"], + "--focus-9": accent["--accent-9"], + "--focus-10": accent["--accent-10"], + "--focus-11": accent["--accent-11"], + "--focus-12": accent["--accent-12"], + "--focus-a1": accent["--accent-a1"], + "--focus-a2": accent["--accent-a2"], + "--focus-a3": accent["--accent-a3"], + "--focus-a4": accent["--accent-a4"], + "--focus-a5": accent["--accent-a5"], + "--focus-a6": accent["--accent-a6"], + "--focus-a7": accent["--accent-a7"], + "--focus-a8": accent["--accent-a8"], + "--focus-a9": accent["--accent-a9"], + "--focus-a10": accent["--accent-a10"], + "--focus-a11": accent["--accent-a11"], + "--focus-a12": accent["--accent-a12"], +}); diff --git a/packages/reflex-components-ui/js/src/tokens/gray.stylex.js b/packages/reflex-components-ui/js/src/tokens/gray.stylex.js new file mode 100644 index 00000000000..f0222cf3049 --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/gray.stylex.js @@ -0,0 +1,34 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const gray = stylex.defineVars({ + "--gray-1": "initial", + "--gray-2": "initial", + "--gray-3": "initial", + "--gray-4": "initial", + "--gray-5": "initial", + "--gray-6": "initial", + "--gray-7": "initial", + "--gray-8": "initial", + "--gray-9": "initial", + "--gray-10": "initial", + "--gray-11": "initial", + "--gray-12": "initial", + "--gray-a1": "initial", + "--gray-a2": "initial", + "--gray-a3": "initial", + "--gray-a4": "initial", + "--gray-a5": "initial", + "--gray-a6": "initial", + "--gray-a7": "initial", + "--gray-a8": "initial", + "--gray-a9": "initial", + "--gray-a10": "initial", + "--gray-a11": "initial", + "--gray-a12": "initial", + "--gray-surface": "initial", + "--gray-indicator": "initial", + "--gray-track": "initial", + "--gray-contrast": "initial", +}); diff --git a/packages/reflex-components-ui/js/src/tokens/panel.stylex.js b/packages/reflex-components-ui/js/src/tokens/panel.stylex.js new file mode 100644 index 00000000000..62945160ebf --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/panel.stylex.js @@ -0,0 +1,8 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const panel = stylex.defineVars({ + "--backdrop-filter-panel": "blur(64px)", + "--panel-solid": "initial", +}); diff --git a/packages/reflex-components-ui/js/src/tokens/radius.stylex.js b/packages/reflex-components-ui/js/src/tokens/radius.stylex.js new file mode 100644 index 00000000000..aa3ffc63083 --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/radius.stylex.js @@ -0,0 +1,20 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "./scaling.stylex.js"; + +export const radiusFactor = stylex.defineVars({ + "--radius-factor": "1", + "--radius-full": "0px", + "--radius-thumb": "9999px", +}); + +export const radius = stylex.defineVars({ + "--radius-1": `calc(3px * ${scaling["--scaling"]} * var(--radius-factor))`, + "--radius-2": `calc(4px * ${scaling["--scaling"]} * var(--radius-factor))`, + "--radius-3": `calc(6px * ${scaling["--scaling"]} * var(--radius-factor))`, + "--radius-4": `calc(8px * ${scaling["--scaling"]} * var(--radius-factor))`, + "--radius-5": `calc(12px * ${scaling["--scaling"]} * var(--radius-factor))`, + "--radius-6": `calc(16px * ${scaling["--scaling"]} * var(--radius-factor))`, +}); diff --git a/packages/reflex-components-ui/js/src/tokens/scaling.stylex.js b/packages/reflex-components-ui/js/src/tokens/scaling.stylex.js new file mode 100644 index 00000000000..12a4d259073 --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/scaling.stylex.js @@ -0,0 +1,7 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const scaling = stylex.defineVars({ + "--scaling": "1", +}); diff --git a/packages/reflex-components-ui/js/src/tokens/shadow.stylex.js b/packages/reflex-components-ui/js/src/tokens/shadow.stylex.js new file mode 100644 index 00000000000..0a533f5ab7a --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/shadow.stylex.js @@ -0,0 +1,15 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { black } from "../colors/black.stylex.js"; +import { gray } from "./gray.stylex.js"; + +export const shadow = stylex.defineVars({ + "--shadow-1": `inset 0 -1px 1px 0 light-dark(transparent, ${gray["--gray-a3"]}), inset 0 0 0 1px light-dark(${gray["--gray-a5"]}, ${gray["--gray-a3"]}), inset 0 1.5px 2px 0 light-dark(${gray["--gray-a2"]}, transparent), inset 0 1.5px 2px 0 light-dark(${black["--black-a2"]}, transparent), inset 0 3px 4px 0 light-dark(transparent, ${black["--black-a5"]}), inset 0 0 0 1px light-dark(transparent, ${gray["--gray-a4"]})`, + "--shadow-2": `0 0 0 1px light-dark(color-mix(in oklab, ${gray["--gray-a3"]}, ${gray["--gray-3"]} 25%), color-mix(in oklab, ${gray["--gray-a6"]}, ${gray["--gray-6"]} 25%)), 0 0 0 0.5px light-dark(${black["--black-a1"]}, ${black["--black-a3"]}), 0 1px 1px 0 light-dark(${gray["--gray-a2"]}, ${black["--black-a6"]}), 0 2px 1px -1px light-dark(${black["--black-a1"]}, ${black["--black-a6"]}), 0 1px 3px 0 light-dark(${black["--black-a1"]}, ${black["--black-a5"]})`, + "--shadow-3": `0 0 0 1px light-dark(color-mix(in oklab, ${gray["--gray-a3"]}, ${gray["--gray-3"]} 25%), color-mix(in oklab, ${gray["--gray-a6"]}, ${gray["--gray-6"]} 25%)), 0 2px 3px -2px light-dark(${gray["--gray-a3"]}, ${black["--black-a3"]}), 0 3px 12px -4px light-dark(${black["--black-a2"]}, transparent), 0 4px 16px -8px light-dark(${black["--black-a2"]}, transparent), 0 3px 8px -2px light-dark(transparent, ${black["--black-a6"]}), 0 4px 12px -4px light-dark(transparent, ${black["--black-a7"]})`, + "--shadow-4": `0 0 0 1px light-dark(color-mix(in oklab, ${gray["--gray-a3"]}, ${gray["--gray-3"]} 25%), color-mix(in oklab, ${gray["--gray-a6"]}, ${gray["--gray-6"]} 25%)), 0 8px 40px light-dark(${black["--black-a1"]}, ${black["--black-a3"]}), 0 12px 32px -16px light-dark(${gray["--gray-a3"]}, ${black["--black-a5"]})`, + "--shadow-5": `0 0 0 1px light-dark(color-mix(in oklab, ${gray["--gray-a3"]}, ${gray["--gray-3"]} 25%), color-mix(in oklab, ${gray["--gray-a6"]}, ${gray["--gray-6"]} 25%)), 0 12px 60px light-dark(${black["--black-a3"]}, ${black["--black-a5"]}), 0 12px 32px -16px light-dark(${gray["--gray-a5"]}, ${black["--black-a7"]})`, + "--shadow-6": `0 0 0 1px light-dark(color-mix(in oklab, ${gray["--gray-a3"]}, ${gray["--gray-3"]} 25%), color-mix(in oklab, ${gray["--gray-a6"]}, ${gray["--gray-6"]} 25%)), 0 12px 60px light-dark(${black["--black-a3"]}, ${black["--black-a4"]}), 0 16px 64px light-dark(${gray["--gray-a2"]}, ${black["--black-a6"]}), 0 16px 36px -20px light-dark(${gray["--gray-a7"]}, ${black["--black-a11"]})`, +}); diff --git a/packages/reflex-components-ui/js/src/tokens/space.stylex.js b/packages/reflex-components-ui/js/src/tokens/space.stylex.js new file mode 100644 index 00000000000..5ba6c7f203f --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/space.stylex.js @@ -0,0 +1,17 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "./scaling.stylex.js"; + +export const space = stylex.defineVars({ + "--space-1": `calc(4px * ${scaling["--scaling"]})`, + "--space-2": `calc(8px * ${scaling["--scaling"]})`, + "--space-3": `calc(12px * ${scaling["--scaling"]})`, + "--space-4": `calc(16px * ${scaling["--scaling"]})`, + "--space-5": `calc(24px * ${scaling["--scaling"]})`, + "--space-6": `calc(32px * ${scaling["--scaling"]})`, + "--space-7": `calc(40px * ${scaling["--scaling"]})`, + "--space-8": `calc(48px * ${scaling["--scaling"]})`, + "--space-9": `calc(64px * ${scaling["--scaling"]})`, +}); diff --git a/packages/reflex-components-ui/js/src/tokens/typography.stylex.js b/packages/reflex-components-ui/js/src/tokens/typography.stylex.js new file mode 100644 index 00000000000..cf6b80720cd --- /dev/null +++ b/packages/reflex-components-ui/js/src/tokens/typography.stylex.js @@ -0,0 +1,92 @@ +// Generated by scripts/generate.js from @radix-ui/themes 3.3.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "./scaling.stylex.js"; + +export const typography = stylex.defineVars({ + "--font-size-1": `calc(12px * ${scaling["--scaling"]})`, + "--font-size-2": `calc(14px * ${scaling["--scaling"]})`, + "--font-size-3": `calc(16px * ${scaling["--scaling"]})`, + "--font-size-4": `calc(18px * ${scaling["--scaling"]})`, + "--font-size-5": `calc(20px * ${scaling["--scaling"]})`, + "--font-size-6": `calc(24px * ${scaling["--scaling"]})`, + "--font-size-7": `calc(28px * ${scaling["--scaling"]})`, + "--font-size-8": `calc(35px * ${scaling["--scaling"]})`, + "--font-size-9": `calc(60px * ${scaling["--scaling"]})`, + "--font-weight-light": "300", + "--font-weight-regular": "400", + "--font-weight-medium": "500", + "--font-weight-bold": "700", + "--line-height-1": `calc(16px * ${scaling["--scaling"]})`, + "--line-height-2": `calc(20px * ${scaling["--scaling"]})`, + "--line-height-3": `calc(24px * ${scaling["--scaling"]})`, + "--line-height-4": `calc(26px * ${scaling["--scaling"]})`, + "--line-height-5": `calc(28px * ${scaling["--scaling"]})`, + "--line-height-6": `calc(30px * ${scaling["--scaling"]})`, + "--line-height-7": `calc(36px * ${scaling["--scaling"]})`, + "--line-height-8": `calc(40px * ${scaling["--scaling"]})`, + "--line-height-9": `calc(60px * ${scaling["--scaling"]})`, + "--letter-spacing-1": "0.0025em", + "--letter-spacing-2": "0em", + "--letter-spacing-3": "0em", + "--letter-spacing-4": "-0.0025em", + "--letter-spacing-5": "-0.005em", + "--letter-spacing-6": "-0.00625em", + "--letter-spacing-7": "-0.0075em", + "--letter-spacing-8": "-0.01em", + "--letter-spacing-9": "-0.025em", + "--default-font-family": + "-apple-system, BlinkMacSystemFont, 'Segoe UI (Custom)', Roboto, 'Helvetica Neue', 'Open Sans (Custom)', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'", + "--default-font-size": "var(--font-size-3)", + "--default-font-style": "normal", + "--default-font-weight": "var(--font-weight-regular)", + "--default-line-height": "1.5", + "--default-letter-spacing": "0em", + "--default-leading-trim-start": "0.42em", + "--default-leading-trim-end": "0.36em", + "--heading-font-family": "var(--default-font-family)", + "--heading-font-size-adjust": "1", + "--heading-font-style": "normal", + "--heading-leading-trim-start": "var(--default-leading-trim-start)", + "--heading-leading-trim-end": "var(--default-leading-trim-end)", + "--heading-letter-spacing": "0em", + "--heading-line-height-1": `calc(16px * ${scaling["--scaling"]})`, + "--heading-line-height-2": `calc(18px * ${scaling["--scaling"]})`, + "--heading-line-height-3": `calc(22px * ${scaling["--scaling"]})`, + "--heading-line-height-4": `calc(24px * ${scaling["--scaling"]})`, + "--heading-line-height-5": `calc(26px * ${scaling["--scaling"]})`, + "--heading-line-height-6": `calc(30px * ${scaling["--scaling"]})`, + "--heading-line-height-7": `calc(36px * ${scaling["--scaling"]})`, + "--heading-line-height-8": `calc(40px * ${scaling["--scaling"]})`, + "--heading-line-height-9": `calc(60px * ${scaling["--scaling"]})`, + "--code-font-family": + "'Menlo', 'Consolas (Custom)', 'Bitstream Vera Sans Mono', monospace, 'Apple Color Emoji', 'Segoe UI Emoji'", + "--code-font-size-adjust": "0.95", + "--code-font-style": "normal", + "--code-font-weight": "inherit", + "--code-letter-spacing": "-0.007em", + "--code-padding-top": "0.1em", + "--code-padding-bottom": "0.1em", + "--code-padding-left": "0.25em", + "--code-padding-right": "0.25em", + "--strong-font-family": "var(--default-font-family)", + "--strong-font-size-adjust": "1", + "--strong-font-style": "inherit", + "--strong-font-weight": "var(--font-weight-bold)", + "--strong-letter-spacing": "0em", + "--em-font-family": "'Times New Roman', 'Times', serif", + "--em-font-size-adjust": "1.18", + "--em-font-style": "italic", + "--em-font-weight": "inherit", + "--em-letter-spacing": "-0.025em", + "--quote-font-family": "'Times New Roman', 'Times', serif", + "--quote-font-size-adjust": "1.18", + "--quote-font-style": "italic", + "--quote-font-weight": "inherit", + "--quote-letter-spacing": "-0.025em", + "--tab-active-letter-spacing": "-0.01em", + "--tab-active-word-spacing": "0em", + "--tab-inactive-letter-spacing": "0em", + "--tab-inactive-word-spacing": "0em", +}); diff --git a/packages/reflex-components-ui/js/src/vite-plugin-stylex.js b/packages/reflex-components-ui/js/src/vite-plugin-stylex.js new file mode 100644 index 00000000000..57a0ddb90d6 --- /dev/null +++ b/packages/reflex-components-ui/js/src/vite-plugin-stylex.js @@ -0,0 +1,242 @@ +// The StyleX Vite plugin, adapted to the React Router build of a Reflex app. +// +// StyleX appends the styles it compiled to a stylesheet of the build once every +// chunk is rendered and named, and gives that stylesheet a new name. Three +// things around that are put right here: +// +// - React Router has recorded the old name by then, and fails when it moves +// the assets of the server build. +// - A chunk that holds the address of the stylesheet is edited after its own +// name was derived from its content, so a change of style would alter the +// chunk under an unchanged name, and a cached copy would ask for a +// stylesheet that is gone. +// - React Router renders the document itself, so nothing loads the module +// through which StyleX delivers the styles while developing. +// - React Router builds a route module several times, for the client, for the +// server and for reading its exports, and StyleX compiles it with Babel +// each time. A build compiles each module once and reuses the result. +// - StyleX compiles a module by parsing and printing all of it with Babel, +// which costs more than the rest of the build spends on a page. The Reflex +// compiler writes the styles of a module as statements of their own, so +// only those are handed to StyleX, and the page around them is left as it is. + +import { basename } from "node:path"; + +import stylexUnplugin from "@stylexjs/unplugin"; + +// The module of the unplugin that fetches the compiled styles in development +// and fetches them again when one changes. +const DEV_RUNTIME = "virtual:stylex:runtime"; + +// The module of an app that runs first in the browser. +const CLIENT_ENTRY = /\/app\/entry\.client\.[jt]sx?$/; + +/** + * The hooks of a Vite plugin that are used here. + * + * @typedef {object} VitePlugin + * @property {string} name + * @property {"serve" | "build"} [apply] + * @property {(this: any, outputOptions: unknown, bundle: Bundle) => void} [generateBundle] + * @property {(chunk: { moduleIds: string[] }) => string | void} [augmentChunkHash] + * @property {(this: any, code: string, id: string) => any} [transform] + * @property {() => string} [__stylexCollectCss] Internal to the unplugin: the + * stylesheet of every style compiled so far. + * @property {() => { rulesById: Map }} [__stylexGetSharedStore] + * Internal to the unplugin: the styles of every module compiled so far, which + * every plugin of the process collects from. + */ + +/** + * The files of a build, by name. + * + * @typedef {Record } }>} Bundle + */ + +/** + * Keep the assets a chunk has recorded in step with the stylesheet StyleX + * renames. + * + * @param {VitePlugin} plugin A plugin of the StyleX unplugin. + * @returns {VitePlugin} The plugin, its `generateBundle` wrapped. + */ +function keepRecordedAssets(plugin) { + const generateBundle = plugin.generateBundle; + if (typeof generateBundle !== "function") return plugin; + return { + ...plugin, + generateBundle(outputOptions, bundle) { + const stylesheets = Object.keys(bundle).filter((name) => + name.endsWith(".css"), + ); + // Rolldown does not expose a file emitted in this hook through `bundle`, + // so record the name the unplugin asks for instead. + /** @type {string | undefined} */ + let renamedTo; + const context = new Proxy(this, { + get(target, key) { + const value = Reflect.get(target, key, target); + if (key === "getFileName") { + return (/** @type {string} */ referenceId) => + (renamedTo = value.call(target, referenceId)); + } + return typeof value === "function" ? value.bind(target) : value; + }, + }); + generateBundle.call(context, outputOptions, bundle); + const removed = stylesheets.filter((name) => !(name in bundle)); + if (removed.length !== 1 || !renamedTo) return; + for (const item of Object.values(bundle)) { + const assets = item.viteMetadata?.importedAssets; + if (assets?.delete(removed[0])) assets.add(renamedTo); + } + }, + }; +} + +// The import and the statements the Reflex compiler writes for the styles of a +// module (`reflex_components_ui.style.emit`): each on a line of its own, named +// after its content. +const STYLEX_IMPORT = 'import * as stylex from "@stylexjs/stylex"'; +const DECLARATION = /^const sx_[0-9a-f]{10}\w* = .*;$/gm; + +/** + * Hand StyleX the styles of a module without the module around them. + * + * @param {VitePlugin} plugin A plugin of the StyleX unplugin. + * @returns {VitePlugin} The plugin, its `transform` compiling the statements + * that declare styles and leaving the rest of the module untouched. A + * module that uses StyleX anywhere else is compiled whole. + */ +function compileDeclarations(plugin) { + const transform = plugin.transform; + if (typeof transform !== "function") return plugin; + return { + ...plugin, + async transform(code, id) { + const declarations = code.match(DECLARATION); + const rest = declarations + ? code.replace(STYLEX_IMPORT, "").replace(DECLARATION, "") + : code; + if (!declarations || /\bstylex\b/.test(rest)) + return transform.call(this, code, id); + const result = await transform.call( + this, + `${STYLEX_IMPORT};\n${declarations.join("\n")}`, + id, + ); + const [first, ...compiled] = String(result?.code).split("\n"); + // Not the module that was handed over: compile the whole one instead. + if (first !== `${STYLEX_IMPORT};`) return transform.call(this, code, id); + let placed = false; + return { + code: code.replace(DECLARATION, () => { + if (placed) return ""; + placed = true; + return compiled.join("\n"); + }), + map: null, + }; + }, + }; +} + +// What StyleX made of each module of this process: the compiled module and +// the styles found in it, by the file and its source. Every plugin of a build +// shares it, as React Router creates more than one. +/** @type {Map>} */ +const compiled = new Map(); + +/** + * Compile a module once in a build, however often it is transformed. + * + * @param {VitePlugin} plugin A plugin of the StyleX unplugin. + * @returns {VitePlugin} The plugin, its `transform` reusing earlier results. + */ +function compileOnce(plugin) { + const transform = plugin.transform; + const store = plugin.__stylexGetSharedStore; + if (typeof transform !== "function" || typeof store !== "function") + return plugin; + return { + ...plugin, + transform(code, id) { + // A development server compiles a module again when it changes, and + // the unplugin skips a module that does not mention StyleX. + if (this?.meta?.watchMode || !code.includes("stylex")) + return transform.call(this, code, id); + const key = `${id.split("?")[0]}\0${code}`; + const earlier = compiled.get(key); + if (earlier) { + return earlier.then(({ result, rules }) => { + // The styles are collected under the name of each module. + const { rulesById } = store(); + if (rules) rulesById.set(id, rules); + else rulesById.delete(id); + return result; + }); + } + const first = Promise.resolve(transform.call(this, code, id)).then( + (result) => ({ result, rules: store().rulesById.get(id) }), + ); + compiled.set(key, first); + // A failed compile is reported by each transform, not remembered. + first.catch(() => compiled.delete(key)); + return first.then(({ result }) => result); + }, + }; +} + +/** + * Compile the StyleX styles of a Reflex app into one of its stylesheets. + * + * @param {string} stylesheet The name, without its extension, of the + * stylesheet the compiled styles are appended to. + * @param {Record} [options] Options of `@stylexjs/unplugin`. + * @returns {VitePlugin[]} The plugins to add to the Vite configuration. + */ +export default function stylex(stylesheet, options) { + /** @type {VitePlugin[]} */ + const plugins = [ + stylexUnplugin.vite({ + ...options, + cssInjectionTarget: (/** @type {string} */ fileName) => + basename(fileName).startsWith(stylesheet), + }), + ].flat(); + const collectors = plugins.flatMap( + (plugin) => plugin.__stylexCollectCss ?? [], + ); + if (collectors.length === 0) { + throw new Error( + "reflex-ui: @stylexjs/unplugin no longer exposes the styles it collected (__stylexCollectCss), which the names of the built files depend on. Install the version of @stylexjs/unplugin that reflex-components-ui pins.", + ); + } + return [ + ...plugins + .map(keepRecordedAssets) + .map(compileDeclarations) + .map(compileOnce), + { + name: "reflex-ui:stylex-hash", + apply: "build", + // The chunk that holds the address of the stylesheet is named after the + // styles too, as they are what moves that address. + augmentChunkHash(chunk) { + const holdsAddress = chunk.moduleIds.some( + (id) => basename(id.split("?")[0]) === `${stylesheet}.css`, + ); + if (holdsAddress) + return collectors.map((collect) => collect()).join(""); + }, + }, + { + name: "reflex-ui:stylex-dev", + apply: "serve", + transform(code, id) { + if (!CLIENT_ENTRY.test(id)) return null; + return `import ${JSON.stringify(DEV_RUNTIME)};\n${code}`; + }, + }, + ]; +} diff --git a/packages/reflex-components-ui/js/tests/base-css.test.js b/packages/reflex-components-ui/js/tests/base-css.test.js new file mode 100644 index 00000000000..a066442d81a --- /dev/null +++ b/packages/reflex-components-ui/js/tests/base-css.test.js @@ -0,0 +1,26 @@ +// @vitest-environment node +import { readFile } from "node:fs/promises"; +import { createRequire } from "node:module"; + +import { expect, test } from "vitest"; + +const FONT_FACE = /@font-face \{[^}]*\}/g; + +/** + * The `@font-face` rules of a stylesheet. + * + * @param {string | URL} path The stylesheet. + * @returns {Promise} The rules, as they are written. + */ +async function fontFaces(path) { + return (await readFile(path, "utf8")).match(FONT_FACE) ?? []; +} + +test("base.css has the font faces of the Radix Themes tokens", async () => { + const require = createRequire(import.meta.url); + const radix = await fontFaces(require.resolve("@radix-ui/themes/tokens.css")); + expect(radix.length).toBe(20); + expect(await fontFaces(new URL("../src/base.css", import.meta.url))).toEqual( + radix, + ); +}); diff --git a/packages/reflex-components-ui/js/tests/class-name.test.js b/packages/reflex-components-ui/js/tests/class-name.test.js new file mode 100644 index 00000000000..8f4e622e664 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/class-name.test.js @@ -0,0 +1,36 @@ +// @vitest-environment node +import * as stylex from "@stylexjs/stylex"; +import { expect, test } from "vitest"; + +import { className } from "../src/class-name.js"; + +const red = { color: "red-class", top: "top-class", $$css: true }; +const blue = { color: "blue-class", $$css: "app/routes/page.jsx:3" }; +const unset = { top: null, $$css: true }; + +test("the class names of every style are joined", () => { + expect(className(red)).toBe("red-class top-class"); + expect(className({ group: "theme group" }, red)).toBe( + "theme group red-class top-class", + ); +}); + +test("a later style wins a property, and a falsy one is skipped", () => { + expect(className(red, blue)).toBe("blue-class top-class"); + expect(className(blue, red)).toBe("red-class top-class"); + expect(className(red, false, null, undefined, unset)).toBe("red-class"); + expect(className()).toBe(""); +}); + +test("the classes are the ones the StyleX runtime gives", () => { + /** @type {any[][]} */ + const cases = [[red], [red, blue], [blue, red], [red, false, unset]]; + for (const styles of cases) { + const expected = stylex.props(...styles).className ?? ""; + expect( + className(...styles) + .split(" ") + .sort(), + ).toEqual(expected.split(" ").filter(Boolean).sort()); + } +}); diff --git a/packages/reflex-components-ui/js/tests/css-props.test.js b/packages/reflex-components-ui/js/tests/css-props.test.js new file mode 100644 index 00000000000..5955a2a6593 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/css-props.test.js @@ -0,0 +1,165 @@ +// @vitest-environment node +import { expect, test } from "vitest"; + +import { + PSEUDO_CLASSES, + readProperties, + readPseudoElements, + renderCssProps, + snakeCase, +} from "../scripts/css-props.js"; + +test("names a property as a Reflex user writes it", () => { + expect( + ["color", "backgroundColor", "WebkitFontSmoothing", "zIndex"].map( + snakeCase, + ), + ).toEqual(["color", "background_color", "webkit_font_smoothing", "z_index"]); +}); + +test("reads what each kind of property accepts from StyleX's types", () => { + const properties = new Map( + readProperties().map((property) => [property.key, property]), + ); + expect(properties.size).toBe(521); + expect(properties.has("theme")).toBe(false); + expect(properties.get("box_sizing")).toEqual({ + name: "boxSizing", + key: "box_sizing", + literals: ["border-box", "content-box", "inherit", "initial", "unset"], + open: null, + }); + expect( + ["background_color", "border", "padding", "z_index", "content"].map((key) => + properties.get(key), + ), + ).toEqual([ + { + name: "backgroundColor", + key: "background_color", + literals: [], + open: "_Color", + }, + { name: "border", key: "border", literals: [], open: "_Color" }, + { name: "padding", key: "padding", literals: [], open: "_Size" }, + { name: "zIndex", key: "z_index", literals: [], open: "_Size" }, + { name: "content", key: "content", literals: [], open: "_Str" }, + ]); +}); + +test("reads the pseudo-elements StyleX types", () => { + const elements = readPseudoElements(); + expect(elements.length).toBe(33); + expect(elements.filter((name) => !name.startsWith("-"))).toEqual([ + "after", + "backdrop", + "before", + "cue", + "cue-region", + "file-selector-button", + "first-letter", + "first-line", + "grammar-error", + "marker", + "placeholder", + "selection", + "spelling-error", + "target-text", + ]); +}); + +test("renders the types and the runtime tables", () => { + const rendered = renderCssProps( + [ + { name: "color", key: "color", literals: [], open: "_Color" }, + { + name: "boxSizing", + key: "box_sizing", + literals: ["border-box", "content-box"], + open: null, + }, + { + name: "backgroundOrigin", + key: "background_origin", + literals: ["border-box", "content-box"], + open: null, + }, + ], + ["before"], + ); + const typed = rendered.slice( + rendered.indexOf(" _BoxSizing"), + rendered.indexOf(" _Selectors"), + ); + expect(typed).toBe(` _BoxSizing: TypeAlias = Literal[ + "border-box", + "content-box", + ] + +`); + const fields = rendered.slice( + rendered.indexOf(" class StyleProps"), + rendered.indexOf(" _active"), + ); + expect(fields).toBe(` class StyleProps(_Selectors, total=False): + """The styles of one element: CSS properties and conditional blocks of them.""" + + color: _Value[_Color] + box_sizing: _Value[_BoxSizing | _StrVar] + background_origin: _Value[_BoxSizing | _StrVar] + bg: _Value[_Color] + bg_color: _Value[_Color] + margin_x: _Value[_Size] + margin_y: _Value[_Size] + padding_x: _Value[_Size] + padding_y: _Value[_Size] +`); + expect( + rendered.slice( + rendered.indexOf("else:"), + rendered.indexOf("PSEUDO_CLASSES"), + ), + ).toBe(`else: + # A TypedDict of this size takes milliseconds to build, and nothing reads + # it at runtime, where a style is a plain dict. + StyleProps = dict + +CSS_PROPS: dict[str, str] = { + "color": "color", + "box_sizing": "boxSizing", + "background_origin": "backgroundOrigin", +} + +`); + expect( + rendered.slice(rendered.indexOf("PSEUDO_ELEMENTS:")), + ).toBe(`PSEUDO_ELEMENTS: frozenset[str] = frozenset({ + "before", +}) +`); + expect( + rendered.slice( + rendered.indexOf(" _Selectors"), + rendered.indexOf(" class StyleProps"), + ), + ).toBe(` _Selectors = TypedDict( + "_Selectors", + { +${PSEUDO_CLASSES.map((name) => ` ":${name}": "StyleProps",\n`).join("")} "::before": "StyleProps", + }, + total=False, + ) + +`); + expect( + rendered.slice( + rendered.indexOf(" _active"), + rendered.indexOf("else:"), + ), + ).toBe( + `${[...PSEUDO_CLASSES, "before"] + .sort() + .map((name) => ` _${name.replaceAll("-", "_")}: StyleProps\n`) + .join("")}\n`, + ); +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/black.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/black.stylex.js new file mode 100644 index 00000000000..b2372a3d471 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/black.stylex.js @@ -0,0 +1,7 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const black = stylex.defineVars({ + "--black-a9": "rgba(0, 0, 0, 0.7)", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/red.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/red.stylex.js new file mode 100644 index 00000000000..5e2fe56f5c1 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/red.stylex.js @@ -0,0 +1,19 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const red = stylex.defineVars({ + "--red-9": { + default: "#e5484d", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.83 0.329 0.324), #e5484d)", + }, + }, + "--red-a9": "light-dark(#db0007b7, #ff5d61b0)", + "--red-contrast": "white", + "--red-track": + "light-dark(var(--red-9), color-mix(in oklab, var(--red-a9), var(--red-9) 65%))", + "--red-surface": "light-dark(#fff7f7cc, #2f151780)", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/slate.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/slate.stylex.js new file mode 100644 index 00000000000..4f72d6ae326 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/colors/slate.stylex.js @@ -0,0 +1,16 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const slate = stylex.defineVars({ + "--slate-9": { + default: "light-dark(#8b8d98, #696e77)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.547 0.553 0.592), color(display-p3 0.415 0.431 0.463))", + }, + }, + "--slate-a9": "light-dark(#00051d74, #d9edff5d)", + "--slate-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/accent/gray.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/accent/gray.js new file mode 100644 index 00000000000..941a70f150a --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/accent/gray.js @@ -0,0 +1,12 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { gray } from "../../tokens/gray.stylex.js"; + +export const accentGray = stylex.createTheme(accent, { + "--accent-9": gray["--gray-9"], + "--accent-a9": gray["--gray-a9"], + "--accent-contrast": gray["--gray-contrast"], +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/accent/red.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/accent/red.js new file mode 100644 index 00000000000..c12e2ac87ac --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/accent/red.js @@ -0,0 +1,12 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "../../tokens/accent.stylex.js"; +import { red } from "../../colors/red.stylex.js"; + +export const accentRed = stylex.createTheme(accent, { + "--accent-9": red["--red-9"], + "--accent-a9": red["--red-a9"], + "--accent-contrast": red["--red-contrast"], +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/focus.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/focus.js new file mode 100644 index 00000000000..267ffc23df4 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/focus.js @@ -0,0 +1,7 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { focus } from "../tokens/focus.stylex.js"; + +export const focusScope = stylex.createTheme(focus, {}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/gray/gray.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/gray/gray.js new file mode 100644 index 00000000000..e6a689f9b0f --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/gray/gray.js @@ -0,0 +1,22 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; + +// StyleX leaves a null level out, which the type of a string token does +// not say. +const NONE = /** @type {string} */ (/** @type {unknown} */ (null)); + +export const grayGray = stylex.createTheme(gray, { + "--gray-9": { + default: "light-dark(#8d8d8d, #6e6e6e)", + "@supports (color: color(display-p3 1 1 1))": { + default: NONE, + "@media (color-gamut: p3)": + "light-dark(color(display-p3 0.553 0.553 0.553), color(display-p3 0.431 0.431 0.431))", + }, + }, + "--gray-a9": "light-dark(#00000072, #ffffff69)", + "--gray-contrast": "white", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/gray/slate.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/gray/slate.js new file mode 100644 index 00000000000..f2820797ec9 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/gray/slate.js @@ -0,0 +1,12 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "../../tokens/gray.stylex.js"; +import { slate } from "../../colors/slate.stylex.js"; + +export const graySlate = stylex.createTheme(gray, { + "--gray-9": slate["--slate-9"], + "--gray-a9": slate["--slate-a9"], + "--gray-contrast": slate["--slate-contrast"], +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/panel.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/panel.js new file mode 100644 index 00000000000..79e7076c5eb --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/panel.js @@ -0,0 +1,15 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { panel } from "../tokens/panel.stylex.js"; + +export const panelSolid = stylex.createTheme(panel, { + "--backdrop-filter-panel": "none", + "--panel-solid": " ", +}); + +export const panelTranslucent = stylex.createTheme(panel, { + "--backdrop-filter-panel": "blur(64px)", + "--panel-solid": "initial", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/radius.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/radius.js new file mode 100644 index 00000000000..3975e96715e --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/radius.js @@ -0,0 +1,15 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { radiusFactor } from "../tokens/radius.stylex.js"; + +export const radiusFull = stylex.createTheme(radiusFactor, { + "--radius-factor": "1.5", + "--radius-full": "9999px", +}); + +export const radiusMedium = stylex.createTheme(radiusFactor, { + "--radius-factor": "1", + "--radius-full": "0px", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/scaling.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/scaling.js new file mode 100644 index 00000000000..b7a2903b5d4 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/scaling.js @@ -0,0 +1,13 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "../tokens/scaling.stylex.js"; + +export const scaling100 = stylex.createTheme(scaling, { + "--scaling": "1", +}); + +export const scaling90 = stylex.createTheme(scaling, { + "--scaling": "0.9", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/scope.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/scope.js new file mode 100644 index 00000000000..fc87f649d1a --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/scope.js @@ -0,0 +1,19 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { color } from "../tokens/color.stylex.js"; +import { radius } from "../tokens/radius.stylex.js"; +import { shadow } from "../tokens/shadow.stylex.js"; +import { space } from "../tokens/space.stylex.js"; +import { typography } from "../tokens/typography.stylex.js"; + +export const spaceScope = stylex.createTheme(space, {}); + +export const radiusScope = stylex.createTheme(radius, {}); + +export const typographyScope = stylex.createTheme(typography, {}); + +export const shadowScope = stylex.createTheme(shadow, {}); + +export const colorScope = stylex.createTheme(color, {}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/theme.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/theme.js new file mode 100644 index 00000000000..d84a0fa4751 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/themes/theme.js @@ -0,0 +1,27 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { color } from "../tokens/color.stylex.js"; +import { gray } from "../tokens/gray.stylex.js"; +import { typography } from "../tokens/typography.stylex.js"; + +export const theme = stylex.create({ + light: { + colorScheme: "light", + }, + dark: { + colorScheme: "dark", + }, + background: { + backgroundColor: color["--color-background"], + }, + root: { + overflowWrap: "break-word", + fontFamily: typography["--default-font-family"], + fontSize: typography["--default-font-size"], + textSizeAdjust: "none", + WebkitFontSmoothing: "antialiased", + color: gray["--gray-9"], + }, +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/accent.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/accent.stylex.js new file mode 100644 index 00000000000..619d6c92737 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/accent.stylex.js @@ -0,0 +1,9 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const accent = stylex.defineVars({ + "--accent-9": "initial", + "--accent-a9": "initial", + "--accent-contrast": "initial", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/color.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/color.stylex.js new file mode 100644 index 00000000000..a7ad4d784cc --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/color.stylex.js @@ -0,0 +1,22 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { gray } from "./gray.stylex.js"; +import { panel } from "./panel.stylex.js"; + +export const color = stylex.defineVars({ + "--color-background": `light-dark(white, ${gray["--gray-9"]})`, + "--color-panel-solid": `light-dark(white, ${gray["--gray-9"]})`, + "--color-panel-translucent": `light-dark(rgba(255, 255, 255, 0.7), ${gray["--gray-a9"]})`, + "--color-transparent": { + default: "rgb(0 0 0 / 0)", + "@supports (color: color(display-p3 1 1 1))": { + default: null, + "@media (color-gamut: p3)": "color(display-p3 0 0 0 / 0)", + }, + }, + "--color-panel-if-solid": `${panel["--panel-solid"]} var(--color-panel-solid)`, + "--color-panel": + "var(--color-panel-if-solid, var(--color-panel-translucent))", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/cursor.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/cursor.stylex.js new file mode 100644 index 00000000000..bb7c709289c --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/cursor.stylex.js @@ -0,0 +1,7 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const cursor = stylex.defineVars({ + "--cursor-button": "default", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/focus.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/focus.stylex.js new file mode 100644 index 00000000000..dd324aec674 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/focus.stylex.js @@ -0,0 +1,9 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { accent } from "./accent.stylex.js"; + +export const focus = stylex.defineVars({ + "--focus-9": accent["--accent-9"], +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/gray.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/gray.stylex.js new file mode 100644 index 00000000000..fce237af53f --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/gray.stylex.js @@ -0,0 +1,9 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const gray = stylex.defineVars({ + "--gray-9": "initial", + "--gray-a9": "initial", + "--gray-contrast": "initial", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/panel.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/panel.stylex.js new file mode 100644 index 00000000000..dba7800ad14 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/panel.stylex.js @@ -0,0 +1,8 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const panel = stylex.defineVars({ + "--backdrop-filter-panel": "blur(64px)", + "--panel-solid": "initial", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/radius.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/radius.stylex.js new file mode 100644 index 00000000000..9ba4889dad5 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/radius.stylex.js @@ -0,0 +1,14 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "./scaling.stylex.js"; + +export const radiusFactor = stylex.defineVars({ + "--radius-factor": "1", + "--radius-full": "0px", +}); + +export const radius = stylex.defineVars({ + "--radius-1": `calc(3px * ${scaling["--scaling"]} * var(--radius-factor))`, +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/scaling.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/scaling.stylex.js new file mode 100644 index 00000000000..dbde33599a3 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/scaling.stylex.js @@ -0,0 +1,7 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +export const scaling = stylex.defineVars({ + "--scaling": "1", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/shadow.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/shadow.stylex.js new file mode 100644 index 00000000000..25d2bfcdda9 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/shadow.stylex.js @@ -0,0 +1,11 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { black } from "../colors/black.stylex.js"; +import { gray } from "./gray.stylex.js"; + +export const shadow = stylex.defineVars({ + "--shadow-1": `inset 0 -1px 1px 0 light-dark(transparent, ${gray["--gray-a9"]}), inset 0 0 0 1px ${gray["--gray-a9"]}, inset 0 1.5px 2px 0 light-dark(${black["--black-a9"]}, transparent)`, + "--shadow-2": `0 0 0 1px color-mix(in oklab, ${gray["--gray-a9"]}, ${gray["--gray-9"]} 25%), 0 1px 3px 0 ${black["--black-a9"]}`, +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/space.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/space.stylex.js new file mode 100644 index 00000000000..e5927e4e3a0 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/space.stylex.js @@ -0,0 +1,9 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "./scaling.stylex.js"; + +export const space = stylex.defineVars({ + "--space-1": `calc(4px * ${scaling["--scaling"]})`, +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/typography.stylex.js b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/typography.stylex.js new file mode 100644 index 00000000000..b7434979258 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/js/src/tokens/typography.stylex.js @@ -0,0 +1,13 @@ +// Generated by scripts/generate.js from @radix-ui/themes 0.0.0. Do not edit. + +import * as stylex from "@stylexjs/stylex"; + +import { scaling } from "./scaling.stylex.js"; + +export const typography = stylex.defineVars({ + "--font-size-3": `calc(16px * ${scaling["--scaling"]})`, + "--font-weight-regular": "400", + "--default-font-family": "-apple-system, 'Segoe UI (Custom)', sans-serif", + "--default-font-size": "var(--font-size-3)", + "--code-font-weight": "inherit", +}); diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/src/reflex_components_ui/_radix_tokens.py b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/src/reflex_components_ui/_radix_tokens.py new file mode 100644 index 00000000000..6467c5b795c --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/expected/src/reflex_components_ui/_radix_tokens.py @@ -0,0 +1,159 @@ +"""The StyleX modules generated from @radix-ui/themes, and what they define. + +Generated by js/scripts/generate.js. Do not edit. +""" + +RADIX_THEMES_VERSION: str = "0.0.0" + +VAR_GROUPS: dict[str, tuple[str, tuple[str, ...]]] = { + "black": ( + "colors/black.stylex.js", + ("--black-a9",), + ), + "red": ( + "colors/red.stylex.js", + ( + "--red-9", + "--red-a9", + "--red-contrast", + "--red-track", + "--red-surface", + ), + ), + "slate": ( + "colors/slate.stylex.js", + ( + "--slate-9", + "--slate-a9", + "--slate-contrast", + ), + ), + "space": ( + "tokens/space.stylex.js", + ("--space-1",), + ), + "scaling": ( + "tokens/scaling.stylex.js", + ("--scaling",), + ), + "radiusFactor": ( + "tokens/radius.stylex.js", + ("--radius-factor", "--radius-full"), + ), + "radius": ( + "tokens/radius.stylex.js", + ("--radius-1",), + ), + "shadow": ( + "tokens/shadow.stylex.js", + ("--shadow-1", "--shadow-2"), + ), + "cursor": ( + "tokens/cursor.stylex.js", + ("--cursor-button",), + ), + "panel": ( + "tokens/panel.stylex.js", + ("--backdrop-filter-panel", "--panel-solid"), + ), + "color": ( + "tokens/color.stylex.js", + ( + "--color-background", + "--color-panel-solid", + "--color-panel-translucent", + "--color-transparent", + "--color-panel-if-solid", + "--color-panel", + ), + ), + "accent": ( + "tokens/accent.stylex.js", + ( + "--accent-9", + "--accent-a9", + "--accent-contrast", + ), + ), + "focus": ( + "tokens/focus.stylex.js", + ("--focus-9",), + ), + "gray": ( + "tokens/gray.stylex.js", + ( + "--gray-9", + "--gray-a9", + "--gray-contrast", + ), + ), + "typography": ( + "tokens/typography.stylex.js", + ( + "--font-size-3", + "--font-weight-regular", + "--default-font-family", + "--default-font-size", + "--code-font-weight", + ), + ), +} + +ACCENT_THEMES: dict[str, tuple[str, str]] = { + "gray": ("themes/accent/gray.js", "accentGray"), + "red": ("themes/accent/red.js", "accentRed"), +} + +GRAY_THEMES: dict[str, tuple[str, str]] = { + "gray": ("themes/gray/gray.js", "grayGray"), + "slate": ("themes/gray/slate.js", "graySlate"), +} + +RADIUS_THEMES: dict[str, tuple[str, str]] = { + "full": ("themes/radius.js", "radiusFull"), + "medium": ("themes/radius.js", "radiusMedium"), +} + +SCALING_THEMES: dict[str, tuple[str, str]] = { + "100%": ("themes/scaling.js", "scaling100"), + "90%": ("themes/scaling.js", "scaling90"), +} + +PANEL_BACKGROUND_THEMES: dict[str, tuple[str, str]] = { + "solid": ("themes/panel.js", "panelSolid"), + "translucent": ("themes/panel.js", "panelTranslucent"), +} + +SCOPE_THEMES: tuple[tuple[str, str], ...] = ( + ("themes/scope.js", "spaceScope"), + ("themes/scope.js", "radiusScope"), + ("themes/scope.js", "typographyScope"), + ("themes/scope.js", "shadowScope"), + ("themes/scope.js", "colorScope"), +) + +FOCUS_THEME: tuple[str, str] = ("themes/focus.js", "focusScope") + +THEME_STYLES: tuple[str, str, tuple[str, ...]] = ( + "themes/theme.js", + "theme", + ( + "light", + "dark", + "background", + "root", + ), +) + +MATCHING_GRAY: dict[str, str] = { + "gray": "gray", + "red": "slate", +} + +DEFAULTS: dict[str, str] = { + "accent_color": "red", + "gray_color": "auto", + "radius": "medium", + "scaling": "100%", + "panel_background": "translucent", +} diff --git a/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/tokens.css b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/tokens.css new file mode 100644 index 00000000000..98610a49037 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/fixtures/radix-tokens/tokens.css @@ -0,0 +1,196 @@ +/* The shapes the token stylesheet of @radix-ui/themes is made of, with two + steps of each scale and a few tokens of each kind. */ +:root, .light, .light-theme { + --gray-9: #8d8d8d; + --gray-a9: #00000072; + --slate-9: #8b8d98; + --slate-a9: #00051d74; + --red-9: #e5484d; + --red-a9: #db0007b7; +} + +@supports (color: color(display-p3 1 1 1)) { + @media (color-gamut: p3) { + :root, .light, .light-theme { + --gray-9: color(display-p3 0.553 0.553 0.553); + --slate-9: color(display-p3 0.547 0.553 0.592); + --red-9: color(display-p3 0.83 0.329 0.324); + } + } +} + +.dark, .dark-theme { + --gray-9: #6e6e6e; + --gray-a9: #ffffff69; + --slate-9: #696e77; + --slate-a9: #d9edff5d; + --red-9: #e5484d; + --red-a9: #ff5d61b0; +} + +@supports (color: color(display-p3 1 1 1)) { + @media (color-gamut: p3) { + .dark, .dark-theme { + --gray-9: color(display-p3 0.431 0.431 0.431); + --slate-9: color(display-p3 0.415 0.431 0.463); + } + } +} + +:root { + --black-a9: rgba(0, 0, 0, 0.7); + --red-contrast: white; + --slate-contrast: white; + --gray-contrast: white; +} + +:root, .light, .light-theme { + --red-track: var(--red-9); + --red-surface: #fff7f7cc; +} + +.dark, .dark-theme { + --red-track: var(--red-9); + --red-surface: #2f151780; +} + +@supports (color: color-mix(in oklab, white, black)) { + .dark, .dark-theme { + --red-track: color-mix(in oklab, var(--red-a9), var(--red-9) 65%); + } +} + +:where(.radix-themes) { + --color-background: white; + --color-panel-solid: white; + --color-panel-translucent: rgba(255, 255, 255, 0.7); + --color-transparent: rgb(0 0 0 / 0); + --shadow-1: + inset 0 0 0 1px var(--gray-a9), + inset 0 1.5px 2px 0 var(--black-a9); + --shadow-2: + 0 0 0 1px var(--gray-a9), + 0 1px 3px 0 var(--black-a9); +} + +:is(.dark, .dark-theme), +:is(.dark, .dark-theme) :where(.radix-themes:not(.light, .light-theme)) { + --color-background: var(--gray-9); + --color-panel-solid: var(--gray-9); + --color-panel-translucent: var(--gray-a9); + --shadow-1: + inset 0 -1px 1px 0 var(--gray-a9), + inset 0 0 0 1px var(--gray-a9); + --shadow-2: + 0 0 0 1px var(--gray-a9), + 0 1px 3px 0 var(--black-a9); +} + +@supports (color: color-mix(in oklab, white, black)) { + :where(.radix-themes) { + --shadow-2: + 0 0 0 1px color-mix(in oklab, var(--gray-a9), var(--gray-9) 25%), + 0 1px 3px 0 var(--black-a9); + } +} + +@supports (color: color(display-p3 1 1 1)) { + @media (color-gamut: p3) { + .radix-themes { + --color-transparent: color(display-p3 0 0 0 / 0); + } + } +} + +.radix-themes:where(.light, .light-theme), :root:where(:has(.radix-themes[data-is-root-theme='true']:where(.light, .light-theme))) { + color-scheme: light; +} + +.radix-themes:where(.dark, .dark-theme), :root:where(:has(.radix-themes[data-is-root-theme='true']:where(.dark, .dark-theme))) { + color-scheme: dark; +} + +.radix-themes, +[data-accent-color]:where(:not([data-accent-color=''], [data-accent-color='gray'])) { + --focus-9: var(--accent-9); +} + +.radix-themes ::selection { + background-color: var(--focus-9); +} + +.radix-themes:where([data-has-background='true']) { + background-color: var(--color-background); +} + +.radix-themes:where([data-panel-background='solid']) { + --color-panel: var(--color-panel-solid); + --backdrop-filter-panel: none; +} + +.radix-themes:where([data-panel-background='translucent']) { + --color-panel: var(--color-panel-translucent); + --backdrop-filter-panel: blur(64px); +} + +[data-accent-color='gray'] { + --accent-9: var(--gray-9); + --accent-a9: var(--gray-a9); + --accent-contrast: var(--gray-contrast); +} + +[data-accent-color='red'] { + --accent-9: var(--red-9); + --accent-a9: var(--red-a9); + --accent-contrast: var(--red-contrast); +} + +.radix-themes:where([data-gray-color='slate']) { + --gray-9: var(--slate-9); + --gray-a9: var(--slate-a9); + --gray-contrast: var(--slate-contrast); +} + +.radix-themes { + --cursor-button: default; + --space-1: calc(4px * var(--scaling)); + --font-size-3: calc(16px * var(--scaling)); + --font-weight-regular: 400; + --default-font-family: -apple-system, 'Segoe UI (Custom)', sans-serif; + --default-font-size: var(--font-size-3); + --code-font-weight: inherit; + overflow-wrap: break-word; + font-family: var(--default-font-family); + font-size: var(--default-font-size); + -webkit-text-size-adjust: none; + text-size-adjust: none; + -webkit-font-smoothing: antialiased; + color: var(--gray-9); +} + +.radix-themes:where([data-scaling='90%']) { + --scaling: 0.9; +} + +.radix-themes:where([data-scaling='100%']) { + --scaling: 1; +} + +[data-radius] { + --radius-1: calc(3px * var(--scaling) * var(--radius-factor)); +} + +[data-radius='medium'] { + --radius-factor: 1; + --radius-full: 0px; +} + +[data-radius='full'] { + --radius-factor: 1.5; + --radius-full: 9999px; +} + +@font-face { + font-family: 'Segoe UI (Custom)'; + src: local('Segoe UI'); +} diff --git a/packages/reflex-components-ui/js/tests/generate.test.js b/packages/reflex-components-ui/js/tests/generate.test.js new file mode 100644 index 00000000000..84ed5b4172f --- /dev/null +++ b/packages/reflex-components-ui/js/tests/generate.test.js @@ -0,0 +1,58 @@ +// @vitest-environment node +import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +import { afterEach, beforeEach, expect, test } from "vitest"; + +import { generate } from "../scripts/generate.js"; + +const GENERATED = [ + { path: "tokens/space.stylex.js", render: () => "export const space = 1;\n" }, + { path: "style/_css_props.py", render: async () => "PROPS = ()\n" }, +]; + +/** @type {string} */ +let root; + +beforeEach(async () => { + root = await mkdtemp(join(tmpdir(), "reflex-ui-generate-")); +}); + +afterEach(async () => { + await rm(root, { recursive: true }); +}); + +test("writes every file, creating its directory", async () => { + expect(await generate(GENERATED, root, false)).toEqual([ + "tokens/space.stylex.js", + "style/_css_props.py", + ]); + expect(await readFile(join(root, "tokens/space.stylex.js"), "utf8")).toBe( + "export const space = 1;\n", + ); + expect(await readFile(join(root, "style/_css_props.py"), "utf8")).toBe( + "PROPS = ()\n", + ); +}); + +test("check reports nothing for files that match their generator", async () => { + await generate(GENERATED, root, false); + expect(await generate(GENERATED, root, true)).toEqual([]); +}); + +test("check reports an edited file and a missing one, and writes neither", async () => { + await generate(GENERATED, root, false); + await writeFile(join(root, "tokens/space.stylex.js"), "edited by hand\n"); + await rm(join(root, "style/_css_props.py")); + expect(await generate(GENERATED, root, true)).toEqual([ + "tokens/space.stylex.js", + "style/_css_props.py", + ]); + expect(await readFile(join(root, "tokens/space.stylex.js"), "utf8")).toBe( + "edited by hand\n", + ); + await expect(readFile(join(root, "style/_css_props.py"))).rejects.toThrow( + "ENOENT", + ); +}); diff --git a/packages/reflex-components-ui/js/tests/harness/base.css b/packages/reflex-components-ui/js/tests/harness/base.css new file mode 100644 index 00000000000..8afe7759719 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/base.css @@ -0,0 +1,9 @@ +/* What the stylesheet every page loads has to say for the themes to work. The + stylesheet itself belongs to the app's build, not to these modules. */ +html, +html.light { + color-scheme: light; +} +html.dark { + color-scheme: dark; +} diff --git a/packages/reflex-components-ui/js/tests/harness/browser.js b/packages/reflex-components-ui/js/tests/harness/browser.js new file mode 100644 index 00000000000..b0b1d7db98f --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/browser.js @@ -0,0 +1,184 @@ +// Opens the two pages of the sweep in headless Chromium and compares what they +// read. + +import { readFileSync } from "node:fs"; +import { mkdtemp, readFile, rm } from "node:fs/promises"; +import { createRequire } from "node:module"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +import { chromium } from "playwright"; + +import { buildHarness } from "./build.js"; +import { labels } from "./probe.js"; + +/** @typedef {import("./page.js").Config} Config */ +/** @typedef {import("./page.js").Harness} Harness */ +/** @typedef {"srgb" | "p3"} Gamut */ + +/** + * A value the two pages disagree on, or that one of them could not read. + * + * @typedef {object} Difference + * @property {Config} config The page that was shown. + * @property {Gamut} gamut The gamut of the screen. + * @property {string} label The custom property, or the property of the theme + * element. + * @property {string} ours What the StyleX modules give. + * @property {string} radix What @radix-ui/themes gives. + */ + +const ORIGIN = "http://harness.test"; +const TYPES = { html: "text/html", js: "text/javascript", css: "text/css" }; +const CHUNK = 250; + +/** + * Every custom property the token stylesheet of @radix-ui/themes defines. + * + * @returns {string[]} Their names, in the order they first appear. + */ +export function radixCustomProperties() { + const css = readFileSync( + createRequire(import.meta.url).resolve("@radix-ui/themes/tokens.css"), + "utf8", + ); + return [ + ...new Set( + Array.from(css.matchAll(/^\s*(--[\w-]+):/gm), ([, name]) => name), + ), + ]; +} + +/** + * Build the two pages and open them. + * + * @returns {Promise<{ + * names: string[], + * ours: import("playwright").Page, + * radix: import("playwright").Page, + * setGamut: (gamut: Gamut) => Promise, + * read: (page: import("playwright").Page, config: Config) => Promise>, + * compare: (configs: Config[], gamut: Gamut) => Promise<{ differences: Difference[], distinct: number }>, + * close: () => Promise, + * }>} The pages, and what drives them. + */ +export async function openHarness() { + const dist = await mkdtemp(join(tmpdir(), "reflex-ui-harness-")); + await buildHarness(["ours.html", "radix.html"], dist); + const browser = await chromium.launch(); + const context = await browser.newContext(); + await context.route(`${ORIGIN}/**`, async (route) => { + const path = new URL(route.request().url()).pathname; + const extension = /** @type {keyof typeof TYPES} */ (path.split(".").pop()); + await route.fulfill({ + body: await readFile(join(dist, path)), + contentType: TYPES[extension], + }); + }); + const names = radixCustomProperties(); + const all = labels(names); + const pages = await Promise.all( + ["ours", "radix"].map(async (name) => { + const page = await context.newPage(); + page.on("pageerror", (error) => { + throw error; + }); + await page.goto(`${ORIGIN}/${name}.html`); + await page.waitForFunction(() => "harness" in window); + await page.evaluate( + (properties) => + /** @type {{ harness: Harness }} */ ( + /** @type {unknown} */ (window) + ).harness.setup(properties), + names, + ); + return { page, session: await context.newCDPSession(page) }; + }), + ); + const [ours, radix] = pages.map(({ page }) => page); + + /** @type {(gamut: Gamut) => Promise} */ + const setGamut = async (gamut) => { + for (const { session } of pages) { + await session.send("Emulation.setEmulatedMedia", { + features: [{ name: "color-gamut", value: gamut }], + }); + } + }; + + /** + * Show pages in one of the two documents. + * + * @template {"show" | "sweep"} Method + * @param {import("playwright").Page} page The document. + * @param {Method} method How much to bring back. + * @param {Parameters[0]} argument What to show. + * @returns {Promise>>} What was read. + */ + const run = (page, method, argument) => + page.evaluate( + ([name, value]) => + /** @type {any} */ (window).harness[/** @type {string} */ (name)]( + value, + ), + [method, argument], + ); + + return { + names, + ours, + radix, + setGamut, + read: async (page, config) => { + const values = await run(page, "show", config); + return Object.fromEntries( + all.map((label, position) => [label, values[position]]), + ); + }, + compare: async (configs, gamut) => { + await setGamut(gamut); + /** @type {Difference[]} */ + const differences = []; + const hashes = new Set(); + for (let start = 0; start < configs.length; start += CHUNK) { + const chunk = configs.slice(start, start + CHUNK); + const [mine, theirs] = await Promise.all([ + run(ours, "sweep", chunk), + run(radix, "sweep", chunk), + ]); + for (const [index, config] of chunk.entries()) { + hashes.add(theirs[index].hash); + if ( + mine[index].hash === theirs[index].hash && + mine[index].invalid + theirs[index].invalid === 0 + ) { + continue; + } + const [mineValues, theirValues] = await Promise.all([ + run(ours, "show", config), + run(radix, "show", config), + ]); + for (const [position, label] of all.entries()) { + if ( + mineValues[position] !== theirValues[position] || + theirValues[position].startsWith("INVALID") + ) { + differences.push({ + config, + gamut, + label, + ours: mineValues[position], + radix: theirValues[position], + }); + } + } + } + } + return { differences, distinct: hashes.size }; + }, + close: async () => { + await browser.close(); + await rm(dist, { recursive: true }); + }, + }; +} diff --git a/packages/reflex-components-ui/js/tests/harness/build.js b/packages/reflex-components-ui/js/tests/harness/build.js new file mode 100644 index 00000000000..e9d99a12a25 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/build.js @@ -0,0 +1,40 @@ +// Builds the pages the live tests load: plain Vite with the StyleX plugin, set +// up the way an app's build sets it up. + +import { fileURLToPath } from "node:url"; + +import stylex from "@stylexjs/unplugin"; +import { Features } from "lightningcss"; +import { build } from "vite"; + +const ROOT = fileURLToPath(new URL("./", import.meta.url)); + +// The options Reflex gives StyleX in an app. +export const STYLEX_OPTIONS = { + useCSSLayers: { prefix: "reflex-ui" }, + styleResolution: /** @type {const} */ ("application-order"), + lightningcssOptions: { minify: true, exclude: Features.LightDark }, +}; + +/** + * Build entries of the harness. + * + * @param {string[]} entries The html or javascript files to build, relative to + * this directory. + * @param {string} outDir Where the build goes. + * @returns {Promise} + */ +export async function buildHarness(entries, outDir) { + await build({ + root: ROOT, + base: "./", + configFile: false, + logLevel: "error", + plugins: [stylex.vite(STYLEX_OPTIONS)], + build: { + outDir, + emptyOutDir: true, + rollupOptions: { input: entries.map((entry) => `${ROOT}${entry}`) }, + }, + }); +} diff --git a/packages/reflex-components-ui/js/tests/harness/configs.js b/packages/reflex-components-ui/js/tests/harness/configs.js new file mode 100644 index 00000000000..6353086efd2 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/configs.js @@ -0,0 +1,90 @@ +// The pages the sweep shows: every value of every prop of a Radix `Theme`. + +import { themePropDefs } from "@radix-ui/themes/props"; + +/** @typedef {import("./page.js").Config} Config */ + +const { accentColor, grayColor, radius, scaling, panelBackground } = + themePropDefs; + +export const APPEARANCES = /** @type {const} */ (["light", "dark"]); +export const ACCENTS = accentColor.values; +export const GRAYS = grayColor.values; +export const RADII = radius.values; +export const SCALINGS = scaling.values; +export const PANELS = panelBackground.values; + +/** @type {Config["theme"]} */ +export const DEFAULT_THEME = { + accentColor: accentColor.default, + grayColor: grayColor.default, + radius: radius.default, + scaling: scaling.default, + panelBackground: panelBackground.default, + hasBackground: true, +}; + +/** + * Every combination of the values of some props, the others at their default. + * + * @param {{ [Key in keyof Config["theme"]]?: readonly Config["theme"][Key][] }} props + * The values to combine. + * @returns {Config[]} One page for each combination, in each appearance. + */ +export function combinations(props) { + /** @type {Config[]} */ + let configs = APPEARANCES.map((appearance) => ({ + appearance, + theme: DEFAULT_THEME, + })); + for (const [prop, values] of Object.entries(props)) { + configs = configs.flatMap((config) => + values.map((value) => ({ + ...config, + theme: { ...config.theme, [prop]: value }, + })), + ); + } + return configs; +} + +/** + * The whole sweep: the product of every accent, gray, appearance, radius and + * scaling, then the panel and the background against every color. + * + * @returns {Config[]} 10,556 pages. + */ +export function fullSweep() { + return [ + ...combinations({ + accentColor: ACCENTS, + grayColor: GRAYS, + radius: RADII, + scaling: SCALINGS, + }), + ...combinations({ + accentColor: ACCENTS, + grayColor: GRAYS, + panelBackground: PANELS, + hasBackground: [true, false], + }), + ]; +} + +/** + * The part of the sweep `npm test` runs: every value of every prop, combined + * only with the props its tokens depend on. + * + * @returns {Config[]} 470 pages. + */ +export function fastSweep() { + return [ + ...combinations({ accentColor: ACCENTS, grayColor: GRAYS }), + ...combinations({ radius: RADII, scaling: SCALINGS }), + ...combinations({ + grayColor: GRAYS, + panelBackground: PANELS, + hasBackground: [true, false], + }), + ]; +} diff --git a/packages/reflex-components-ui/js/tests/harness/exceptions.js b/packages/reflex-components-ui/js/tests/harness/exceptions.js new file mode 100644 index 00000000000..9327aecc0ca --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/exceptions.js @@ -0,0 +1,36 @@ +// Where a value read under the StyleX modules is allowed to differ from the +// one read under @radix-ui/themes, and why. Both pages put what they read +// through `normalize` before the two are compared, so an entry here has to say +// why the difference cannot be seen. + +/** + * @typedef {object} Exception + * @property {RegExp} pattern The custom properties it applies to. + * @property {string} reason Why the difference is not one. + * @property {(value: string) => string} [normalize] Removes the difference + * from a computed value. + * @property {true} [undefined] Neither page defines the custom property, which + * is otherwise a failure of the sweep. + */ + +/** @type {Exception[]} */ +export const EXCEPTIONS = [ + { + pattern: + /^--(code-font-weight|strong-font-style|em-font-weight|quote-font-weight)$/, + reason: + "Radix declares these as `inherit`. That is a CSS-wide keyword on a custom property too: the property inherits from the parent, which has none, so it is not defined and `var()` of it is invalid. The modules declare the same and get the same.", + undefined: true, + }, + { + pattern: /^--shadow-\d$/, + reason: + "The light and dark shadows of Radix differ in geometry, and `light-dark()` only chooses between colors. A shadow here lists the layers of both appearances, and a layer the current appearance does not have is `transparent`: it paints nothing, but it is in the computed value.", + normalize: (value) => { + const layers = value + .split(/, (?![^(]*\))/) + .filter((layer) => !layer.startsWith("rgba(0, 0, 0, 0) ")); + return layers.join(", ") || "none"; + }, + }, +]; diff --git a/packages/reflex-components-ui/js/tests/harness/ours.html b/packages/reflex-components-ui/js/tests/harness/ours.html new file mode 100644 index 00000000000..daca2566ff8 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/ours.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packages/reflex-components-ui/js/tests/harness/ours.js b/packages/reflex-components-ui/js/tests/harness/ours.js new file mode 100644 index 00000000000..6530796283c --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/ours.js @@ -0,0 +1,101 @@ +// The page under test: the StyleX modules of `src`, applied the way the python +// side applies them. Nothing here is specific to the root: a nested theme is +// the same classes on another element. + +import { getMatchingGrayColor } from "@radix-ui/themes/helpers"; +import * as stylex from "@stylexjs/stylex"; + +import { focusScope } from "../../src/themes/focus.js"; +import * as panels from "../../src/themes/panel.js"; +import * as radii from "../../src/themes/radius.js"; +import * as scalings from "../../src/themes/scaling.js"; +import * as scopes from "../../src/themes/scope.js"; +import { theme as styles } from "../../src/themes/theme.js"; +import { install } from "./page.js"; + +/** @typedef {import("@stylexjs/stylex").Theme} StyleXTheme */ + +/** + * The themes of a directory with one module for each. + * + * @param {Record>} modules What + * `import.meta.glob` found. + * @returns {Record} The theme of each module, by the name + * of its file. + */ +function byName(modules) { + return Object.fromEntries( + Object.entries(modules).map(([path, module]) => [ + path.replace(/^.*\/|\.js$/g, ""), + Object.values(module)[0], + ]), + ); +} + +// Every scale and every token is on the page, as the sweep reads them all. An +// app only has the ones something imports. +import.meta.glob("../../src/{colors,tokens}/*.stylex.js", { eager: true }); + +const accents = byName( + import.meta.glob("../../src/themes/accent/*.js", { eager: true }), +); +const grays = byName( + import.meta.glob("../../src/themes/gray/*.js", { eager: true }), +); + +/** + * The export of a module with a theme for each value of a prop. + * + * @param {Record} module The module. + * @param {string} prefix What its exports start with. + * @param {string | undefined} value The value of the prop. + * @returns {StyleXTheme | undefined} The theme, when the prop is set. + */ +function member(module, prefix, value) { + if (value === undefined) return undefined; + const word = value.replace(/\W/g, ""); + return module[prefix + word[0].toUpperCase() + word.slice(1)]; +} + +/** + * The classes of a theme element. + * + * @param {import("./page.js").ThemeProps} props What the theme sets. A prop + * that is left out is inherited. + * @returns {string} The class names. + */ +function themeClass(props) { + const { accentColor, hasBackground, appearance } = props; + const grayColor = + props.grayColor === "auto" + ? getMatchingGrayColor(/** @type {any} */ (accentColor)) + : props.grayColor; + return /** @type {string} */ ( + stylex.props( + Object.values(scopes), + focusScope, + accentColor ? accents[accentColor] : null, + grayColor ? grays[grayColor] : null, + member(radii, "radius", props.radius), + member(scalings, "scaling", props.scaling), + member(panels, "panel", props.panelBackground), + styles.root, + hasBackground && styles.background, + appearance && styles[appearance], + ).className + ); +} + +const root = document.body.appendChild(document.createElement("div")); +const inner = document.createElement("div"); + +install(({ theme, nested }) => { + root.className = themeClass(theme); + if (nested) { + inner.className = themeClass(nested); + root.append(inner); + return inner; + } + inner.remove(); + return root; +}); diff --git a/packages/reflex-components-ui/js/tests/harness/page.js b/packages/reflex-components-ui/js/tests/harness/page.js new file mode 100644 index 00000000000..e001b246f35 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/page.js @@ -0,0 +1,95 @@ +// What the two pages of the sweep share: the theme a page is asked to show, +// and reading it back. + +import { digest, mount, read } from "./probe.js"; + +/** + * The props of a Radix `Theme`, by their Radix names. + * + * @typedef {object} ThemeProps + * @property {string} [accentColor] + * @property {string} [grayColor] + * @property {string} [radius] + * @property {string} [scaling] + * @property {string} [panelBackground] + * @property {boolean} [hasBackground] + * @property {"light" | "dark"} [appearance] On a nested theme only: the page's + * own appearance is the class of `html`. + */ + +/** + * A page to show. + * + * @typedef {object} Config + * @property {"light" | "dark"} appearance The class of `html`. + * @property {Required>} theme The root theme. + * @property {ThemeProps} [nested] A theme inside it, around what is read. + * @property {boolean} [popover] Read from an open popover, which the browser + * renders in the top layer. + */ + +/** + * The functions the test drives a page with. + * + * @typedef {object} Harness + * @property {(names: string[]) => void} setup Says which custom properties to + * read. + * @property {(config: Config) => string[]} show Shows a page and reads it. + * @property {(configs: Config[]) => Promise[]>} sweep + * Shows each page and digests what it reads. + */ + +// React counts the renders it is asked for without a task ending between them, +// and stops at fifty. +const channel = new MessageChannel(); + +/** + * Let the current task end. + * + * @returns {Promise} Resolved in a task of its own. + */ +function nextTask() { + return new Promise((resolve) => { + channel.port1.onmessage = () => resolve(); + channel.port2.postMessage(null); + }); +} + +/** + * Give the page its harness. + * + * @param {(config: Config) => Element} render Shows the themes of a + * configuration and returns the innermost theme element. + */ +export function install(render) { + const container = document.createElement("div"); + /** @type {ReturnType} */ + let probes = []; + /** @type {Harness["show"]} */ + const show = (config) => { + if (container.matches(":popover-open")) container.hidePopover(); + container.toggleAttribute("popover", config.popover === true); + document.documentElement.className = config.appearance; + const theme = render(config); + theme.append(container); + if (config.popover) container.showPopover(); + return read(probes, theme); + }; + /** @type {Harness} */ + const harness = { + setup: (names) => { + container.replaceChildren(); + probes = mount(container, names); + }, + show, + sweep: async (configs) => { + const digests = []; + for (const config of configs) { + digests.push(digest(show(config))); + await nextTask(); + } + return digests; + }, + }; + Object.assign(window, { harness }); +} diff --git a/packages/reflex-components-ui/js/tests/harness/probe.js b/packages/reflex-components-ui/js/tests/harness/probe.js new file mode 100644 index 00000000000..c85ebe6d675 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/probe.js @@ -0,0 +1,114 @@ +// Runs in both pages of the sweep: reads what every custom property resolves to +// on an element, through a property of the type the value has. The computed +// value of the custom property itself would not do: here it is the +// `light-dark()` pair, in Radix the color of one appearance. + +import { EXCEPTIONS } from "./exceptions.js"; + +// The property each custom property is read through. The first match wins, and +// a custom property with no match fails the sweep. +const PROBES = /** @type {const} */ ([ + [/^--shadow-/, "box-shadow"], + [/^--cursor-/, "cursor"], + [/^--backdrop-filter-/, "backdrop-filter"], + [/-font-family$/, "font-family"], + [/-font-style$/, "font-style"], + [/^--font-weight-|-font-weight$/, "font-weight"], + [/^--default-line-height$/, "line-height"], + [/^--scaling$|^--radius-factor$|-font-size-adjust$/, "flex-grow"], + [ + /^--(space|radius|font-size|line-height|heading-line-height|letter-spacing)-|^--default-font-size$|-(letter|word)-spacing$|-leading-trim-(start|end)$|^--code-padding-/, + "margin-left", + ], + [/^--color-|^--[a-z]+-(a?\d+|contrast|surface|indicator|track)$/, "color"], +]); + +// What Radix sets on a theme element itself. +const ELEMENT = [ + "color", + "background-color", + "font-family", + "font-size", + "font-weight", + "font-style", + "line-height", + "letter-spacing", + "overflow-wrap", + "text-size-adjust", + "-webkit-font-smoothing", +]; + +/** + * The names of the values `read` returns. + * + * @param {string[]} names The custom properties. + * @returns {string[]} Them, then the properties of the theme element. + */ +export function labels(names) { + return [...names, ...ELEMENT.map((property) => `(element) ${property}`)]; +} + +/** + * Add an element for each custom property, styled with it. + * + * @param {Element} container Where the elements go. + * @param {string[]} names The custom properties. + * @returns {{ name: string, property: string, style: CSSStyleDeclaration, exception?: import("./exceptions.js").Exception }[]} + * What to read each one from. + */ +export function mount(container, names) { + return names.map((name) => { + const property = PROBES.find(([pattern]) => pattern.test(name))?.[1]; + if (!property) throw new Error(`No probe for ${name}`); + const element = document.createElement("i"); + element.style.setProperty(property, `var(${name})`); + container.append(element); + const exception = EXCEPTIONS.find(({ pattern }) => pattern.test(name)); + return { name, property, style: getComputedStyle(element), exception }; + }); +} + +/** + * What every custom property resolves to, and the theme element's own styles. + * + * @param {ReturnType} probes What `mount` returned. + * @param {Element} theme The theme element the probes are in. + * @returns {string[]} A value for each of `labels`. A custom property that is + * not defined, or whose value is not one its probe takes, reads as `INVALID` + * and what it holds, as both pages would otherwise agree on the fallback. + */ +export function read(probes, theme) { + const inherited = getComputedStyle(theme); + const values = probes.map(({ name, property, style, exception }) => { + const raw = style.getPropertyValue(name); + if (raw === "" && exception?.undefined) return "undefined"; + if (raw === "" || !CSS.supports(property, raw)) return `INVALID ${raw}`; + const value = style.getPropertyValue(property); + return exception?.normalize ? exception.normalize(value) : value; + }); + for (const property of ELEMENT) { + values.push(inherited.getPropertyValue(property)); + } + return values; +} + +/** + * A short digest of the values, to compare a combination without moving them + * all out of the page. + * + * @param {string[]} values What `read` returned. + * @returns {{ hash: number, invalid: number }} An FNV-1a hash, and how many of + * the values are invalid. + */ +export function digest(values) { + let hash = 0x811c9dc5; + let invalid = 0; + for (const value of values) { + if (value.startsWith("INVALID")) invalid++; + for (let index = 0; index < value.length; index++) { + hash = Math.imul(hash ^ value.charCodeAt(index), 0x01000193); + } + hash = Math.imul(hash ^ 0xff, 0x01000193); + } + return { hash: hash >>> 0, invalid }; +} diff --git a/packages/reflex-components-ui/js/tests/harness/radix.html b/packages/reflex-components-ui/js/tests/harness/radix.html new file mode 100644 index 00000000000..d3b85af6435 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/radix.html @@ -0,0 +1,10 @@ + + + + + + +
+ + + diff --git a/packages/reflex-components-ui/js/tests/harness/radix.js b/packages/reflex-components-ui/js/tests/harness/radix.js new file mode 100644 index 00000000000..f12acac30d8 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/radix.js @@ -0,0 +1,42 @@ +// The reference page: the stylesheet of @radix-ui/themes and its `Theme` +// component, which decides the attributes the stylesheet selects on. + +import "@radix-ui/themes/styles.css"; + +import { Theme } from "@radix-ui/themes"; +import { createElement } from "react"; +import { flushSync } from "react-dom"; +import { createRoot } from "react-dom/client"; + +import { install } from "./page.js"; + +const root = createRoot( + /** @type {Element} */ (document.getElementById("root")), +); + +install(({ theme, nested }) => { + const target = createElement("div", { id: "target" }); + flushSync(() => + root.render( + createElement( + Theme, + // A root `Theme` copies its props into state after it has painted. A + // new one for each theme starts from the props it is given. + /** @type {import("@radix-ui/themes").ThemeProps} */ ({ + key: JSON.stringify(theme), + ...theme, + }), + nested + ? createElement( + Theme, + /** @type {import("@radix-ui/themes").ThemeProps} */ (nested), + target, + ) + : target, + ), + ), + ); + return /** @type {Element} */ ( + document.querySelector(".radix-themes:has(> #target)") + ); +}); diff --git a/packages/reflex-components-ui/js/tests/harness/size/accents.js b/packages/reflex-components-ui/js/tests/harness/size/accents.js new file mode 100644 index 00000000000..745fe5e3e31 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/size/accents.js @@ -0,0 +1,33 @@ +// The whole theme and the other twenty-five accents, which is what an accent +// bound to state costs. + +import * as stylex from "@stylexjs/stylex"; + +import { accentIndigo } from "../../../src/themes/accent/indigo.js"; +import { focusScope } from "../../../src/themes/focus.js"; +import { graySlate } from "../../../src/themes/gray/slate.js"; +import { panelTranslucent } from "../../../src/themes/panel.js"; +import { radiusMedium } from "../../../src/themes/radius.js"; +import { scaling100 } from "../../../src/themes/scaling.js"; +import * as scopes from "../../../src/themes/scope.js"; +import { theme } from "../../../src/themes/theme.js"; + +import.meta.glob("../../../src/tokens/*.stylex.js", { eager: true }); +import.meta.glob("../../../src/themes/accent/*.js", { eager: true }); + +const styles = stylex.create({ body: { margin: 0 } }); + +const applied = [ + styles.body, + ...Object.values(scopes), + focusScope, + accentIndigo, + graySlate, + radiusMedium, + scaling100, + panelTranslucent, + theme.root, + theme.background, +]; + +document.body.className = stylex.props(applied).className ?? ""; diff --git a/packages/reflex-components-ui/js/tests/harness/size/baseline.js b/packages/reflex-components-ui/js/tests/harness/size/baseline.js new file mode 100644 index 00000000000..d421c5cb24b --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/size/baseline.js @@ -0,0 +1,11 @@ +// What a page pays for StyleX before it has a token or a theme. + +import * as stylex from "@stylexjs/stylex"; + +const styles = stylex.create({ body: { margin: 0 } }); + +// A list the compiler cannot see through, so that every entry has the runtime +// of StyleX and they differ by their styles alone. +const applied = [styles.body]; + +document.body.className = stylex.props(applied).className ?? ""; diff --git a/packages/reflex-components-ui/js/tests/harness/size/theme.js b/packages/reflex-components-ui/js/tests/harness/size/theme.js new file mode 100644 index 00000000000..70ff5503154 --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/size/theme.js @@ -0,0 +1,32 @@ +// One whole theme, as the root of an app has it: every token, the scope, one +// accent and one gray in both appearances, a radius, a scaling and a panel. + +import * as stylex from "@stylexjs/stylex"; + +import { accentIndigo } from "../../../src/themes/accent/indigo.js"; +import { focusScope } from "../../../src/themes/focus.js"; +import { graySlate } from "../../../src/themes/gray/slate.js"; +import { panelTranslucent } from "../../../src/themes/panel.js"; +import { radiusMedium } from "../../../src/themes/radius.js"; +import { scaling100 } from "../../../src/themes/scaling.js"; +import * as scopes from "../../../src/themes/scope.js"; +import { theme } from "../../../src/themes/theme.js"; + +import.meta.glob("../../../src/tokens/*.stylex.js", { eager: true }); + +const styles = stylex.create({ body: { margin: 0 } }); + +const applied = [ + styles.body, + ...Object.values(scopes), + focusScope, + accentIndigo, + graySlate, + radiusMedium, + scaling100, + panelTranslucent, + theme.root, + theme.background, +]; + +document.body.className = stylex.props(applied).className ?? ""; diff --git a/packages/reflex-components-ui/js/tests/harness/size/tokens.js b/packages/reflex-components-ui/js/tests/harness/size/tokens.js new file mode 100644 index 00000000000..3910b5b97ad --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/size/tokens.js @@ -0,0 +1,14 @@ +// The baseline and every token, with no color scale but the black one that the +// shadows and the overlay are made of. + +import * as stylex from "@stylexjs/stylex"; + +import.meta.glob("../../../src/tokens/*.stylex.js", { eager: true }); + +const styles = stylex.create({ body: { margin: 0 } }); + +// A list the compiler cannot see through, so that every entry has the runtime +// of StyleX and they differ by their styles alone. +const applied = [styles.body]; + +document.body.className = stylex.props(applied).className ?? ""; diff --git a/packages/reflex-components-ui/js/tests/harness/sweep.js b/packages/reflex-components-ui/js/tests/harness/sweep.js new file mode 100644 index 00000000000..6d4a5121feb --- /dev/null +++ b/packages/reflex-components-ui/js/tests/harness/sweep.js @@ -0,0 +1,27 @@ +// The whole token sweep, `npm run sweep`: every custom property Radix Themes +// defines, in every combination of accent, gray, appearance, radius and +// scaling, read under the StyleX modules and under @radix-ui/themes, on an sRGB +// screen and on a display-P3 one. `npm test` runs part of it. + +import { openHarness } from "./browser.js"; +import { fullSweep } from "./configs.js"; + +const start = Date.now(); +const harness = await openHarness(); +const configs = fullSweep(); +let failed = false; +for (const gamut of /** @type {const} */ (["srgb", "p3"])) { + const { differences, distinct } = await harness.compare(configs, gamut); + console.log( + `${gamut}: ${configs.length} themes x ${harness.names.length} custom properties, ${distinct} distinct results, ${differences.length} differences`, + ); + for (const { config, label, ours, radix } of differences.slice(0, 50)) { + console.log( + ` ${label} in ${JSON.stringify(config)}\n ours: ${ours}\n radix: ${radix}`, + ); + } + failed ||= differences.length > 0; +} +await harness.close(); +console.log(`${((Date.now() - start) / 1000).toFixed(1)}s`); +process.exit(failed ? 1 : 0); diff --git a/packages/reflex-components-ui/js/tests/lint.test.js b/packages/reflex-components-ui/js/tests/lint.test.js new file mode 100644 index 00000000000..ac3bcb9cd1e --- /dev/null +++ b/packages/reflex-components-ui/js/tests/lint.test.js @@ -0,0 +1,228 @@ +// @vitest-environment node +// Each rule the package's lint enforces on `src`, shown rejecting a file that +// breaks it: a rule that is only configured can stop matching unnoticed. +import { fileURLToPath } from "node:url"; + +import { ESLint } from "eslint"; +import { expect, test } from "vitest"; + +const eslint = new ESLint({ + cwd: fileURLToPath(new URL("..", import.meta.url)), +}); + +const NO_JSX = + "No JSX here: the markup of an rx.ui component comes from its Python wrapper. Only tests/behaviors may render JSX."; +const NO_BARREL = + "No barrel files: a re-export leaks the CSS of everything it names. Import from the module that defines the name."; +const VARS_EXTENSION = + "Files that export variables from `stylex.defineVars()`, `stylex.defineConsts()`, or `stylex.defineMarker()` must end with a `.stylex.js` extension."; +const NOT_STANDARD = + 'The value "start" is not a standard CSS value for "float". Did you mean "inline-start"?'; + +/** + * Lint source text as if it were the file at a path in the package. + * + * @param {string} filePath The path, relative to the package. + * @param {string} code The content of the file. + * @returns {Promise<{rule: string | null, line: number, message: string}[]>} + * Every problem reported, warnings included. + */ +async function lint(filePath, code) { + const [result] = await eslint.lintText(code, { filePath }); + return result.messages.map(({ ruleId, line, message }) => ({ + rule: ruleId, + line, + message, + })); +} + +test("a behaviour hook that follows the rules is clean", async () => { + const code = `import { useState } from "react"; + +export function useToggle() { + return useState(false); +} +`; + expect(await lint("src/behaviors/useToggle.js", code)).toEqual([]); +}); + +test.each([ + ["src/behaviors/Button.js", "an element", "', + ); + run(); + click(document.getElementById("icon"), { clientX: 7, ctrlKey: true }); + expect(clicks.length).toBe(1); + + await hydrate(); + expect( + clicks.map(({ target, clientX, ctrlKey, bubbles }) => ({ + target: target.id, + clientX, + ctrlKey, + bubbles, + })), + ).toEqual([ + { target: "icon", clientX: 7, ctrlKey: true, bubbles: true }, + { target: "icon", clientX: 7, ctrlKey: true, bubbles: true }, + ]); + expect(clicks[1]).not.toBe(clicks[0]); + expect(window.__reflex_early).toBe(undefined); + + // The page handles its own clicks from here on. + click(target); + await hydrate(); + expect(clicks.length).toBe(3); + }); + + test("only the last one is dispatched again", async () => { + const first = addToPage(''); + run(); + click(first.target); + const other = document.body.appendChild(document.createElement("button")); + const otherClicks = []; + other.addEventListener("click", (event) => otherClicks.push(event)); + click(other); + click(other); + + await hydrate(); + expect(first.clicks.length).toBe(1); + expect(otherClicks.length).toBe(3); + }); + + test.each([ + 'link', + 'link', + '', + '', + '', + '', + '
more
', + '
', + ])("is left alone where the browser acted on it: %s", async (html) => { + const { target, clicks } = addToPage(html); + target.addEventListener("click", (event) => event.preventDefault()); + run(); + click(target); + await hydrate(); + expect(clicks.length).toBe(1); + }); + + test("is dropped when its target has left the page", async () => { + const { target, clicks } = addToPage(''); + run(); + click(target); + target.remove(); + await hydrate(); + expect(clicks.length).toBe(1); + }); + + test("is not recorded once the entry point took it over", async () => { + const { target, clicks } = addToPage(''); + run(); + const { record } = window.__reflex_early; + const removed = vi.spyOn(document, "removeEventListener"); + await hydrate(); + expect(removed.mock.calls).toEqual([["click", record, true]]); + click(target); + await hydrate(); + expect(clicks.length).toBe(1); + }); + + test("is not dispatched again by an entry point that did not take it over", async () => { + const { target, clicks } = addToPage(''); + run(); + click(target); + await hydrate({ take: false }); + expect(clicks.length).toBe(1); + }); + + test("taking it over on a page without the inline script does nothing", async () => { + const { clicks } = addToPage(''); + await hydrate(); + expect(clicks).toEqual([]); + expect(window.__reflex_early).toBe(undefined); + }); + }); +}); diff --git a/packages/reflex-frontend/tests/state.test.js b/packages/reflex-frontend/tests/state.test.js index 3cd3440e5cf..f49dfcbfa09 100644 --- a/packages/reflex-frontend/tests/state.test.js +++ b/packages/reflex-frontend/tests/state.test.js @@ -41,6 +41,9 @@ import { ReflexEvent, spreadArraysOrObjects, } from "$/utils/state"; +// The connection to the backend, as the context module of an app with state +// loads it: the token and the cookie reader are its. +import "$/utils/socket"; const clearCookies = () => { for (const cookie of document.cookie.split("; ")) { diff --git a/packages/reflex-frontend/tests/state_connection.test.js b/packages/reflex-frontend/tests/state_connection.test.js index b8d40202803..2af4a6fb43e 100644 --- a/packages/reflex-frontend/tests/state_connection.test.js +++ b/packages/reflex-frontend/tests/state_connection.test.js @@ -1,10 +1,10 @@ /** - * The connection lifecycle of `utils/state.js`, with the socket replaced by a + * The connection lifecycle of `utils/socket.js`, with the socket replaced by a * fake the test drives: what happens to queued events when the connection * drops at an awkward moment, and what a torn-down event loop leaves behind. * - * `state.js` keeps its event queue, token and socket bookkeeping in module - * scope, so every test loads a fresh copy of the module. + * The event queue, token and socket bookkeeping are kept in module scope, so + * every test loads a fresh copy of the modules. */ import { act, createElement } from "react"; import { createRoot } from "react-dom/client"; @@ -95,6 +95,8 @@ beforeEach(async () => { looseSockets = []; sessionStorage.clear(); state = await import("$/utils/state"); + // An app with state loads the connection from its compiled context module. + await import("$/utils/socket"); registry = await import("$/utils/context-registry"); // Let the import's speculative transport warmup see an app without state, // then give it one: an app with a single substate never connects. diff --git a/packages/reflex-frontend/tests/state_without_backend.test.js b/packages/reflex-frontend/tests/state_without_backend.test.js new file mode 100644 index 00000000000..47b84595153 --- /dev/null +++ b/packages/reflex-frontend/tests/state_without_backend.test.js @@ -0,0 +1,229 @@ +/** + * `utils/state.js` in an app without state, whose compiled context module + * never imports `utils/socket.js`: the connection to the backend, socket.io + * and the cookie library stay out of the bundle, and what the browser can do + * by itself still works. + * + * The backend registry is module state, so every test loads fresh modules. + */ +import { act, createElement } from "react"; +import { createRoot } from "react-dom/client"; +import { MemoryRouter, useLocation } from "react-router"; +import { afterEach, beforeEach, expect, test, vi } from "vitest"; + +// Each factory runs when its module is first imported, and not before. +const loaded = vi.hoisted(() => []); +vi.mock("socket.io-client", () => { + loaded.push("socket.io-client"); + return { default: vi.fn() }; +}); +vi.mock("universal-cookie", () => { + loaded.push("universal-cookie"); + return { default: class {} }; +}); + +globalThis.IS_REACT_ACT_ENVIRONMENT = true; + +let state; + +beforeEach(async () => { + vi.resetModules(); + loaded.length = 0; + state = await import("$/utils/state"); + const registry = await import("$/utils/context-registry"); + // What the context module of an app without state registers. + registry.registerApp({ + initialState: {}, + clientStorage: {}, + initialEvents: () => [], + onLoadInternalEvent: () => [], + isDevMode: false, + }); +}); + +afterEach(() => { + vi.restoreAllMocks(); + document.body.replaceChildren(); +}); + +/** Mount a component running the event loop, as the app's root layout does. */ +const mountEventLoop = async () => { + const mounted = {}; + const Probe = () => { + [mounted.addEvents, mounted.connectErrors] = state.useEventLoop({}); + mounted.location = useLocation(); + return null; + }; + const root = createRoot( + document.body.appendChild(document.createElement("div")), + ); + await act(async () => { + root.render(createElement(MemoryRouter, null, createElement(Probe))); + }); + return { + mounted, + addEvents: (...args) => act(async () => mounted.addEvents(...args)), + unmount: () => act(async () => root.unmount()), + }; +}; + +test("loading utils/state.js loads neither socket.io nor the cookie library", async () => { + const { backend } = await import("$/utils/event_loop"); + expect(loaded).toEqual([]); + expect(backend).toEqual({}); +}); + +test("loading utils/socket.js registers the connection with utils/state.js", async () => { + const socket = await import("$/utils/socket"); + const { backend } = await import("$/utils/event_loop"); + expect(loaded.sort()).toEqual(["socket.io-client", "universal-cookie"]); + expect(Object.keys(backend).sort()).toEqual([ + "connect", + "getToken", + "hydrateClientStorage", + "sendEvent", + "useEventLoop", + "waitForSession", + ]); + expect(backend.connect).toBe(socket.connect); + expect(backend.useEventLoop).toBe(socket.useEventLoop); +}); + +test("the event loop runs browser events without a backend", async () => { + const loop = await mountEventLoop(); + const called = []; + + await loop.addEvents([ + state.ReflexEvent("_call_function", { function: () => called.push("fn") }), + state.ReflexEvent("_call_script", { + javascript_code: "[typeof socket, typeof token, isTrue([])]", + callback: (result) => called.push(result), + }), + state.ReflexEvent("_redirect", { path: "/other?x=1" }), + ]); + + expect(called).toEqual(["fn", ["object", "undefined", false]]); + expect(loop.mounted.location.pathname + loop.mounted.location.search).toBe( + "/other?x=1", + ); + expect(loop.mounted.connectErrors).toEqual([]); + expect(state.isStateful()).toBe(false); + expect(loaded).toEqual([]); + await loop.unmount(); +}); + +test("the event loop keeps one addEvents and one connectErrors across renders", async () => { + const loop = await mountEventLoop(); + const { addEvents, connectErrors } = loop.mounted; + await loop.addEvents([state.ReflexEvent("_redirect", { path: "/again" })]); + expect(loop.mounted.location.pathname).toBe("/again"); + expect(loop.mounted.addEvents).toBe(addEvents); + expect(loop.mounted.connectErrors).toBe(connectErrors); + await loop.unmount(); +}); + +test("event actions apply, and a temporal event is dropped", async () => { + const loop = await mountEventLoop(); + const called = []; + const dom_event = { preventDefault: vi.fn(), stopPropagation: vi.fn() }; + + await loop.addEvents( + [ + state.ReflexEvent( + "_call_function", + { function: () => called.push("kept") }, + { preventDefault: true }, + ), + ], + [dom_event], + { stopPropagation: true }, + ); + await loop.addEvents( + [state.ReflexEvent("_call_function", { function: () => called.push(1) })], + [], + { temporal: true }, + ); + + expect(called).toEqual(["kept"]); + expect(dom_event.preventDefault).toHaveBeenCalledTimes(1); + expect(dom_event.stopPropagation).toHaveBeenCalledTimes(1); + await loop.unmount(); +}); + +test("an event for the backend is dropped rather than sent", async () => { + const loop = await mountEventLoop(); + const called = []; + await loop.addEvents([ + state.ReflexEvent("some_state.handler", { value: 1 }), + state.ReflexEvent("_call_function", { + function: () => called.push("after"), + }), + ]); + expect(called).toEqual(["after"]); + await loop.unmount(); +}); + +test("_remove_cookie expires the cookie with the options it was set with", async () => { + document.cookie = "kept=1; path=/"; + document.cookie = "gone=1; path=/"; + const written = vi.spyOn(document, "cookie", "set"); + + await state.applyEvent( + state.ReflexEvent("_remove_cookie", { + key: "gone", + options: { path: "/" }, + }), + null, + null, + null, + ); + await state.applyEvent( + state.ReflexEvent("_remove_cookie", { + key: "scoped", + options: { + path: "/app", + domain: "example.com", + secure: true, + partitioned: true, + sameSite: "none", + }, + }), + null, + null, + null, + ); + + expect(written.mock.calls).toEqual([ + ["gone=; Max-Age=0; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT"], + [ + "scoped=; Max-Age=0; Domain=example.com; Path=/app; " + + "Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; Partitioned; SameSite=None", + ], + ]); + written.mockRestore(); + expect(document.cookie).toBe("kept=1"); + expect(loaded).toEqual([]); +}); + +test("the names that need the backend say so, or answer for an app without one", async () => { + expect(state.getToken()).toBe(""); + await expect(state.waitForSession()).resolves.toBeUndefined(); + expect(() => state.hydrateClientStorage({})).toThrow( + new Error( + "hydrateClientStorage needs the connection to the backend, which an app without state does not load.", + ), + ); + expect(() => state.connect({ current: null })).toThrow( + new Error( + "connect needs the connection to the backend, which an app without state does not load.", + ), + ); +}); + +test("with utils/socket.js loaded, the same names reach the connection", async () => { + sessionStorage.setItem("token", "stored-token"); + await import("$/utils/socket"); + expect(state.getToken()).toBe("stored-token"); + expect(state.hydrateClientStorage({})).toEqual({}); + sessionStorage.clear(); +}); diff --git a/packages/reflex-frontend/types/globals.d.ts b/packages/reflex-frontend/types/globals.d.ts index 01de4202d2d..da27fb87598 100644 --- a/packages/reflex-frontend/types/globals.d.ts +++ b/packages/reflex-frontend/types/globals.d.ts @@ -41,6 +41,11 @@ interface Window { /** Loads bundled libraries a dynamic component names, before it is evaluated. */ __reflex_load?: (libraries: string[]) => Promise; __reflex_otel?: ReflexOtelHooks; + /** + * The last click on a prerendered page before its scripts loaded, and the + * listener recording it. Set by the inline script of `utils/scripts.js`. + */ + __reflex_early?: { click: MouseEvent | null; record: (event: Event) => void }; /** Dynamic components are evaluated outside any module and expect a global React. */ React?: any; } diff --git a/pyi_hashes.json b/pyi_hashes.json index fec0b8f2474..1a475e4aae8 100644 --- a/pyi_hashes.json +++ b/pyi_hashes.json @@ -5,7 +5,7 @@ "packages/reflex-components-core/src/reflex_components_core/base/__init__.pyi": "d46e910c03263a8d3456d473de9e76c7", "packages/reflex-components-core/src/reflex_components_core/base/app_wrap.pyi": "4a701f7eaf84ec041c8fd5c8af4e48ff", "packages/reflex-components-core/src/reflex_components_core/base/body.pyi": "8550ac0cdb7f57b35dc639b605294b98", - "packages/reflex-components-core/src/reflex_components_core/base/document.pyi": "92be3177fff806cd44281cb912b21463", + "packages/reflex-components-core/src/reflex_components_core/base/document.pyi": "04d20bcfba980db936b2e88974e0b02c", "packages/reflex-components-core/src/reflex_components_core/base/error_boundary.pyi": "2bec3beeafea96787d10838d73e47bdc", "packages/reflex-components-core/src/reflex_components_core/base/fragment.pyi": "04de5816bc98f33bbf14370af7f787b3", "packages/reflex-components-core/src/reflex_components_core/base/link.pyi": "d39ded31424a9af8532b9d4eb0ce8abf", @@ -117,8 +117,12 @@ "packages/reflex-components-recharts/src/reflex_components_recharts/general.pyi": "fe22b3cf69e9ae3d425cc88c3511525b", "packages/reflex-components-recharts/src/reflex_components_recharts/polar.pyi": "adc4db1a3ca7cd292b099ec4d97a4346", "packages/reflex-components-recharts/src/reflex_components_recharts/recharts.pyi": "f2a9cf6db58d169289fbc76de6813300", - "packages/reflex-components-sonner/src/reflex_components_sonner/toast.pyi": "b195e3845260389ced026d2f5c4adb93", - "reflex/__init__.pyi": "067a60e22fb825072f2f0b690662da5a", + "packages/reflex-components-sonner/src/reflex_components_sonner/toast.pyi": "87566e8afc48f0df46be8ca188bac2fb", + "packages/reflex-components-ui/src/reflex_components_ui/__init__.pyi": "d47c2b7331062c2d3b4588b19b2d530f", + "packages/reflex-components-ui/src/reflex_components_ui/base.pyi": "43a46ffcfbd608e124e7c9f9b971910d", + "packages/reflex-components-ui/src/reflex_components_ui/layout/box.pyi": "fc1116971a8f022d5b67dcbe81275acb", + "packages/reflex-components-ui/src/reflex_components_ui/layout/theme.pyi": "b220429b137abe449810ba9f03d044ec", + "reflex/__init__.pyi": "540ab90bd8a7a89647f0bdd0a2fa3590", "reflex/components/__init__.pyi": "9facd05a776d0641432696bbf8e34388", "reflex/experimental/memo.pyi": "0fc8eae24cd0def5ea9d8d66ce87206e" } diff --git a/pyproject.toml b/pyproject.toml index 43f486a5a9c..ea5dfb9e479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ dependencies = [ "reflex-components-radix >= 0.11.0", "reflex-components-react-player >= 0.10.0", "reflex-components-recharts >= 0.10.0", - "reflex-components-sonner >= 0.10.0", + "reflex-components-sonner >= 0.10.1.dev0", "reflex-hosting-cli >= 0.2.2.post2.dev0", ] @@ -79,6 +79,9 @@ testing = [ "selenium >=4.0.0,<5.0", "uvicorn >=0.34.0,<1.0", ] +# `rx.ui`: components compiled to plain HTML and static CSS. Optional while +# the package is pre-release. +ui = ["reflex-components-ui"] [project.urls] homepage = "https://reflex.dev" @@ -121,6 +124,7 @@ dev = [ "python-dotenv", "pyyaml", "reflex-bench", + "reflex-components-ui", "reflex-docgen", "reflex-otel", "reflex-release", @@ -186,6 +190,9 @@ extraPaths = [ "packages/reflex-react-router/src", "packages/reflex-recharts/src", "packages/reflex-sonner/src", + "packages/reflex-components-ui/src", + # The parity harness is read from the repository rather than installed. + "packages/reflex-components-ui/parity", "packages/reflex-components-internal/src", "packages/reflex-otel/src", "packages/reflex-build-sdk/src", @@ -312,7 +319,12 @@ preview = true "docs/package/scripts/*.py" = ["INP001"] "packages/reflex-build-sdk/scripts/*.py" = ["INP001", "T201"] "packages/reflex-base/hatch_build.py" = ["INP001"] +"packages/reflex-components-ui/hatch_build.py" = ["INP001"] +"packages/reflex-components-ui/js/tests/fixtures/*" = ["INP001"] "scripts/changed_paths.py" = ["T201"] +"scripts/ui_parity.py" = ["T201"] +# A Reflex project of its own, beside the package it runs. +"packages/reflex-components-ui/parity/rxconfig.py" = ["INP001"] "scripts/check_min_deps.py" = ["T201"] "scripts/check_outdated_deps.py" = ["T201"] "scripts/hash_examples.py" = ["T201"] @@ -324,13 +336,15 @@ preview = true filterwarnings = "ignore:fields may not start with an underscore:RuntimeWarning" asyncio_default_fixture_loop_scope = "function" asyncio_mode = "auto" +# The rx.ui parity harness, which no wheel ships. +pythonpath = ["packages/reflex-components-ui/parity"] markers = [ "performance: scheduled wall-time, service, memory, lifecycle, or browser benchmark", ] [tool.codespell] skip = "*.html, examples, *.pyi, */nba.csv, */olympic-winners.json, packages/reflex-build-sdk/openapi.json, uv.lock, */bun.lock, */package-lock.json, node_modules" -ignore-words-list = "te, TreeE, selectin" +ignore-words-list = "te, TreeE, selectin, afterAll" [tool.coverage.run] @@ -348,6 +362,7 @@ source = [ "reflex_components_react_player", "reflex_components_recharts", "reflex_components_sonner", + "reflex_components_ui", "reflex_base", "reflex_docgen", "reflex_otel", @@ -409,8 +424,9 @@ root-package = "reflex" root-source-dirs = ["reflex"] packages-dir = "packages" package-source-subdirs = ["src"] -# reflex-base embeds the frontend javascript package as its web template. -extra-source-dirs = { reflex-base = ["packages/reflex-frontend/src"] } +# reflex-base embeds the frontend javascript package as its web template, and +# reflex-components-ui the javascript its components are compiled against. +extra-source-dirs = { reflex-base = ["packages/reflex-frontend/src"], reflex-components-ui = ["packages/reflex-components-ui/js/src"] } # Changelog dates and r/pre- branch names are stamped in the project's # home timezone, so an evening release is not dated tomorrow by a UTC runner. release-timezone = "America/Los_Angeles" @@ -553,6 +569,7 @@ reflex-components-radix = false reflex-components-react-player = false reflex-components-recharts = false reflex-components-sonner = false +reflex-components-ui = false reflex-enterprise = false reflex-hosting-cli = false pillow = "2026-10-21T00:00:00Z" @@ -575,6 +592,7 @@ reflex-components-radix.workspace = true reflex-components-react-player.workspace = true reflex-components-recharts.workspace = true reflex-components-sonner.workspace = true +reflex-components-ui.workspace = true reflex-docgen.workspace = true reflex-release.workspace = true reflex-hosting-cli.workspace = true diff --git a/reflex/__init__.py b/reflex/__init__.py index 75cb5a1328b..52da2115eea 100644 --- a/reflex/__init__.py +++ b/reflex/__init__.py @@ -84,6 +84,8 @@ from __future__ import annotations +import importlib + from reflex_base.utils import lazy_loader from reflex_components_radix.mappings import RADIX_MAPPING @@ -247,14 +249,59 @@ "plugins", } _SUBMOD_ATTRS: lazy_loader.SubmodAttrsType = _MAPPING -_EXTRA_MAPPINGS: dict[str, str] = _COMPONENT_NAME_TO_PATH -getattr, __dir__, __all__ = lazy_loader.attach( - __name__, - submodules=_SUBMODULES, - submod_attrs=_SUBMOD_ATTRS, - **_EXTRA_MAPPINGS, -) +# `rx.ui` comes from the `ui` extra, which may not be installed. It stays out of +# `attach` so that resolving it goes through `_import_ui`, whose error says what +# to install: a native lazy import (Python 3.15) would raise its own instead. +_EXTRA_MAPPINGS: dict[str, str] = { + **_COMPONENT_NAME_TO_PATH, + "ui": "reflex_components_ui", +} + + +def _attach(): + """Attach the lazy names of the package, and list `ui` beside them. + + Returns: + The lazy ``__getattr__``, and the ``__dir__`` and ``__all__`` of the package. + """ + lazy_getattr, _, names = lazy_loader.attach( + __name__, + submodules=_SUBMODULES, + submod_attrs=_SUBMOD_ATTRS, + **_COMPONENT_NAME_TO_PATH, + ) + names.append("ui") + return lazy_getattr, lambda: names, names + + +getattr, __dir__, __all__ = _attach() + + +def _import_ui(): + """Import the `rx.ui` namespace and cache it on this module. + + Returns: + The reflex_components_ui package. + + Raises: + ModuleNotFoundError: If the `ui` extra is not installed. + """ + package = _EXTRA_MAPPINGS["ui"] + try: + ui = importlib.import_module(package) + except ModuleNotFoundError as err: + if err.name != package: + raise + msg = ( + "`rx.ui` requires the reflex-components-ui package, which is not " + "installed. Install it with `pip install 'reflex[ui]'`." + ) + raise ModuleNotFoundError(msg, name=package) from None + globals()["ui"] = ui + return ui def __getattr__(name: str): + if name == "ui": + return _import_ui() return getattr(name) diff --git a/reflex/app.py b/reflex/app.py index 0800bcf2b10..4c71e8d9790 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -78,7 +78,7 @@ ) from reflex_components_core.core.breakpoints import set_breakpoints from reflex_components_core.core.sticky import sticky -from reflex_components_sonner.toast import toast +from reflex_components_sonner.toast import ToasterRequest from socketio import ASGIApp as EngineIOApp from socketio import AsyncNamespace, AsyncServer from starlette.applications import Starlette @@ -264,6 +264,15 @@ def extra_overlay_function() -> Component | None: return None +def default_toaster() -> Component: + """Default toaster: bundled only when the app sends a toast. + + Returns: + The toaster the compiler tells from one the app configured. + """ + return compiler.DEFAULT_TOASTER + + def default_overlay_component() -> Component: """Default overlay component included in the app wraps. @@ -931,7 +940,7 @@ class App(MiddlewareMixin, LifespanMixin): admin_dash: Removed. rx.AdminDash raises with a link to the migration guide. frontend_exception_handler: Frontend [error handler](https://reflex.dev/docs/utility-methods/exception-handlers/) function. backend_exception_handler: Backend [error handler](https://reflex.dev/docs/utility-methods/exception-handlers/) function. - toaster: Put the [toast](https://reflex.dev/docs/library/overlay/toast/) provider in the app wrap. + toaster: Put the [toast](https://reflex.dev/docs/library/overlay/toast/) provider in the app wrap. The default one is bundled only when the app sends a toast; pass a provider to always bundle it, or None for no provider. api_transformer: One or more transforms applied to the backend ASGI app before it runs — mount a FastAPI/Starlette app or wrap it in ASGI middleware. See the [API Transformer docs](https://reflex.dev/docs/api-routes/overview/) for examples. """ @@ -1034,7 +1043,7 @@ class App(MiddlewareMixin, LifespanMixin): [Exception], EventSpec | list[EventSpec] | None ] = default_backend_exception_handler - toaster: Component | None = dataclasses.field(default_factory=toast.provider) + toaster: Component | None = dataclasses.field(default_factory=default_toaster) hydrate_fallback: Component | ComponentCallable | None = None @@ -2168,7 +2177,17 @@ def _get_frontend_package_name(import_name: str) -> str | None: def _app_root(self, app_wrappers: dict[tuple[int, str], Component]) -> Component: for component in tuple(app_wrappers.values()): app_wrappers.update(component._get_all_app_wrap_components()) - order = sorted(app_wrappers, key=operator.itemgetter(0), reverse=True) + # A toast call asks for the toaster with a marker wrap, which the + # compiler answered when it resolved the wraps: it is not rendered. + order = sorted( + ( + key + for key, wrapper in app_wrappers.items() + if not isinstance(wrapper, ToasterRequest) + ), + key=operator.itemgetter(0), + reverse=True, + ) root = copy.deepcopy(app_wrappers[order[0]]) def reducer(parent: Component, key: tuple[int, str]) -> Component: diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index 83d72e5dd12..6f8824e57b2 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -3,12 +3,15 @@ from __future__ import annotations import collections +import contextlib import dataclasses import json import logging +import sys from collections.abc import Callable, Iterable, Sequence from inspect import getattr_static, getmodule from pathlib import Path +from types import CodeType, FunctionType, ModuleType from typing import TYPE_CHECKING, Any, cast from reflex_base import constants, otel @@ -31,6 +34,7 @@ from reflex_base.constants.compiler import PageNames, ResetStylesheet from reflex_base.constants.state import FIELD_MARKER from reflex_base.environment import environment +from reflex_base.event import EventHandler, EventSpec from reflex_base.plugins import CompileContext, CompilerHooks, PageContext, Plugin from reflex_base.registry import RegistrationContext, _default_bundled_libraries from reflex_base.utils import log, memo_paths @@ -41,11 +45,13 @@ ImportVar, ParsedImportDict, ) +from reflex_base.vars import VarData from reflex_base.vars.base import LiteralVar, Var from reflex_base.vars.sequence import LiteralStringVar from reflex_components_core.base.app_wrap import AppWrap from reflex_components_core.base.fragment import Fragment from reflex_components_radix.plugin import RadixThemesPlugin +from reflex_components_sonner.toast import ToasterRequest, toast from rich.progress import Progress from reflex.compiler import templates, utils @@ -58,6 +64,10 @@ logger = logging.getLogger(__name__) +# The toaster of an app that passes none. An app's toaster is told from one it +# configured by identity, and this one is bundled only when a toast is sent. +DEFAULT_TOASTER = toast.provider() + RADIX_THEMES_STYLESHEET = "@radix-ui/themes/styles.css" @@ -165,8 +175,43 @@ def _get_window_libraries() -> list[tuple[str, str]]: return window_libraries +def _split_window_libraries( + dynamic_components: bool, +) -> tuple[list[tuple[str, str]], list[tuple[str, str]]]: + """Split the bundled libraries into those root.jsx imports and those it defers. + + A deferred library costs a chunk of its whole namespace, so one the compiler + registered is only kept when the app renders a dynamic component. A library + the app registered itself is always kept. + + Args: + dynamic_components: Whether the app renders a dynamic component. + + Returns: + The eagerly imported libraries and the lazily loaded libraries, each + as aliases paired with module paths. + """ + window_libraries = _get_window_libraries() + if not get_config().frontend_lazy_bundled_libraries: + return window_libraries, [] + core_libraries = set(_default_bundled_libraries()) + explicit_libraries = ( + RegistrationContext.ensure_context()._explicit_bundled_libraries + ) + eager: list[tuple[str, str]] = [] + lazy: list[tuple[str, str]] = [] + for library in window_libraries: + if library[1] in core_libraries: + eager.append(library) + elif dynamic_components or library[1] in explicit_libraries: + lazy.append(library) + return eager, lazy + + def _compile_app( - app_root: Component, hydrate_fallback_export: str | None = None + app_root: Component, + hydrate_fallback_export: str | None = None, + dynamic_components: bool = True, ) -> str: """Compile the app template component. @@ -174,20 +219,14 @@ def _compile_app( app_root: The app root to compile. hydrate_fallback_export: The exported name of the hydrate-fallback memo component to re-export as ``HydrateFallback``, or None for no fallback. + dynamic_components: Whether the app renders a dynamic component. Returns: The compiled app. """ - window_libraries = _get_window_libraries() - lazy_window_libraries = [] - if get_config().frontend_lazy_bundled_libraries: - core_libraries = set(_default_bundled_libraries()) - lazy_window_libraries = [ - library for library in window_libraries if library[1] not in core_libraries - ] - window_libraries = [ - library for library in window_libraries if library[1] in core_libraries - ] + window_libraries, lazy_window_libraries = _split_window_libraries( + dynamic_components + ) app_root_imports = app_root._get_all_imports() _apply_common_imports(app_root_imports) @@ -720,7 +759,10 @@ def compile_document_root( def compile_app_root( - app_root: Component, hydrate_fallback_export: str | None = None + app_root: Component, + hydrate_fallback_export: str | None = None, + *, + dynamic_components: bool = True, ) -> tuple[str, str]: """Compile the app root. @@ -728,6 +770,9 @@ def compile_app_root( app_root: The app root component to compile. hydrate_fallback_export: The exported name of the hydrate-fallback memo component to re-export as ``HydrateFallback``, or None for no fallback. + dynamic_components: Whether the app renders a dynamic component. Without + one, only the libraries the app registered itself are made available + to load. Returns: The path and code of the compiled app wrapper. @@ -738,10 +783,31 @@ def compile_app_root( ) # Compile the document root. - code = _compile_app(app_root, hydrate_fallback_export) + code = _compile_app(app_root, hydrate_fallback_export, dynamic_components) return output_path, code +def compile_dynamic_libraries( + *, dynamic_components: bool = True +) -> list[tuple[str, str]]: + """Compile the modules the app root loads dynamic-component libraries from. + + Args: + dynamic_components: Whether the app renders a dynamic component. + + Returns: + The path and code of the module of each lazily loaded library. + """ + output_dir = get_web_dir() / constants.Dirs.DYNAMIC_LIBRARIES_PATH + return [ + ( + str(output_dir / (alias + constants.Ext.JS)), + templates.dynamic_library_template(library), + ) + for alias, library in _split_window_libraries(dynamic_components)[1] + ] + + def compile_theme(style: ComponentStyle) -> tuple[str, str]: """Compile the theme. @@ -1071,6 +1137,219 @@ def compile_unevaluated_page( return component +class _PlainToast(Fragment): + """App wrap that shows toasts as plain notices, without the toaster. + + It takes the place of the toaster the compiler left out of an app with + state, so a toast the backend sends anyway and a connection error still + show. A toaster a page mounts itself keeps precedence. + """ + + def add_hooks(self) -> list[str | Var]: + """Install the plain notice unless a toaster already did. + + Returns: + The hook installing the plain notice. + """ + return [ + Var( + "refs['__toast'] ??= plainToast", + _var_data=VarData( + imports={ + f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="refs")], + f"$/{constants.Dirs.UTILS}/helpers/plain_toast": [ + ImportVar(tag="plainToast", is_default=True) + ], + } + ), + ) + ] + + +def _is_reflex_module(name: str) -> bool: + """Check whether a module is part of Reflex itself. + + Args: + name: The dotted name of the module. + + Returns: + Whether the module belongs to one of the packages of this repository. + """ + top_level = name.partition(".")[0] + return top_level in ("reflex", "reflex_base") or top_level.startswith( + "reflex_components_" + ) + + +def _is_app_module(name: str) -> bool: + """Check whether a module is the app's own code. + + Args: + name: The dotted name of the module. + + Returns: + False for the standard library, Reflex, and installed distributions. + """ + if name.partition(".")[0] in sys.stdlib_module_names or _is_reflex_module(name): + return False + file = getattr(sys.modules.get(name), "__file__", None) + return file is not None and not {"site-packages", "dist-packages"}.intersection( + Path(file).parts + ) + + +def _references_toast(roots: Iterable[Any]) -> bool: + """Check whether code reachable from the given objects refers to ``rx.toast``. + + Follows the names a function refers to: a global, a closure variable or an + attribute of a module it imported. A reference counts when its name is + ``toast`` or it resolves to something the toast module defines. Functions + and classes of the app's own modules are followed in turn; installed + distributions are not, which keeps the walk off their call graphs. + + This reads names, it does not run code: a toast reached through a name + computed at runtime, or through an object the code is handed rather than + names, is not found. Reflex's own functions are not read. + + Args: + roots: The functions, event handlers and classes to start from. + + Returns: + Whether a reference to ``rx.toast`` was found. + """ + pending = list(roots) + seen: set[int] = set() + while pending: + obj = pending.pop() + if isinstance(obj, (staticmethod, classmethod)): + obj = obj.__func__ + elif isinstance(obj, EventHandler): + obj = obj.fn + if id(obj) in seen: + continue + seen.add(id(obj)) + if isinstance(obj, type): + pending.extend(vars(obj).values()) + continue + # Reflex's own code is not read: its default handler for a backend + # exception falls back to an alert, and to a plain notice here. A + # function is judged by its own module, since a state class defined + # inside a function is moved to one of Reflex's. + if not isinstance(obj, FunctionType) or _is_reflex_module(obj.__module__): + continue + names: set[str] = set() + codes = [obj.__code__] + while codes: + code = codes.pop() + names.update(code.co_names) + codes.extend( + const for const in code.co_consts if isinstance(const, CodeType) + ) + if "toast" in names: + return True + referenced = [ + obj.__globals__[name] for name in names if name in obj.__globals__ + ] + for cell in obj.__closure__ or (): + with contextlib.suppress(ValueError): + referenced.append(cell.cell_contents) + for value in referenced: + if isinstance(value, ModuleType): + if value.__name__ == ToasterRequest.__module__: + return True + if _is_app_module(value.__name__): + pending.extend( + vars(value)[name] for name in names if name in vars(value) + ) + continue + module = getattr(value, "__module__", None) + if module == ToasterRequest.__module__: + return True + if isinstance(module, str) and _is_app_module(module): + # An object is as good as its class: its methods are read. + pending.append( + value if isinstance(value, (type, FunctionType)) else type(value) + ) + return False + + +def _backend_sends_toast(app: App) -> bool: + """Check whether the backend of the app may send a toast. + + The frontend is compiled before any event handler runs, so this looks at + what the handlers refer to instead: see ``_references_toast``. An ``on_load`` + event is sent by the backend too, and its toast call says so itself. + + Args: + app: The app being compiled. + + Returns: + Whether a toast sent from the backend was found. + """ + roots: list[Any] = [ + app.backend_exception_handler, + app.frontend_exception_handler, + ] + for events in app._load_events.values(): + for event in events: + if not isinstance(event, EventSpec): + roots.append(event) + continue + for _, arg in event.args: + var_data = arg._get_all_var_data() + if var_data is not None and any( + isinstance(wrapper, ToasterRequest) + for _, wrapper in var_data.app_wraps + ): + return True + states = [app._state] if app._state is not None else [] + while states: + state = states.pop() + states.extend(state.get_substates()) + roots.extend(state.__mro__) + return _references_toast(roots) + + +def _resolve_toaster( + app: App, app_wrappers: dict[tuple[int, str], Component] +) -> Component | None: + """Resolve the toast provider to put in the app wrap, if any. + + A toaster the app configured is always used. The default one costs every + page its library, so it is used only when the app sends a toast: from the + frontend, where the compiled toast call asks for it with a + ``ToasterRequest``, or from the backend, as far as ``_backend_sends_toast`` + can tell. Where it cannot tell, an app with state gets plain notices in + place of the toaster, so no toast is lost. + + Args: + app: The app being compiled. + app_wrappers: The app wraps collected from the pages and the other wraps. + + Returns: + The app wrap providing toasts, or None for an app that gets none. + """ + toaster = app.toaster + if toaster is None: + return None + if ( + toaster is DEFAULT_TOASTER + and not any( + isinstance(wrapper, ToasterRequest) for wrapper in app_wrappers.values() + ) + and not _backend_sends_toast(app) + ): + return _PlainToast.create() if app._state is not None else None + + from reflex_base.components.memo import memo + + @memo + def memoized_toast_provider() -> Component: + return toaster + + return Fragment.create(memoized_toast_provider()) + + def _resolve_app_wrap_components( app: App, page_app_wrap_components: dict[tuple[int, str], Component], @@ -1096,15 +1375,6 @@ def _resolve_app_wrap_components( app_wrappers[200, "StrictMode"] = StrictMode.create() - if (toaster := app.toaster) is not None: - from reflex_base.components.memo import memo - - @memo - def memoized_toast_provider() -> Component: - return toaster - - app_wrappers[44, "ToasterProvider"] = Fragment.create(memoized_toast_provider()) - for wrap_mapping in (app.app_wraps, app.extra_app_wraps): for key, app_wrap in wrap_mapping.items(): component = app_wrap(app._state is not None) @@ -1115,16 +1385,23 @@ def memoized_toast_provider() -> Component: # own subtrees (e.g. ``ErrorBoundary``'s fallback render). Surface their # Var-declared ``app_wraps`` here, fixpoint-iterating because newly added # wraps may themselves contain further declarations. - pending: list[Component] = list(app_wrappers.values()) - while pending: - next_pending: list[Component] = [] - for wrapper in pending: - before = set(app_wrappers) - collect_var_app_wraps_in_subtree(app_wrappers, wrapper) - next_pending.extend( - app_wrappers[key] for key in app_wrappers.keys() - before - ) - pending = next_pending + def surface_var_app_wraps(pending: list[Component]) -> None: + while pending: + next_pending: list[Component] = [] + for wrapper in pending: + before = set(app_wrappers) + collect_var_app_wraps_in_subtree(app_wrappers, wrapper) + next_pending.extend( + app_wrappers[key] for key in app_wrappers.keys() - before + ) + pending = next_pending + + surface_var_app_wraps(list(app_wrappers.values())) + + # Decided last: only now is every toast call in the frontend accounted for. + if (toaster := _resolve_toaster(app, app_wrappers)) is not None: + app_wrappers[44, "ToasterProvider"] = toaster + surface_var_app_wraps([toaster]) return app_wrappers @@ -1592,7 +1869,19 @@ def add_save_task( ]) progress.advance(task) - compile_results.append(compile_app_root(app_root, hydrate_fallback_export)) + # A dynamic component is evaluated by evalReactComponent, wherever it renders. + dynamic_components = any( + field.tag == "evalReactComponent" + for field in all_imports.get(f"$/{constants.Dirs.STATE_PATH}", ()) + ) + compile_results.extend( + compile_dynamic_libraries(dynamic_components=dynamic_components) + ) + compile_results.append( + compile_app_root( + app_root, hydrate_fallback_export, dynamic_components=dynamic_components + ) + ) progress.advance(task) progress.stop() diff --git a/reflex/plugins/__init__.py b/reflex/plugins/__init__.py index ba9c0775f54..4381860f6c7 100644 --- a/reflex/plugins/__init__.py +++ b/reflex/plugins/__init__.py @@ -1,5 +1,7 @@ """Re-export from reflex_base.plugins.""" +from typing import TYPE_CHECKING + from reflex_base.plugins import ( BaseContext, CommonContext, @@ -14,6 +16,7 @@ SitemapPlugin, TailwindV3Plugin, TailwindV4Plugin, + VitePluginEntry, _ScreenshotPlugin, embed, get_plugin, @@ -23,6 +26,12 @@ ) from reflex_components_radix.plugin import RadixThemesPlugin +# `UIPlugin` comes from the `ui` extra, which may not be installed: it is +# resolved on first use and stays out of `__all__`, so that a star import does +# not need the extra. +if TYPE_CHECKING: + from reflex_components_ui.plugin import UIPlugin + __all__ = [ "BaseContext", "CommonContext", @@ -38,6 +47,7 @@ "SitemapPlugin", "TailwindV3Plugin", "TailwindV4Plugin", + "VitePluginEntry", "_ScreenshotPlugin", "embed", "get_plugin", @@ -45,3 +55,34 @@ "tailwind_v3", "tailwind_v4", ] + + +def __getattr__(name: str): + """Resolve `UIPlugin`, which comes from the `ui` extra, on first use. + + Args: + name: The attribute that was not found in the module. + + Returns: + The UIPlugin class. + + Raises: + AttributeError: If the name is not `UIPlugin`. + ModuleNotFoundError: If the `ui` extra is not installed. + """ + if name != "UIPlugin": + msg = f"module {__name__!r} has no attribute {name!r}" + raise AttributeError(msg) + package = "reflex_components_ui" + try: + from reflex_components_ui.plugin import UIPlugin + except ModuleNotFoundError as err: + if err.name != package: + raise + msg = ( + "`rx.plugins.UIPlugin` requires the reflex-components-ui package, " + "which is not installed. Install it with `pip install 'reflex[ui]'`." + ) + raise ModuleNotFoundError(msg, name=package) from None + globals()[name] = UIPlugin + return UIPlugin diff --git a/reflex/utils/frontend_skeleton.py b/reflex/utils/frontend_skeleton.py index c32e1f0e893..226745d5da7 100644 --- a/reflex/utils/frontend_skeleton.py +++ b/reflex/utils/frontend_skeleton.py @@ -2,14 +2,18 @@ import json import logging +import re import uuid +from collections.abc import Sequence from pathlib import Path from typing import Literal from reflex_base import constants from reflex_base.config import Config, get_config from reflex_base.environment import environment +from reflex_base.plugins.base import Plugin, VitePluginEntry from reflex_base.plugins.embed import get_embed_plugin +from reflex_base.utils.exceptions import InvalidVitePluginError from reflex.compiler import templates from reflex.utils import net, path_ops @@ -629,6 +633,67 @@ def initialize_package_json(): _write_package_json(output_path, _compile_package_json()) +# A static import statement; ``import(...)`` and ``import.meta`` are expressions. +_VITE_IMPORT_STATEMENT = re.compile(r"""\s*import[\s"'{*]""") + + +def _vite_plugin_entry_problem(entry: object) -> str | None: + """Find what is wrong with an entry a plugin returned from ``get_vite_plugins``. + + Args: + entry: The entry to check. + + Returns: + The problem, or ``None`` when the entry can be rendered. + """ + if not isinstance(entry, VitePluginEntry): + return f"is a {type(entry).__name__}, not a VitePluginEntry" + call = entry.call + if not isinstance(call, str) or not (call := call.strip()): + return f"has call={entry.call!r}, which is not a JavaScript expression" + if call[-1] in ";,": + return ( + f"has call={entry.call!r}, which must be an expression without a " + f"trailing {call[-1]!r}" + ) + if isinstance(entry.imports, str): + return ( + f"has imports={entry.imports!r}, which must be a sequence of import " + "statements, not a single string" + ) + for statement in entry.imports: + if not isinstance(statement, str) or not _VITE_IMPORT_STATEMENT.match( + statement + ): + return f"has {statement!r} in imports, which is not an import statement" + return None + + +def _get_vite_plugins(plugins: Sequence[Plugin]) -> list[VitePluginEntry]: + """Collect the Vite plugins that the configured Reflex plugins contribute. + + Args: + plugins: The configured plugins, in ``rxconfig.py`` order. + + Returns: + The entries in plugin order, then in the order each plugin returned them. + + Raises: + InvalidVitePluginError: When a plugin returns a malformed entry. + """ + entries: list[VitePluginEntry] = [] + for plugin in plugins: + for index, entry in enumerate(plugin.get_vite_plugins()): + if problem := _vite_plugin_entry_problem(entry): + msg = ( + f"{type(plugin).__name__}.get_vite_plugins() returned an " + f"invalid entry: entry {index} {problem}." + ) + raise InvalidVitePluginError(msg) + entries.append(entry) + return entries + + def _compile_vite_config(config: Config): base = config.prepend_frontend_path("/") embed_plugin = get_embed_plugin() @@ -648,6 +713,7 @@ def _compile_vite_config(config: Config): sourcemap=environment.VITE_SOURCEMAP.get(), minify=environment.VITE_MINIFY.get(), allowed_hosts=config.vite_allowed_hosts, + vite_plugins=_get_vite_plugins(config.plugins), ) diff --git a/scripts/make_pyi.py b/scripts/make_pyi.py index 4d1c00b9830..8ca89a16671 100644 --- a/scripts/make_pyi.py +++ b/scripts/make_pyi.py @@ -30,6 +30,7 @@ "packages/reflex-components-react-player/src/reflex_components_react_player", "packages/reflex-components-recharts/src/reflex_components_recharts", "packages/reflex-components-sonner/src/reflex_components_sonner", + "packages/reflex-components-ui/src/reflex_components_ui", ] diff --git a/scripts/ui_parity.py b/scripts/ui_parity.py new file mode 100644 index 00000000000..c8b33e24963 --- /dev/null +++ b/scripts/ui_parity.py @@ -0,0 +1,103 @@ +"""Run the rx.ui parity harness: one command for the look and the behaviour. + + uv run python scripts/ui_parity.py box one component, in Chromium + uv run python scripts/ui_parity.py every component, in Chromium + uv run python scripts/ui_parity.py --all-engines and in Firefox and WebKit + uv run python scripts/ui_parity.py differences the intended differences, as markdown + +The checks are the tests of tests/integration/tests_playwright/test_ui_parity.py; +this builds the pytest command for them. +""" + +from __future__ import annotations + +import argparse +import os +import subprocess +import sys +from pathlib import Path + +REPO_ROOT = Path(__file__).parents[1] +PARITY = REPO_ROOT / "packages" / "reflex-components-ui" / "parity" +TESTS = "tests/integration/tests_playwright/test_ui_parity.py" +ENGINES = ("chromium", "firefox", "webkit") +DIFFERENCES = "differences" + + +def pytest_command( + components: list[str], engines: list[str], extra: list[str] +) -> list[str]: + """Build the pytest command of a run. + + Args: + components: The components to check: every one when empty. + engines: The browser engines to run in. + extra: Arguments passed on to pytest. + + Returns: + The command. + """ + command = [sys.executable, "-m", "pytest", TESTS, "-rs"] + for engine in engines: + command += ["--browser", engine] + if components: + # A test id holds its component after the engine: "chromium-box]" for + # a matrix, "chromium-box-rx.ui-..." for a step. The run time is + # recorded whatever ran. + selected = [f"-{name}] or -{name}-" for name in components] + command += ["-k", " or ".join([*selected, "test_run_time"])] + return command + extra + + +def main(argv: list[str] | None = None) -> int: + """Run the harness, or print the intended differences. + + Args: + argv: The command line, without the program name. + + Returns: + The exit code: that of pytest. + """ + parser = argparse.ArgumentParser(description=(__doc__ or "").partition("\n")[0]) + parser.add_argument( + "components", + nargs="*", + help=f'components to check (default: all), or "{DIFFERENCES}"', + ) + parser.add_argument( + "--engine", + action="append", + choices=ENGINES, + help="a browser engine to run in; may be repeated (default: chromium)", + ) + parser.add_argument( + "--all-engines", action="store_true", help="run in every browser engine" + ) + parser.add_argument( + "--report", + type=Path, + help=f"where the report goes (default: {PARITY / 'report'})", + ) + args, extra = parser.parse_known_args(argv) + if args.components == [DIFFERENCES]: + sys.path.insert(0, str(PARITY)) + from ui_parity import allowlist + + print(allowlist.differences_markdown(allowlist.load())) + return 0 + env = dict(os.environ) + if args.report is not None: + env["UI_PARITY_REPORT"] = str(args.report.resolve()) + engines: list[str] = ( + list(ENGINES) if args.all_engines else args.engine or [ENGINES[0]] + ) + return subprocess.run( + pytest_command(args.components, engines, extra), + cwd=REPO_ROOT, + env=env, + check=False, + ).returncode + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/integration/tests_playwright/test_dynamic_components.py b/tests/integration/tests_playwright/test_dynamic_components.py index bf7e55a3c9f..64c026265f2 100644 --- a/tests/integration/tests_playwright/test_dynamic_components.py +++ b/tests/integration/tests_playwright/test_dynamic_components.py @@ -55,7 +55,7 @@ def client_token_component(self) -> rx.Component: rx.el.input( custom_attrs={"id": "token"}, value=self.router.session.client_token, - is_read_only=True, + read_only=True, ), rx.button( "Update", @@ -171,13 +171,16 @@ def lazy_bundled_libraries(request: pytest.FixtureRequest) -> bool: @pytest.fixture(scope="module") def dynamic_components( - tmp_path_factory, lazy_bundled_libraries: bool + tmp_path_factory, + lazy_bundled_libraries: bool, + app_harness_env: type[AppHarness], ) -> Generator[AppHarness, None, None]: """Start VarOperations app at tmp_path via AppHarness. Args: tmp_path_factory: pytest tmp_path_factory fixture lazy_bundled_libraries: whether optional libraries load on demand + app_harness_env: the harness class, for a dev or a production frontend Yields: The running app harness. @@ -186,7 +189,7 @@ def dynamic_components( monkeypatch.setenv( "REFLEX_FRONTEND_LAZY_BUNDLED_LIBRARIES", str(lazy_bundled_libraries) ) - with AppHarness.create( + with app_harness_env.create( root=tmp_path_factory.mktemp("dynamic_components"), app_source=DynamicComponents, ) as harness: @@ -211,6 +214,23 @@ def test_dynamic_components( lazy_bundled_libraries: whether lazy loading of bundled libraries is enabled. """ banana = "lucide-react/dist/esm/icons/banana.mjs" + errors: list[str] = [] + radix_requests: list[str] = [] + page.on("pageerror", lambda error: errors.append(str(error))) + page.on( + "console", + lambda message: ( + errors.append(message.text) if message.type == "error" else None + ), + ) + page.on( + "request", + lambda request: ( + radix_requests.append(request.url) + if "/radix_ui_themes" in request.url + else None + ), + ) assert dynamic_components.frontend_url is not None page.goto(dynamic_components.frontend_url) expect(page.locator("#token")).not_to_have_value("", timeout=15_000) @@ -258,3 +278,8 @@ def test_dynamic_components( expect(page.locator("#initial-icon")).to_be_attached() page.locator("#activate").click() expect(page.locator("#delayed-icon")).to_be_attached() + # Every dynamic component on the page shares one fetch of the Radix module + # (in production, the chunk built from it), + # however many mount at once or are evaluated again later. + assert len(radix_requests) == (1 if lazy_bundled_libraries else 0) + assert errors == [] diff --git a/tests/integration/tests_playwright/test_icon.py b/tests/integration/tests_playwright/test_icon.py index 0863a3b46e7..99e87554b80 100644 --- a/tests/integration/tests_playwright/test_icon.py +++ b/tests/integration/tests_playwright/test_icon.py @@ -1,4 +1,8 @@ -"""Integration tests for the Icon component.""" +"""Integration tests for the Icon component. + +The app also carries a plugin that adds a Vite plugin, since it already builds +in both dev and prod. +""" from collections.abc import Generator @@ -8,13 +12,70 @@ from reflex.testing import AppHarness +VITE_CONSTANT = "defined by a vite plugin" + + +def Icons(vite_constant: str = VITE_CONSTANT): + """App rendering every icon, built with a plugin-contributed Vite plugin. + + Args: + vite_constant: The value the Vite plugin defines for the page to read. + """ + import json + from pathlib import Path -def Icons(): from reflex_components_lucide.icon import LUCIDE_ICON_LIST import reflex as rx + class DefineConstantPlugin(rx.plugins.Plugin): + """Adds a Vite plugin, shipped in the app, that defines a constant.""" + + def get_static_assets(self, **context): + """Write the Vite plugin's module into ``.web``. + + Args: + context: The context for the plugin. + + Returns: + The module's path and source. + """ + return [ + ( + Path("vite-plugin-define-constants.js"), + ( + "export default function defineConstants(constants) {\n" + ' return { name: "define-constants", config: () => ({ define: constants }) };\n' + "}\n" + ), + ) + ] + + def get_vite_plugins(self, **context): + """Add the Vite plugin to ``vite.config.js``. + + Args: + context: The context for the plugin. + + Returns: + The entry importing and calling the module. + """ + # Doubly encoded: once as a JS string literal in the config, and + # once more because `define` substitutes source text. + value = json.dumps(json.dumps(vite_constant)) + return [ + rx.plugins.VitePluginEntry( + imports=[ + 'import defineConstants from "./vite-plugin-define-constants.js"' + ], + call=f"defineConstants({{ __REFLEX_TEST_VITE_CONSTANT__: {value} }})", + ) + ] + app = rx.App() + # Set plugins after rx.App(), which reloads the config from rxconfig.py. + config = rx.config.get_config() + config.plugins = [*config.plugins, DefineConstantPlugin()] class State(rx.State): """State for the Icons app.""" @@ -33,6 +94,10 @@ def index(): rx.icon(State.dynamic_icon), id="dynamic_icon", ), + rx.el.div( + rx.Var("__REFLEX_TEST_VITE_CONSTANT__", _var_type=str), + id="vite_constant", + ), *[ rx.el.div(rx.icon(icon_name), id=icon_name) for icon_name in LUCIDE_ICON_LIST @@ -74,3 +139,16 @@ def test_icons(icons: AppHarness, page: Page) -> None: for icon_name in [*LUCIDE_ICON_LIST, "dynamic_icon"]: expect(page.locator(f'[id="{icon_name}"] svg')).to_have_count(1) + + +def test_vite_plugin_from_reflex_plugin(icons: AppHarness, page: Page) -> None: + """A constant defined by a plugin-contributed Vite plugin reaches the page. + + Args: + icons: harness for the icon app. + page: Playwright page. + """ + assert icons.frontend_url is not None + page.goto(icons.frontend_url) + + expect(page.locator("#vite_constant")).to_have_text(VITE_CONSTANT) diff --git a/tests/integration/tests_playwright/test_scripts_after_first_paint.py b/tests/integration/tests_playwright/test_scripts_after_first_paint.py new file mode 100644 index 00000000000..b31796b7b72 --- /dev/null +++ b/tests/integration/tests_playwright/test_scripts_after_first_paint.py @@ -0,0 +1,177 @@ +"""A prerendered page starts its scripts after its first paint, and still hydrates.""" + +import json +import re +from collections.abc import Generator + +import pytest +from playwright.sync_api import Page, expect + +import reflex.constants as constants +import reflex.utils.prerequisites as prerequisites +from reflex.testing import AppHarness, AppHarnessProd +from reflex.utils.misc import preload_color_theme + +HYDRATED = """() => Object.keys(document.getElementById("increment")).some( + (key) => key.startsWith("__reactProps$") +)""" + +# Keeps the page from learning that it painted, and drops the timeout that +# covers for that (FIRST_PAINT_TIMEOUT_MS in utils/scripts.js), while the +# document is parsed: only an input is left to start the scripts. +NEVER_PAINTED = """ +PerformanceObserver.prototype.observe = function () {}; +const setTimeout_ = window.setTimeout; +window.setTimeout = (handler, delay, ...args) => + delay === 1000 ? 0 : setTimeout_(handler, delay, ...args); +document.addEventListener("DOMContentLoaded", () => { + window.setTimeout = setTimeout_; +}); +""" + + +def ScriptsAfterFirstPaintApp(): + """App with prerendered pages and a page that is rendered in the browser.""" + import reflex as rx + + class CounterState(rx.State): + count: int = 0 + + @rx.event + def increment(self): + self.count += 1 + + def counter(heading: rx.Component, *links: rx.Component) -> rx.Component: + return rx.el.main( + heading, + rx.el.p(CounterState.count, id="count"), + rx.el.button("Increment", id="increment", on_click=CounterState.increment), + *links, + ) + + def index(): + return counter(rx.el.h1("Index"), rx.link("Other", href="/other")) + + def other(): + return counter(rx.el.h1("Other")) + + def post(): + return counter(rx.el.h1("Post ", rx.State.post_id)) # pyright: ignore [reportAttributeAccessIssue] + + app = rx.App() + app.add_page(index, title="Index") + app.add_page(other, title="Other") + app.add_page(post, route="/post/[post_id]", title="Post") + + +@pytest.fixture(scope="module") +def scripts_app( + app_harness_env: type[AppHarness], + tmp_path_factory: pytest.TempPathFactory, +) -> Generator[AppHarness, None, None]: + """Start the app in dev or production mode. + + Yields: + The running app harness. + """ + with app_harness_env.create( + root=tmp_path_factory.mktemp("scripts_after_first_paint"), + app_name=f"scriptsafterfirstpaint_{app_harness_env.__name__.lower()}", + app_source=ScriptsAfterFirstPaintApp, + ) as harness: + yield harness + + +def _frontend_url(harness: AppHarness) -> str: + """Get the frontend URL of a running harness. + + Args: + harness: The running app harness. + + Returns: + The URL, without a trailing slash. + """ + assert harness.frontend_url is not None + return harness.frontend_url.rstrip("/") + + +def test_prerendered_head_preloads_no_script(scripts_app: AppHarness): + """The head of a prerendered page holds the stylesheet and no module preload.""" + if not isinstance(scripts_app, AppHarnessProd): + pytest.skip("pages are prerendered in prod only") + static_dir = ( + scripts_app.app_path / prerequisites.get_web_dir() / constants.Dirs.STATIC + ) + html = (static_dir / "index.html").read_text() + head = html[html.index("") : html.index("") + len("")] + theme_script = json.loads( + preload_color_theme("system").render()["children"][0]["contents"] + ) + stylesheet = "/assets/__reflex_global_styles-HASH.css" + assert re.sub(r"-[\w-]{8}\.css", "-HASH.css", head) == ( + '' + '' + f'' + "Index" + '' + f"" + f'' + ) + + +def test_pages_hydrate_and_handle_events(scripts_app: AppHarness, page: Page): + """Prerendered, client-navigated and client-rendered pages all handle a click.""" + frontend_url = _frontend_url(scripts_app) + problems: list[str] = [] + page.on( + "console", + lambda message: ( + problems.append(f"{message.type}: {message.text}") + if message.type in {"warning", "error"} + else None + ), + ) + page.on("pageerror", lambda error: problems.append(f"pageerror: {error}")) + count = page.locator("#count") + increment = page.get_by_role("button", name="Increment") + + # A prerendered page in prod. + page.goto(frontend_url) + expect(page.get_by_role("heading", name="Index")).to_be_visible() + page.wait_for_function(HYDRATED) + increment.click() + expect(count).to_have_text("1") + + # A client-side navigation. + page.get_by_role("link", name="Other").click() + expect(page.get_by_role("heading", name="Other")).to_be_visible() + increment.click() + expect(count).to_have_text("2") + + # A dynamic route, which is rendered in the browser. + page.goto(f"{frontend_url}/post/7") + expect(page.get_by_role("heading", name="Post 7")).to_be_visible() + increment.click() + expect(count).to_have_text("3") + + assert problems == [] + + +def test_input_before_first_paint_starts_scripts(scripts_app: AppHarness, page: Page): + """A click on a page that cannot handle one yet starts its scripts and is not lost.""" + if not isinstance(scripts_app, AppHarnessProd): + pytest.skip("pages are prerendered in prod only") + page.add_init_script(NEVER_PAINTED) + page.goto(_frontend_url(scripts_app), wait_until="load") + modules = page.locator('head script[type="module"]') + increment = page.get_by_role("button", name="Increment") + expect(increment).to_be_visible() + assert modules.count() == 0 + assert not page.evaluate(HYDRATED) + + # No handler is attached yet: the click is dispatched again after hydration. + increment.click() + assert modules.count() == 1 + expect(page.locator("#count")).to_have_text("1") + increment.click() + expect(page.locator("#count")).to_have_text("2") diff --git a/tests/integration/tests_playwright/test_stateless_app.py b/tests/integration/tests_playwright/test_stateless_app.py index ef566819f48..c199a9928d0 100644 --- a/tests/integration/tests_playwright/test_stateless_app.py +++ b/tests/integration/tests_playwright/test_stateless_app.py @@ -1,6 +1,7 @@ """Integration tests for a stateless app.""" from collections.abc import Generator +from urllib.parse import urlsplit import httpx2 import pytest @@ -8,31 +9,73 @@ from reflex_base.config import get_config from reflex_base.constants import Endpoint -from reflex.testing import AppHarness +from reflex.testing import AppHarness, AppHarnessProd +from tests.integration.utils import built_scripts, libraries_in_scripts, record_scripts def StatelessApp(): - """A stateless app that renders a heading.""" + """A stateless app whose events all run in the browser.""" import reflex as rx + counter = rx.client_state(0, name="counter") + def index(): - return rx.heading("This is a stateless app") + return rx.el.div( + rx.heading("This is a stateless app"), + rx.el.input(id="field"), + rx.el.p(id="script-output"), + rx.el.button( + "Run script", + id="run-script", + on_click=rx.call_script( + "document.getElementById('script-output').textContent =" + " 'stored: ' + localStorage.getItem('stateless-key')" + ), + ), + rx.el.button( + "Fill", id="fill", on_click=rx.set_value("field", "filled in") + ), + rx.el.button( + "Forget", + id="forget", + on_click=[ + rx.remove_cookie("stateless-cookie"), + rx.remove_local_storage("stateless-key"), + ], + ), + rx.el.button( + counter.value, id="count", on_click=counter.set(lambda v: v + 1) + ), + rx.el.button("Toggle", id="toggle", on_click=rx.toggle_color_mode), + rx.el.button("Go", id="go", on_click=rx.redirect("/other")), + rx.link("Other page", href="/other", id="link"), + ) + + def other(): + return rx.el.div( + rx.heading("The other page"), + rx.el.button("Back", id="back", on_click=rx.redirect("/")), + ) app = rx.App(enable_state=False) app.add_page(index) + app.add_page(other, route="/other") @pytest.fixture(scope="module") -def stateless_app(tmp_path_factory) -> Generator[AppHarness, None, None]: +def stateless_app( + app_harness_env: type[AppHarness], tmp_path_factory +) -> Generator[AppHarness, None, None]: """Create a stateless app AppHarness. Args: + app_harness_env: AppHarness (dev) or AppHarnessProd (prod). tmp_path_factory: pytest fixture for creating temporary directories. Yields: AppHarness: A harness for testing the stateless app. """ - with AppHarness.create( + with app_harness_env.create( root=tmp_path_factory.mktemp("stateless_app"), app_source=StatelessApp, ) as harness: @@ -59,3 +102,95 @@ def test_statelessness(stateless_app: AppHarness, page: Page): page.goto(stateless_app.frontend_url) expect(page.get_by_role("heading")).to_have_text("This is a stateless app") + + +def test_stateless_app_runs_without_the_state_runtime( + stateless_app: AppHarness, page: Page +): + """The page loads no socket, cookie library or toaster, and its events still run. + + Args: + stateless_app: A harness for testing the stateless app. + page: A Playwright page. + """ + assert stateless_app.frontend_url is not None + websockets: list[str] = [] + page_errors: list[str] = [] + page.on("websocket", lambda ws: websockets.append(ws.url)) + page.on("pageerror", lambda exc: page_errors.append(str(exc))) + scripts = record_scripts(page) + + page.goto(stateless_app.frontend_url) + expect(page.get_by_role("heading")).to_have_text("This is a stateless app") + page.evaluate( + "() => { localStorage.setItem('stateless-key', 'kept');" + " document.cookie = 'stateless-cookie=1; path=/'; }" + ) + + # A script reads browser storage. + page.locator("#run-script").click() + expect(page.locator("#script-output")).to_have_text("stored: kept") + + # Refs, cookies and local storage. + page.locator("#fill").click() + expect(page.locator("#field")).to_have_value("filled in") + page.locator("#forget").click() + page.locator("#run-script").click() + expect(page.locator("#script-output")).to_have_text("stored: null") + assert page.evaluate("() => document.cookie") == "" + + # Client state. + expect(page.locator("#count")).to_have_text("0") + page.locator("#count").click() + page.locator("#count").click() + expect(page.locator("#count")).to_have_text("2") + + # Color mode. + initial_mode = page.evaluate("() => document.documentElement.className") + assert initial_mode in ("light", "dark") + page.locator("#toggle").click() + expect(page.locator("html")).to_have_class( + "dark" if initial_mode == "light" else "light" + ) + + # Navigation, by event and by link. + page.locator("#go").click() + expect(page.get_by_role("heading")).to_have_text("The other page") + page.locator("#back").click() + expect(page.get_by_role("heading")).to_have_text("This is a stateless app") + page.locator("#link").click() + expect(page.get_by_role("heading")).to_have_text("The other page") + + # There is no backend to lose: nothing reports a connection error. + expect(page.locator("[title^='Connection Error']")).to_have_count(0) + expect(page.get_by_text("Cannot connect to server")).to_have_count(0) + + assert page_errors == [] + # The dev server's own hot-reload socket, to the frontend, is the only one. + frontend = urlsplit(stateless_app.frontend_url).netloc + assert [url for url in websockets if urlsplit(url).netloc != frontend] == [] + if isinstance(stateless_app, AppHarnessProd): + assert websockets == [] + assert scripts + assert libraries_in_scripts(scripts) == { + "socket.io": False, + "universal-cookie": False, + "sonner": False, + } + + +def test_stateless_build_contains_no_state_runtime(stateless_app: AppHarness): + """No chunk of the production build holds socket.io, the cookie library or the toaster. + + Args: + stateless_app: A harness for testing the stateless app. + """ + if not isinstance(stateless_app, AppHarnessProd): + pytest.skip("only a production build is bundled") + scripts = built_scripts(stateless_app) + assert scripts + assert libraries_in_scripts(scripts) == { + "socket.io": False, + "universal-cookie": False, + "sonner": False, + } diff --git a/tests/integration/tests_playwright/test_toast.py b/tests/integration/tests_playwright/test_toast.py index d92e5270841..5002b51b863 100644 --- a/tests/integration/tests_playwright/test_toast.py +++ b/tests/integration/tests_playwright/test_toast.py @@ -3,6 +3,9 @@ Regression coverage for the frontend ``ReferenceError: queueEvents is not defined`` that fired when clicking a toast action/cancel button whose ``on_click`` was queued via a toast triggered directly from a frontend event. + +Also covers when the toaster is bundled at all: an app that sends a toast gets +it, and an app that sends none shows a toast it did not expect as a plain notice. """ from collections.abc import Generator @@ -10,7 +13,8 @@ import pytest from playwright.sync_api import Page, expect -from reflex.testing import AppHarness +from reflex.testing import AppHarness, AppHarnessProd +from tests.integration.utils import built_scripts, libraries_in_scripts, record_scripts def ToastApp(): @@ -309,3 +313,112 @@ def test_upload_callbacks( expect(page.locator("#upload-count")).to_have_text("2") expect(page.locator("#uploaded")).to_have_text("[]") assert not page_errors, f"Frontend raised unexpected errors: {page_errors}" + + +def test_app_that_sends_toasts_bundles_the_toaster(toast_app: AppHarness, page: Page): + """An app with a toast call loads the toaster with the page. + + Args: + toast_app: AppHarness running the test app. + page: Playwright page. + """ + assert toast_app.frontend_url is not None + scripts = record_scripts(page) + page.goto(toast_app.frontend_url) + expect(page.locator("#token")).not_to_have_value("") + + with_toaster = {"socket.io": True, "universal-cookie": True, "sonner": True} + assert libraries_in_scripts(scripts) == with_toaster + if isinstance(toast_app, AppHarnessProd): + assert libraries_in_scripts(built_scripts(toast_app)) == with_toaster + + +def NoToastApp(): + """App with state whose code names no toast, and sends one all the same.""" + import reflex as rx + + class NoToastState(rx.State): + count: int = 0 + + @rx.event + def increment(self): + self.count += 1 + + @rx.event + def surprise(self): + """Send a toast through a name the compiler cannot read. + + Returns: + A warning toast. + """ + send = getattr(rx, "to" + "ast") + return send.warning("Surprise", description="Sent anyway", duration=30000) + + def index(): + return rx.el.div( + rx.el.input( + value=NoToastState.router.session.client_token, + read_only=True, + id="token", + ), + rx.el.button( + NoToastState.count, id="count", on_click=NoToastState.increment + ), + rx.el.button("Surprise", id="surprise", on_click=NoToastState.surprise), + ) + + app = rx.App() + app.add_page(index) + + +@pytest.fixture(scope="module") +def no_toast_app( + app_harness_env: type[AppHarness], tmp_path_factory +) -> Generator[AppHarness, None, None]: + """Start NoToastApp in dev or prod mode via AppHarness. + + Args: + app_harness_env: AppHarness (dev) or AppHarnessProd (prod). + tmp_path_factory: pytest fixture for creating temporary directories. + + Yields: + Running AppHarness instance. + """ + with app_harness_env.create( + root=tmp_path_factory.mktemp("no_toast_app"), + app_source=NoToastApp, + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +def test_app_that_sends_no_toast_leaves_the_toaster_out( + no_toast_app: AppHarness, page: Page +): + """Handlers work without the toaster, and an unexpected toast shows plainly. + + Args: + no_toast_app: AppHarness running the test app. + page: Playwright page. + """ + assert no_toast_app.frontend_url is not None + page_errors: list[str] = [] + page.on("pageerror", lambda exc: page_errors.append(str(exc))) + scripts = record_scripts(page) + + page.goto(no_toast_app.frontend_url) + expect(page.locator("#token")).not_to_have_value("") + page.locator("#count").click() + expect(page.locator("#count")).to_have_text("1") + + # The state runtime is loaded, the toaster is not. + without_toaster = {"socket.io": True, "universal-cookie": True, "sonner": False} + assert libraries_in_scripts(scripts) == without_toaster + if isinstance(no_toast_app, AppHarnessProd): + assert libraries_in_scripts(built_scripts(no_toast_app)) == without_toaster + + page.locator("#surprise").click() + notice = page.locator("#reflex-plain-toasts-bottom-right > [role=status]") + expect(notice.locator("div")).to_have_text(["Surprise", "Sent anyway"]) + expect(page.locator("[data-sonner-toast]")).to_have_count(0) + assert page_errors == [] diff --git a/tests/integration/tests_playwright/test_ui_components.py b/tests/integration/tests_playwright/test_ui_components.py new file mode 100644 index 00000000000..3bf0a9746fe --- /dev/null +++ b/tests/integration/tests_playwright/test_ui_components.py @@ -0,0 +1,1184 @@ +"""The rx.ui components in a real app, in dev and prod. + +One app is shared by every test of the components: add a page or an element to +``UIComponentsApp`` rather than a new app. It is built twice, on its own and +beside Radix Themes: the stylesheet of Radix Themes is unlayered and defines +every color scale on the root element, so only the app without it shows what +the rx.ui stylesheet does alone. +""" + +import functools +import hashlib +import json +import re +import shutil +from collections.abc import Generator +from pathlib import Path +from typing import Any + +import pytest +from playwright.sync_api import Browser, Page, Route, expect +from reflex_components_ui import _radix_tokens +from reflex_components_ui.constants import JS_SRC + +from reflex.testing import AppHarness, AppHarnessProd, chdir +from reflex.utils import build + +# What the box sets on its own, then the `style` and `class_name` of each box +# of the index page: its padding shows which stylesheet won. +BOX_STYLES = { + # The box against the browser's defaults. + "plain": {"display": "block", "box-sizing": "border-box", "padding": "0px"}, + # A `style` beats the resets of Reflex and Tailwind, which zero the padding. + "styled": {"display": "block", "box-sizing": "border-box", "padding": "4px"}, + # A Tailwind utility beats the `style` of the box. + "utility": {"display": "block", "box-sizing": "border-box", "padding": "32px"}, + # An unlayered stylesheet beats both. + "unlayered": {"display": "block", "box-sizing": "border-box", "padding": "2px"}, +} + +# A style of the literal page as it is compiled, and what the caching test +# changes it to. +LITERAL_STYLE = '"paddingTop": "6px"' +CHANGED_STYLE = '"paddingTop": "7px"' + +# The elements of the styled page below the first breakpoint, before any event. +STYLED = { + # A width bound to state. + "var": {"width": "100px"}, + "hover": {"color": "rgb(0, 0, 0)"}, + "responsive": {"margin-top": "2px"}, + # A variant bound to state: the base, and what its value changes. + "tone": { + "color": "rgb(0, 0, 255)", + "background-color": "rgb(0, 128, 0)", + "padding": "1px", + }, + # The same variant with a value known at compile time. + "loud": { + "color": "rgb(255, 255, 255)", + "background-color": "rgb(255, 0, 0)", + "padding": "1px", + }, +} + +# What differs from STYLED at and above the first breakpoint. +STYLED_WIDE = {**STYLED, "responsive": {"margin-top": "6px"}} + +# What differs from STYLED once the state has changed. +STYLED_CHANGED = { + **STYLED, + "var": {"width": "200px"}, + "tone": { + "color": "rgb(255, 255, 255)", + "background-color": "rgb(255, 0, 0)", + "padding": "1px", + }, +} + +# The declarations of the styled page: one for each distinct style, with the +# constant that holds its class names. The hundred rows share the last. +STYLED_PAGE_DECLARATIONS = [ + ( + 'const sx_e5e3dab07a = stylex.create({ s: {"boxSizing": "border-box", ' + '"display": "block", "color": {"default": "rgb(0, 0, 0)", ":hover": ' + '"rgb(255, 0, 0)"}} });' + ), + "const sx_e5e3dab07a_c = stylex.props(sx_e5e3dab07a.s).className;", + ( + 'const sx_4c7f040d01 = stylex.create({ s: {"boxSizing": "border-box", ' + '"display": "block", "marginTop": {"default": "2px", "@media screen and ' + '(min-width: 30em)": "6px"}} });' + ), + "const sx_4c7f040d01_c = stylex.props(sx_4c7f040d01.s).className;", + ( + 'const sx_9cbecd042a = stylex.create({ s: {"color": "rgb(255, 255, 255)", ' + '"paddingTop": "1px", "paddingRight": "1px", "paddingBottom": "1px", ' + '"paddingLeft": "1px", "backgroundColor": "rgb(255, 0, 0)"} });' + ), + "const sx_9cbecd042a_c = stylex.props(sx_9cbecd042a.s).className;", + ( + 'const sx_e9f4c4c063 = stylex.create({ s: {"boxSizing": "border-box", ' + '"display": "block", "paddingTop": "3px", "paddingRight": "3px", ' + '"paddingBottom": "3px", "paddingLeft": "3px", "opacity": {":hover": 0.5}} });' + ), + "const sx_e9f4c4c063_c = stylex.props(sx_e9f4c4c063.s).className;", +] + +# The declarations of its elements that read state, which the compiler moves +# into a module of their own: a custom property for the width, and the class +# names of each value of the variant. +STYLED_MEMO_DECLARATIONS = [ + ( + 'const sx_723c142d42 = stylex.create({ s: {"boxSizing": "border-box", ' + '"display": "block", "width": "var(--v0)"} });' + ), + "const sx_723c142d42_c = stylex.props(sx_723c142d42.s).className;", + ( + 'const sx_5f1012736b = stylex.create({ s: {"paddingTop": "1px", ' + '"paddingRight": "1px", "paddingBottom": "1px", "paddingLeft": "1px"}, a0_0: ' + '{"color": "rgb(0, 0, 255)", "backgroundColor": "rgb(0, 128, 0)"}, a0_1: ' + '{"color": "rgb(255, 255, 255)", "backgroundColor": "rgb(255, 0, 0)"}, a0: ' + '{"color": "rgb(0, 0, 255)"} });' + ), + "const sx_5f1012736b_c = stylex.props(sx_5f1012736b.s).className;", + ( + "const sx_5f1012736b_0 = { __proto__: null, " + '"calm": stylex.props(sx_5f1012736b.a0_0).className, ' + '"loud": stylex.props(sx_5f1012736b.a0_1).className };' + ), + "const sx_5f1012736b_0d = stylex.props(sx_5f1012736b.a0).className;", +] + + +# The colors the theme pages are read through, as Radix Themes defines them. +INDIGO_11 = {"light": "rgb(58, 91, 199)", "dark": "rgb(158, 177, 255)"} +RED_11 = {"light": "rgb(206, 44, 49)", "dark": "rgb(255, 149, 146)"} +SLATE_2 = {"light": "rgb(249, 249, 251)", "dark": "rgb(24, 25, 27)"} + +# The scripts of the token sweep of the javascript package, which read every +# custom property through a property of its type and hold the exceptions. +SWEEP_HARNESS = JS_SRC.parent / "tests" / "harness" +SWEEP_SCRIPTS = "/__reflex_ui_sweep__/" + + +def UIComponentsApp(radix: bool = False): + """An app with a page for each thing the rx.ui tests look at. + + Args: + radix: Whether the app also has Radix Themes and its components. + """ + import json + from pathlib import Path + from typing import Any, ClassVar, Literal + + from reflex_components_ui import _radix_tokens + from reflex_components_ui.base import UIComponent + from reflex_components_ui.style import ComponentStyles + + import reflex as rx + + tokens = rx.ui.tokens + + class StyleState(rx.State): + """What the styles of the styled page are bound to.""" + + width: rx.Field[str] = rx.field("100px") + tone: rx.Field[str] = rx.field("calm") + + @rx.event + def change(self): + """Change every value a style is bound to.""" + self.width = "200px" + self.tone = "loud" + + class Tone(UIComponent): + """An element whose look a prop selects.""" + + styles: ClassVar[ComponentStyles] = { + "base": {"color": "rgb(0, 0, 255)", "padding": "1px"}, + "variants": { + "tone": { + "calm": {"background_color": "rgb(0, 128, 0)"}, + "loud": { + "background_color": "rgb(255, 0, 0)", + "color": "rgb(255, 255, 255)", + }, + }, + }, + } + + # Which look the element has. + tone: rx.Var[Literal["calm", "loud"]] + + class Chip(UIComponent): + """An element with a color of its own.""" + + styles: ClassVar[ComponentStyles] = { + "base": { + "background_color": tokens.accent[9], + "outline_color": tokens.focus[8], + }, + } + + # The accent color of the element. + color_scheme: rx.Var[str] + + def index(): + return rx.el.main( + rx.ui.box("plain", id="plain"), + rx.ui.box("styled", id="styled", style={"padding": "4px"}), + rx.ui.box( + "utility", id="utility", style={"padding": "4px"}, class_name="p-8" + ), + rx.ui.box( + "unlayered", + id="unlayered", + style={"padding": "4px"}, + class_name="p-8 unlayered", + ), + ) + + def literal(): + return rx.ui.box("literal", id="literal", style={"padding": "6px"}) + + def probe(name: str): + # Each style reads a token through a property that takes its value. + return rx.ui.box( + name, + id=name, + style={ + "color": tokens.accent[11], + "background_color": tokens.gray[2], + "border_top_left_radius": tokens.radius[3], + "padding_top": tokens.space[4], + "font_size": tokens.font_size[2], + }, + ) + + def theme(): + return rx.el.main( + probe("root-probe"), + rx.ui.theme( + probe("nested-probe"), + rx.el.div( + probe("popover-probe"), + id="popover", + custom_attrs={"popover": "auto"}, + ), + accent_color="red", + radius="full", + scaling="110%", + appearance="dark", + id="nested", + ), + probe("after-probe"), + Chip.create("theme", id="chip-theme"), + Chip.create("red", id="chip-red", color_scheme="red"), + Chip.create("gray", id="chip-gray", color_scheme="gray"), + rx.el.button("toggle", id="toggle", on_click=rx.toggle_color_mode), + ) + + # The themes the sweep compares with Radix Themes: every accent with the + # gray that matches it and every gray, in both appearances, then every + # radius, scaling and panel background. Each sets every option, as a + # nested theme of Radix Themes inherits from the Radix theme of the app + # and one of rx.ui from the rx.ui one. A gray is given an appearance + # because Radix Themes has no rule for the plain gray: without the class + # of an appearance, its nested theme keeps the gray around it. + defaults = { + "accent_color": "indigo", + "gray_color": "auto", + "radius": "medium", + "scaling": "100%", + "panel_background": "translucent", + } + variations = [ + {"accent_color": accent, "appearance": appearance} + for accent in _radix_tokens.ACCENT_THEMES + for appearance in ("light", "dark") + ] + variations += [ + {"gray_color": gray, "appearance": appearance} + for gray in _radix_tokens.GRAY_THEMES + for appearance in ("light", "dark") + ] + variations += [{"radius": radius} for radius in _radix_tokens.RADIUS_THEMES] + variations += [{"scaling": scaling} for scaling in _radix_tokens.SCALING_THEMES] + variations += [ + {"panel_background": panel} for panel in _radix_tokens.PANEL_BACKGROUND_THEMES + ] + configs: list[dict[str, Any]] = [ + {**defaults, **variation} for variation in variations + ] + + def sweep(): + themes = [] + for index, config in enumerate(configs): + label = {"data-sweep": json.dumps(config)} + themes.append(rx.ui.theme(id=f"ui-{index}", custom_attrs=label, **config)) + if radix: + # Reflex keeps the appearance of an `rx.theme` for the color + # mode of the app. Radix Themes selects on the class, and gives + # a theme with an appearance its background. + options: dict[str, Any] = { + k: v for k, v in config.items() if k != "appearance" + } + if "appearance" in config: + options.update(class_name=config["appearance"], has_background=True) + themes.append( + rx.theme(id=f"radix-{index}", custom_attrs=label, **options) + ) + # The tokens no theme defines are on a page through what uses them. + uses = rx.ui.box(cursor=tokens.cursor.button, color=tokens.white.a[1]) + return rx.el.main(*themes, uses) + + def buttons(): + return rx.fragment( + rx.button("accent"), + rx.button("green", color_scheme="green", variant="soft"), + ) + + def mixed(): + return rx.el.main( + rx.button("radix", id="radix-button"), + probe("ui-box"), + # Beside Radix Themes a theme with an appearance names its gray: + # the Radix stylesheet sets the plain gray wherever the class of + # an appearance is. + rx.ui.theme( + buttons(), + accent_color="red", + gray_color="slate", + appearance="dark", + id="ui-dark", + ), + rx.theme( + buttons(), + accent_color="red", + gray_color="slate", + class_name="dark", + has_background=True, + id="radix-dark", + ), + ) + + def styled(): + return rx.el.main( + rx.ui.box("var", id="var", width=StyleState.width), + rx.ui.box( + "hover", + id="hover", + style={"color": "rgb(0, 0, 0)", "_hover": {"color": "rgb(255, 0, 0)"}}, + ), + rx.ui.box("responsive", id="responsive", margin_top=["2px", "6px"]), + Tone.create("tone", id="tone", tone=StyleState.tone), + Tone.create("loud", id="loud", tone="loud"), + rx.el.button("change", id="change", on_click=StyleState.change), + *[ + rx.ui.box( + f"row {index}", + class_name="row", + style={"padding": "3px", "_hover": {"opacity": 0.5}}, + ) + for index in range(100) + ], + ) + + assets = Path.cwd() / "assets" + assets.mkdir(exist_ok=True) + (assets / "unlayered.css").write_text(".unlayered { padding: 2px }") + + app = rx.App(stylesheets=["unlayered.css"]) + app.add_page(index) + app.add_page(literal, route="/literal") + app.add_page(styled, route="/styled") + app.add_page(theme, route="/theme") + app.add_page(sweep, route="/sweep") + if radix: + app.add_page(mixed, route="/mixed") + + class ThemeState(rx.State): + accent: str = "red" + appearance: str = "inherit" + + @rx.event + def change(self): + self.accent = "green" + self.appearance = "dark" + + def bound(): + return rx.el.main( + rx.ui.theme( + probe("bound-probe"), + accent_color=ThemeState.accent, # pyright: ignore [reportArgumentType] + gray_color="slate", + appearance=ThemeState.appearance, # pyright: ignore [reportArgumentType] + id="bound", + ), + Chip.create("bound", id="chip-bound", color_scheme=ThemeState.accent), + rx.el.button("change", id="change", on_click=ThemeState.change), + ) + + app.add_page(bound, route="/bound") + + config = rx.config.get_config() + config.plugins = [ + rx.plugins.UIPlugin(theme=rx.ui.Theme(accent_color="indigo", radius="large")), + rx.plugins.TailwindV4Plugin(), + ] + if radix: + # Its own theme is blue: the theme of rx.ui is the one a page follows. + config.plugins.append(rx.plugins.RadixThemesPlugin()) + + +def _run( + app_harness_env: type[AppHarness], + tmp_path_factory: pytest.TempPathFactory, + radix: bool, +) -> Generator[AppHarness, None, None]: + """Run the shared app in dev or prod. + + Args: + app_harness_env: AppHarness (dev) or AppHarnessProd (prod). + tmp_path_factory: pytest fixture for creating temporary directories. + radix: Whether the app also has Radix Themes. + + Yields: + The running harness. + """ + name = f"ui_{'mixed' if radix else 'components'}_{app_harness_env.__name__.lower()}" + with app_harness_env.create( + root=tmp_path_factory.mktemp(name), + app_name=name, + app_source=functools.partial(UIComponentsApp, radix=radix), + ) as harness: + assert harness.app_instance is not None, "app is not running" + yield harness + + +@pytest.fixture(scope="module") +def ui_app( + app_harness_env: type[AppHarness], tmp_path_factory: pytest.TempPathFactory +) -> Generator[AppHarness, None, None]: + """Run the shared app in dev or prod. + + Args: + app_harness_env: AppHarness (dev) or AppHarnessProd (prod). + tmp_path_factory: pytest fixture for creating temporary directories. + + Yields: + The running harness. + """ + yield from _run(app_harness_env, tmp_path_factory, radix=False) + + +@pytest.fixture(scope="module") +def mixed_app( + app_harness_env: type[AppHarness], tmp_path_factory: pytest.TempPathFactory +) -> Generator[AppHarness, None, None]: + """Run the shared app beside Radix Themes, in dev or prod. + + Args: + app_harness_env: AppHarness (dev) or AppHarnessProd (prod). + tmp_path_factory: pytest fixture for creating temporary directories. + + Yields: + The running harness. + """ + yield from _run(app_harness_env, tmp_path_factory, radix=True) + + +@pytest.fixture +def prod_app(ui_app: AppHarness) -> AppHarness: + """Skip a test of the production build when the app runs in dev. + + Args: + ui_app: The running harness. + + Returns: + The harness, running a production build. + """ + if not isinstance(ui_app, AppHarnessProd): + pytest.skip("only a production build is prerendered and bundled") + return ui_app + + +def _computed_styles( + page: Page, elements: dict[str, dict[str, str]] +) -> dict[str, dict[str, str]]: + """Read the computed style of elements of the page. + + Args: + page: A page of the app. + elements: The properties to read, as the keys of a dict, by element id. + + Returns: + The properties as the browser computed them, by element id. + """ + return page.evaluate( + """(elements) => Object.fromEntries( + Object.entries(elements).map(([id, properties]) => { + const style = getComputedStyle(document.getElementById(id)); + return [ + id, + Object.fromEntries( + Object.keys(properties).map((name) => [ + name, + style.getPropertyValue(name), + ]), + ), + ]; + }), + )""", + elements, + ) + + +def test_box_is_styled_in_cascade_order(ui_app: AppHarness, page: Page): + """The box is a styled div, between the resets and the utilities.""" + assert ui_app.frontend_url is not None + page.goto(ui_app.frontend_url) + # In dev the styles of a page arrive once its module was compiled. + expect(page.locator("#styled")).to_have_css("padding", "4px") + assert _computed_styles(page, BOX_STYLES) == BOX_STYLES + assert page.locator("#plain").evaluate("(box) => box.tagName") == "DIV" + + +def test_first_paint_is_styled_without_javascript( + prod_app: AppHarness, browser: Browser +): + """The prerendered page links the styles and carries the class names.""" + assert prod_app.frontend_url is not None + context = browser.new_context(java_script_enabled=False) + try: + page = context.new_page() + page.goto(prod_app.frontend_url) + # Evaluating in the page still works: only its own scripts are off. + assert _computed_styles(page, BOX_STYLES) == BOX_STYLES + finally: + context.close() + + +def _client_files(harness: AppHarness) -> dict[str, bytes]: + """Read what the production build serves to the browser. + + Args: + harness: A harness running a production build. + + Returns: + The content of every file, by path. The compressed copies are left + out: each is derived from a file that is included. + """ + client = harness.app_path / ".web" / "build" / "client" + return { + path.relative_to(client).as_posix(): path.read_bytes() + for path in sorted(client.rglob("*")) + if path.is_file() and path.suffix != ".gz" + } + + +def _styled_url(harness: AppHarness) -> str: + """Get the address of the styled page. + + Args: + harness: The running harness. + + Returns: + The address. + """ + assert harness.frontend_url is not None + return harness.frontend_url.rstrip("/") + "/styled/" + + +def test_styles_follow_the_viewport_the_state_and_the_pointer( + ui_app: AppHarness, page: Page +): + """Every kind of style applies where and when it should.""" + page.set_viewport_size({"width": 400, "height": 600}) + page.goto(_styled_url(ui_app)) + # In dev the styles of a page arrive once its module was compiled. + expect(page.locator("#tone")).to_have_css("padding", "1px") + assert _computed_styles(page, STYLED) == STYLED + + page.set_viewport_size({"width": 1280, "height": 600}) + expect(page.locator("#responsive")).to_have_css("margin-top", "6px") + assert _computed_styles(page, STYLED) == STYLED_WIDE + + page.set_viewport_size({"width": 400, "height": 600}) + page.locator("#hover").hover() + expect(page.locator("#hover")).to_have_css("color", "rgb(255, 0, 0)") + + # The value bound to state is a custom property of the element. + variable = "(box) => box.style.getPropertyValue('--v0')" + assert page.locator("#var").evaluate(variable) == "100px" + page.locator("#change").click() + expect(page.locator("#var")).to_have_css("width", "200px") + assert _computed_styles(page, STYLED) == STYLED_CHANGED + assert page.locator("#var").evaluate(variable) == "200px" + + +def test_equal_styles_share_one_declaration(ui_app: AppHarness, page: Page): + """A hundred rows with one style declare it once and carry the same classes.""" + web = ui_app.app_path / ".web" + + def declarations(path: Path) -> list[str]: + return re.findall(r"^const sx_\w+ = .*$", path.read_text(), re.MULTILINE) + + (route,) = (web / "app" / "routes").glob("*styled*.jsx") + assert declarations(route) == STYLED_PAGE_DECLARATIONS + name = ui_app.app_name + assert declarations(web / "app_components" / name / f"{name}.jsx") == ( + STYLED_MEMO_DECLARATIONS + ) + + page.goto(_styled_url(ui_app)) + rows = page.locator(".row") + expect(rows).to_have_count(100) + class_names = set(rows.evaluate_all("(rows) => rows.map((row) => row.className)")) + assert len(class_names) == 1 + (class_name,) = class_names + # Its own class, then display, box-sizing, the four sides of the padding and + # the opacity. While developing, StyleX names the declaration ahead of them. + assert re.fullmatch(r"row (\w+__sx_e9f4c4c063\.s )?x\w+( x\w+){6}", class_name), ( + class_name + ) + expect(rows.first).to_have_css("padding", "3px") + + +def _scripts(harness: AppHarness) -> dict[str, str]: + """Read the scripts the production build serves to the browser. + + Args: + harness: A harness running a production build. + + Returns: + The source of every script, by path. + """ + return { + name: content.decode() + for name, content in _client_files(harness).items() + if name.endswith(".js") + } + + +def test_literal_page_folds_to_class_names(prod_app: AppHarness, page: Page): + """StyleX leaves a class name string in the page, and none of itself.""" + assert prod_app.frontend_url is not None + page.goto(prod_app.frontend_url.rstrip("/") + "/literal/") + box = page.locator("#literal") + expect(box).to_have_css("padding", "6px") + class_name = box.get_attribute("class") + assert class_name is not None + # Six atomic classes: display, box-sizing and the four sides of the padding. + assert re.fullmatch(r"x\w+( x\w+){5}", class_name), class_name + + scripts = _scripts(prod_app) + literal_chunks = [name for name in scripts if name.startswith("assets/_literal_")] + assert len(literal_chunks) == 1, sorted(scripts) + # The chunk of the page holds the folded string once, and nothing else + # that names a class. + assert re.findall(r"className:`([^`]*)`", scripts[literal_chunks[0]]) == [ + class_name + ] + + +def test_no_page_ships_the_stylex_runtime(prod_app: AppHarness): + """Styles bound to state are compiled away too. + + A value bound to state is a custom property, and a variant bound to state + indexes a table of folded class names, so no script holds a call into + StyleX: neither the literal page nor the styled one, whose element holds + the table. + """ + scripts = _scripts(prod_app) + # No script holds the StyleX runtime, whose name minifying leaves alone. + assert [ + name for name, code in scripts.items() if re.search(r"stylex|styleq", code) + ] == [] + # A compiled style is only kept where a theme reads it: a theme is + # declared in a module of its own, so its classes are joined when the + # page loads. The pages without a theme of their own hold none. + assert [ + name + for name, code in scripts.items() + if name.startswith(("assets/_literal_", "assets/_styled_", "assets/_index")) + and "$$css" in code + ] == [] + # The table of the variant, in the chunk that renders the element: the + # class names of each value. The element is in the module of the + # components the app keeps apart from their pages, which two pages load. + tables = [ + (name.split("-")[0], table) + for name, code in scripts.items() + for table in re.findall(r"\{__proto__:null,calm:.*?,loud:.*?\}[^}]*\}", code) + ] + ((chunk, table),) = tables + assert chunk == f"assets/{prod_app.app_name}" + assert re.fullmatch( + r"\{__proto__:null,calm:\{className:`x\w+ x\w+`\}\.className," + r"loud:\{className:`x\w+ x\w+`\}\.className\}", + table, + ), table + + +def _digests(files: dict[str, bytes]) -> dict[str, str]: + """Reduce files to what tells two versions of one apart. + + Args: + files: The content of every file, by path. + + Returns: + The digest of every file, by path. + """ + return { + name: hashlib.sha256(content).hexdigest() for name, content in files.items() + } + + +def _rebuild_literal_page(harness: AppHarness, old: str, new: str) -> dict[str, str]: + """Change a style of the compiled literal page and build again. + + Args: + harness: A harness running a production build. + old: The style as the page declares it. + new: The style to declare instead. + + Returns: + The digest of every file of the new build, by path. + """ + routes = harness.app_path / ".web" / "app" / "routes" + (page,) = routes.glob("*literal*.jsx") + source = page.read_text() + assert source.count(old) == 1, source + page.write_text(source.replace(old, new)) + with chdir(harness.app_path): + build.build() + return _digests(_client_files(harness)) + + +def test_changed_style_renames_every_changed_file(prod_app: AppHarness, tmp_path: Path): + """A browser never keeps a stale file under the name of a new one. + + StyleX renames the stylesheet after the chunks were named, and writes the + new name into the chunk that links it. + """ + static = prod_app.app_path / ".web" / "build" / "client" + # Outside the web directory: a build removes its output, and Tailwind + # reads class names from every file beside it. + kept = tmp_path / "client" + shutil.copytree(static, kept) + before = _digests(_client_files(prod_app)) + try: + after = _rebuild_literal_page(prod_app, LITERAL_STYLE, CHANGED_STYLE) + restored = _rebuild_literal_page(prod_app, CHANGED_STYLE, LITERAL_STYLE) + finally: + # The other tests of the module read the build the harness serves. + shutil.rmtree(static) + shutil.move(kept, static) + + def named(digests: dict[str, str]) -> dict[str, str]: + # A document is addressed by its route and is not cached by its name. + return { + name: digest + for name, digest in digests.items() + if not name.endswith(".html") + } + + before, after, restored = named(before), named(after), named(restored) + changed_in_place = sorted( + name for name, digest in after.items() if before.get(name, digest) != digest + ) + assert changed_in_place == [] + renamed = sorted(Path(name).name.split("-")[0] for name in after.keys() - before) + assert renamed == [ + "__reflex_global_styles", + "_literal_._index", + "manifest", + "root", + ] + # The same styles build the same files: a name is a function of content. + assert restored == before + + +# What each probe of the theme page reads, and through which token. +PROBE_PROPERTIES = ( + "color", + "background-color", + "border-top-left-radius", + "padding-top", + "font-size", +) + +# The probes under the theme of the app, indigo and large, in each color mode. +APP_PROBE = { + mode: { + "color": INDIGO_11[mode], + "background-color": SLATE_2[mode], + "border-top-left-radius": "9px", + "padding-top": "16px", + "font-size": "14px", + } + for mode in ("light", "dark") +} + +# The probes under the nested theme: red, full, 110% and always dark. +NESTED_PROBE = { + "color": RED_11["dark"], + # The gray is the one around the theme, as an accent does not set it. + "background-color": SLATE_2["dark"], + "border-top-left-radius": "9.9px", + "padding-top": "17.6px", + "font-size": "15.4px", +} + + +def _probes(page: Page) -> dict[str, dict[str, str]]: + """Read the probes of the theme page. + + Args: + page: A page showing the theme page of the app. + + Returns: + The properties in PROBE_PROPERTIES as the browser computed them, by + probe id. + """ + return page.evaluate( + """(properties) => Object.fromEntries( + [...document.querySelectorAll('[id$="-probe"]')].map((probe) => { + const style = getComputedStyle(probe); + return [ + probe.id, + Object.fromEntries( + properties.map((name) => [name, style.getPropertyValue(name)]), + ), + ]; + }), + )""", + list(PROBE_PROPERTIES), + ) + + +def _goto_theme_page(harness: AppHarness, page: Page) -> None: + """Show the theme page, styled. + + Args: + harness: The running harness. + page: The page to navigate. + """ + assert harness.frontend_url is not None + page.goto(harness.frontend_url.rstrip("/") + "/theme/") + # In dev the styles of a page arrive once its module was compiled. + expect(page.locator("#nested-probe")).to_have_css("font-size", "15.4px") + + +def test_nested_theme_overrides_its_subtree_only(ui_app: AppHarness, page: Page): + """The theme of the plugin is around the page, and a nested one inside it.""" + _goto_theme_page(ui_app, page) + page.locator("#popover").evaluate("(popover) => popover.showPopover()") + assert _probes(page) == { + "root-probe": APP_PROBE["light"], + "nested-probe": NESTED_PROBE, + # The browser renders a popover in the top layer, outside the theme + # element: it inherits from where it is declared all the same. + "popover-probe": NESTED_PROBE, + "after-probe": APP_PROBE["light"], + } + themes = page.evaluate( + """() => [...document.querySelectorAll(".reflex-ui-theme")].map((theme) => { + const style = getComputedStyle(theme); + const parent = theme.parentElement; + return [ + theme.id, + style.colorScheme, + style.backgroundColor, + style.minHeight, + parent.classList.contains("dark"), + getComputedStyle(parent).display, + ]; + })""" + ) + # Text selected inside a theme has the color of its focus ring. + selection = page.evaluate( + """() => ["root-probe", "nested-probe"].map((id) => { + const probe = document.getElementById(id); + const reference = probe.appendChild(document.createElement("i")); + reference.style.color = "var(--focus-a5)"; + return [ + getComputedStyle(probe, "::selection").backgroundColor, + getComputedStyle(reference).color, + ]; + })""" + ) + # Indigo a5 of the light scale, and red a5 of the dark one. + assert selection == [ + ["rgba(0, 68, 255, 0.176)", "rgba(0, 68, 255, 0.176)"], + ["rgba(255, 32, 71, 0.337)", "rgba(255, 32, 71, 0.337)"], + ] + viewport = page.viewport_size + assert viewport is not None + assert themes == [ + # The background of a light theme is white, and of a dark one its + # darkest gray: slate here. Only the theme of the app fills the page. + ["", "light", "rgb(255, 255, 255)", f"{viewport['height']}px", False, "block"], + # The class of an appearance is on an element without a box. + ["nested", "dark", "rgb(17, 17, 19)", "0px", True, "contents"], + ] + + +def test_color_mode_toggle_flips_the_palette(ui_app: AppHarness, page: Page): + """A color is one value for both modes, chosen by the class of the page.""" + _goto_theme_page(ui_app, page) + html = page.locator("html") + expect(html).to_have_class("light") + assert _probes(page)["root-probe"] == APP_PROBE["light"] + page.locator("#toggle").click() + expect(html).to_have_class("dark") + assert _probes(page) == { + "root-probe": APP_PROBE["dark"], + # A theme with an appearance of its own keeps it. + "nested-probe": NESTED_PROBE, + "popover-probe": NESTED_PROBE, + "after-probe": APP_PROBE["dark"], + } + page.locator("#toggle").click() + expect(html).to_have_class("light") + assert _probes(page)["root-probe"] == APP_PROBE["light"] + + +def test_prerendered_theme_page_is_themed_without_javascript( + prod_app: AppHarness, browser: Browser +): + """The theme is class names in the document, and needs no script.""" + assert prod_app.frontend_url is not None + context = browser.new_context(java_script_enabled=False) + try: + page = context.new_page() + page.goto(prod_app.frontend_url.rstrip("/") + "/theme/") + # Nothing has set the class of a color mode: the page is light. + assert page.locator("html").get_attribute("class") is None + assert _probes(page) == { + "root-probe": APP_PROBE["light"], + "nested-probe": NESTED_PROBE, + "popover-probe": NESTED_PROBE, + "after-probe": APP_PROBE["light"], + } + finally: + context.close() + + +# The themes of the sweep page, as the app builds them. +SWEEP_DEFAULTS = { + "accent_color": "indigo", + "gray_color": "auto", + "radius": "medium", + "scaling": "100%", + "panel_background": "translucent", +} +SWEEP_CONFIGS: list[dict[str, str]] = [ + {**SWEEP_DEFAULTS, **variation} + for variation in ( + *( + {"accent_color": accent, "appearance": appearance} + for accent in _radix_tokens.ACCENT_THEMES + for appearance in ("light", "dark") + ), + *( + {"gray_color": gray, "appearance": appearance} + for gray in _radix_tokens.GRAY_THEMES + for appearance in ("light", "dark") + ), + *({"radius": radius} for radius in _radix_tokens.RADIUS_THEMES), + *({"scaling": scaling} for scaling in _radix_tokens.SCALING_THEMES), + *( + {"panel_background": panel} + for panel in _radix_tokens.PANEL_BACKGROUND_THEMES + ), + ) +] + +# Every custom property Radix Themes defines: the modules add two of their +# own, through which a theme switches the background of its panels. +SWEEP_NAMES = [ + name + for _, names in _radix_tokens.VAR_GROUPS.values() + for name in names + if name not in ("--panel-solid", "--color-panel-if-solid") +] + +READ_SWEEP = """async ([scripts, names, prefix]) => { + const { labels, mount, read } = await import(scripts + "probe.js"); + const container = document.createElement("div"); + const probes = mount(container, names); + const themes = [...document.querySelectorAll(`[data-sweep][id^="${prefix}-"]`)]; + return { + labels: labels(names), + themes: themes.map((theme) => { + theme.append(container); + return [theme.id, theme.dataset.sweep, read(probes, theme)]; + }), + }; +}""" + + +def _serve_sweep_script(route: Route) -> None: + """Answer a request for a script of the token sweep with the file. + + Args: + route: The intercepted request. + """ + name = route.request.url.rsplit("/", 1)[1] + route.fulfill(path=SWEEP_HARNESS / name, content_type="text/javascript") + + +def _read_sweep(harness: AppHarness, page: Page, prefix: str) -> dict[str, Any]: + """Read every custom property under every theme of the sweep page. + + Args: + harness: The running harness. + page: The page to navigate. + prefix: What the ids of the themes to read start with: ``ui`` for the + ones of rx.ui, ``radix`` for the ones of Radix Themes. + + Returns: + The names of the values, and the id, the options and the values of + each theme. + """ + assert harness.frontend_url is not None + page.route(f"**{SWEEP_SCRIPTS}*", _serve_sweep_script) + page.goto(harness.frontend_url.rstrip("/") + "/sweep/") + # In dev the styles of a page arrive once its module was compiled. + expect(page.locator("#ui-0")).to_have_css("overflow-wrap", "break-word") + return page.evaluate(READ_SWEEP, [SWEEP_SCRIPTS, SWEEP_NAMES, prefix]) + + +def _sweep_differences( + reference: dict[str, Any], ours: dict[str, Any] +) -> list[tuple[str, str, str, str]]: + """List where two readings of the sweep page differ. + + Args: + reference: The reading under the themes of Radix Themes. + ours: A reading under the themes of rx.ui. + + Returns: + The options, the name of the value, the value under Radix Themes and + the value under rx.ui, for each difference. + """ + return [ + (config, label, expected, value) + for (_, config, expected_values), (_, _, values) in zip( + reference["themes"], ours["themes"], strict=True + ) + for label, expected, value in zip( + reference["labels"], expected_values, values, strict=True + ) + if expected != value + ] + + +def test_tokens_resolve_as_under_radix_themes( + ui_app: AppHarness, mixed_app: AppHarness, page: Page +): + """Every custom property has the value Radix Themes gives it. + + The same themes are read under ``rx.theme`` and under ``rx.ui.theme`` on + one page, and under ``rx.ui.theme`` in the app without Radix Themes. What + may differ is listed with its reason in the exceptions of the javascript + package, which the script that reads the values applies. + """ + radix = _read_sweep(mixed_app, page, "radix") + mixed = _read_sweep(mixed_app, page, "ui") + alone = _read_sweep(ui_app, page, "ui") + + configs = [json.dumps(config) for config in SWEEP_CONFIGS] + assert len(configs) == 76 + for reading, prefix in ((radix, "radix"), (mixed, "ui"), (alone, "ui")): + assert [theme[:2] for theme in reading["themes"]] == [ + [f"{prefix}-{index}", config] for index, config in enumerate(configs) + ] + assert len(radix["labels"]) == 1068 + 11 + # A value neither side defines would compare equal: Radix defines them all. + assert [ + (config, label, value) + for _, config, values in radix["themes"] + for label, value in zip(radix["labels"], values, strict=True) + if value.startswith("INVALID") + ] == [] + assert _sweep_differences(radix, mixed) == [] + assert _sweep_differences(radix, alone) == [] + + +def test_radix_components_follow_the_rx_ui_theme(mixed_app: AppHarness, page: Page): + """On a page with both, a Radix button and an rx.ui box show one palette.""" + assert mixed_app.frontend_url is not None + page.goto(mixed_app.frontend_url.rstrip("/") + "/mixed/") + expect(page.locator("#ui-box")).to_have_css("color", INDIGO_11["light"]) + accents = page.evaluate( + """() => ["radix-button", "ui-box"].map((id) => + getComputedStyle(document.getElementById(id)).getPropertyValue("--accent-9"), + )""" + ) + # Indigo, the accent of the rx.ui theme, and not the blue of the Radix one. + assert accents == ["#3e63dd", "#3e63dd"] + expect(page.locator("#radix-button")).to_have_css( + "background-color", "rgb(62, 99, 221)" + ) + + # A nested rx.ui theme is to the Radix components inside it what a nested + # Radix theme is: its accent, and the dark scale of a color of their own. + def read(theme: str) -> list[list[str]]: + return page.locator(f"#{theme}").evaluate( + """(theme) => [theme, ...theme.querySelectorAll("button")].map((element) => { + const style = getComputedStyle(element); + return [style.backgroundColor, style.color]; + })""" + ) + + in_ui_theme = read("ui-dark") + assert in_ui_theme == [ + # The theme itself, its red button and its soft green button: slate 1 + # and 12, red 9, then green a3 and a11, all of the dark scales. + ["rgb(17, 17, 19)", "rgb(237, 238, 240)"], + ["rgb(229, 72, 77)", "rgb(255, 255, 255)"], + ["rgba(34, 255, 153, 0.118)", "rgba(70, 254, 165, 0.83)"], + ] + assert in_ui_theme == read("radix-dark") + + +def test_theme_bound_to_state_follows_it(mixed_app: AppHarness, page: Page): + """Every accent is on the page, and the browser applies the one in state.""" + assert mixed_app.frontend_url is not None + page.goto(mixed_app.frontend_url.rstrip("/") + "/bound/") + probe = page.locator("#bound-probe") + expect(probe).to_have_css("color", RED_11["light"]) + + def read() -> list[str]: + return page.locator("#bound").evaluate( + """(theme) => [ + getComputedStyle(theme.querySelector("#bound-probe")).backgroundColor, + getComputedStyle(theme).colorScheme, + getComputedStyle(theme).backgroundColor, + [...theme.parentElement.classList].filter((name) => + ["inherit", "light", "dark"].includes(name), + ).join(" "), + getComputedStyle(theme.parentElement).display, + ]""" + ) + + # The appearance of the page, and no background of its own. + assert read() == [ + SLATE_2["light"], + "light", + "rgba(0, 0, 0, 0)", + "inherit", + "contents", + ] + # A component with a color bound to the same state: red 9. + chip = page.locator("#chip-bound") + expect(chip).to_have_css("background-color", "rgb(229, 72, 77)") + page.locator("#change").click() + expect(probe).to_have_css("color", "rgb(61, 214, 140)") + # Green 9, and step 8 of the focus ring that follows it. + expect(chip).to_have_css("background-color", "rgb(48, 164, 108)") + expect(chip).to_have_css("outline-color", "rgb(91, 185, 139)") + assert read() == [SLATE_2["dark"], "dark", "rgb(17, 17, 19)", "dark", "contents"] + + +def test_color_scheme_is_the_accent_of_one_element(ui_app: AppHarness, page: Page): + """A component with a color follows it, and the focus ring with it.""" + _goto_theme_page(ui_app, page) + # Step 9 of the accent, then step 8 of the focus ring. The theme is + # indigo, and its gray is slate: a gray component keeps the indigo focus. + assert page.evaluate( + """() => Object.fromEntries( + [...document.querySelectorAll('[id^="chip-"]')].map((chip) => { + const style = getComputedStyle(chip); + return [chip.id, [style.backgroundColor, style.outlineColor]]; + }), + )""" + ) == { + "chip-theme": ["rgb(62, 99, 221)", "rgb(141, 164, 239)"], + "chip-red": ["rgb(229, 72, 77)", "rgb(235, 142, 144)"], + "chip-gray": ["rgb(139, 141, 152)", "rgb(141, 164, 239)"], + } diff --git a/tests/integration/tests_playwright/test_ui_parity.py b/tests/integration/tests_playwright/test_ui_parity.py new file mode 100644 index 00000000000..1b21f17f91b --- /dev/null +++ b/tests/integration/tests_playwright/test_ui_parity.py @@ -0,0 +1,393 @@ +"""The rx.ui parity harness: the look and the behaviour of every component. + +One production build of the generated app serves every test. A matrix test +compares the pixels, computed styles and accessibility tree of a component with +its Radix counterpart, and a contract test runs one step of a behaviour +contract against one of the two systems. Both run in whichever engines +``--browser`` names; ``scripts/ui_parity.py`` builds the command. +""" + +import json +import os +import time +from collections.abc import Generator +from pathlib import Path + +import pytest +from playwright.sync_api import Browser, Page + +from reflex.testing import AppHarness, AppHarnessProd + +# The steps of a contract are plain asserts: have them explain themselves. +pytest.register_assert_rewrite("ui_parity") + +from ui_parity import allowlist, report # noqa: E402 +from ui_parity.app import contract_route, parity_route # noqa: E402 +from ui_parity.components import CONTRACTS, MATRICES # noqa: E402 +from ui_parity.contract import HYDRATED, ContractError, Step, run_step # noqa: E402 +from ui_parity.hydration import ATTRIBUTE # noqa: E402 +from ui_parity.look import ( # noqa: E402 + READ_SCRIPT, + READY_SCRIPT, + StyleDifference, + run_matrix, +) +from ui_parity.systems import CANDIDATE, REFERENCE, SYSTEMS # noqa: E402 + +# Where the report of a run goes, unless UI_PARITY_REPORT names a directory. +DEFAULT_REPORT = Path(allowlist.ALLOWLIST).parent / "report" +# How long the build and every matrix may take together, in seconds. +BUDGET = float(os.environ.get("UI_PARITY_BUDGET_SECONDS", "900")) +TIMINGS = "timings.json" + +# What the runs of this module took: the build, then each matrix by engine and +# component. +_seconds: dict[str, float] = {} + + +def UIParityApp(): + """The generated app: a page per matrix and two per contract.""" + from ui_parity.app import create_app + + import reflex as rx + + app = create_app() # noqa: F841 + + config = rx.config.get_config() + config.plugins = [rx.plugins.UIPlugin(), rx.plugins.TailwindV4Plugin()] + # The badge floats over the page, and over whatever cell lies under it. + config.show_built_with_reflex = False + + +@pytest.fixture(scope="module") +def parity_app( + tmp_path_factory: pytest.TempPathFactory, +) -> Generator[AppHarness, None, None]: + """Build the generated app for production and serve it. + + Args: + tmp_path_factory: pytest fixture for creating temporary directories. + + Yields: + The running harness. + """ + started = time.perf_counter() + with AppHarnessProd.create( + root=tmp_path_factory.mktemp("ui_parity_app"), + app_name="ui_parity_app", + app_source=UIParityApp, + ) as harness: + assert harness.frontend_url is not None, "app is not running" + _seconds["build"] = time.perf_counter() - started + yield harness + + +@pytest.fixture(scope="module") +def report_dir() -> Path: + """Start a report: forget the results of the run before. + + The images stay, and are replaced as their cells run again: the directory + is one a developer named, and may hold more than the report. + + Returns: + The directory the report is written to. + """ + directory = Path(os.environ.get("UI_PARITY_REPORT", DEFAULT_REPORT)).resolve() + directory.mkdir(parents=True, exist_ok=True) + for name in (report.RESULTS, report.INDEX, TIMINGS): + (directory / name).unlink(missing_ok=True) + return directory + + +def _url(harness: AppHarness, route: str) -> str: + """Get the address of a page of the app. + + Args: + harness: The running harness. + route: The route of the page. + + Returns: + The address a production build serves the page at. + """ + assert harness.frontend_url is not None + return harness.frontend_url.rstrip("/") + route + "/" + + +@pytest.mark.parametrize("component", MATRICES) +def test_matrix( + parity_app: AppHarness, browser: Browser, report_dir: Path, component: str +): + """Every cell of a component looks like the Radix component.""" + result = run_matrix( + browser, + _url(parity_app, parity_route(component)), + MATRICES[component], + report_dir, + allowlist.load(), + scale=int(os.environ.get("UI_PARITY_SCALE", "1")), + ) + index = report.write(report_dir, result) + _seconds[f"{result.engine}/{component}"] = result.seconds + failures = result.failures(report_dir) + assert not failures, "\n".join([*failures, f"report: {index}"]) + + +def _pad_candidate(page: Page) -> None: + """Give every rx.ui element of a parity page a padding of its own. + + Args: + page: The loaded page. + """ + page.add_style_tag( + content='[data-parity-system="candidate"] > * { padding: 3px !important }' + ) + + +def test_changed_padding_fails_the_matrix( + parity_app: AppHarness, browser: Browser, tmp_path: Path +): + """A box padded differently from the Radix one fails, with the numbers.""" + result = run_matrix( + browser, + _url(parity_app, parity_route("box")), + MATRICES["box"], + tmp_path, + allowlist.Allowlist(), + prepare=_pad_candidate, + ) + base = result.cells[0] + assert base.cell == "base" + assert base.styles == [ + StyleDifference("", "height", "24px", "30px"), + *( + StyleDifference("", f"padding-{side}", "0px", "3px") + for side in ("top", "right", "bottom", "left") + ), + ] + assert base.a11y is None + # The text moved by three pixels each way: its old and its new place differ. + assert base.differing > 0 + assert base.ratio > base.tolerance + assert base.problems[0] == ( + f"{base.differing} of {base.width * base.height} pixels differ " + f"({base.ratio:.2%}, 0.00% allowed)" + ) + # Every cell fails, each naming itself and its three images. + failures = result.failures(tmp_path) + assert [failure.splitlines()[0] for failure in failures] == [ + f"box [{result.engine}] cell {cell.cell}:" for cell in result.cells + ] + directory = tmp_path / result.engine / "box" + assert failures[0].splitlines()[-1] == ( + f" images: {directory}/base.{{reference,candidate,diff}}.png" + ) + assert sorted(path.name for path in directory.iterdir()) == sorted( + f"{cell.cell}.{kind}.png" + for cell in result.cells + for kind in ("reference", "candidate", "diff") + ) + + +def _name_candidate(page: Page) -> None: + """Give every rx.ui element of a parity page a role the Radix one lacks. + + Args: + page: The loaded page. + """ + page.evaluate( + """() => { + for (const element of document.querySelectorAll( + '[data-parity-system="candidate"] > *', + )) { + element.setAttribute("role", "note"); + } + }""" + ) + + +def test_changed_role_fails_the_matrix( + parity_app: AppHarness, browser: Browser, tmp_path: Path +): + """A box the accessibility tree describes differently fails, once per element.""" + result = run_matrix( + browser, + _url(parity_app, parity_route("box")), + MATRICES["box"], + tmp_path, + allowlist.Allowlist(), + prepare=_name_candidate, + ) + trees = ("The quick brown fox", "- note: The quick brown fox") + assert {cell.cell: cell.a11y for cell in result.cells} == { + "base": trees, + "style-padding": trees, + "style-border": trees, + "custom-attrs-focusable": trees, + # The same elements as above, in another environment. + "base@dark": None, + "base@hover": None, + "base@520": None, + "custom-attrs-focusable@focus-visible": None, + } + assert result.cells[0].problems == [ + ( + "accessibility tree: rx 'The quick brown fox', " + "rx.ui '- note: The quick brown fox'" + ) + ] + + +# A reference frame as React leaves it while it still renders the hydration: +# the frame has its fiber, and the style tag Emotion prerendered beside the +# Radix box has not moved to the head yet. +RENDERING = """ + + +
+ +
box
+
+ + + +""" + + +def test_page_is_read_only_once_hydration_committed(page: Page): + """A fiber on a frame is not hydration, and a style tag is not the component.""" + page.set_content(RENDERING) + assert page.evaluate(READY_SCRIPT, "light") is False + # What the read would measure all the same: the box, never the style tag. + request = { + "properties": ["display", "padding-top"], + "targets": {"reference": None, "candidate": None}, + "parts": {}, + "only": None, + "matches": None, + "first": ":scope > :not(style):not(script):not(link):not(template)", + } + assert page.evaluate(READ_SCRIPT, request) == [ + { + "id": "style-padding", + "system": "reference", + "stage": [0, 0, 1280, 44], + # The content box and its padding of 12 pixels a side. + "target": [0, 0, 64, 44], + "styles": {"": {"display": "block", "padding-top": "12px"}}, + "missing": [], + "matched": True, + "view": [0, 0, 1280, 720], + } + ] + # An effect of the first render runs after the commit, and flags the page. + page.evaluate(f'() => document.documentElement.setAttribute("{ATTRIBUTE}", "")') + assert page.evaluate(READY_SCRIPT, "light") is True + # In the wrong color scheme the page is still not the one to read. + assert page.evaluate(READY_SCRIPT, "dark") is False + + +CONTRACT_STEPS = [ + pytest.param(component, system, step, id=f"{component}-{system.name}-{step.name}") + for component, contract in CONTRACTS.items() + for system in SYSTEMS + for step in contract.steps +] + + +@pytest.mark.parametrize(("component", "system", "step"), CONTRACT_STEPS) +def test_contract(parity_app: AppHarness, browser: Browser, component, system, step): + """A step of a component's contract passes, or is listed as a difference.""" + run_step( + browser, + _url(parity_app, contract_route(component, system)), + CONTRACTS[component], + system, + step, + allowlist.load(), + ) + + +def _fail(run) -> None: + """Fail a step: the box is not what the step says it is. + + Args: + run: The run of the step. + """ + assert run.page.locator("#box").inner_text() == "something else" + + +def test_contract_failure_names_what_failed(parity_app: AppHarness, browser: Browser): + """A failing step names the component, the system, the engine and itself.""" + engine = browser.browser_type.name + contract = CONTRACTS["box"] + url = _url(parity_app, contract_route("box", CANDIDATE)) + step = Step("says something else", _fail, on=HYDRATED) + with pytest.raises(ContractError) as failure: + run_step(browser, url, contract, CANDIDATE, step, allowlist.Allowlist()) + assert str(failure.value) == ( + f'box [rx.ui, {engine}] step "says something else" failed: ' + "AssertionError: assert 'content' == 'something else'\n" + " \n - something else\n + content" + ) + + # Listed as a difference of rx.ui in this engine, the failure passes, and + # the same step of the Radix component is not excused by it. + entry = allowlist.ContractEntry( + component="box", + step="says something else", + system=CANDIDATE.name, + engines=(engine,), + reason="The box says what it was given.", + ) + listed = allowlist.Allowlist(contract=(entry,)) + run_step(browser, url, contract, CANDIDATE, step, listed) + with pytest.raises(ContractError): + run_step( + browser, + _url(parity_app, contract_route("box", REFERENCE)), + contract, + REFERENCE, + step, + listed, + ) + + # A listed difference that is none any more fails until it is removed. + stale = allowlist.Allowlist( + contract=( + allowlist.ContractEntry( + component="box", + step=contract.steps[0].name, + system=CANDIDATE.name, + engines=(), + reason="It used to warn.", + ), + ) + ) + with pytest.raises(ContractError) as failure: + run_step(browser, url, contract, CANDIDATE, contract.steps[0], stale) + assert str(failure.value) == ( + f'box [rx.ui, {engine}] step "hydrates with no warnings" passes, but ' + 'allowlist.toml says it does not ("It used to warn."). Remove the entry.' + ) + + +def test_run_time_is_within_budget(report_dir: Path): + """The build and the matrices of the run fit the budget, and are recorded.""" + total = sum(_seconds.values()) + (report_dir / TIMINGS).write_text( + json.dumps( + { + "budget": BUDGET, + "total": round(total, 3), + "seconds": {name: round(value, 3) for name, value in _seconds.items()}, + }, + indent=2, + ) + + "\n" + ) + assert total <= BUDGET, ( + f"The parity run took {total:.0f} s, over its budget of {BUDGET:.0f} s: " + f"{_seconds}. Cross fewer dimensions and sweep the rest." + ) diff --git a/tests/integration/utils.py b/tests/integration/utils.py index b4db8a96ce0..8c7871486c6 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -3,14 +3,14 @@ from __future__ import annotations from collections import Counter -from collections.abc import Generator, Sequence +from collections.abc import Generator, Mapping, Sequence from contextlib import contextmanager from http.client import HTTPConnection from urllib.parse import urlsplit -from playwright.sync_api import Page, expect +from playwright.sync_api import Page, Response, expect -from reflex.testing import DEFAULT_TIMEOUT +from reflex.testing import DEFAULT_TIMEOUT, AppHarness # JavaScript for the client token of a tab. The frontend keeps it in # sessionStorage under a key that is scoped to the backend URL. @@ -219,3 +219,62 @@ def poll_assert_relative_event_order( assert_relative_event_order( events.all_text_contents(), expected_counts, ordering_rules ) + + +# Text only the named library puts in a script: the path socket.io connects to, +# an option of the cookie library, and the attribute the toaster marks toasts with. +LIBRARY_MARKERS = { + "socket.io": "socket.io", + "universal-cookie": "doNotParse", + "sonner": "data-sonner-toast", +} + + +def libraries_in_scripts(scripts: Mapping[str, str]) -> dict[str, bool]: + """Find which libraries of the state runtime and the toaster scripts hold. + + Args: + scripts: The source of each script, by its name or URL. + + Returns: + For each library in ``LIBRARY_MARKERS``, whether any script contains it. + """ + return { + library: any(marker in body for body in scripts.values()) + for library, marker in LIBRARY_MARKERS.items() + } + + +def record_scripts(page: Page) -> dict[str, str]: + """Record the source of every script a page loads from now on. + + Args: + page: Playwright page. + + Returns: + A dict filled, as the page loads them, with the source of each script + by URL. + """ + scripts: dict[str, str] = {} + + def record(response: Response) -> None: + if response.request.resource_type == "script" and response.ok: + scripts[response.url] = response.text() + + page.on("response", record) + return scripts + + +def built_scripts(harness: AppHarness) -> dict[str, str]: + """Read every script of an app's production build. + + Args: + harness: The harness of an app that was exported. + + Returns: + The source of each script of the client build, by file name. + """ + return { + script.name: script.read_text() + for script in (harness.app_path / ".web" / "build" / "client").rglob("*.js") + } diff --git a/tests/units/compiler/state_js.test.mjs b/tests/units/compiler/state_js.test.mjs index 2b4fdd40757..f795c0ddcc9 100644 --- a/tests/units/compiler/state_js.test.mjs +++ b/tests/units/compiler/state_js.test.mjs @@ -3,13 +3,18 @@ import { readFile } from "node:fs/promises"; import test from "node:test"; import vm from "node:vm"; -const source = await readFile( - new URL( - "../../../packages/reflex-frontend/src/utils/state.js", - import.meta.url, - ), - "utf8", -); +// The modules under test: an app with state loads the connection in +// utils/socket.js, which reaches the event queue in utils/state.js. +const sources = {}; +for (const name of ["state", "event_loop", "socket"]) { + sources[`$/utils/${name}`] = await readFile( + new URL( + `../../../packages/reflex-frontend/src/utils/${name}.js`, + import.meta.url, + ), + "utf8", + ); +} const tokenKey = "reflex:ws://localhost:8000/_event:token"; /** Evaluate the actual frontend module with controlled transport and browser APIs. */ @@ -239,19 +244,26 @@ async function setup({ "$/utils/helpers/throttle": { default() {} }, "$/utils/helpers/upload": { uploadFiles() {} }, }; - const module = new vm.SourceTextModule(source, { - context, - initializeImportMeta(meta) { - meta.hot = { - dispose(fn) { - dispose = fn; + const modules = Object.fromEntries( + Object.entries(sources).map(([name, source]) => [ + name, + new vm.SourceTextModule(source, { + context, + initializeImportMeta(meta) { + meta.hot = { + dispose(fn) { + dispose = fn; + }, + }; }, - }; - }, - }); - await module.link((name) => { - // state.js imports itself to hand its exports to server-provided scripts. - if (name === "$/utils/state") return module; + }), + ]), + ); + // What compiled code imports; its calls reach the connection once loaded. + const module = modules["$/utils/state"]; + const connection = modules["$/utils/socket"]; + await connection.link((name) => { + if (modules[name]) return modules[name]; assert.ok(imports[name], `unexpected import: ${name}`); return new vm.SyntheticModule( Object.keys(imports[name]), @@ -262,7 +274,7 @@ async function setup({ { context }, ); }); - await module.evaluate(); + await connection.evaluate(); const socket = { current: null }; return { sockets, diff --git a/tests/units/compiler/test_compiler.py b/tests/units/compiler/test_compiler.py index 0f42e0ea870..323413db3a0 100644 --- a/tests/units/compiler/test_compiler.py +++ b/tests/units/compiler/test_compiler.py @@ -6,12 +6,18 @@ import shutil import sys from pathlib import Path, PureWindowsPath +from typing import Any import pytest from pytest_mock import MockerFixture from reflex_base import constants +from reflex_base.components.app_wraps import collect_subtree_app_wraps from reflex_base.components.component import BaseComponent, Component -from reflex_base.components.dynamic import bundle_library, reset_bundled_libraries +from reflex_base.components.dynamic import ( + _bundle_library, + bundle_library, + reset_bundled_libraries, +) from reflex_base.components.memo import MEMOS from reflex_base.constants.base import LiteralColorMode from reflex_base.constants.compiler import PageNames @@ -19,6 +25,7 @@ from reflex_base.plugins import CompileContext, CompilerHooks, PageContext from reflex_base.plugins.sitemap import SitemapPlugin from reflex_base.registry import RegistrationContext +from reflex_base.utils import memo_paths from reflex_base.utils.console import PoorProgress from reflex_base.utils.exceptions import ( DynamicRouteArgShadowsStateVarError, @@ -34,10 +41,12 @@ from reflex_components_core.el.elements.other import Html import reflex as rx +from reflex.app import default_backend_exception_handler from reflex.compiler import compiler, utils from reflex.compiler.plugins import default_page_plugins from reflex.state import BaseState from reflex.utils import prerequisites +from reflex.utils.misc import preload_color_theme @pytest.mark.parametrize("with_plugin", [False, True]) @@ -627,8 +636,10 @@ def index(): assert all("d3-format" in libraries for libraries in seen) assert "d3-format" in context.bundled_libraries _, code = compiler.compile_app_root(rx.el.div()) - assert 'import * as d3_format from "d3-format";' in code - assert '"d3-format": d3_format' in code + assert ( + ' "d3-format": () => import("$/utils/dynamic_libraries/d3_format")' + ".then((module) => module.default)," + ) in code.splitlines() assert "compile-only-library" in context.bundled_libraries assert "@radix-ui/themes" in context.bundled_libraries @@ -704,8 +715,14 @@ def test_compile_app_root_uses_unique_window_library_aliases( _, code = compiler.compile_app_root(rx.el.div("hello")) if lazy: - assert '"foo.bar": () => import("foo.bar")' in code - assert '"foo/bar.mjs": () => import("foo/bar.mjs")' in code + loader = ( + ' "{}": () => import("$/utils/dynamic_libraries/{}")' + ".then((module) => module.default)," + ) + lines = code.splitlines() + assert loader.format("foo.bar", "foo_bar") in lines + assert loader.format("foo_bar", "foo_bar_2") in lines + assert loader.format("foo/bar.mjs", "foo_bar_mjs") in lines else: assert 'import * as foo_bar from "foo.bar";' in code assert 'import * as foo_bar_2 from "foo_bar";' in code @@ -737,7 +754,9 @@ def test_compile_app_root_includes_radix_window_library_when_bundled(mocker): """Bundled Radix libraries should be exposed to window.__reflex.""" mocker.patch( "reflex.compiler.compiler.get_config", - return_value=rx.Config(app_name="eager_libraries"), + return_value=rx.Config( + app_name="eager_libraries", frontend_lazy_bundled_libraries=False + ), ) reset_bundled_libraries() try: @@ -751,25 +770,272 @@ def test_compile_app_root_includes_radix_window_library_when_bundled(mocker): reset_bundled_libraries() -def test_compile_app_root_can_defer_optional_window_libraries(mocker): - """Dynamic libraries need not force their entire exports into every page.""" +_APP_ROOT_HEAD = """ +import {jsx} from "@emotion/react" +import {Fragment,useEffect} from "react" + +import { defaultColorMode } from "$/utils/context"; +import { ThemeProvider } from '$/utils/react-theme'; +import { Layout as AppLayout } from './_document'; +import { Outlet } from 'react-router'; +import * as React from "react"; +import * as emotion_react from "@emotion/react"; +import * as utils_context from "$/utils/context"; +import * as utils_context_registry from "$/utils/context-registry"; +import * as utils_state from "$/utils/state"; +""" + +_APP_ROOT_TAIL = """ + return jsx(ThemeProvider, {defaultTheme: defaultColorMode, attribute: "class"}, + jsx(AppWrap, {}, children) + ); +} + + +function AppWrap({children}) { + +return (jsx("div",{},"hello")) +} + +export function Layout({children}) { + return jsx(AppLayout, {}, jsx(ReflexProviders, {}, children)); +} + +// Used by entry.client.js when mount_target is configured: skips the document +// shell (which renders react-router's // and requires a +// framework router context) but keeps the runtime providers. +export function EmbedLayout({children}) { + return jsx(ReflexProviders, {}, children); +} + +export default function App() { + return jsx(Outlet, {}); +} + +""" + +_APP_ROOT_WITHOUT_LOADERS = ( + _APP_ROOT_HEAD + + """ + + + +function ReflexProviders({children}) { + useEffect(() => { + // Make contexts and state objects available globally for dynamic eval'd components + window.__reflex = { + "react": React, + "@emotion/react": emotion_react, + "$/utils/context": utils_context, + "$/utils/context-registry": utils_context_registry, + "$/utils/state": utils_state, + }; + }, []); +""" + + _APP_ROOT_TAIL +) + + +def _app_root_with_loaders(*loaders: str) -> str: + """Build the root.jsx that loads optional libraries on demand. + + Args: + *loaders: The loader entry of each optional library, in order. + + Returns: + The complete expected module. + """ + return ( + _APP_ROOT_HEAD + + """ +if (typeof window !== "undefined") { + window.__reflex = { ...window.__reflex, + "react": React, + "@emotion/react": emotion_react, + "$/utils/context": utils_context, + "$/utils/context-registry": utils_context_registry, + "$/utils/state": utils_state, + }; + const loaders = { +""" + + "".join(f" {loader}\n" for loader in loaders) + + """ }; + const pending = Object.create(null); + window.__reflex_load = (libraries = Object.keys(loaders)) => { + return Promise.all(libraries.filter((name) => Object.hasOwn(loaders, name) && !Object.hasOwn(window.__reflex, name)).map((name) => { + if (!pending[name]) { + pending[name] = loaders[name]().then((module) => { + window.__reflex[name] = module; + }).catch((error) => { + delete pending[name]; + throw error; + }); + } + return pending[name]; + })); + }; +} + + + + +function ReflexProviders({children}) { + \n""" + + _APP_ROOT_TAIL + ) + + +_RADIX_LOADER = '"@radix-ui/themes": () => import("$/utils/dynamic_libraries/radix_ui_themes").then((module) => module.default),' +_D3_LOADER = '"d3-format": () => import("$/utils/dynamic_libraries/d3_format").then((module) => module.default),' +_RADIX_MODULE = ( + "radix_ui_themes.js", + 'import * as library from "@radix-ui/themes";\nexport default library;\n', +) +_D3_MODULE = ( + "d3_format.js", + 'import * as library from "d3-format";\nexport default library;\n', +) + + +@pytest.mark.parametrize( + ("app_libraries", "dynamic_components", "expected_root", "expected_modules"), + [ + pytest.param( + (), + True, + _app_root_with_loaders(_RADIX_LOADER), + [_RADIX_MODULE], + id="dynamic_components", + ), + pytest.param( + (), False, _APP_ROOT_WITHOUT_LOADERS, [], id="no_dynamic_components" + ), + pytest.param( + ("d3-format@3.1.0",), + True, + _app_root_with_loaders(_RADIX_LOADER, _D3_LOADER), + [_RADIX_MODULE, _D3_MODULE], + id="dynamic_components_and_app_library", + ), + pytest.param( + ("d3-format@3.1.0",), + False, + _app_root_with_loaders(_D3_LOADER), + [_D3_MODULE], + id="app_library_only", + ), + ], +) +def test_compile_app_root_loads_optional_libraries_on_demand( + app_libraries: tuple[str, ...], + dynamic_components: bool, + expected_root: str, + expected_modules: list[tuple[str, str]], + mocker: MockerFixture, +): + """Keep optional library namespaces out of root.jsx, in modules of their own. + + A library the compiler registered is only loadable when the app renders a + dynamic component, a library the app registered is always loadable. + + Args: + app_libraries: The libraries the app registers with bundle_library. + dynamic_components: Whether the app renders a dynamic component. + expected_root: The complete expected root.jsx. + expected_modules: The expected file name and code of each library module. + mocker: Fixture for configuring the app. + """ mocker.patch( - "reflex.compiler.compiler.get_config", + "reflex_base.config._get_config", + return_value=rx.Config(app_name="lazy_libraries"), + ) + with RegistrationContext(): + _bundle_library("@radix-ui/themes") + for library in app_libraries: + bundle_library(library) + root_path, code = compiler.compile_app_root( + rx.el.div("hello"), dynamic_components=dynamic_components + ) + modules = compiler.compile_dynamic_libraries( + dynamic_components=dynamic_components + ) + + assert root_path == str(prerequisites.get_web_dir() / "app" / "root.jsx") + assert code == expected_root + assert modules == [ + ( + str(prerequisites.get_web_dir() / "utils" / "dynamic_libraries" / name), + module_code, + ) + for name, module_code in expected_modules + ] + + +def test_compile_dynamic_libraries_is_empty_for_eager_libraries(mocker: MockerFixture): + """Write no library modules when root.jsx imports the namespaces itself. + + Args: + mocker: Fixture for configuring the app. + """ + mocker.patch( + "reflex_base.config._get_config", return_value=rx.Config( - app_name="lazy_libraries", frontend_lazy_bundled_libraries=True + app_name="eager_libraries", frontend_lazy_bundled_libraries=False ), ) with RegistrationContext(): - bundle_library("@radix-ui/themes@3.3.0") - bundle_library("constructor") - _, code = compiler.compile_app_root(rx.el.div("hello")) + bundle_library("d3-format@3.1.0") + assert compiler.compile_dynamic_libraries() == [] + + +@pytest.mark.parametrize("dynamic", [False, True]) +def test_compile_detects_dynamic_components( + dynamic: bool, + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + mocker: MockerFixture, +): + """Tell the app root whether any page renders a dynamic component. + + Args: + dynamic: Whether the page renders a component held in state. + tmp_path: Directory for compiler output. + monkeypatch: Fixture for changing the app directory. + mocker: Fixture for configuring the test app. + """ + monkeypatch.chdir(tmp_path) + with RegistrationContext(): + mocker.patch( + "reflex_base.config._get_config", + return_value=rx.Config(app_name="dynamic_detection", plugins=[]), + ) + + class DynamicDetectionState(rx.State): + """A state holding a component and a plain value.""" - assert 'import * as radix_ui_themes from "@radix-ui/themes"' not in code - assert '() => import("@radix-ui/themes")' in code - assert '"constructor": () => import("constructor")' in code - assert 'import * as React from "react"' in code - assert 'import * as utils_context from "$/utils/context"' in code - assert "window.__reflex_load" in code + component: rx.Component = rx.el.div("dynamic") + text: str = "static" + + def index() -> rx.Component: + """Render the component or the plain value from state. + + Returns: + The page. + """ + return rx.el.div( + DynamicDetectionState.component + if dynamic + else DynamicDetectionState.text + ) + + app = rx.App() + app.add_page(index) + compile_root = mocker.spy(compiler, "compile_app_root") + compile_libraries = mocker.spy(compiler, "compile_dynamic_libraries") + compiler.compile_app(app, dry_run=True, use_rich=False) + + assert compile_root.call_args.kwargs == {"dynamic_components": dynamic} + assert compile_libraries.call_args == mocker.call(dynamic_components=dynamic) def _mock_config_color_mode(mocker: MockerFixture, mode: LiteralColorMode) -> None: @@ -893,6 +1159,40 @@ def test_compile_document_root_bakes_default_color_mode(mocker: MockerFixture): assert "|| 'dark'" in code +def test_compile_document_root_prod( + mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch +): + """A production document preloads its stylesheet and no script of its own. + + Its scripts are the Reflex wrapper of react-router's, which starts them + after the first paint on a prerendered page. + """ + monkeypatch.setenv("REFLEX_ENV_MODE", constants.Env.PROD.value) + mocker.patch( + "reflex.compiler.compiler.get_web_dir", + return_value=Path("/tmp/does_not_matter"), + ) + + path, code = compiler.compile_document_root([], default_color_mode="system") + + theme_script = preload_color_theme("system").render()["children"][0]["contents"] + assert path == str(Path("/tmp/does_not_matter/app/_document.js")) + assert ( + code + == f"""import {{Links,Meta,ScrollRestoration}} from "react-router" +import reflexGlobalStyles from "$/styles/__reflex_global_styles.css?url" +import {{Scripts}} from "$/utils/scripts" +import {{jsx}} from "@emotion/react" +import {{Fragment,useEffect}} from "react" + +export function Layout({{children}}) {{ + return ( + jsx("html",{{lang:"en"}},jsx("head",{{}},jsx("script",{{}},{theme_script}),jsx("meta",{{charSet:"utf-8"}},),jsx("meta",{{content:"width=device-width, initial-scale=1",name:"viewport"}},),jsx(Meta,{{}},),jsx("link",{{as:"style",href:reflexGlobalStyles,rel:"preload"}},),jsx("link",{{href:reflexGlobalStyles,rel:"stylesheet",type:"text/css"}},),jsx(Links,{{}},)),jsx("body",{{}},children,jsx(ScrollRestoration,{{}},),jsx(Scripts,{{}},))) + ) +}}""" + ) + + def test_compile_nonexistent_stylesheet(tmp_path, mocker: MockerFixture): """Test that an error is thrown for non-existent stylesheets. @@ -2402,3 +2702,310 @@ def page() -> Component: assert any("const refs = {};" in code for _, code in memo_files) for code in modules: assert not _IMPORTS_REFS.search(code), code + + +def _notify(message: str) -> rx.event.EventSpec: + """Send a toast, as a helper an event handler calls. + + Args: + message: The text of the toast. + + Returns: + The toast event. + """ + return rx.toast.info(message) + + +def _log(message: str) -> None: + """Do something other than sending a toast. + + Args: + message: The text to print. + """ + print(message) + + +class _Notifier: + """A class whose method sends a toast.""" + + @staticmethod + def warn(message: str) -> rx.event.EventSpec: + """Send a warning toast. + + Args: + message: The text of the toast. + + Returns: + The toast event. + """ + return rx.toast.warning(message) + + +def _closing_over(send: Any) -> Any: + """Build a function that reaches ``send`` through its closure only. + + Args: + send: The function to close over. + + Returns: + A function calling ``send``. + """ + + def inner() -> Any: + return send("closed over") + + return inner + + +_send_error = rx.toast.error +_notifier = _Notifier() +_this_module = sys.modules[__name__] +_closes_over_a_toast = _closing_over(rx.toast.success) +_closes_over_print = _closing_over(print) + + +@pytest.mark.parametrize( + ("root", "expected"), + [ + (lambda: rx.toast("direct"), True), + (lambda: rx.toast.error("a level"), True), + (lambda: [(lambda text: rx.toast(text))(text) for text in "ab"], True), + (lambda: _send_error("an alias of a toast function"), True), + (lambda: _notify("a helper function"), True), + (lambda: _Notifier.warn("a helper class"), True), + (lambda: _notifier.warn("an instance of a helper class"), True), + (lambda: _this_module._notify("a helper reached through its module"), True), + (_closes_over_a_toast, True), + (_Notifier, True), + (staticmethod(_notify), True), + (rx.event.EventHandler(fn=_notify), True), + (lambda: _log("no toast"), False), + (lambda: rx.redirect("/elsewhere"), False), + (lambda: json.dumps({"module": "of the standard library"}), False), + (lambda: pytest.fail("an installed distribution is not followed"), False), + (_closes_over_print, False), + (dataclasses.dataclass, False), + ("not code", False), + ], +) +def test_references_toast(root: Any, expected: bool): + """A toast is found through the names code refers to, in the app's modules. + + Args: + root: The function, handler or class to start from. + expected: Whether it reaches ``rx.toast``. + """ + assert compiler._references_toast([root]) is expected + + +@pytest.mark.parametrize( + ("name", "expected"), + [ + (__name__, True), + ("json", False), + ("reflex.app", False), + ("reflex_base.event", False), + ("reflex_components_sonner.toast", False), + ("pytest", False), + ("a_module_nothing_imported", False), + ], +) +def test_is_app_module(name: str, expected: bool): + """The app's modules are what is neither Reflex, standard nor installed. + + Args: + name: The dotted name of a module. + expected: Whether it is the app's own code. + """ + assert compiler._is_app_module(name) is expected + + +def _toast_wrap(app: rx.App, page: Component | None = None) -> str | None: + """Resolve what an app puts in its app wrap to show toasts. + + Args: + app: The app to resolve the app wraps of. + page: A page of the app, or None for an app with no toast call in a page. + + Returns: + "toaster" for the toaster, "plain" for plain notices, None for neither. + """ + wraps = compiler._resolve_app_wrap_components( + app, collect_subtree_app_wraps(page) if page is not None else {} + ) + wrap = wraps.get((44, "ToasterProvider")) + if wrap is None: + return None + if isinstance(wrap, compiler._PlainToast): + return "plain" + assert [child.tag for child in wrap.children if isinstance(child, Component)] == [ + memo_paths.mirrored_symbol("MemoizedToastProvider", compiler.__name__) + ] + return "toaster" + + +def _toast_button() -> Component: + """Build a page that sends a toast from the frontend. + + Returns: + A button whose click sends a toast. + """ + return rx.el.button("Notify", on_click=rx.toast("Hello")) + + +@pytest.mark.usefixtures("clean_registration_context") +def test_toaster_of_an_app_without_state(mocker: MockerFixture): + """Without state, only a toast call in the frontend can send a toast.""" + mocker.patch( + "reflex_base.config._get_config", return_value=rx.Config(app_name="testing") + ) + app = rx.App(enable_state=False) + + assert _toast_wrap(app) is None + assert _toast_wrap(app, rx.el.div("Static")) is None + assert _toast_wrap(app, _toast_button()) == "toaster" + + app.extra_app_wraps[1, "Notify"] = lambda _stateful: _toast_button() + assert _toast_wrap(app) == "toaster" + del app.extra_app_wraps[1, "Notify"] + + app.add_page(lambda: rx.el.div("Static"), route="/", on_load=rx.toast("Hi")) + assert _toast_wrap(app) == "toaster" + app._load_events["index"] = [lambda: _notify("From a function")] + assert _toast_wrap(app) == "toaster" + app._load_events["index"] = [lambda: rx.redirect("/elsewhere")] + assert _toast_wrap(app) is None + app._load_events.clear() + + app.toaster = rx.toast.provider() + assert _toast_wrap(app) == "toaster" + + app.toaster = None + assert _toast_wrap(app) is None + assert _toast_wrap(app, _toast_button()) is None + + +@pytest.mark.usefixtures("clean_registration_context") +def test_toaster_of_an_app_whose_handlers_send_no_toast(mocker: MockerFixture): + """With state and no toast found, toasts and connection errors show plainly.""" + mocker.patch( + "reflex_base.config._get_config", return_value=rx.Config(app_name="testing") + ) + + class QuietState(rx.State): + """A state whose handlers send no toast.""" + + count: int = 0 + + @rx.event + def increment(self): + """Count up, then go elsewhere. + + Returns: + The redirect event. + """ + self.count += 1 + return rx.redirect("/elsewhere") + + app = rx.App() + + assert _toast_wrap(app) == "plain" + assert _toast_wrap(app, rx.el.div(QuietState.count)) == "plain" + assert _toast_wrap(app, _toast_button()) == "toaster" + + app.backend_exception_handler = lambda exception: _notify(str(exception)) + assert _toast_wrap(app) == "toaster" + app.backend_exception_handler = default_backend_exception_handler + + app.toaster = rx.toast.provider() + assert _toast_wrap(app) == "toaster" + + app.toaster = None + assert _toast_wrap(app) is None + + +@pytest.mark.parametrize("where", ["handler", "helper", "mixin", "substate"]) +@pytest.mark.usefixtures("clean_registration_context") +def test_toaster_of_an_app_whose_backend_sends_a_toast( + where: str, mocker: MockerFixture +): + """A toast an event handler can send bundles the toaster. + + Args: + where: The code of the state tree that refers to the toast. + mocker: Fixture for configuring the test app. + """ + mocker.patch( + "reflex_base.config._get_config", return_value=rx.Config(app_name="testing") + ) + + if where == "handler": + + class HandlerState(rx.State): + """A state whose handler sends a toast.""" + + @rx.event + def notify(self): + """Send a toast. + + Returns: + The toast event. + """ + return rx.toast("From the handler") + + elif where == "helper": + + class HelperState(rx.State): + """A state whose handler sends a toast through a method.""" + + @rx.event + def notify(self): + """Send what the helper method builds. + + Returns: + The toast event. + """ + return self._build() + + def _build(self): + return _notify("From a helper") + + elif where == "mixin": + + class Mixin(rx.State, mixin=True): + """A mixin whose handler sends a toast.""" + + @rx.event + def notify(self): + """Send a toast. + + Returns: + The toast event. + """ + return rx.toast.success("From a mixin") + + class MixedState(Mixin, rx.State): + """A state that takes its handler from the mixin.""" + + else: + + class ParentState(rx.State): + """A state that sends no toast.""" + + @rx.event + def quiet(self): + """Do nothing.""" + + class ChildState(ParentState): + """A substate that sends a toast.""" + + @rx.event + def notify(self): + """Send a toast. + + Returns: + The toast event. + """ + return rx.toast("From a substate") + + assert _toast_wrap(rx.App()) == "toaster" diff --git a/tests/units/compiler/test_context_js_template.py b/tests/units/compiler/test_context_js_template.py index 2e1b6b82468..56dddd8536d 100644 --- a/tests/units/compiler/test_context_js_template.py +++ b/tests/units/compiler/test_context_js_template.py @@ -12,6 +12,13 @@ requires_node = pytest.mark.skipif(shutil.which("node") is None, reason="node missing") +# Stands in for the connection to the backend, which the context of an app +# with state imports. +_SOCKET_STUB = """ +export const hydrateClientStorage = () => ({}); +export const useEventLoop = () => []; +""" + # Stand-ins for the modules context.js imports, keyed by the specifier they # replace. Server tests fail if a client-only hook runs without a dispatcher. _STUB_MODULES = { @@ -46,10 +53,9 @@ "$/utils/state": """ export const applyDelta = () => {}; export const ReflexEvent = () => ({}); -export const hydrateClientStorage = () => ({}); -export const useEventLoop = () => []; export const refs = {}; """, + "$/utils/socket": _SOCKET_STUB, "$/utils/context-registry": """ export const ColorModeContext = {}; export const UploadFilesContext = {}; @@ -111,6 +117,47 @@ def _event_loop_provider_body() -> str: return rendered[start:end] +def _imports(rendered: str) -> list[str]: + """Get the import statements of a rendered context module. + + Args: + rendered: The source of the context module. + + Returns: + Its import statements, in order. + """ + return [line for line in rendered.splitlines() if line.startswith("import ")] + + +def test_stateful_context_imports_the_backend_connection() -> None: + """An app with state loads the socket and what syncs browser storage.""" + rendered = context_template( + is_dev_mode=False, + default_color_mode='"light"', + initial_state={"state": {}}, + state_name="state", + ) + assert _imports(rendered) == [ + 'import { useContext, useMemo, useState, createElement, useEffect } from "react"', + 'import { applyDelta, ReflexEvent, refs } from "$/utils/state"', + 'import { hydrateClientStorage, useEventLoop } from "$/utils/socket"', + 'import { ColorModeContext, UploadFilesContext, DispatchContext, EventLoopContext, StateStoreContext, registerApp, eventLoop } from "$/utils/context-registry"', + 'import { jsx } from "@emotion/react";', + ] + + +def test_stateless_context_does_not_import_the_backend_connection() -> None: + """An app without state bundles no socket: its context never names it.""" + rendered = context_template(is_dev_mode=False, default_color_mode='"light"') + assert _imports(rendered) == [ + 'import { useContext, useMemo, useState, createElement, useEffect } from "react"', + 'import { applyDelta, useEventLoop, refs } from "$/utils/state"', + 'import { ColorModeContext, UploadFilesContext, DispatchContext, EventLoopContext, StateStoreContext, registerApp, eventLoop } from "$/utils/context-registry"', + 'import { jsx } from "@emotion/react";', + ] + assert "utils/socket" not in rendered + + def test_event_loop_provider_memoizes_its_element() -> None: """``EventLoopProvider`` must return a memoized provider element. @@ -247,8 +294,6 @@ def test_client_state_store_notifies_only_substate_subscribers(tmp_path: Path): return out ?? state; }; export const ReflexEvent = () => ({}); -export const hydrateClientStorage = () => ({}); -export const useEventLoop = () => []; export const refs = {}; """ registry_path = Templates.Dirs.WEB_TEMPLATE / "utils" / "context-registry.js" @@ -258,6 +303,7 @@ def test_client_state_store_notifies_only_substate_subscribers(tmp_path: Path): for specifier, source in ( ("react", react_stub), ("$/utils/state", state_stub), + ("$/utils/socket", _SOCKET_STUB), ("$/utils/context-registry", registry_source), ("@emotion/react", "export const jsx = () => null;\n"), ): diff --git a/tests/units/compiler/test_dynamic_components_codegen.py b/tests/units/compiler/test_dynamic_components_codegen.py index f000349e225..618d8e2c1da 100644 --- a/tests/units/compiler/test_dynamic_components_codegen.py +++ b/tests/units/compiler/test_dynamic_components_codegen.py @@ -42,9 +42,10 @@ def test_dynamic_component_codegen_rewrites_bundled_library_subpath() -> None: "const {DynamicIcon} = window.__reflex['lucide-react/dynamic.mjs']" ) in dynamic_code assert ( - "import * as lucide_react_dist_esm_icons_apple_mjs " - 'from "lucide-react/dist/esm/icons/apple.mjs";' - ) in app_root_code + ' "lucide-react/dist/esm/icons/apple.mjs": () => ' + 'import("$/utils/dynamic_libraries/lucide_react_dist_esm_icons_apple_mjs")' + ".then((module) => module.default)," + ) in app_root_code.splitlines() def test_lazy_dynamic_component_lists_only_its_optional_libraries(mocker) -> None: @@ -70,7 +71,11 @@ def test_lazy_dynamic_component_lists_only_its_optional_libraries(mocker) -> Non ) assert default_only_code.split("\n", 1)[0] == "//__reflex_evaluate:[]" # The app can load the unused library, but the icon does not request it. - assert '"unused-library": () => import("unused-library")' in app_root_code + assert ( + ' "unused-library": () => ' + 'import("$/utils/dynamic_libraries/unused_library")' + ".then((module) => module.default)," + ) in app_root_code.splitlines() @pytest.mark.parametrize("reactive", [False, True]) @@ -113,8 +118,8 @@ class ComponentWithSlot(rx.Component): with context.fork(): _reset_bundled_libraries_for_compile() _, app_root_code = compiler.compile_app_root(rx.el.div()) - assert f'from "{subpath}";' in app_root_code - assert 'from "lucide-react";' not in app_root_code + assert f' "{subpath}": () => ' in app_root_code + assert ' "lucide-react": () => ' not in app_root_code assert RegistrationContext.get().bundled_libraries.count(subpath) == 1 code = serializers.serialize(prototype) assert isinstance(code, str) @@ -141,7 +146,7 @@ def test_explicit_subpath_registration_does_not_require_package_root(reactive: b _, app_root_code = compiler.compile_app_root(rx.el.div()) code = serializers.serialize(icon) assert "lucide-react" not in context.bundled_libraries - assert f'from "{subpath}";' in app_root_code + assert f' "{subpath}": () => ' in app_root_code assert isinstance(code, str) assert f"window.__reflex['{subpath}']" in code assert "cdn.jsdelivr.net/npm/lucide-react" not in code @@ -212,7 +217,7 @@ async def nested_components(self) -> list[rx.Component]: assert subpath in context.bundled_libraries assert f"window.__reflex['{subpath}'].default" in context_code assert ( - f'() => import("{subpath}")' if lazy else f'from "{subpath}";' + f' "{subpath}": () => ' if lazy else f'from "{subpath}";' ) in root_code assert subpath not in context._explicit_bundled_libraries assert any( @@ -326,8 +331,8 @@ def import_var(self) -> ImportVar: with context.fork() as forked: _reset_bundled_libraries_for_compile() _, app_root_code = compiler.compile_app_root(rx.el.div()) - assert f'from "{root}";' not in app_root_code - assert f'from "{subpath}";' in app_root_code + assert f' "{root}": () => ' not in app_root_code + assert f' "{subpath}": () => ' in app_root_code assert root not in forked.bundled_libraries code = serializers.serialize(component) assert root not in forked.bundled_libraries diff --git a/tests/units/compiler/test_state_js_template.py b/tests/units/compiler/test_state_js_template.py index 7a27a17b030..e33606a592d 100644 --- a/tests/units/compiler/test_state_js_template.py +++ b/tests/units/compiler/test_state_js_template.py @@ -9,6 +9,9 @@ from reflex_base.constants import Templates STATE_JS_TEMPLATE = Templates.Dirs.WEB_TEMPLATE / "utils" / "state.js" +# The connection to the backend, split from state.js so that an app without +# state does not bundle it. +SOCKET_JS_TEMPLATE = Templates.Dirs.WEB_TEMPLATE / "utils" / "socket.js" ADD_EVENTS_ALIAS = "const addEvents = (...args) => eventLoop.addEvents(...args);" @@ -65,7 +68,7 @@ def test_state_js_does_not_register_deprecated_unload_listener() -> None: (tab close, navigation, bfcache), so the deprecated listener must not be re-introduced. """ - content = STATE_JS_TEMPLATE.read_text() + content = STATE_JS_TEMPLATE.read_text() + SOCKET_JS_TEMPLATE.read_text() assert 'addEventListener("unload"' not in content, ( "state.js registers a deprecated `unload` listener; use `pagehide` instead." @@ -82,13 +85,13 @@ def test_state_js_still_handles_page_lifecycle_disconnect() -> None: recommended Web Page Lifecycle pattern; verify the replacement listeners remain wired so the socket is closed when the user navigates away. """ - content = STATE_JS_TEMPLATE.read_text() + content = SOCKET_JS_TEMPLATE.read_text() assert 'addEventListener("pagehide"' in content, ( - "state.js should register a `pagehide` listener to disconnect the socket." + "socket.js should register a `pagehide` listener to disconnect the socket." ) assert 'addEventListener("beforeunload"' in content, ( - "state.js should keep its `beforeunload` listener as a disconnect fallback." + "socket.js should keep its `beforeunload` listener as a disconnect fallback." ) diff --git a/tests/units/components/core/test_banner.py b/tests/units/components/core/test_banner.py index 8ea73a93775..d11c1bf8049 100644 --- a/tests/units/components/core/test_banner.py +++ b/tests/units/components/core/test_banner.py @@ -1,3 +1,4 @@ +from reflex_base.components.app_wraps import collect_subtree_app_wraps from reflex_components_core.core.banner import ( ConnectionBanner, ConnectionModal, @@ -63,3 +64,16 @@ def test_connection_toaster_shows_hydration_errors_at_once(): assert hydration_check < hooks.index("(connectErrors.length >= 2)") assert 'id: "hydration-payload-error"' in hooks assert "duration: Infinity" in hooks + + +def test_connection_toaster_does_not_ask_for_the_toaster(): + """A connection error alone is no reason to bundle the toaster.""" + toaster = ConnectionToaster.create() + hooks = toaster._get_all_hooks() + + # It shows through whichever toast function the app installed. + assert list(hooks)[:2] == [ + "const connectErrors = useContext(EventLoopContext)[1];", + "const toast = refs['__toast'];", + ] + assert collect_subtree_app_wraps(toaster) == {} diff --git a/tests/units/plugins/test_init.py b/tests/units/plugins/test_init.py new file mode 100644 index 00000000000..90f994e0fc8 --- /dev/null +++ b/tests/units/plugins/test_init.py @@ -0,0 +1,99 @@ +"""Tests for the names reflex.plugins resolves on first use.""" + +import subprocess +import sys + +import pytest +import reflex_components_ui.plugin + +import reflex as rx +import reflex.plugins + + +@pytest.fixture +def unresolved_ui_plugin(monkeypatch: pytest.MonkeyPatch): + """Forget that `UIPlugin` was resolved, so the next access imports it again. + + Args: + monkeypatch: The pytest fixture that restores the module afterwards. + """ + monkeypatch.delitem(vars(reflex.plugins), "UIPlugin", raising=False) + + +def test_ui_plugin_resolves_to_the_plugin_of_the_components_package( + unresolved_ui_plugin: None, +): + assert rx.plugins.UIPlugin is reflex_components_ui.plugin.UIPlugin + # Resolved once: the module attribute now answers. + assert vars(reflex.plugins)["UIPlugin"] is reflex_components_ui.plugin.UIPlugin + + +def test_importing_reflex_plugins_does_not_import_the_components_package(): + code = ( + "import sys, reflex.plugins\n" + "from reflex.plugins import *\n" + "print('reflex_components_ui' in sys.modules)\n" + "reflex.plugins.UIPlugin\n" + "print('reflex_components_ui' in sys.modules)\n" + ) + result = subprocess.run( + [sys.executable, "-c", code], capture_output=True, text=True, check=True + ) + assert result.stdout == "False\nTrue\n" + + +class _NotInstalled: + """A finder that answers as the import system does for an absent package.""" + + @staticmethod + def find_spec(name: str, path: object = None, target: object = None) -> None: + """Refuse to find the components package. + + Args: + name: The module being imported. + path: The search path of its parent package. + target: The module being reloaded. + + Raises: + ModuleNotFoundError: If the module belongs to the package. + """ + if name.partition(".")[0] == "reflex_components_ui": + msg = f"No module named {name!r}" + raise ModuleNotFoundError(msg, name="reflex_components_ui") + + +def test_ui_plugin_without_the_extra_says_what_to_install( + unresolved_ui_plugin: None, monkeypatch: pytest.MonkeyPatch +): + for name in [ + name for name in sys.modules if name.startswith("reflex_components_ui") + ]: + monkeypatch.delitem(sys.modules, name) + monkeypatch.setattr(sys, "meta_path", [_NotInstalled, *sys.meta_path]) + with pytest.raises(ModuleNotFoundError) as raised: + rx.plugins.UIPlugin + assert str(raised.value) == ( + "`rx.plugins.UIPlugin` requires the reflex-components-ui package, which is " + "not installed. Install it with `pip install 'reflex[ui]'`." + ) + assert raised.value.name == "reflex_components_ui" + assert "UIPlugin" not in vars(reflex.plugins) + + +def test_ui_plugin_does_not_hide_a_missing_dependency_of_the_package( + unresolved_ui_plugin: None, monkeypatch: pytest.MonkeyPatch +): + """Only the package itself being absent means the extra is not installed.""" + monkeypatch.delitem(sys.modules, "reflex_components_ui.plugin") + monkeypatch.setitem(sys.modules, "reflex_components_ui.constants", None) + with pytest.raises(ModuleNotFoundError) as raised: + rx.plugins.UIPlugin + assert raised.value.name == "reflex_components_ui.constants" + + +def test_unknown_plugin_is_an_attribute_error(): + with pytest.raises(AttributeError) as raised: + rx.plugins.NoSuchPlugin # pyright: ignore[reportAttributeAccessIssue] + assert str(raised.value) == ( + "module 'reflex.plugins' has no attribute 'NoSuchPlugin'" + ) diff --git a/tests/units/reflex_base/client_event_queue_runtime.mjs b/tests/units/reflex_base/client_event_queue_runtime.mjs index a2970bfe6d7..aa08a324e54 100644 --- a/tests/units/reflex_base/client_event_queue_runtime.mjs +++ b/tests/units/reflex_base/client_event_queue_runtime.mjs @@ -1,6 +1,12 @@ +import fs from "node:fs"; +import path from "node:path"; import { SourceTextModule, SyntheticModule } from "node:vm"; -/** Evaluate the complete frontend module with isolated dependency stubs. */ +// The modules next to utils/state.js that make up the runtime of an app with +// state: the connection to the backend, and what the two share. +const SIBLINGS = ["event_loop", "socket"]; + +/** Evaluate the complete frontend runtime with isolated dependency stubs. */ export async function createQueueRuntime( source, { @@ -78,17 +84,23 @@ export async function createQueueRuntime( }, ...dependencyOverrides, }; - // Let Node parse the unchanged module; only expose private state to tests. - const module = new SourceTextModule( - `import { window, document, localStorage, sessionStorage } from "test:browser"; -${source} -export { event_queue }; + // Let Node parse the unchanged modules, with the browser globals in scope. + const browserModule = (text) => + new SourceTextModule( + `import { window, document, localStorage, sessionStorage } from "test:browser"; +${text} `, - ); + ); + const utils = path.dirname(process.argv[2]); + const modules = { "$/utils/state": browserModule(source) }; + for (const name of SIBLINGS) { + modules[`$/utils/${name}`] = browserModule( + fs.readFileSync(path.join(utils, `${name}.js`), "utf8"), + ); + } const linked = new Map(); - await module.link((specifier) => { - // state.js imports itself to hand its exports to server-provided scripts. - if (specifier === "$/utils/state") return module; + await modules["$/utils/socket"].link((specifier) => { + if (modules[specifier]) return modules[specifier]; if (!linked.has(specifier)) { const exports = dependencies[specifier]; if (!exports) @@ -104,6 +116,10 @@ export { event_queue }; } return linked.get(specifier); }); - await module.evaluate(); - return module.namespace; + await modules["$/utils/socket"].evaluate(); + // What compiled code imports, and the private queue for the tests to read. + return { + ...modules["$/utils/state"].namespace, + event_queue: modules["$/utils/event_loop"].namespace.event_queue, + }; } diff --git a/tests/units/reflex_base/compiler/test_templates.py b/tests/units/reflex_base/compiler/test_templates.py index 196a30a218a..a0a4a0f3594 100644 --- a/tests/units/reflex_base/compiler/test_templates.py +++ b/tests/units/reflex_base/compiler/test_templates.py @@ -1,7 +1,12 @@ """Tests for reflex_base.compiler.templates.""" -from reflex_base.compiler.templates import _merge_state_hooks, _render_hooks +from reflex_base.compiler.templates import ( + _merge_state_hooks, + _render_hooks, + vite_config_template, +) from reflex_base.constants.state import FIELD_MARKER +from reflex_base.plugins import VitePluginEntry from reflex_base.utils.format import format_state_name from reflex_base.vars.base import Var, VarData from reflex_components_core.el.elements.typography import Div @@ -78,3 +83,109 @@ def test_render_hooks_declares_a_merged_state_hook_before_its_readers(): f"const parentRead = {state_var}.a{FIELD_MARKER}", f"const childValue = {state_var}.b{FIELD_MARKER}", ]) + + +_VITE_CONFIG_KWARGS = { + "base": "/", + "hmr": True, + "force_full_reload": False, + "experimental_hmr": False, + "sourcemap": False, +} +_VITE_IMPORTS_ANCHOR = ( + 'import safariCacheBustPlugin from "./vite-plugin-safari-cachebust.js";\n' +) +_VITE_PLUGINS_ANCHOR = " reactRouter(),\n" + + +def _vite_config_with( + imports: str, calls: str, *, after_imports: str = _VITE_IMPORTS_ANCHOR, **kwargs +) -> str: + """Build the expected vite.config.js from the one rendered without plugins. + + Args: + imports: The import lines the plugins add. + calls: The lines the plugins add to the ``plugins`` array. + after_imports: The line of the plugin-free file the imports follow. + kwargs: Template arguments on top of the defaults. + + Returns: + The plugin-free file with ``imports`` and ``calls`` inserted. + """ + baseline = vite_config_template(**_VITE_CONFIG_KWARGS, **kwargs) + head, imports_anchor, rest = baseline.partition(after_imports) + body, plugins_anchor, tail = rest.partition(_VITE_PLUGINS_ANCHOR) + assert imports_anchor + assert plugins_anchor + assert _VITE_PLUGINS_ANCHOR not in tail + return head + imports_anchor + imports + body + calls + plugins_anchor + tail + + +def test_vite_config_template_without_vite_plugins_is_unchanged(): + """No entries render the same file as omitting the argument.""" + assert vite_config_template( + **_VITE_CONFIG_KWARGS, vite_plugins=[] + ) == vite_config_template(**_VITE_CONFIG_KWARGS) + + +def test_vite_config_template_one_vite_plugin(): + """An entry's imports follow the built-in ones; its call precedes reactRouter().""" + rendered = vite_config_template( + **_VITE_CONFIG_KWARGS, + vite_plugins=[ + VitePluginEntry( + imports=[ + 'import stylex from "./reflex-ui/vite-plugin-stylex.js"', + 'import { Features } from "lightningcss";', + ], + call="""stylex({ + useCSSLayers: true, + lightningcssOptions: { minify: true, exclude: Features.LightDark }, +})""", + ) + ], + ) + assert rendered == _vite_config_with( + 'import stylex from "./reflex-ui/vite-plugin-stylex.js";\n' + 'import { Features } from "lightningcss";\n', + """ stylex({ + useCSSLayers: true, + lightningcssOptions: { minify: true, exclude: Features.LightDark }, +}), +""", + ) + + +def test_vite_config_template_two_vite_plugins(): + """Entries keep their order, after React Compiler; a shared import is written once.""" + rendered = vite_config_template( + **_VITE_CONFIG_KWARGS, + react_compiler=True, + vite_plugins=[ + VitePluginEntry( + imports=[ + 'import { Features } from "lightningcss"', + 'import second from "second-plugin"', + ], + call="second({ exclude: Features.LightDark })", + ), + VitePluginEntry( + imports=[ + 'import first from "first-plugin";', + ' import { Features } from "lightningcss" ;\n', + ], + call=" [first(), first.extra(Features.Nesting)]\n", + ), + VitePluginEntry(call='{ name: "inline", config: () => ({}) }'), + ], + ) + assert rendered == _vite_config_with( + 'import { Features } from "lightningcss";\n' + 'import second from "second-plugin";\n' + 'import first from "first-plugin";\n', + " second({ exclude: Features.LightDark }),\n" + " [first(), first.extra(Features.Nesting)],\n" + ' { name: "inline", config: () => ({}) },\n', + after_imports='import reactCompiler from "./vite-plugin-react-compiler.js";\n', + react_compiler=True, + ) diff --git a/tests/units/reflex_base/components/test_dynamic.py b/tests/units/reflex_base/components/test_dynamic.py index 5f05159f213..3dca98c4a40 100644 --- a/tests/units/reflex_base/components/test_dynamic.py +++ b/tests/units/reflex_base/components/test_dynamic.py @@ -165,3 +165,26 @@ def test_unknown_attribute_raises(module_name: str): module = importlib.import_module(f"{module_name}.components.dynamic") with pytest.raises(AttributeError, match=f"{module.__name__!r}"): _ = module.definitely_not_an_attribute + + +def test_is_rendering_dynamic_component_only_while_one_is_serialized(): + """A component can tell that its code will be evaluated in the browser.""" + from reflex_base.utils.serializers import serialize + + seen = [] + + class Probe(Component): + tag = "div" + + def add_custom_code(self) -> list[str]: + seen.append(dynamic.is_rendering_dynamic_component()) + return [] + + assert dynamic.is_rendering_dynamic_component() is False + serialize(Probe.create()) + assert seen + assert set(seen) == {True} + assert dynamic.is_rendering_dynamic_component() is False + seen.clear() + Probe.create()._get_all_custom_code() + assert seen == [False] diff --git a/tests/units/reflex_base/plugins/test_base.py b/tests/units/reflex_base/plugins/test_base.py index 7f4e9aa466b..34504968d6b 100644 --- a/tests/units/reflex_base/plugins/test_base.py +++ b/tests/units/reflex_base/plugins/test_base.py @@ -70,3 +70,8 @@ def test_register_route_default_is_noop(): ) is None ) + + +def test_get_vite_plugins_defaults_to_none(): + """A plugin contributes no Vite plugins unless it overrides the hook.""" + assert Plugin().get_vite_plugins() == [] diff --git a/tests/units/reflex_base/utils/pyi_generator/dataset/overwrite_types.py b/tests/units/reflex_base/utils/pyi_generator/dataset/overwrite_types.py new file mode 100644 index 00000000000..cbb5eabe538 --- /dev/null +++ b/tests/units/reflex_base/utils/pyi_generator/dataset/overwrite_types.py @@ -0,0 +1,54 @@ +"""Components that type a prop of their parents more narrowly in the stub. + +This module tests: +- `_pyi_overwrite_types`: the annotation a class gives a prop in its stub +- `_pyi_imports`: the names those annotations need, imported into the stub +- Both are inherited by subclasses, which may overwrite them again +- A class without them keeps the annotation every component has +""" + +from typing import ClassVar + +from reflex_base.components.component import Component +from reflex_base.vars.base import Var + + +class TypedStyleComponent(Component): + """A component whose style is typed more narrowly than a mapping.""" + + _pyi_overwrite_types: ClassVar[dict[str, str]] = { + "style": "OrderedDict[str, str] | None", + } + _pyi_imports: ClassVar[dict[str, list[str]]] = { + "collections": ["OrderedDict"], + } + + # The title displayed on the component. + title: Var[str] + + +class InheritingComponent(TypedStyleComponent): + """A component that inherits the annotation of its parent.""" + + # The count to display. + count: Var[int] + + +class RetypedComponent(TypedStyleComponent): + """A component that overwrites one of its own props as well.""" + + _pyi_overwrite_types: ClassVar[dict[str, str]] = { + **TypedStyleComponent._pyi_overwrite_types, + "title": "Decimal | None", + } + _pyi_imports: ClassVar[dict[str, list[str]]] = { + **TypedStyleComponent._pyi_imports, + "decimal": ["Decimal"], + } + + +class PlainComponent(Component): + """A component that keeps the annotation every component has.""" + + # The label of the component. + label: Var[str] diff --git a/tests/units/reflex_base/utils/pyi_generator/golden/overwrite_types.pyi b/tests/units/reflex_base/utils/pyi_generator/golden/overwrite_types.pyi new file mode 100644 index 00000000000..414f4ee4d2f --- /dev/null +++ b/tests/units/reflex_base/utils/pyi_generator/golden/overwrite_types.pyi @@ -0,0 +1,272 @@ +"""Stub file for """ + +# ------------------- DO NOT EDIT ---------------------- +# This file was generated by `reflex/utils/pyi_generator.py`! +# ------------------------------------------------------ +from collections import OrderedDict +from collections.abc import Mapping, Sequence +from decimal import Decimal +from typing import Any + +from reflex_base.components.component import Component +from reflex_base.event import EventType, PointerEventInfo +from reflex_base.vars.base import Var +from reflex_components_core.core.breakpoints import Breakpoints + +class TypedStyleComponent(Component): + @classmethod + def create( + cls, + *children, + title: Var[str] | str | None = None, + style: OrderedDict[str, str] | None = None, + key: Any | None = None, + id: Any | None = None, + ref: Var | None = None, + class_name: Any | None = None, + custom_attrs: dict[str, Any | Var] | None = None, + on_blur: EventType[()] | None = None, + on_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None, + on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_focus: EventType[()] | None = None, + on_mount: EventType[()] | None = None, + on_mouse_down: EventType[()] | None = None, + on_mouse_enter: EventType[()] | None = None, + on_mouse_leave: EventType[()] | None = None, + on_mouse_move: EventType[()] | None = None, + on_mouse_out: EventType[()] | None = None, + on_mouse_over: EventType[()] | None = None, + on_mouse_up: EventType[()] | None = None, + on_scroll: EventType[()] | None = None, + on_scroll_end: EventType[()] | None = None, + on_unmount: EventType[()] | None = None, + **props, + ) -> TypedStyleComponent: + """Create the component. + + Args: + *children: The children of the component. + title: The title displayed on the component. + style: The style of the component. + key: A unique key for the component. + id: The id for the component. + ref: The Var to pass as the ref to the component. + class_name: The class name for the component. + custom_attrs: Attributes passed directly to the component. + on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input. + on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input. + on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button. + on_context_menu: Fired when the user right-clicks on an element. + on_double_click: Fired when the user double-clicks on an element. + on_mouse_down: Fired when the user presses a mouse button on an element. + on_mouse_enter: Fired when the mouse pointer enters the element. + on_mouse_leave: Fired when the mouse pointer leaves the element. + on_mouse_move: Fired when the mouse pointer moves over the element. + on_mouse_out: Fired when the mouse pointer moves out of the element. + on_mouse_over: Fired when the mouse pointer moves onto the element. + on_mouse_up: Fired when the user releases a mouse button on an element. + on_scroll: Fired when the user scrolls the element. + on_scroll_end: Fired when scrolling ends on the element. + on_mount: Fired when the component is mounted to the page. + on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh. + **props: The props of the component. + + Returns: + The component. + """ + +class InheritingComponent(TypedStyleComponent): + @classmethod + def create( + cls, + *children, + count: Var[int] | int | None = None, + title: Var[str] | str | None = None, + style: OrderedDict[str, str] | None = None, + key: Any | None = None, + id: Any | None = None, + ref: Var | None = None, + class_name: Any | None = None, + custom_attrs: dict[str, Any | Var] | None = None, + on_blur: EventType[()] | None = None, + on_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None, + on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_focus: EventType[()] | None = None, + on_mount: EventType[()] | None = None, + on_mouse_down: EventType[()] | None = None, + on_mouse_enter: EventType[()] | None = None, + on_mouse_leave: EventType[()] | None = None, + on_mouse_move: EventType[()] | None = None, + on_mouse_out: EventType[()] | None = None, + on_mouse_over: EventType[()] | None = None, + on_mouse_up: EventType[()] | None = None, + on_scroll: EventType[()] | None = None, + on_scroll_end: EventType[()] | None = None, + on_unmount: EventType[()] | None = None, + **props, + ) -> InheritingComponent: + """Create the component. + + Args: + *children: The children of the component. + count: The count to display. + title: The title displayed on the component. + style: The style of the component. + key: A unique key for the component. + id: The id for the component. + ref: The Var to pass as the ref to the component. + class_name: The class name for the component. + custom_attrs: Attributes passed directly to the component. + on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input. + on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input. + on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button. + on_context_menu: Fired when the user right-clicks on an element. + on_double_click: Fired when the user double-clicks on an element. + on_mouse_down: Fired when the user presses a mouse button on an element. + on_mouse_enter: Fired when the mouse pointer enters the element. + on_mouse_leave: Fired when the mouse pointer leaves the element. + on_mouse_move: Fired when the mouse pointer moves over the element. + on_mouse_out: Fired when the mouse pointer moves out of the element. + on_mouse_over: Fired when the mouse pointer moves onto the element. + on_mouse_up: Fired when the user releases a mouse button on an element. + on_scroll: Fired when the user scrolls the element. + on_scroll_end: Fired when scrolling ends on the element. + on_mount: Fired when the component is mounted to the page. + on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh. + **props: The props of the component. + + Returns: + The component. + """ + +class RetypedComponent(TypedStyleComponent): + @classmethod + def create( + cls, + *children, + title: Decimal | None = None, + style: OrderedDict[str, str] | None = None, + key: Any | None = None, + id: Any | None = None, + ref: Var | None = None, + class_name: Any | None = None, + custom_attrs: dict[str, Any | Var] | None = None, + on_blur: EventType[()] | None = None, + on_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None, + on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_focus: EventType[()] | None = None, + on_mount: EventType[()] | None = None, + on_mouse_down: EventType[()] | None = None, + on_mouse_enter: EventType[()] | None = None, + on_mouse_leave: EventType[()] | None = None, + on_mouse_move: EventType[()] | None = None, + on_mouse_out: EventType[()] | None = None, + on_mouse_over: EventType[()] | None = None, + on_mouse_up: EventType[()] | None = None, + on_scroll: EventType[()] | None = None, + on_scroll_end: EventType[()] | None = None, + on_unmount: EventType[()] | None = None, + **props, + ) -> RetypedComponent: + """Create the component. + + Args: + *children: The children of the component. + title: The title displayed on the component. + style: The style of the component. + key: A unique key for the component. + id: The id for the component. + ref: The Var to pass as the ref to the component. + class_name: The class name for the component. + custom_attrs: Attributes passed directly to the component. + on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input. + on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input. + on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button. + on_context_menu: Fired when the user right-clicks on an element. + on_double_click: Fired when the user double-clicks on an element. + on_mouse_down: Fired when the user presses a mouse button on an element. + on_mouse_enter: Fired when the mouse pointer enters the element. + on_mouse_leave: Fired when the mouse pointer leaves the element. + on_mouse_move: Fired when the mouse pointer moves over the element. + on_mouse_out: Fired when the mouse pointer moves out of the element. + on_mouse_over: Fired when the mouse pointer moves onto the element. + on_mouse_up: Fired when the user releases a mouse button on an element. + on_scroll: Fired when the user scrolls the element. + on_scroll_end: Fired when scrolling ends on the element. + on_mount: Fired when the component is mounted to the page. + on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh. + **props: The props of the component. + + Returns: + The component. + """ + +class PlainComponent(Component): + @classmethod + def create( + cls, + *children, + label: Var[str] | str | None = None, + style: Sequence[Mapping[str, Any]] + | Mapping[str, Any] + | Var[Mapping[str, Any]] + | Breakpoints + | None = None, + key: Any | None = None, + id: Any | None = None, + ref: Var | None = None, + class_name: Any | None = None, + custom_attrs: dict[str, Any | Var] | None = None, + on_blur: EventType[()] | None = None, + on_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None, + on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None, + on_focus: EventType[()] | None = None, + on_mount: EventType[()] | None = None, + on_mouse_down: EventType[()] | None = None, + on_mouse_enter: EventType[()] | None = None, + on_mouse_leave: EventType[()] | None = None, + on_mouse_move: EventType[()] | None = None, + on_mouse_out: EventType[()] | None = None, + on_mouse_over: EventType[()] | None = None, + on_mouse_up: EventType[()] | None = None, + on_scroll: EventType[()] | None = None, + on_scroll_end: EventType[()] | None = None, + on_unmount: EventType[()] | None = None, + **props, + ) -> PlainComponent: + """Create the component. + + Args: + *children: The children of the component. + label: The label of the component. + style: The style of the component. + key: A unique key for the component. + id: The id for the component. + ref: The Var to pass as the ref to the component. + class_name: The class name for the component. + custom_attrs: Attributes passed directly to the component. + on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input. + on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input. + on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button. + on_context_menu: Fired when the user right-clicks on an element. + on_double_click: Fired when the user double-clicks on an element. + on_mouse_down: Fired when the user presses a mouse button on an element. + on_mouse_enter: Fired when the mouse pointer enters the element. + on_mouse_leave: Fired when the mouse pointer leaves the element. + on_mouse_move: Fired when the mouse pointer moves over the element. + on_mouse_out: Fired when the mouse pointer moves out of the element. + on_mouse_over: Fired when the mouse pointer moves onto the element. + on_mouse_up: Fired when the user releases a mouse button on an element. + on_scroll: Fired when the user scrolls the element. + on_scroll_end: Fired when scrolling ends on the element. + on_mount: Fired when the component is mounted to the page. + on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh. + **props: The props of the component. + + Returns: + The component. + """ diff --git a/tests/units/reflex_base/utils/pyi_generator/test_unit.py b/tests/units/reflex_base/utils/pyi_generator/test_unit.py index b862f15a5c9..7faffccc42d 100644 --- a/tests/units/reflex_base/utils/pyi_generator/test_unit.py +++ b/tests/units/reflex_base/utils/pyi_generator/test_unit.py @@ -23,6 +23,7 @@ _is_literal, _is_optional, _is_union, + _rewrite_component_import, _safe_issubclass, type_to_ast, ) @@ -516,3 +517,24 @@ class CreateComp(Component): assert "**props" in result # Return type should reference the class. assert "CreateComp" in result + + +@pytest.mark.parametrize( + ("module", "is_reflex_package", "expected"), + [ + ("components", True, "reflex_components_core"), + ("components.radix.themes.base", True, "reflex_components_radix.themes.base"), + ("components.datadisplay.code", True, "reflex_components_code.code"), + ("components.ui", True, "reflex_components_ui"), + ( + "components.ui.components.button", + True, + "reflex_components_ui.components.button", + ), + ("components.component", True, ".components.component"), + ("components.ui", False, ".components.ui"), + ("event", True, ".event"), + ], +) +def test_rewrite_component_import(module: str, is_reflex_package: bool, expected: str): + assert _rewrite_component_import(module, is_reflex_package) == expected diff --git a/tests/units/reflex_components_core/base/__init__.py b/tests/units/reflex_components_core/base/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/units/reflex_components_core/base/test_document.py b/tests/units/reflex_components_core/base/test_document.py new file mode 100644 index 00000000000..ac5552b23cc --- /dev/null +++ b/tests/units/reflex_components_core/base/test_document.py @@ -0,0 +1,13 @@ +"""Tests for the document components.""" + +from reflex_base import constants +from reflex_base.utils.imports import ImportVar +from reflex_components_core.base.document import Scripts + + +def test_scripts_come_from_the_reflex_frontend(): + """The document's scripts are Reflex's wrapper, which the web template ships.""" + scripts = Scripts.create() + assert scripts.render() == {"name": "Scripts", "props": [], "children": []} + assert scripts._get_all_imports() == {"$/utils/scripts": [ImportVar(tag="Scripts")]} + assert (constants.Templates.Dirs.WEB_TEMPLATE / "utils" / "scripts.js").is_file() diff --git a/tests/units/reflex_components_sonner/test_toast.py b/tests/units/reflex_components_sonner/test_toast.py index bca21a536ed..cf87981b5fe 100644 --- a/tests/units/reflex_components_sonner/test_toast.py +++ b/tests/units/reflex_components_sonner/test_toast.py @@ -3,7 +3,7 @@ import json from reflex_base.style import Style -from reflex_components_sonner.toast import Toaster, ToastProps +from reflex_components_sonner.toast import Toaster, ToasterRequest, ToastProps, toast def test_toaster_hotkey_accepts_key_list(): @@ -25,3 +25,23 @@ def test_toast_button_styles_use_sonner_prop_names(): assert serialized["cancelButtonStyle"]["color"] == "white" assert "actionButtonStyles" not in serialized assert "cancelButtonStyles" not in serialized + + +def test_toast_call_asks_the_app_for_its_toaster(): + """Every toast event carries the marker wrap the compiler looks for.""" + for event in ( + toast("Hello"), + toast.error("Failed", description="Try again"), + toast.dismiss("some-id"), + toast.dismiss(), + ): + requests = [ + (priority, type(wrapper), wrapper.render()) + for _, arg in event.args + if (var_data := arg._get_all_var_data()) is not None + for priority, wrapper in var_data.app_wraps + ] + assert requests == [(44, ToasterRequest, ToasterRequest.create().render())] + + # Left in place, the marker renders nothing of its own. + assert str(ToasterRequest.create()) == "jsx(Fragment,{},)" diff --git a/tests/units/reflex_components_ui/__init__.py b/tests/units/reflex_components_ui/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/units/reflex_components_ui/conftest.py b/tests/units/reflex_components_ui/conftest.py new file mode 100644 index 00000000000..bb0d1d6972a --- /dev/null +++ b/tests/units/reflex_components_ui/conftest.py @@ -0,0 +1,116 @@ +"""Fixtures for the tests of reflex-components-ui.""" + +import dataclasses +import json +import shutil +import subprocess +import sys +from collections.abc import Callable +from pathlib import Path +from typing import Any + +import pytest +from reflex_base.components.component import Component +from reflex_base.config import get_config +from reflex_base.plugins import CompileContext, CompilerHooks, Plugin +from reflex_components_ui.plugin import UIPlugin + +from reflex.compiler.plugins import default_page_plugins + +# Code for a type checker, kept as text so that no other tool checks it. +FIXTURES = Path(__file__).parent / "style" / "fixtures" + + +@dataclasses.dataclass(slots=True) +class _Page: + route: str + component: Callable[[], Component] + title: Any = None + description: Any = None + image: str = "" + meta: tuple[dict[str, Any], ...] = () + _source_module: str | None = None + + +@pytest.fixture +def ui_plugin(monkeypatch: pytest.MonkeyPatch) -> UIPlugin: + """Configure the plugin, as an app does in its rxconfig.py. + + Args: + monkeypatch: The pytest fixture that undoes the change. + + Returns: + The configured plugin. + """ + plugin = UIPlugin() + monkeypatch.setattr(get_config(), "plugins", [plugin]) + return plugin + + +@pytest.fixture +def compile_page(preserve_memo_registries: None) -> Callable[..., CompileContext]: + """Compile a page the way an app compile does. + + Args: + preserve_memo_registries: Restores the memos a compile registers. + + Returns: + A function from a page, and the plugins of the app to run beside the + ones of every compile, to its compile context: the source of the page + is ``compiled_pages["/"].output_code``. + """ + + def compile_page(page: Callable[[], Component], *plugins: Plugin) -> CompileContext: + ctx = CompileContext( + pages=[_Page(route="/", component=page)], + hooks=CompilerHooks(plugins=(*default_page_plugins(), *plugins)), + ) + with ctx: + ctx.compile() + return ctx + + return compile_page + + +@pytest.fixture +def pyright(tmp_path: Path) -> Callable[[str], list[tuple[int, str, str]]]: + """Run pyright over a fixture, outside the configuration of the repository. + + Args: + tmp_path: A directory to copy the fixture to. + + Returns: + A function from the name of a fixture, without its extension, to the + line, rule and whole message of every diagnostic. + """ + + def pyright(fixture: str) -> list[tuple[int, str, str]]: + target = tmp_path / f"{fixture}.py" + shutil.copy(FIXTURES / f"{fixture}.py.txt", target) + result = subprocess.run( + [ + sys.executable, + "-m", + "pyright", + "--outputjson", + "--pythonpath", + sys.executable, + str(target), + ], + capture_output=True, + text=True, + cwd=tmp_path, + check=False, + ) + diagnostics = json.loads(result.stdout)["generalDiagnostics"] + assert {diagnostic["file"] for diagnostic in diagnostics} <= {str(target)} + return [ + ( + diagnostic["range"]["start"]["line"] + 1, + diagnostic["rule"], + diagnostic["message"], + ) + for diagnostic in diagnostics + ] + + return pyright diff --git a/tests/units/reflex_components_ui/layout/__init__.py b/tests/units/reflex_components_ui/layout/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/units/reflex_components_ui/layout/test_box.py b/tests/units/reflex_components_ui/layout/test_box.py new file mode 100644 index 00000000000..37d166e69f2 --- /dev/null +++ b/tests/units/reflex_components_ui/layout/test_box.py @@ -0,0 +1,210 @@ +"""Tests for reflex_components_ui.layout.box.""" + +import ast +from collections.abc import Callable +from pathlib import Path + +import pytest +from reflex_base.plugins import CompileContext +from reflex_base.utils.pyi_generator import PyiGenerator +from reflex_components_ui.layout import box as box_module +from reflex_components_ui.layout.box import Box +from reflex_components_ui.plugin import UIPlugin + +import reflex as rx + +BOX_PAGE = """import * as stylex from "@stylexjs/stylex" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + + + +const sx_b26ac4fb71 = stylex.create({ s: {"boxSizing": "border-box", "display": "block"} }); +const sx_b26ac4fb71_c = stylex.props(sx_b26ac4fb71.s).className; +const sx_30d00d85a0 = stylex.create({ s: {"boxSizing": "border-box", "display": "block", "paddingTop": "4px", "paddingRight": "4px", "paddingBottom": "4px", "paddingLeft": "4px"} }); +const sx_30d00d85a0_c = stylex.props(sx_30d00d85a0.s).className; + +function Component() { + + + return ( + jsx(Fragment,{},jsx("main",{},jsx("div",{className:sx_b26ac4fb71_c},"hello"),jsx("div",{className:sx_b26ac4fb71_c},"again"),jsx("div",{className:"p-8 " + sx_30d00d85a0_c},"padded")),jsx("title",{}," | Index"),jsx("meta",{content:"",property:"og:image"},)) + ) +} +Component.displayName = "Component(/)"; + +export default Component; +""" + + +def test_box_page_source( + ui_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + """A box is a div: no component is imported, and equal styles declare once.""" + + def page(): + return rx.el.main( + rx.ui.box("hello"), + rx.ui.box("again"), + rx.ui.box("padded", style={"padding": "4px"}, class_name="p-8"), + ) + + assert compile_page(page).compiled_pages["/"].output_code == BOX_PAGE + + +def test_box_is_a_name_of_the_ui_namespace(): + assert rx.ui.box == Box.create + assert "box" in dir(rx.ui) + + +@pytest.fixture(scope="module") +def box_stub() -> ast.Module: + """Generate the stub of the box, where a build writes it. + + Returns: + The stub, parsed. + """ + source = Path(box_module.__file__) + PyiGenerator().scan_all([source]) + return ast.parse(source.with_suffix(".pyi").read_text()) + + +def test_stub_types_the_style_as_css(box_stub: ast.Module): + """The stub of every rx.ui component types its style, and imports the type.""" + (box,) = [node for node in box_stub.body if isinstance(node, ast.ClassDef)] + (create,) = [node for node in box.body if isinstance(node, ast.FunctionDef)] + annotations = { + argument.arg: ast.unparse(argument.annotation) + for argument in create.args.kwonlyargs + if argument.annotation is not None + } + assert annotations["style"] == ( + "Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | Breakpoints " + "| None" + ) + # Keyword arguments stay open: data_* and aria_* come through them. + assert create.args.kwarg is not None + assert create.args.kwarg.arg == "props" + assert [ + ast.unparse(node) + for node in box_stub.body + if isinstance(node, ast.ImportFrom) + and node.module == "reflex_components_ui.style" + ] == ["from reflex_components_ui.style import ComponentStyles, StyleProps"] + + +def test_valid_styles_of_a_component_type_check( + box_stub: ast.Module, pyright: Callable[[str], list[tuple[int, str, str]]] +): + assert pyright("component_valid") == [] + + +def test_invalid_styles_of_a_component_are_type_errors( + box_stub: ast.Module, pyright: Callable[[str], list[tuple[int, str, str]]] +): + assert pyright("component_errors") == COMPONENT_ERRORS + + +# What pyright says of each call of the fixture: its line, rule and message. +COMPONENT_ERRORS: list[tuple[int, str, str]] = [ + ( + 5, + "reportArgumentType", + ( + 'Argument of type "dict[str, str]" cannot be assigned to parameter "style" of type ' + '"Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | Breakpoints[Unknown, ' + 'Unknown] | None" in function "create"\n' + '\xa0\xa0Type "dict[str, str]" is not assignable to type "Sequence[StyleProps] | ' + 'StyleProps | Var[Mapping[str, Any]] | Breakpoints[Unknown, Unknown] | None"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Sequence[StyleProps]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "StyleProps"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Var[Mapping[str, Any]]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Breakpoints[Unknown, ' + 'Unknown]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "None"' + ), + ), + ( + 7, + "reportArgumentType", + ( + 'Argument of type "dict[str, str]" cannot be assigned to parameter "style" of type ' + '"Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | Breakpoints[Unknown, ' + 'Unknown] | None" in function "create"\n' + '\xa0\xa0Type "dict[str, str]" is not assignable to type "Sequence[StyleProps] | ' + 'StyleProps | Var[Mapping[str, Any]] | Breakpoints[Unknown, Unknown] | None"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Sequence[StyleProps]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "StyleProps"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Var[Mapping[str, Any]]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Breakpoints[Unknown, ' + 'Unknown]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "None"' + ), + ), + ( + 9, + "reportArgumentType", + ( + 'Argument of type "dict[str, dict[str, str]]" cannot be assigned to parameter ' + '"style" of type "Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | ' + 'Breakpoints[Unknown, Unknown] | None" in function "create"\n' + '\xa0\xa0Type "dict[str, dict[str, str]]" is not assignable to type ' + '"Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | Breakpoints[Unknown, ' + 'Unknown] | None"\n' + '\xa0\xa0\xa0\xa0"dict[str, dict[str, str]]" is not assignable to ' + '"Sequence[StyleProps]"\n' + '\xa0\xa0\xa0\xa0"dict[str, dict[str, str]]" is not assignable to "StyleProps"\n' + '\xa0\xa0\xa0\xa0"dict[str, dict[str, str]]" is not assignable to "Var[Mapping[str, ' + 'Any]]"\n' + '\xa0\xa0\xa0\xa0"dict[str, dict[str, str]]" is not assignable to ' + '"Breakpoints[Unknown, Unknown]"\n' + '\xa0\xa0\xa0\xa0"dict[str, dict[str, str]]" is not assignable to "None"' + ), + ), + ( + 11, + "reportArgumentType", + ( + 'Argument of type "list[StyleProps | dict[str, str]]" cannot be assigned to ' + 'parameter "style" of type "Sequence[StyleProps] | StyleProps | Var[Mapping[str, ' + 'Any]] | Breakpoints[Unknown, Unknown] | None" in function "create"\n' + '\xa0\xa0Type "Literal[\'flx\']" is not assignable to type "_Value[_Display | ' + '_StrVar]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'flx\']" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'flx\']" is not assignable to "Sequence[_Display | ' + '_StrVar]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0Type parameter "_T_co@Sequence" is covariant, but "str" is ' + 'not a subtype of "_Display | _StrVar"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0Type "str" is not assignable to type "_Display | ' + '_StrVar"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to type ' + "\"Literal['-webkit-box']\"\n" + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to type ' + "\"Literal['block']\"" + ), + ), + ( + 13, + "reportArgumentType", + ( + "Argument of type \"Literal['padding: 1em']\" cannot be assigned to parameter " + '"style" of type "Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | ' + 'Breakpoints[Unknown, Unknown] | None" in function "create"\n' + "\xa0\xa0Type \"Literal['padding: 1em']\" is not assignable to type " + '"Sequence[StyleProps] | StyleProps | Var[Mapping[str, Any]] | Breakpoints[Unknown, ' + 'Unknown] | None"\n' + "\xa0\xa0\xa0\xa0\"Literal['padding: 1em']\" is not assignable to " + '"Sequence[StyleProps]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0Type parameter "_T_co@Sequence" is covariant, but "str" is ' + 'not a subtype of "StyleProps"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to "StyleProps"\n' + '\xa0\xa0\xa0\xa0"Literal[\'padding: 1em\']" is not assignable to "StyleProps"\n' + '\xa0\xa0\xa0\xa0"Literal[\'padding: 1em\']" is not assignable to "Var[Mapping[str, ' + 'Any]]"\n' + "\xa0\xa0\xa0\xa0\"Literal['padding: 1em']\" is not assignable to " + '"Breakpoints[Unknown, Unknown]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'padding: 1em\']" is not assignable to "None"' + ), + ), +] diff --git a/tests/units/reflex_components_ui/layout/test_theme.py b/tests/units/reflex_components_ui/layout/test_theme.py new file mode 100644 index 00000000000..0d3aca90681 --- /dev/null +++ b/tests/units/reflex_components_ui/layout/test_theme.py @@ -0,0 +1,448 @@ +"""Tests for reflex_components_ui.layout.theme.""" + +from collections.abc import Callable + +import pytest +from pytest_mock import MockerFixture +from reflex_base.components.component import Component +from reflex_base.config import get_config +from reflex_base.plugins import CompileContext +from reflex_base.utils.exceptions import ConfigError +from reflex_base.utils.serializers import serialize +from reflex_components_core.base.app_wrap import AppWrap +from reflex_components_ui.layout.theme import Appearance, AppTheme, ThemeElement +from reflex_components_ui.plugin import APP_THEME_WRAP, UIPlugin +from reflex_components_ui.themes import Theme, ThemeError + +import reflex as rx +from reflex.compiler import compiler + +APP_ROOT = ( + """ +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentIndigo} from "$/reflex-ui/themes/accent/indigo.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {graySlate} from "$/reflex-ui/themes/gray/slate.js" +import {panelTranslucent} from "$/reflex-ui/themes/panel.js" +import {radiusLarge} from "$/reflex-ui/themes/radius.js" +import {scaling100} from "$/reflex-ui/themes/scaling.js" +import {colorScope,radiusScope,shadowScope,spaceScope,typographyScope} from "$/reflex-ui/themes/scope.js" +import {theme as reflexUITheme} from "$/reflex-ui/themes/theme.js" +import * as stylex from "@stylexjs/stylex" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + +import { defaultColorMode } from "$/utils/context"; +import { ThemeProvider } from '$/utils/react-theme'; +import { Layout as AppLayout } from './_document'; +import { Outlet } from 'react-router'; + + + +const sx_c1c0436182 = stylex.create({ s: {"position": "relative", "zIndex": 0, "minHeight": {"default": "100vh", "@supports (min-height: 100dvh)": "100dvh"}} }); +const sx_c1c0436182_c = stylex.props(sx_c1c0436182.s).className; +const sx_c1c0436182_o = sx_c1c0436182.s; +const reflexUIClasses_48dbd5f3d5 = "reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, accentIndigo, graySlate, radiusLarge, scaling100, panelTranslucent, reflexUITheme.root, reflexUITheme.background, sx_c1c0436182_o); + +function ReflexProviders({children}) { + useEffect(() => { + // Make contexts and state objects available globally for dynamic eval'd components + window.__reflex = { +""" + # The template indents the libraries of the app, of which there are none. + " \n" + """ }; + }, []); + + return jsx(ThemeProvider, {defaultTheme: defaultColorMode, attribute: "class"}, + jsx(AppWrap, {}, children) + ); +} + + +function AppWrap({children}) { + +return (jsx("div",{className:reflexUIClasses_48dbd5f3d5},jsx(Fragment,{},children))) +} + +export function Layout({children}) { + return jsx(AppLayout, {}, jsx(ReflexProviders, {}, children)); +} + +// Used by entry.client.js when mount_target is configured: skips the document +// shell (which renders react-router's // and requires a +// framework router context) but keeps the runtime providers. +export function EmbedLayout({children}) { + return jsx(ReflexProviders, {}, children); +} + +export default function App() { + return jsx(Outlet, {}); +} + +""" +) + +NESTED_PAGE = """import * as stylex from "@stylexjs/stylex" +import "$/reflex-ui/tokens/accent.stylex.js" +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentRed} from "$/reflex-ui/themes/accent/red.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {colorScope,radiusScope,shadowScope,spaceScope,typographyScope} from "$/reflex-ui/themes/scope.js" +import {theme as reflexUITheme} from "$/reflex-ui/themes/theme.js" +import {useRegisteredRef} from "$/utils/state" +import {radiusFull} from "$/reflex-ui/themes/radius.js" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + + + +const sx_e0e666cdfc = stylex.create({ s: {"boxSizing": "border-box", "display": "block", "color": "var(--accent-9)"} }); +const sx_e0e666cdfc_c = stylex.props(sx_e0e666cdfc.s).className; +const reflexUIClasses_22039616de = "reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, accentRed, reflexUITheme.root); +const sx_2ccd5239f0 = stylex.create({ s: {"paddingTop": "4px", "paddingRight": "4px", "paddingBottom": "4px", "paddingLeft": "4px"} }); +const sx_2ccd5239f0_c = stylex.props(sx_2ccd5239f0.s).className; +const sx_2ccd5239f0_o = sx_2ccd5239f0.s; +const reflexUIClasses_fd8fdcb49a = "reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, radiusFull, reflexUITheme.root, reflexUITheme.background, reflexUITheme.dark, sx_2ccd5239f0_o); +const sx_71b84cd269 = stylex.create({ s: {"display": "contents"} }); +const sx_71b84cd269_c = stylex.props(sx_71b84cd269.s).className; +const reflexUIClasses_7830a5bcf7 = "reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, reflexUITheme.root); + +function Component() { +const ref_dark = useRegisteredRef("ref_dark"); + + return ( + jsx(Fragment,{},jsx("main",{},jsx("div",{className:reflexUIClasses_22039616de},jsx("div",{className:sx_e0e666cdfc_c},"red")),jsx("div",{className:"dark " + sx_71b84cd269_c},jsx("div",{className:"p-8 " + reflexUIClasses_fd8fdcb49a,id:"dark",ref:ref_dark},"dark")),jsx("div",{className:reflexUIClasses_7830a5bcf7},"plain")),jsx("title",{}," | Index"),jsx("meta",{content:"",property:"og:image"},)) + ) +} +Component.displayName = "Component(/)"; + +export default Component; +""" + +BOUND_PAGE = """import {Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5} from "$/utils/components/Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5" +import {Themeelement_div_110e113e071e5dc30028d2a466586629} from "$/utils/components/Themeelement_div_110e113e071e5dc30028d2a466586629" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + + + + + +function Component() { + + + return ( + jsx(Fragment,{},jsx("main",{},jsx(Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5,{},"accent"),jsx(Themeelement_div_110e113e071e5dc30028d2a466586629,{},"names")),jsx("title",{}," | Index"),jsx("meta",{content:"",property:"og:image"},)) + ) +} +Component.displayName = "Component(/)"; + +export default Component; +""" + +BOUND_ACCENT_THEME = """ +import {isTrue,mergeSlotProps} from "$/utils/state" +import {useStateContext} from "$/utils/context-registry" +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentAmber} from "$/reflex-ui/themes/accent/amber.js" +import {accentBlue} from "$/reflex-ui/themes/accent/blue.js" +import {accentBronze} from "$/reflex-ui/themes/accent/bronze.js" +import {accentBrown} from "$/reflex-ui/themes/accent/brown.js" +import {accentCrimson} from "$/reflex-ui/themes/accent/crimson.js" +import {accentCyan} from "$/reflex-ui/themes/accent/cyan.js" +import {accentGold} from "$/reflex-ui/themes/accent/gold.js" +import {accentGrass} from "$/reflex-ui/themes/accent/grass.js" +import {accentGray} from "$/reflex-ui/themes/accent/gray.js" +import {accentGreen} from "$/reflex-ui/themes/accent/green.js" +import {accentIndigo} from "$/reflex-ui/themes/accent/indigo.js" +import {accentIris} from "$/reflex-ui/themes/accent/iris.js" +import {accentJade} from "$/reflex-ui/themes/accent/jade.js" +import {accentLime} from "$/reflex-ui/themes/accent/lime.js" +import {accentMint} from "$/reflex-ui/themes/accent/mint.js" +import {accentOrange} from "$/reflex-ui/themes/accent/orange.js" +import {accentPink} from "$/reflex-ui/themes/accent/pink.js" +import {accentPlum} from "$/reflex-ui/themes/accent/plum.js" +import {accentPurple} from "$/reflex-ui/themes/accent/purple.js" +import {accentRed} from "$/reflex-ui/themes/accent/red.js" +import {accentRuby} from "$/reflex-ui/themes/accent/ruby.js" +import {accentSky} from "$/reflex-ui/themes/accent/sky.js" +import {accentTeal} from "$/reflex-ui/themes/accent/teal.js" +import {accentTomato} from "$/reflex-ui/themes/accent/tomato.js" +import {accentViolet} from "$/reflex-ui/themes/accent/violet.js" +import {accentYellow} from "$/reflex-ui/themes/accent/yellow.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {colorScope,radiusScope,shadowScope,spaceScope,typographyScope} from "$/reflex-ui/themes/scope.js" +import {theme as reflexUITheme} from "$/reflex-ui/themes/theme.js" +import {jsx} from "@emotion/react" +import {Fragment,memo,useEffect} from "react" + + + +const reflexUIAccents = { __proto__: null, "amber": accentAmber, "blue": accentBlue, "bronze": accentBronze, "brown": accentBrown, "crimson": accentCrimson, "cyan": accentCyan, "gold": accentGold, "grass": accentGrass, "gray": accentGray, "green": accentGreen, "indigo": accentIndigo, "iris": accentIris, "jade": accentJade, "lime": accentLime, "mint": accentMint, "orange": accentOrange, "pink": accentPink, "plum": accentPlum, "purple": accentPurple, "red": accentRed, "ruby": accentRuby, "sky": accentSky, "teal": accentTeal, "tomato": accentTomato, "violet": accentViolet, "yellow": accentYellow }; + + +export const Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5 = /*#__PURE__*/ (() => { +const Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5 = memo(({children, ...rest}) => { + const reflex___state____state__tests___units___reflex_components_ui___layout___test_theme____theme_state = useStateContext("reflex___state____state.tests___units___reflex_components_ui___layout___test_theme____theme_state", ["accent_rx_state_"]) + return( + jsx("div",{...mergeSlotProps(rest, ({ className:"reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, reflexUIAccents[reflex___state____state__tests___units___reflex_components_ui___layout___test_theme____theme_state.accent_rx_state_], reflexUITheme.root) }))},children) + ) +}); +Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5.displayName = "ThemeElement"; +return Themeelement_div_45c9f04fbd77a86b901df8ec7c9186f5; +})(); +""" + +BOUND_NAMES_THEME = """ +import {isTrue,mergeSlotProps} from "$/utils/state" +import {useStateContext} from "$/utils/context-registry" +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentAmber} from "$/reflex-ui/themes/accent/amber.js" +import {accentBlue} from "$/reflex-ui/themes/accent/blue.js" +import {accentBronze} from "$/reflex-ui/themes/accent/bronze.js" +import {accentBrown} from "$/reflex-ui/themes/accent/brown.js" +import {accentCrimson} from "$/reflex-ui/themes/accent/crimson.js" +import {accentCyan} from "$/reflex-ui/themes/accent/cyan.js" +import {accentGold} from "$/reflex-ui/themes/accent/gold.js" +import {accentGrass} from "$/reflex-ui/themes/accent/grass.js" +import {accentGray} from "$/reflex-ui/themes/accent/gray.js" +import {accentGreen} from "$/reflex-ui/themes/accent/green.js" +import {accentIndigo} from "$/reflex-ui/themes/accent/indigo.js" +import {accentIris} from "$/reflex-ui/themes/accent/iris.js" +import {accentJade} from "$/reflex-ui/themes/accent/jade.js" +import {accentLime} from "$/reflex-ui/themes/accent/lime.js" +import {accentMint} from "$/reflex-ui/themes/accent/mint.js" +import {accentOrange} from "$/reflex-ui/themes/accent/orange.js" +import {accentPink} from "$/reflex-ui/themes/accent/pink.js" +import {accentPlum} from "$/reflex-ui/themes/accent/plum.js" +import {accentPurple} from "$/reflex-ui/themes/accent/purple.js" +import {accentRed} from "$/reflex-ui/themes/accent/red.js" +import {accentRuby} from "$/reflex-ui/themes/accent/ruby.js" +import {accentSky} from "$/reflex-ui/themes/accent/sky.js" +import {accentTeal} from "$/reflex-ui/themes/accent/teal.js" +import {accentTomato} from "$/reflex-ui/themes/accent/tomato.js" +import {accentViolet} from "$/reflex-ui/themes/accent/violet.js" +import {accentYellow} from "$/reflex-ui/themes/accent/yellow.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {graySand} from "$/reflex-ui/themes/gray/sand.js" +import {colorScope,radiusScope,shadowScope,spaceScope,typographyScope} from "$/reflex-ui/themes/scope.js" +import {theme as reflexUITheme} from "$/reflex-ui/themes/theme.js" +import {jsx} from "@emotion/react" +import {Fragment,memo,useEffect} from "react" + + + +const reflexUIAccents = { __proto__: null, "amber": accentAmber, "blue": accentBlue, "bronze": accentBronze, "brown": accentBrown, "crimson": accentCrimson, "cyan": accentCyan, "gold": accentGold, "grass": accentGrass, "gray": accentGray, "green": accentGreen, "indigo": accentIndigo, "iris": accentIris, "jade": accentJade, "lime": accentLime, "mint": accentMint, "orange": accentOrange, "pink": accentPink, "plum": accentPlum, "purple": accentPurple, "red": accentRed, "ruby": accentRuby, "sky": accentSky, "teal": accentTeal, "tomato": accentTomato, "violet": accentViolet, "yellow": accentYellow }; + + +export const Themeelement_div_110e113e071e5dc30028d2a466586629 = /*#__PURE__*/ (() => { +const Themeelement_div_110e113e071e5dc30028d2a466586629 = memo(({children, ...rest}) => { + const reflex___state____state__tests___units___reflex_components_ui___layout___test_theme____theme_state = useStateContext("reflex___state____state.tests___units___reflex_components_ui___layout___test_theme____theme_state", ["names_rx_state_", "accent_rx_state_"]) + return( + jsx("div",{...mergeSlotProps(rest, ({ className:(reflex___state____state__tests___units___reflex_components_ui___layout___test_theme____theme_state.names_rx_state_) + " " + "reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, typographyScope, shadowScope, colorScope, focusScope, reflexUIAccents[reflex___state____state__tests___units___reflex_components_ui___layout___test_theme____theme_state.accent_rx_state_], graySand, reflexUITheme.root) }))},children) + ) +}); +Themeelement_div_110e113e071e5dc30028d2a466586629.displayName = "ThemeElement"; +return Themeelement_div_110e113e071e5dc30028d2a466586629; +})(); +""" + + +class ThemeState(rx.State): + """State whose fields are bound to a theme.""" + + accent: str = "red" + names: str = "wide" + appearance: str = "dark" + + +@pytest.fixture +def indigo_plugin(monkeypatch: pytest.MonkeyPatch) -> UIPlugin: + """Configure the plugin with a theme, as an app does in its rxconfig.py. + + Args: + monkeypatch: The pytest fixture that undoes the change. + + Returns: + The configured plugin. + """ + plugin = UIPlugin(theme=Theme(accent_color="indigo", radius="large")) + monkeypatch.setattr(get_config(), "plugins", [plugin]) + return plugin + + +def test_app_root_source(monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture): + """The element around the app names one accent, one gray and the options.""" + # The libraries a dynamic component may load are no part of the theme. + mocker.patch( + "reflex.compiler.compiler._split_window_libraries", return_value=([], []) + ) + app = rx.App(enable_state=False) + plugin = UIPlugin(theme=Theme(accent_color="indigo", radius="large")) + monkeypatch.setattr(get_config(), "plugins", [plugin]) + root = app._app_root({ + (0, "AppWrap"): AppWrap.create(), + APP_THEME_WRAP: AppTheme.create(), + }) + assert compiler._compile_app(root, dynamic_components=False) == APP_ROOT + + +def test_plugin_wraps_an_app_with_an_appearance_in_its_class( + monkeypatch: pytest.MonkeyPatch, compile_page: Callable[..., CompileContext] +): + """The class of the appearance is on an element around the theme element.""" + plugin = UIPlugin(theme=Theme(appearance="dark")) + monkeypatch.setattr(get_config(), "plugins", [plugin]) + wraps = compile_page(lambda: rx.el.main("hello"), plugin).app_wrap_components + assert {key: type(wrap) for key, wrap in wraps.items()} == { + (15, "ReflexUITheme"): AppTheme, + (16, "ReflexUIAppearance"): Appearance, + } + assert wraps[16, "ReflexUIAppearance"].render() == { + "name": '"div"', + "props": ['className:"dark " + sx_71b84cd269_c'], + "children": [], + } + theme = wraps[15, "ReflexUITheme"] + assert theme.render() == { + "name": '"div"', + "props": ["className:reflexUIClasses_ac4861b877"], + "children": [], + } + assert theme._get_all_custom_code() == { + 'const sx_c1c0436182 = stylex.create({ s: {"position": "relative", ' + '"zIndex": 0, "minHeight": {"default": "100vh", "@supports ' + '(min-height: 100dvh)": "100dvh"}} });\n' + "const sx_c1c0436182_c = stylex.props(sx_c1c0436182.s).className;": None, + "const sx_c1c0436182_o = sx_c1c0436182.s;": None, + 'const reflexUIClasses_ac4861b877 = "reflex-ui-theme " + ' + "reflexUIClassName(spaceScope, radiusScope, typographyScope, " + "shadowScope, colorScope, focusScope, accentBlue, graySlate, " + "radiusMedium, scaling100, panelTranslucent, reflexUITheme.root, " + "reflexUITheme.background, reflexUITheme.dark, sx_c1c0436182_o);": None, + } + + +def test_theme_with_an_appearance_is_inside_the_element_of_its_class( + indigo_plugin: UIPlugin, +): + """Only a theme with an appearance of its own has the element around it.""" + assert type(rx.ui.theme("hello")) is ThemeElement + assert type(rx.ui.theme("hello", appearance="inherit")) is ThemeElement + dark: Component = rx.ui.theme("hello", appearance="dark", id="dark") + assert [type(dark), *map(type, dark.children)] == [Appearance, ThemeElement] + bound: Component = rx.ui.theme( + "hello", + appearance=ThemeState.appearance, # pyright: ignore [reportArgumentType] + ) + assert bound.render()["props"] == [ + f'className:({ThemeState.appearance!s}) + " " + sx_71b84cd269_c' + ] + assert bound.children[0].render()["props"] == [ + ( + 'className:"reflex-ui-theme " + reflexUIClassName(spaceScope, ' + "radiusScope, typographyScope, shadowScope, colorScope, focusScope, " + f'reflexUITheme.root, ({ThemeState.appearance!s}) !== "inherit" && ' + f"reflexUITheme.background, reflexUITheme[{ThemeState.appearance!s}])" + ) + ] + + +def test_plugin_wraps_every_app_in_its_theme( + indigo_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + """A page asks for the wrap, inside the one of Radix Themes.""" + wraps = compile_page(lambda: rx.el.main("hello"), indigo_plugin).app_wrap_components + assert list(wraps) == [(15, "ReflexUITheme")] + assert type(wraps[15, "ReflexUITheme"]) is AppTheme + assert APP_THEME_WRAP == (15, "ReflexUITheme") + + +def test_nested_theme_page_source( + indigo_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + """A literal option imports one module, and the element stays a div.""" + + def page(): + return rx.el.main( + rx.ui.theme( + rx.ui.box("red", style={"color": rx.ui.tokens.accent[9]}), + accent_color="red", + ), + rx.ui.theme( + "dark", + appearance="dark", + radius="full", + class_name="p-8", + style={"padding": "4px"}, + id="dark", + ), + rx.ui.theme("plain"), + ) + + assert compile_page(page).compiled_pages["/"].output_code == NESTED_PAGE + + +def test_theme_bound_to_state_imports_every_accent( + indigo_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + """The element moves to a module of its own, which chooses among them.""" + + def page(): + return rx.el.main( + rx.ui.theme( + "accent", + accent_color=ThemeState.accent, # pyright: ignore [reportArgumentType] + ), + rx.ui.theme( + "names", + accent_color=ThemeState.accent, # pyright: ignore [reportArgumentType] + gray_color="sand", + class_name=ThemeState.names, + ), + ) + + ctx = compile_page(page) + assert ctx.compiled_pages["/"].output_code == BOUND_PAGE + files, _ = compiler.compile_memo_components(ctx.auto_memo_components.values()) + sources = [code for path, code in files if "Themeelement_div_" in path] + assert sources == [BOUND_ACCENT_THEME, BOUND_NAMES_THEME] + + +def test_theme_is_a_name_of_the_ui_namespace(): + assert rx.ui.theme == ThemeElement.create + assert rx.ui.Theme is Theme + assert {"theme", "Theme"} <= set(dir(rx.ui)) + + +def test_theme_needs_the_plugin(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(get_config(), "plugins", []) + with pytest.raises(ConfigError) as error: + rx.ui.theme("hello", accent_color="red").render() + assert str(error.value) == ( + "rx.ui components need rx.plugins.UIPlugin() in rxconfig.py plugins." + ) + + +def test_theme_refuses_a_value_an_option_does_not_take(indigo_plugin: UIPlugin): + with pytest.raises(ThemeError) as error: + rx.ui.theme("hello", accent_color="indgo").render() # pyright: ignore [reportArgumentType] + assert str(error.value) == ( + 'rx.ui.theme: unknown accent_color "indgo". Did you mean "indigo"? The ' + 'values are "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".' + ) + + +def test_theme_held_in_state_cannot_be_applied(): + """Its code never reaches the StyleX compiler, which has the class names.""" + with pytest.raises(ThemeError) as error: + serialize(rx.ui.theme("hello", accent_color="red")) + assert str(error.value) == ( + "rx.ui.theme: a theme rendered from state cannot be applied: its code " + "is evaluated in the browser and never reaches the StyleX compiler. " + "Render the theme in a page, and what comes from state inside it." + ) diff --git a/tests/units/reflex_components_ui/parity/__init__.py b/tests/units/reflex_components_ui/parity/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/units/reflex_components_ui/parity/test_allowlist.py b/tests/units/reflex_components_ui/parity/test_allowlist.py new file mode 100644 index 00000000000..40520d3d614 --- /dev/null +++ b/tests/units/reflex_components_ui/parity/test_allowlist.py @@ -0,0 +1,221 @@ +"""Tests for the allowlist of the parity harness.""" + +import pytest +import reflex_components_ui +from ui_parity import allowlist +from ui_parity.allowlist import ( + Allowlist, + AllowlistError, + ApiEntry, + ContractEntry, + LookEntry, +) + +# The accepted differences the first component waves bring, in the file's form. +DOCUMENT = { + "api": [ + { + "component": "select", + "kind": "prop", + "names": ["position"], + "reason": "Select has no item-aligned positioning.", + } + ], + "contract": [ + { + "component": "dialog", + "step": "Tab stays inside the dialog", + "reason": "A native modal dialog lets Tab reach the browser's own UI.", + }, + { + "component": "switch", + "step": "Enter toggles", + "system": "rx.ui", + "engines": ["firefox", "webkit"], + "reason": "A switch toggles on Space but not Enter.", + }, + ], + "look": [ + { + "component": "tooltip", + "check": "pixels", + "cells": "*@open", + "reason": "Tooltips have no arrow.", + }, + { + "component": "select", + "check": "style", + "properties": ["top", "left"], + "engines": ["webkit"], + "reason": "Select has no item-aligned positioning.", + }, + ], +} + +ENTRIES = Allowlist( + api=( + ApiEntry( + component="select", + kind="prop", + names=("position",), + reason="Select has no item-aligned positioning.", + ), + ), + contract=( + ContractEntry( + component="dialog", + step="Tab stays inside the dialog", + system="rx.ui", + engines=(), + reason="A native modal dialog lets Tab reach the browser's own UI.", + ), + ContractEntry( + component="switch", + step="Enter toggles", + system="rx.ui", + engines=("firefox", "webkit"), + reason="A switch toggles on Space but not Enter.", + ), + ), + look=( + LookEntry( + component="tooltip", + check="pixels", + cells="*@open", + properties=(), + engines=(), + reason="Tooltips have no arrow.", + ), + LookEntry( + component="select", + check="style", + cells="*", + properties=("top", "left"), + engines=("webkit",), + reason="Select has no item-aligned positioning.", + ), + ), +) + + +def test_parse_reads_every_table_with_its_defaults(): + assert allowlist.parse(DOCUMENT) == ENTRIES + assert allowlist.parse({}) == Allowlist() + + +@pytest.mark.parametrize( + ("document", "message"), + [ + ({"pixels": []}, "Unknown allowlist tables: ['pixels']."), + ( + {"api": [{"component": "box", "kind": "prop", "names": ["a"]}]}, + ( + "[[api]] entry {'component': 'box', 'kind': 'prop', 'names': ['a']} " + "is missing: ['reason']." + ), + ), + ( + {"contract": [{"component": "box", "step": "s", "reason": " "}]}, + ( + "[[contract]] entry {'component': 'box', 'step': 's', 'reason': ' '} " + "needs a reason." + ), + ), + ( + { + "look": [ + {"component": "box", "check": "pixels", "cell": "*", "reason": "r"} + ] + }, + ( + "[[look]] entry {'component': 'box', 'check': 'pixels', 'cell': '*', " + "'reason': 'r'} has unknown keys: ['cell']." + ), + ), + ( + { + "api": [ + {"component": "box", "kind": "props", "names": [], "reason": "r"} + ] + }, + "[[api]] kind = \"props\" is not one of ['prop', 'type', 'event'].", + ), + ( + { + "contract": [ + {"component": "b", "step": "s", "system": "ui", "reason": "r"} + ] + }, + "[[contract]] system = \"ui\" is not one of ['rx', 'rx.ui'].", + ), + ( + {"look": [{"component": "box", "check": "color", "reason": "r"}]}, + "[[look]] check = \"color\" is not one of ['pixels', 'style', 'a11y'].", + ), + ], +) +def test_parse_rejects_what_it_does_not_understand(document: dict, message: str): + with pytest.raises(AllowlistError) as error: + allowlist.parse(document) + assert str(error.value) == message + + +def test_contract_entry_covers_its_system_and_engines(): + everywhere, some = ENTRIES.contract + step = "Tab stays inside the dialog" + assert [ + everywhere.covers("dialog", step, system, engine) + for system in ("rx.ui", "rx") + for engine in ("chromium", "webkit") + ] == [True, True, False, False] + assert everywhere.covers("dialog", "Escape closes", "rx.ui", "chromium") is False + assert everywhere.covers("select", step, "rx.ui", "chromium") is False + assert [ + some.covers("switch", "Enter toggles", "rx.ui", engine) + for engine in ("chromium", "firefox", "webkit") + ] == [False, True, True] + + +def test_look_entry_covers_its_check_cells_and_engines(): + arrow, position = ENTRIES.look + assert [ + arrow.covers("tooltip", check, cell, "firefox") + for check in ("pixels", "style") + for cell in ("base@open", "side-top@dark@open", "base") + ] == [True, True, False, False, False, False] + assert [ + position.covers("select", "style", "base", engine) + for engine in ("chromium", "webkit") + ] == [False, True] + + +def test_differences_markdown_lists_every_entry_by_component(): + assert allowlist.differences_markdown(ENTRIES) == ( + "### dialog\n" + "\n" + '- behaviour, `rx.ui`, "Tab stays inside the dialog": A native modal ' + "dialog lets Tab reach the browser's own UI.\n" + "\n" + "### select\n" + "\n" + "- prop `position`: Select has no item-aligned positioning.\n" + "- style in webkit, `top`, `left`: Select has no item-aligned positioning.\n" + "\n" + "### switch\n" + "\n" + '- behaviour, `rx.ui` in firefox, webkit, "Enter toggles": A switch ' + "toggles on Space but not Enter.\n" + "\n" + "### tooltip\n" + "\n" + "- pixels, *@open: Tooltips have no arrow." + ) + + +def test_committed_allowlist_names_only_rx_ui_components(): + components = set(reflex_components_ui.__all__) + entries = allowlist.load() + listed = { + entry.component for entry in (*entries.api, *entries.contract, *entries.look) + } + assert sorted(listed - components) == [] diff --git a/tests/units/reflex_components_ui/parity/test_contract.py b/tests/units/reflex_components_ui/parity/test_contract.py new file mode 100644 index 00000000000..56c6a8f66c1 --- /dev/null +++ b/tests/units/reflex_components_ui/parity/test_contract.py @@ -0,0 +1,96 @@ +"""Tests for the contract declaration that need no browser.""" + +import pytest +from ui_parity.contract import ( + HYDRATED, + HYDRATION_STEP, + NO_JAVASCRIPT, + SERVER, + Contract, + Run, + ServerElement, + ServerHtml, +) +from ui_parity.systems import CANDIDATE + +DOCUMENT = ServerHtml( + '
before' + 'in
side
after
' + '

outside

' +) + + +def test_server_html_finds_an_element_and_its_text(): + assert DOCUMENT.element("a") == ServerElement( + tag="div", attributes={"id": "a", "class": "x y"}, text="beforeinside after" + ) + assert DOCUMENT.element("inner") == ServerElement( + tag="span", attributes={"id": "inner"}, text="inside" + ) + # An element that cannot hold text does not take what follows it. + assert DOCUMENT.element("field") == ServerElement( + tag="input", attributes={"id": "field", "disabled": None, "value": "v"} + ) + + +def test_server_html_fails_for_an_element_the_server_did_not_render(): + with pytest.raises(AssertionError) as error: + DOCUMENT.element("missing") + assert str(error.value) == 'the server HTML has no element with id "missing"' + + +def test_contract_starts_with_the_hydration_step_and_keeps_declared_order(): + contract = Contract(component="switch", render=lambda namespace: None) + + @contract.step("is a checkbox in the server render", on=SERVER) + def server(run: Run) -> None: ... + + @contract.step("is checked with JavaScript disabled", on=NO_JAVASCRIPT) + def without_javascript(run: Run) -> None: ... + + @contract.step("Space toggles") + def space(run: Run) -> None: ... + + assert [(step.name, step.on) for step in contract.steps] == [ + (HYDRATION_STEP, HYDRATED), + ("is a checkbox in the server render", SERVER), + ("is checked with JavaScript disabled", NO_JAVASCRIPT), + ("Space toggles", HYDRATED), + ] + assert [step.check for step in contract.steps[1:]] == [ + server, + without_javascript, + space, + ] + # Each contract has steps of its own. + assert len(Contract(component="box", render=lambda namespace: None).steps) == 1 + + +def test_contract_rejects_a_duplicate_step_and_an_unknown_page(): + contract = Contract(component="switch", render=lambda namespace: None) + with pytest.raises(ValueError) as error: + contract.step(HYDRATION_STEP) + assert str(error.value) == ( + 'switch: two steps are named "hydrates with no warnings".' + ) + with pytest.raises(ValueError) as error: + contract.step("works offline", on="offline") + assert str(error.value) == "switch: a step cannot run on 'offline'." + + +def test_hydration_step_fails_on_what_the_browser_reported(): + (step,) = Contract(component="box", render=lambda namespace: None).steps + run = Run(component="box", system=CANDIDATE, engine="chromium", server=DOCUMENT) + step.check(run) + run.problems.append("console error: Minified React error #418") + with pytest.raises(AssertionError): + step.check(run) + + +def test_server_step_has_no_page(): + run = Run(component="box", system=CANDIDATE, engine="chromium", server=DOCUMENT) + with pytest.raises(RuntimeError) as error: + run.page + assert str(error.value) == ( + "A step on 'server' has no page: read run.server instead." + ) diff --git a/tests/units/reflex_components_ui/parity/test_diff.py b/tests/units/reflex_components_ui/parity/test_diff.py new file mode 100644 index 00000000000..1f7d940f3ee --- /dev/null +++ b/tests/units/reflex_components_ui/parity/test_diff.py @@ -0,0 +1,130 @@ +"""Tests for the image diff of the parity harness.""" + +from collections.abc import Callable + +import numpy as np +import pytest +from PIL import Image +from ui_parity.diff import ANTIALIASED, DIFFERENT, ImageDiff, diff_images + +WHITE = (255, 255, 255) +BLACK = (0, 0, 0) +GRAY = (128, 128, 128) +# How the diff image draws black: the reference faded to a tenth. +FADED_BLACK = (230, 230, 230) + +Color = tuple[int, int, int] + + +def fixture(width: int, height: int, color: Callable[[int, int], Color]) -> Image.Image: + """Draw a fixture image. + + Args: + width: The width of the image. + height: The height of the image. + color: The color of the pixel at a column and a row. + + Returns: + The image. + """ + image = Image.new("RGB", (width, height)) + image.putdata([color(x, y) for y in range(height) for x in range(width)]) + return image + + +def pixels(image: Image.Image) -> list[Color]: + """Read the colors of an image. + + Args: + image: The image. + + Returns: + The color of each pixel, row by row. + """ + return [tuple(color) for row in np.asarray(image).tolist() for color in row] + + +def square(left: int) -> Image.Image: + """Draw a black square of 4 pixels on a white image of 10. + + Args: + left: The first column of the square. + + Returns: + The image. + """ + return fixture( + 10, + 10, + lambda x, y: BLACK if left <= x < left + 4 and 2 <= y < 6 else WHITE, + ) + + +def numbers(diff: ImageDiff) -> tuple[int, int, int, int]: + """Get the counts of a diff. + + Args: + diff: The diff. + + Returns: + The width, the height, the differing and the anti-aliased pixels. + """ + return (diff.width, diff.height, diff.differing, diff.antialiased) + + +def test_equal_images_do_not_differ(): + diff = diff_images(square(2), square(2), threshold=0) + assert numbers(diff) == (10, 10, 0, 0) + assert diff.ratio == 0 + # The reference, faded, and no mark. + assert pixels(diff.image) == [ + FADED_BLACK if 2 <= x < 6 and 2 <= y < 6 else WHITE + for y in range(10) + for x in range(10) + ] + + +def test_moved_shape_differs_where_it_left_and_where_it_arrived(): + diff = diff_images(square(2), square(3)) + assert numbers(diff) == (10, 10, 8, 0) + assert diff.ratio == pytest.approx(0.08) + assert pixels(diff.image) == [ + DIFFERENT + if x in (2, 6) and 2 <= y < 6 + else FADED_BLACK + if 2 <= x < 6 and 2 <= y < 6 + else WHITE + for y in range(10) + for x in range(10) + ] + + +def test_antialiased_edge_is_set_aside(): + hard = fixture(7, 7, lambda x, y: BLACK if x < 3 else WHITE) + soft = fixture(7, 7, lambda x, y: BLACK if x < 3 else GRAY if x == 3 else WHITE) + diff = diff_images(hard, soft) + assert numbers(diff) == (7, 7, 0, 7) + assert pixels(diff.image) == [ + FADED_BLACK if x < 3 else ANTIALIASED if x == 3 else WHITE + for y in range(7) + for x in range(7) + ] + # The same pixels count when anti-aliasing is not ignored. + assert numbers(diff_images(hard, soft, include_antialiasing=True)) == (7, 7, 7, 0) + + +def test_threshold_is_the_color_distance_that_counts(): + gray = Image.new("RGB", (4, 4), (100, 100, 100)) + near = Image.new("RGB", (4, 4), (102, 102, 102)) + far = Image.new("RGB", (4, 4), (103, 103, 103)) + assert numbers(diff_images(gray, near, threshold=0)) == (4, 4, 16, 0) + assert numbers(diff_images(gray, near, threshold=0.01)) == (4, 4, 0, 0) + assert numbers(diff_images(gray, far, threshold=0.01)) == (4, 4, 16, 0) + + +def test_images_of_different_sizes_differ_where_only_one_reaches(): + diff = diff_images(Image.new("RGB", (4, 4), WHITE), Image.new("RGB", (6, 5), WHITE)) + assert numbers(diff) == (6, 5, 14, 0) + assert pixels(diff.image) == [ + WHITE if x < 4 and y < 4 else DIFFERENT for y in range(5) for x in range(6) + ] diff --git a/tests/units/reflex_components_ui/parity/test_look.py b/tests/units/reflex_components_ui/parity/test_look.py new file mode 100644 index 00000000000..14d8c2b9f5d --- /dev/null +++ b/tests/units/reflex_components_ui/parity/test_look.py @@ -0,0 +1,207 @@ +"""Tests for the comparison of a matrix that need no browser.""" + +from pathlib import Path + +import pytest +from ui_parity.allowlist import Allowlist, LookEntry +from ui_parity.look import ( + CellResult, + MatrixResult, + StyleDifference, + _crop, + _Excuses, + _style_differences, + split_a11y, +) +from ui_parity.matrix import Matrix + + +def test_split_a11y_gives_each_frame_its_tree(): + snapshot = ( + "- main:\n" + ' - group "reference:base":\n' + ' - button "Save"\n' + ' - group "candidate:base":\n' + ' - button "Save":\n' + " - img\n" + ' - group "reference:size-1"\n' + ' - group "candidate:size-1": text\n' + " - paragraph: between\n" + " - text: not of a frame\n" + ' - group "candidate:base@x":\n' + " - text: after\n" + "- contentinfo" + ) + assert split_a11y(snapshot) == { + ("reference", "base"): '- button "Save"', + ("candidate", "base"): '- button "Save":\n - img', + ("reference", "size-1"): "", + ("candidate", "size-1"): "text", + ("candidate", "base@x"): "- text: after", + } + + +def frame(stage: list[float], target: list[float]) -> dict: + """Describe a frame as the page reports it. + + Args: + stage: The left, top, width and height of the frame. + target: The same of its element. + + Returns: + The frame. + """ + return {"stage": stage, "target": target} + + +def test_crop_is_the_union_of_both_elements_and_a_margin_within_the_frame(): + matrix = Matrix(component="button", stage=(240, 120), margin=8) + reference = frame([8, 8, 240, 120], [24, 24, 80.5, 32]) + candidate = frame([256, 8, 240, 120], [272, 24, 84, 30.25]) + # Each element starts 16 pixels into its frame; the wider and the taller + # one set the far edges, rounded out to whole pixels. + assert _crop(matrix, reference, candidate) == (8, 8, 108, 56) + # An element that fills its frame is cropped by the frame. + full = frame([8, 8, 240, 120], [8, 8, 240, 120]) + assert _crop(matrix, full, full) == (0, 0, 240, 120) + whole = Matrix(component="tooltip", stage=(300, 200), crop="stage") + assert _crop(whole, reference, candidate) == (0, 0, 300, 200) + + +def test_style_differences_name_the_part_and_both_values(): + reference = { + "": {"color": "rgb(0, 0, 0)", "height": "32px"}, + "thumb": {"width": "16px"}, + "arrow": {"width": "8px"}, + } + candidate = { + "": {"color": "rgb(0, 0, 0)", "height": "30px"}, + "thumb": {"width": "14px"}, + } + assert _style_differences(reference, candidate) == [ + StyleDifference("", "height", "32px", "30px"), + StyleDifference("arrow", "(element)", "present", None), + StyleDifference("thumb", "width", "16px", "14px"), + ] + assert _style_differences(reference, reference) == [] + + +def result(cell: str, differing: int, **differences) -> CellResult: + """Build the result of a cell of 100 by 50 pixels. + + Args: + cell: The id of the cell. + differing: The pixels that differ. + differences: The other fields of the result. + + Returns: + The result. + """ + fields = { + "styles": [], + "a11y": None, + "allowed": [], + "images": { + kind: f"chromium/button/{cell}.{kind}.png" + for kind in ("reference", "candidate", "diff") + }, + **differences, + } + return CellResult( + cell=cell, + width=100, + height=50, + differing=differing, + antialiased=0, + tolerance=0.005, + **fields, + ) + + +def test_problems_say_which_check_failed_and_by_how_much(): + assert result("base", 25).problems == [] + assert result("base", 26).ratio == pytest.approx(0.0052) + assert result("base", 26).problems == [ + "26 of 5000 pixels differ (0.52%, 0.50% allowed)" + ] + assert result("base", 26, pixels_allowed=True).problems == [] + assert result( + "base", + 0, + styles=[ + StyleDifference("", "height", "32px", "30px"), + StyleDifference("thumb", "width", "16px", None), + ], + a11y=('- button "Save"', "- text: Save"), + ).problems == [ + "height: rx '32px', rx.ui '30px'", + "thumb width: rx '16px', rx.ui None", + "accessibility tree: rx '- button \"Save\"', rx.ui '- text: Save'", + ] + + +def test_failures_name_the_cell_and_where_its_images_are(): + stale = LookEntry( + component="button", + check="pixels", + cells="*@hover", + properties=(), + engines=(), + reason="The hover is lighter.", + ) + matrix = MatrixResult( + component="button", + engine="chromium", + cells=[ + result("base", 0), + result( + "size-1@hover", + 400, + styles=[StyleDifference("", "height", "32px", "30px")], + ), + ], + seconds=1.5, + passes=1, + stale=[stale], + ) + assert matrix.failures(Path("/report")) == [ + ( + "button [chromium] cell size-1@hover:\n" + " - 400 of 5000 pixels differ (8.00%, 0.50% allowed)\n" + " - height: rx '32px', rx.ui '30px'\n" + " images: /report/chromium/button/size-1@hover.{reference,candidate,diff}.png" + ), + ( + "button [chromium]: nothing differs as the allowlist.toml entry says " + "(pixels, cells '*@hover': \"The hover is lighter.\"). Remove the entry." + ), + ] + + +def test_excuses_match_by_check_cell_and_property_and_report_the_unused(): + def entry(check: str, **fields) -> LookEntry: + return LookEntry(**{ + "component": "select", + "check": check, + "cells": "*", + "properties": (), + "engines": (), + "reason": check, + **fields, + }) + + position = entry("style", properties=("top",), reason="position") + arrow = entry("pixels", cells="*@open", reason="arrow") + webkit = entry("a11y", engines=("webkit",), reason="webkit") + other = entry("pixels", component="tooltip", reason="other") + unused = entry("a11y", reason="unused") + excuses = _Excuses( + Allowlist(look=(position, arrow, webkit, other, unused)), "select", "chromium" + ) + assert excuses.entries == [position, arrow, unused] + assert excuses.reasons("style", "base", "top") == ["position"] + assert excuses.reasons("style", "base", "left") == [] + assert excuses.reasons("pixels", "base") == [] + assert excuses.stale() == [arrow, unused] + assert excuses.reasons("pixels", "base@open") == ["arrow"] + assert excuses.stale() == [unused] diff --git a/tests/units/reflex_components_ui/parity/test_matrix.py b/tests/units/reflex_components_ui/parity/test_matrix.py new file mode 100644 index 00000000000..62eee7c46fd --- /dev/null +++ b/tests/units/reflex_components_ui/parity/test_matrix.py @@ -0,0 +1,95 @@ +"""Tests for the matrix declaration of the parity harness.""" + +from types import SimpleNamespace + +from ui_parity.matrix import Cell, Matrix, label + + +def test_label_names_a_value_in_a_cell_id(): + assert [label(value) for value in ("solid", True, 3, "Focus Visible!")] == [ + "solid", + "true", + "3", + "focus-visible", + ] + + +def test_cells_cross_some_dimensions_and_sweep_the_rest(): + matrix = Matrix( + component="button", + base={"variant": "solid", "size": "2", "children": "Save"}, + cross={"variant": ["solid", "soft"], "size": ["1", "2"]}, + sweep={ + "color_scheme": ["tomato", "indigo"], + "size": {"responsive": {"initial": "1", "md": "3"}}, + "appearance": ["dark"], + "state": ["hover"], + "viewport": [520], + }, + groups=[{"variant": ["soft"], "state": ["hover", "active"]}], + ) + cells = matrix.cells() + assert [cell.id for cell in cells] == [ + "base", + "size-1", + "size-1_variant-soft", + "variant-soft", + "color-scheme-tomato", + "color-scheme-indigo", + "size-responsive", + "base@dark", + "base@hover", + "base@520", + "variant-soft@hover", + "variant-soft@active", + ] + assert cells[2] == Cell( + props_id="size-1_variant-soft", + props={"variant": "soft", "size": "1", "children": "Save"}, + appearance="light", + state="rest", + viewport=1280, + ) + assert cells[6].props == { + "variant": "solid", + "size": {"initial": "1", "md": "3"}, + "children": "Save", + } + assert cells[-1] == Cell( + props_id="variant-soft", + props={"variant": "soft", "size": "2", "children": "Save"}, + appearance="light", + state="active", + viewport=1280, + ) + # A page renders an element once, however many environments read it. + assert list(matrix.rendered()) == [ + "base", + "size-1", + "size-1_variant-soft", + "variant-soft", + "color-scheme-tomato", + "color-scheme-indigo", + "size-responsive", + ] + assert matrix.rendered()["variant-soft"] == { + "variant": "soft", + "size": "2", + "children": "Save", + } + + +def test_create_calls_the_component_of_the_namespace_unless_told_how(): + namespace = SimpleNamespace(button=lambda **props: ("button", props)) + assert Matrix(component="button").create(namespace, {"size": "1"}) == ( + "button", + {"size": "1"}, + ) + rendered = Matrix( + component="button", + render=lambda namespace, props: namespace.button(text="Save", **props), + ) + assert rendered.create(namespace, {"size": "1"}) == ( + "button", + {"text": "Save", "size": "1"}, + ) diff --git a/tests/units/reflex_components_ui/parity/test_report.py b/tests/units/reflex_components_ui/parity/test_report.py new file mode 100644 index 00000000000..d6de0487e87 --- /dev/null +++ b/tests/units/reflex_components_ui/parity/test_report.py @@ -0,0 +1,145 @@ +"""Tests for the report of a parity run.""" + +import json +from pathlib import Path + +from ui_parity import report +from ui_parity.look import CellResult, MatrixResult, StyleDifference + + +def matrix(component: str, engine: str, differing: int) -> MatrixResult: + """Build the result of a matrix of one cell. + + Args: + component: The component. + engine: The browser engine. + differing: The pixels of the cell that differ. + + Returns: + The result. + """ + return MatrixResult( + component=component, + engine=engine, + cells=[ + CellResult( + cell="size-1@hover", + width=100, + height=50, + differing=differing, + antialiased=3, + tolerance=0.005, + styles=[StyleDifference("", "height", "32px", "30px")] + if differing + else [], + a11y=None, + allowed=["Tooltips have arrow."], + images={ + kind: f"{engine}/{component}/size-1@hover.{kind}.png" + for kind in ("reference", "candidate", "diff") + }, + ) + ], + seconds=1.5, + passes=1, + stale=[], + ) + + +ENTRY = { + "component": "button", + "engine": "chromium", + "seconds": 1.5, + "passes": 1, + "stale": [], + "cells": [ + { + "cell": "size-1@hover", + "width": 100, + "height": 50, + "differing": 400, + "antialiased": 3, + "ratio": 0.08, + "tolerance": 0.005, + "styles": [ + { + "part": "", + "property": "height", + "reference": "32px", + "candidate": "30px", + } + ], + "a11y": None, + "allowed": ["Tooltips have arrow."], + "problems": [ + "400 of 5000 pixels differ (8.00%, 0.50% allowed)", + "height: rx '32px', rx.ui '30px'", + ], + "images": { + "reference": "chromium/button/size-1@hover.reference.png", + "candidate": "chromium/button/size-1@hover.candidate.png", + "diff": "chromium/button/size-1@hover.diff.png", + }, + } + ], +} + + +def image(kind: str) -> str: + """Get the table cell the report shows an image of the entry in. + + Args: + kind: Which image: the reference, the candidate or the diff. + + Returns: + The HTML of the cell. + """ + path = f"chromium/button/size-1@hover.{kind}.png" + return ( + f'{kind}' + ) + + +PAGE = ( + '' + f"rx.ui parity" + "

rx.ui parity with Radix Themes

" + "

1 matrices, 1 cells, 1 failing, 1.5 s

" + '" + '

button · chromium

' + "

1 cells, 1 failing, 1 page loads, 1.5 s

" + "" + "" + '' + '' + f"{image('reference')}{image('candidate')}{image('diff')}" + "" + "
cellpixelsrx (Radix)rx.uidiffdifferences
size-1@hover400 / 5000
8.00%
3 anti-aliased
400 of 5000 pixels differ (8.00%, 0.50% allowed)\n"
+    "height: rx '32px', rx.ui '30px'\n"
+    "allowed: Tooltips have <no> arrow.
" +) + + +def test_entry_keeps_the_numbers_of_every_cell(): + assert report.entry(matrix("button", "chromium", 400)) == ENTRY + + +def test_render_shows_each_cell_with_its_images_and_differences(): + assert report.render([ENTRY]) == PAGE + + +def test_write_adds_a_matrix_and_replaces_its_earlier_run(tmp_path: Path): + index = report.write(tmp_path, matrix("button", "webkit", 0)) + assert index == tmp_path / "index.html" + report.write(tmp_path, matrix("button", "chromium", 0)) + report.write(tmp_path, matrix("box", "webkit", 0)) + report.write(tmp_path, matrix("button", "chromium", 400)) + results = json.loads((tmp_path / "results.json").read_text()) + assert [(entry["component"], entry["engine"]) for entry in results] == [ + ("box", "webkit"), + ("button", "chromium"), + ("button", "webkit"), + ] + assert results[1] == ENTRY + assert index.read_text(encoding="utf-8") == report.render(results) diff --git a/tests/units/reflex_components_ui/style/__init__.py b/tests/units/reflex_components_ui/style/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/units/reflex_components_ui/style/fixtures/component_errors.py.txt b/tests/units/reflex_components_ui/style/fixtures/component_errors.py.txt new file mode 100644 index 00000000000..a759ce7050b --- /dev/null +++ b/tests/units/reflex_components_ui/style/fixtures/component_errors.py.txt @@ -0,0 +1,13 @@ +"""Styles of a component that must not type-check: every call below is an error.""" + +from reflex_components_ui.layout.box import box + +box(style={"paddng": "1em"}) + +box(style={"display": "flx"}) + +box(style={"_hover": {"colr": "red"}}) + +box(style=[{"padding": "1em"}, {"display": "flx"}]) + +box(style="padding: 1em") diff --git a/tests/units/reflex_components_ui/style/fixtures/component_valid.py.txt b/tests/units/reflex_components_ui/style/fixtures/component_valid.py.txt new file mode 100644 index 00000000000..055c90350e8 --- /dev/null +++ b/tests/units/reflex_components_ui/style/fixtures/component_valid.py.txt @@ -0,0 +1,32 @@ +"""Styles of a component as users write them: none of the calls is an error.""" + +import reflex as rx +from reflex_components_ui.layout.box import box + + +class State(rx.State): + """State the styles are bound to.""" + + width: rx.Field[str] = rx.field("1em") + styles: rx.Field[dict[str, str]] = rx.field(default_factory=dict) + + +box(style={"padding": "1em"}) + +box(style={"display": "flex", "width": State.width, "margin_top": 2}) + +box(style={"_hover": {"color": "red"}, ":focus-visible": {"outline_width": "2px"}}) + +box(style={"width": ["100%", "50%"], "color": rx.color("ruby", 9)}) + +box(style={"padding": rx.breakpoints(initial="1em", md="2em")}) + +box(style=[{"padding": "1em"}, {"display": "flex"}]) + +box(style=State.styles) + +box(style=rx.breakpoints(initial={"padding": "1em"}, md={"padding": "2em"})) + +# Keyword arguments stay open, as data_* and aria_* come through them: a +# misspelt property there is an error of the compile, not of the type checker. +box(padding="1em", data_state="open", aria_label="Box", paddng="1em") diff --git a/tests/units/reflex_components_ui/style/fixtures/style_errors.py.txt b/tests/units/reflex_components_ui/style/fixtures/style_errors.py.txt new file mode 100644 index 00000000000..9bf2700fa0c --- /dev/null +++ b/tests/units/reflex_components_ui/style/fixtures/style_errors.py.txt @@ -0,0 +1,32 @@ +"""Styles that must not type-check: every assignment below is an error.""" + +import reflex as rx +from reflex_components_ui.style import ComponentStyles, CompoundStyle, StyleProps + +unknown_property: StyleProps = {"paddng": "1em"} + +unknown_keyword: StyleProps = {"display": "flx"} + +keyword_as_number: StyleProps = {"position": 1} + +unknown_keyword_under_a_condition: StyleProps = {"display": {":hover": "flx"}} + +unknown_keyword_at_a_breakpoint: StyleProps = {"display": ["none", "flx"]} + +unknown_property_in_a_block: StyleProps = {"_hover": {"colr": "red"}} + +unknown_pseudo_class: StyleProps = {"_hovr": {"color": "red"}} + +component_as_value: StyleProps = {"color": rx.text("red")} + +unknown_table_key: ComponentStyles = {"variant": {"size": {"1": {"height": "1em"}}}} + +unknown_property_in_a_variant: ComponentStyles = { + "variants": {"size": {"1": {"heght": "1em"}}}, +} + +unknown_keyword_in_a_part: ComponentStyles = { + "parts": {"thumb": {"base": {"visibility": "invisible"}}}, +} + +compound_without_props: CompoundStyle = {"style": {"color": "red"}} diff --git a/tests/units/reflex_components_ui/style/fixtures/style_valid.py.txt b/tests/units/reflex_components_ui/style/fixtures/style_valid.py.txt new file mode 100644 index 00000000000..73f7d63e82c --- /dev/null +++ b/tests/units/reflex_components_ui/style/fixtures/style_valid.py.txt @@ -0,0 +1,115 @@ +"""Styles that type-check: what Reflex users write today and what rx.ui adds.""" + +import reflex as rx +from reflex_components_ui.style import ComponentStyles, CompoundStyle, StyleProps + + +class State(rx.State): + """State whose fields are bound to styles.""" + + width: rx.Field[int] = rx.field(320) + color: rx.Field[str] = rx.field("tomato") + hidden: rx.Field[bool] = rx.field(False) + + +literals: StyleProps = { + "display": "flex", + "flex_direction": "column", + "align_items": "center", + "justify_content": "space-between", + "position": "relative", + "overflow": "hidden", + "padding": "1em", + "margin": "0 auto", + "width": "100%", + "max_width": 960, + "line_height": 1.5, + "opacity": "0.8", + "z_index": "10", + "font_weight": "bold", + "border": "1px solid #eaeaea", + "border_radius": "0.5em", + "box_shadow": "rgba(0, 0, 0, 0.1) 0px 4px 12px", + "background_image": "linear-gradient(271.68deg, #EE756A 0.75%, #756AEE 88.52%)", + "transition": "all 0.2s ease-in-out", + "cursor": "pointer", +} + +reflex_keys: StyleProps = { + "bg": "white", + "bg_color": rx.color("gray", 2), + "padding_x": "1em", + "padding_y": ["0.5em", "1em"], + "margin_x": "auto", + "margin_y": 4, +} + +colors: StyleProps = { + "color": rx.color("accent", 11), + "background_color": rx.color("ruby", 3, alpha=True), + "border_color": rx.color(State.color, 6), + "outline_color": "var(--accent-8)", +} + +state: StyleProps = { + "width": State.width, + "height": f"{State.width}px", + "color": State.color, + "display": rx.cond(State.hidden, "none", "block"), + "opacity": rx.cond(State.hidden, 0, 1), +} + +responsive: StyleProps = { + "font_size": ["1em", "1.25em", "1.5em"], + "display": ["none", "none", "flex"], + "flex_direction": rx.breakpoints(initial="column", md="row"), + "padding": rx.breakpoints(initial="1em", sm="2em", lg="4em"), + "width": {"initial": "100%", "md": "50%"}, +} + +conditions: StyleProps = { + "color": {"default": "black", ":hover": "blue", "[data-disabled]": "gray"}, + "display": {"default": "block", "@media print": "none"}, + "_hover": {"background_color": rx.color("accent", 4), "cursor": "pointer"}, + "_focus_visible": {"outline": "2px solid", "outline_offset": "2px"}, + "_before": {"content": '""', "position": "absolute"}, + "_placeholder": {"color": rx.color("gray", 9)}, + ":active": {"transform": "scale(0.98)"}, + "::selection": {"background_color": "highlight"}, + "::-webkit-scrollbar": {"display": "none"}, + "_disabled": {"_hover": {"cursor": "not-allowed"}}, +} + +BUTTON: ComponentStyles = { + "base": {"display": "inline-flex", "align_items": "center", "font_weight": "500"}, + "variants": { + "variant": { + "solid": { + "background_color": { + "default": "var(--accent-9)", + ":hover": "var(--accent-10)", + }, + "color": "var(--accent-contrast)", + }, + "soft": { + "background_color": rx.color("accent", 3, alpha=True), + "color": rx.color("accent", 11, alpha=True), + }, + }, + "size": { + "1": {"height": "var(--space-5)"}, + "2": {"height": "var(--space-6)"}, + }, + }, + "compound": [ + {"props": {"variant": "solid", "size": "2"}, "style": {"font_weight": "700"}}, + ], + "parts": { + "icon": { + "base": {"flex_shrink": 0}, + "variants": {"size": {"2": {"width": "1.25em"}}}, + }, + }, +} + +compound: CompoundStyle = {"props": {"size": "1"}, "style": {"padding": 0}} diff --git a/tests/units/reflex_components_ui/style/test_css_props.py b/tests/units/reflex_components_ui/style/test_css_props.py new file mode 100644 index 00000000000..d8ba4df090f --- /dev/null +++ b/tests/units/reflex_components_ui/style/test_css_props.py @@ -0,0 +1,182 @@ +"""Tests for what a type checker makes of the generated style types.""" + +from collections.abc import Callable + +Diagnostics = list[tuple[int, str, str]] + + +def test_valid_styles_type_check(pyright: Callable[[str], Diagnostics]): + """What Reflex users write today, and a style table, raise nothing.""" + assert pyright("style_valid") == [] + + +def test_invalid_styles_are_type_errors(pyright: Callable[[str], Diagnostics]): + """A misspelt property, keyword or table key is caught before compiling.""" + assert pyright("style_errors") == EXPECTED_ERRORS + + +EXPECTED_ERRORS: Diagnostics = [ + ( + 6, + "reportAssignmentType", + ( + 'Type "dict[str, str]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0"paddng" is an undefined item in type "StyleProps"' + ), + ), + ( + 8, + "reportAssignmentType", + ( + 'Type "dict[str, str]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0Type "Literal[\'flx\']" is not assignable to type "_Value[_Display | ' + '_StrVar]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'flx\']" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'flx\']" is not assignable to "Sequence[_Display | ' + '_StrVar]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0Type parameter "_T_co@Sequence" is covariant, but "str" is ' + 'not a subtype of "_Display | _StrVar"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0Type "str" is not assignable to type "_Display | ' + '_StrVar"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to type ' + "\"Literal['-webkit-box']\"\n" + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to type ' + "\"Literal['block']\"" + ), + ), + ( + 10, + "reportAssignmentType", + ( + 'Type "dict[str, int]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0Type "Literal[1]" is not assignable to type "_Value[_Position | _StrVar]"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Sequence[_Position | _StrVar]"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Breakpoints[Any, Any]"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Mapping[str, _Position | _StrVar ' + '| Mapping[str, _Position | _StrVar]]"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Literal[\'absolute\']"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Literal[\'fixed\']"\n' + '\xa0\xa0\xa0\xa0"Literal[1]" is not assignable to "Literal[\'inherit\']"' + ), + ), + ( + 12, + "reportAssignmentType", + ( + 'Type "dict[str, dict[str, str]]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0Type "dict[str, str]" is not assignable to type "_Value[_Display | ' + '_StrVar]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Sequence[_Display | ' + '_StrVar]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Breakpoints[Any, Any]"\n' + '\xa0\xa0\xa0\xa0"dict[str, str]" is not assignable to "Mapping[str, _Display | ' + '_StrVar | Mapping[str, _Display | _StrVar]]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0Type parameter "_VT_co@Mapping" is covariant, but "str" is ' + 'not a subtype of "_Display | _StrVar | Mapping[str, _Display | _StrVar]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0Type "str" is not assignable to type "_Display | ' + '_StrVar | Mapping[str, _Display | _StrVar]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to "Var[str]"' + ), + ), + ( + 14, + "reportAssignmentType", + ( + 'Type "dict[str, list[str]]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0Type "Literal[\'flx\']" is not assignable to type "_Display | _StrVar"\n' + '\xa0\xa0\xa0\xa0"Literal[\'flx\']" is not assignable to "Var[str]"\n' + "\xa0\xa0\xa0\xa0\"Literal['flx']\" is not assignable to type " + "\"Literal['-webkit-box']\"\n" + "\xa0\xa0\xa0\xa0\"Literal['flx']\" is not assignable to type \"Literal['block']\"\n" + "\xa0\xa0\xa0\xa0\"Literal['flx']\" is not assignable to type " + "\"Literal['contents']\"\n" + "\xa0\xa0\xa0\xa0\"Literal['flx']\" is not assignable to type \"Literal['flex']\"\n" + "\xa0\xa0\xa0\xa0\"Literal['flx']\" is not assignable to type " + "\"Literal['flow-root']\"\n" + "\xa0\xa0\xa0\xa0\"Literal['flx']\" is not assignable to type \"Literal['grid']\"" + ), + ), + ( + 16, + "reportAssignmentType", + ( + 'Type "dict[str, dict[str, str]]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0"colr" is an undefined item in type "StyleProps"' + ), + ), + ( + 18, + "reportAssignmentType", + ( + 'Type "dict[str, dict[str, str]]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0"_hovr" is an undefined item in type "StyleProps"' + ), + ), + ( + 20, + "reportAssignmentType", + ( + 'Type "dict[str, Text]" is not assignable to declared type "StyleProps"\n' + '\xa0\xa0Type "Text" is not assignable to type "_Value[_Color]"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "str"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "Color"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "Var[Color]"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "Sequence[_Color]"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "Breakpoints[Any, Any]"\n' + '\xa0\xa0\xa0\xa0"Text" is not assignable to "Mapping[str, _Color | Mapping[str, ' + '_Color]]"' + ), + ), + ( + 22, + "reportAssignmentType", + ( + 'Type "dict[str, dict[str, dict[str, dict[str, str]]]]" is not assignable to ' + 'declared type "ComponentStyles"\n' + '\xa0\xa0"variant" is an undefined item in type "ComponentStyles"' + ), + ), + ( + 25, + "reportAssignmentType", + ( + 'Type "dict[str, dict[str, dict[str, dict[str, str]]]]" is not assignable to ' + 'declared type "ComponentStyles"\n' + '\xa0\xa0"heght" is an undefined item in type "StyleProps"' + ), + ), + ( + 29, + "reportAssignmentType", + ( + 'Type "dict[str, dict[str, dict[str, dict[str, str]]]]" is not assignable to ' + 'declared type "ComponentStyles"\n' + '\xa0\xa0Type "Literal[\'invisible\']" is not assignable to type "_Value[_Visibility ' + '| _StrVar]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'invisible\']" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0"Literal[\'invisible\']" is not assignable to "Sequence[_Visibility ' + '| _StrVar]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0Type parameter "_T_co@Sequence" is covariant, but "str" is ' + 'not a subtype of "_Visibility | _StrVar"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0Type "str" is not assignable to type "_Visibility | ' + '_StrVar"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to "Var[str]"\n' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to type ' + "\"Literal['collapse']\"\n" + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0"str" is not assignable to type ' + "\"Literal['hidden']\"" + ), + ), + ( + 32, + "reportAssignmentType", + ( + 'Type "dict[str, StyleProps]" is not assignable to declared type "CompoundStyle"\n' + '\xa0\xa0"props" is required in "CompoundStyle"' + ), + ), +] diff --git a/tests/units/reflex_components_ui/style/test_emit.py b/tests/units/reflex_components_ui/style/test_emit.py new file mode 100644 index 00000000000..7cc5e638a7a --- /dev/null +++ b/tests/units/reflex_components_ui/style/test_emit.py @@ -0,0 +1,610 @@ +"""Tests for reflex_components_ui.style.emit.""" + +from typing import Any + +import pytest +from reflex_base.vars.base import Var +from reflex_components_ui.style import ComponentStyles, StyleError, merge +from reflex_components_ui.style.emit import Emitted, emit, inline + +import reflex as rx + +RUBY = "$/reflex-ui/colors/ruby.stylex.js" +JADE = "$/reflex-ui/colors/jade.stylex.js" + + +class EmitState(rx.State): + """State the styles and the props are bound to.""" + + width: rx.Field[str] = rx.field("320px") + count: rx.Field[int] = rx.field(2) + kind: rx.Field[str] = rx.field("solid") + size: rx.Field[str] = rx.field("1") + styles: rx.Field[dict[str, str]] = rx.field(default_factory=dict) + + +S = EmitState + +# What the expected source names each Var by. +VARS = { + "": S.width, + "": S.count, + "": S.kind, + "": S.size, + "": S.styles, + "": Var.create(f"calc({S.width} * 2)"), + "": Var("props.raw"), + "": Var("props.tone", _var_type=str), +} + +CARD: ComponentStyles = { + "base": { + "padding": "var(--space-3)", + "border_radius": "var(--radius-4)", + "box_shadow": "var(--shadow-2)", + }, +} + +# Typed loosely: a variant unsets a property with None, which a user's style +# does not take. +BUTTON: dict[str, Any] = { + "base": {"color": "black", "padding_top": "4px"}, + "variants": { + "kind": { + "solid": {"color": "white", "background_color": rx.color("ruby", 9)}, + "soft": {"opacity": 0.5, "padding_top": None}, + }, + "size": {"1": {"height": "1em"}, "2": {"height": "2em"}}, + "tone": {"warm": {"outline_color": "red"}}, + }, + "compound": [ + {"props": {"kind": "solid", "size": "2"}, "style": {"font_weight": 700}}, + ], +} + +# A variant whose style holds a value bound to state. +SIZED: ComponentStyles = { + "variants": {"kind": {"a": {"width": S.width}, "b": {"width": "1px"}}}, +} + +NO_STYLES: ComponentStyles = {} + + +def js(source: str) -> str: + """Write the expression of each Var into expected source. + + Args: + source: Source that names Vars as in ``VARS``. + + Returns: + The source as it is emitted. + """ + for name, var in VARS.items(): + source = source.replace(name, str(var)) + return source + + +def emitted( + declaration: str | None = None, + classes: str | None = None, + lookups: tuple[str, ...] = (), + variables: tuple[str, ...] = (), + inline: str | None = None, + imports: tuple[str, ...] = (), + vars: tuple[str, ...] = (), +) -> tuple[Any, ...]: + """Describe an expected result, with every Var named as in ``VARS``. + + Args: + declaration: The module-level statements. + classes: The constant holding the class names every instance has. + lookups: The expressions that give the class names of bound props. + variables: The entries of the inline style. + inline: The Var spread into the inline style. + imports: The modules imported for their CSS. + vars: The Vars the element reads. + + Returns: + What ``comparable`` makes of the result. + """ + return ( + declaration, + classes, + tuple([js(lookup) for lookup in lookups]), + tuple([js(variable) for variable in variables]), + None if inline is None else js(inline), + imports, + tuple([js(var) for var in vars]), + ) + + +def comparable(result: Emitted) -> tuple[Any, ...]: + """Reduce a result to values that compare: a Var does not. + + Args: + result: What ``emit`` returned. + + Returns: + Its fields, each Var replaced by its expression. + """ + return ( + result.declaration, + result.classes, + result.lookups, + result.variables, + None if result.inline is None else str(result.inline), + result.imports, + tuple([str(var) for var in result.vars]), + ) + + +# The style table, the props, the style and the layout props of an element, +# and what is emitted for it. One group for each kind of input. +CASES: dict[str, tuple[dict[str, Any], tuple[Any, ...]]] = { + "nothing": ({"styles": NO_STYLES}, emitted()), + "literal": ( + { + "styles": CARD, + "style": {"width": "320px", "z_index": 2, "line_height": 1.5}, + }, + emitted( + declaration=( + 'const sx_283e421a96 = stylex.create({ s: {"paddingTop": ' + '"var(--space-3)", "paddingRight": "var(--space-3)", ' + '"paddingBottom": "var(--space-3)", "paddingLeft": ' + '"var(--space-3)", "borderTopLeftRadius": "var(--radius-4)", ' + '"borderTopRightRadius": "var(--radius-4)", ' + '"borderBottomRightRadius": "var(--radius-4)", ' + '"borderBottomLeftRadius": "var(--radius-4)", "boxShadow": ' + '"var(--shadow-2)", "width": "320px", "zIndex": 2, ' + '"lineHeight": 1.5} });\n' + "const sx_283e421a96_c = " + "stylex.props(sx_283e421a96.s).className;" + ), + classes="sx_283e421a96_c", + imports=( + "$/reflex-ui/tokens/radius.stylex.js", + "$/reflex-ui/tokens/shadow.stylex.js", + "$/reflex-ui/tokens/space.stylex.js", + ), + ), + ), + # The card of the plan: its width bound to state, and a hover shadow. + "var": ( + { + "styles": CARD, + "style": { + "width": S.width, + "_hover": {"box_shadow": "var(--shadow-3)"}, + }, + }, + emitted( + declaration=( + 'const sx_75ce444dca = stylex.create({ s: {"paddingTop": ' + '"var(--space-3)", "paddingRight": "var(--space-3)", ' + '"paddingBottom": "var(--space-3)", "paddingLeft": ' + '"var(--space-3)", "borderTopLeftRadius": "var(--radius-4)", ' + '"borderTopRightRadius": "var(--radius-4)", ' + '"borderBottomRightRadius": "var(--radius-4)", ' + '"borderBottomLeftRadius": "var(--radius-4)", "boxShadow": ' + '{"default": "var(--shadow-2)", ":hover": "var(--shadow-3)"}, ' + '"width": "var(--v0)"} });\n' + "const sx_75ce444dca_c = " + "stylex.props(sx_75ce444dca.s).className;" + ), + classes="sx_75ce444dca_c", + imports=( + "$/reflex-ui/tokens/radius.stylex.js", + "$/reflex-ui/tokens/shadow.stylex.js", + "$/reflex-ui/tokens/space.stylex.js", + ), + variables=('"--v0": () ?? "initial"',), + vars=("",), + ), + ), + # A number is a length except where CSS takes a bare number, and one Var + # is one custom property wherever it reads the same. + "var_number": ( + { + "styles": NO_STYLES, + "style": { + "width": S.count, + "opacity": S.count, + "height": S.count, + "margin_top": f"calc({S.width} * 2)", + "_hover": {"width": S.count}, + }, + }, + emitted( + declaration=( + 'const sx_545699866d = stylex.create({ s: {"width": {"default": ' + '"var(--v0)", ":hover": "var(--v0)"}, "opacity": "var(--v1)", ' + '"height": "var(--v0)", "marginTop": "var(--v2)"} });\n' + "const sx_545699866d_c = stylex.props(sx_545699866d.s).className;" + ), + classes="sx_545699866d_c", + variables=( + '"--v0": () + "px"', + '"--v1": () ?? "initial"', + '"--v2": (("calc("++" * 2)")) ?? "initial"', + ), + vars=( + "", + "", + '("calc("++" * 2)")', + ), + ), + ), + "var_untyped": ( + { + "styles": NO_STYLES, + "style": {"width": VARS[""], "z_index": VARS[""]}, + }, + emitted( + declaration=( + 'const sx_bea9985a2e = stylex.create({ s: {"width": "var(--v0)", ' + '"zIndex": "var(--v1)"} });\n' + "const sx_bea9985a2e_c = stylex.props(sx_bea9985a2e.s).className;" + ), + classes="sx_bea9985a2e_c", + variables=( + ( + '"--v0": ((v) => typeof v === "number" ? v + "px" : v)() ?? ' + '"initial"' + ), + '"--v1": () ?? "initial"', + ), + vars=( + "", + "", + ), + ), + ), + "hover": ( + { + "styles": NO_STYLES, + "style": { + "color": "red", + "_hover": {"color": "blue"}, + ":focus-visible": {"outline_width": "2px"}, + }, + }, + emitted( + declaration=( + 'const sx_20caa62f24 = stylex.create({ s: {"color": {"default": ' + '"red", ":hover": "blue"}, "outlineWidth": {":focus-visible": ' + '"2px"}} });\n' + "const sx_20caa62f24_c = stylex.props(sx_20caa62f24.s).className;" + ), + classes="sx_20caa62f24_c", + ), + ), + "responsive": ( + { + "styles": NO_STYLES, + "style": { + "width": ["100%", "50%"], + "color": rx.breakpoints(initial="red", md="blue"), + }, + }, + emitted( + declaration=( + 'const sx_efb6e842bc = stylex.create({ s: {"width": {"default": ' + '"100%", "@media screen and (min-width: 30em)": "50%"}, "color": ' + '{"default": "red", "@media screen and (min-width: 62em)": "blue"}} ' + "});\n" + "const sx_efb6e842bc_c = stylex.props(sx_efb6e842bc.s).className;" + ), + classes="sx_efb6e842bc_c", + ), + ), + "color": ( + { + "styles": NO_STYLES, + "style": { + "color": rx.color("ruby", 9), + "_hover": {"background_color": rx.color("jade", 3)}, + }, + }, + emitted( + declaration=( + 'const sx_fe91e1112f = stylex.create({ s: {"color": "var(--ruby-9)", ' + '"backgroundColor": {":hover": "var(--jade-3)"}} });\n' + "const sx_fe91e1112f_c = stylex.props(sx_fe91e1112f.s).className;" + ), + classes="sx_fe91e1112f_c", + imports=( + JADE, + RUBY, + ), + ), + ), + "layout": ( + { + "styles": NO_STYLES, + "layout": { + "gap": "3", + "p": ["1", "2"], + "m": "-2", + "columns": "3", + "direction": "column", + }, + }, + emitted( + declaration=( + 'const sx_dae5511f98 = stylex.create({ s: {"rowGap": ' + '"var(--space-3)", "columnGap": "var(--space-3)", "paddingTop":' + ' {"default": "var(--space-1)", "@media screen and (min-width: ' + '30em)": "var(--space-2)"}, "paddingRight": {"default": ' + '"var(--space-1)", "@media screen and (min-width: 30em)": ' + '"var(--space-2)"}, "paddingBottom": {"default": ' + '"var(--space-1)", "@media screen and (min-width: 30em)": ' + '"var(--space-2)"}, "paddingLeft": {"default": ' + '"var(--space-1)", "@media screen and (min-width: 30em)": ' + '"var(--space-2)"}, "marginTop": "calc(-1 * var(--space-2))", ' + '"marginRight": "calc(-1 * var(--space-2))", "marginBottom": ' + '"calc(-1 * var(--space-2))", "marginLeft": "calc(-1 * ' + 'var(--space-2))", "gridTemplateColumns": "repeat(3, minmax(0, ' + '1fr))", "flexDirection": "column"} });\n' + "const sx_dae5511f98_c = " + "stylex.props(sx_dae5511f98.s).className;" + ), + classes="sx_dae5511f98_c", + imports=("$/reflex-ui/tokens/space.stylex.js",), + ), + ), + "shorthand": ( + {"styles": NO_STYLES, "style": {"margin": "0 auto"}}, + emitted( + declaration=( + 'const sx_9cc5d777ce = stylex.create({ s: {"marginTop": "0", ' + '"marginRight": "auto", "marginBottom": "0", "marginLeft": "auto"} ' + "});\n" + "const sx_9cc5d777ce_c = stylex.props(sx_9cc5d777ce.s).className;" + ), + classes="sx_9cc5d777ce_c", + ), + ), + # Props known at compile time select their styles there. + "variant_literal": ( + {"styles": BUTTON, "props": {"kind": "solid", "size": "2"}}, + emitted( + declaration=( + 'const sx_6f8a31de05 = stylex.create({ s: {"color": "white", ' + '"paddingTop": "4px", "backgroundColor": "var(--ruby-9)", "height": ' + '"2em", "fontWeight": 700} });\n' + "const sx_6f8a31de05_c = stylex.props(sx_6f8a31de05.s).className;" + ), + classes="sx_6f8a31de05_c", + imports=(RUBY,), + ), + ), + # One bound prop: a style for each of its values, holding the whole value + # of what it changes, and the style of a value that is none of them. + "variant_bound": ( + { + "styles": BUTTON, + "props": {"kind": S.kind, "size": "2"}, + "style": {"margin_top": "1px"}, + }, + emitted( + declaration=( + 'const sx_097e4917a8 = stylex.create({ s: {"height": "2em", ' + '"marginTop": "1px"}, a0_0: {"color": "white", "paddingTop": "4px", ' + '"backgroundColor": "var(--ruby-9)", "fontWeight": 700}, a0_1: ' + '{"color": "black", "opacity": 0.5}, a0: {"color": "black", ' + '"paddingTop": "4px"} });\n' + "const sx_097e4917a8_c = stylex.props(sx_097e4917a8.s).className;\n" + 'const sx_097e4917a8_0 = { __proto__: null, "solid": ' + 'stylex.props(sx_097e4917a8.a0_0).className, "soft": ' + "stylex.props(sx_097e4917a8.a0_1).className };\n" + "const sx_097e4917a8_0d = stylex.props(sx_097e4917a8.a0).className;" + ), + classes="sx_097e4917a8_c", + lookups=("(sx_097e4917a8_0[] ?? sx_097e4917a8_0d)",), + imports=(RUBY,), + vars=("",), + ), + ), + # A bound prop that changes nothing the element has without it. + "variant_bound_adds": ( + {"styles": BUTTON, "props": {"kind": "soft", "tone": VARS[""]}}, + emitted( + declaration=( + 'const sx_4dbc04f090 = stylex.create({ s: {"color": "black", ' + '"opacity": 0.5}, a0_0: {"outlineColor": "red"} });\n' + "const sx_4dbc04f090_c = stylex.props(sx_4dbc04f090.s).className;\n" + 'const sx_4dbc04f090_0 = { __proto__: null, "warm": ' + "stylex.props(sx_4dbc04f090.a0_0).className };" + ), + classes="sx_4dbc04f090_c", + lookups=('(sx_4dbc04f090_0[] ?? "")',), + vars=("",), + ), + ), + # Two bound props that a compound style combines are indexed together. + "variant_bound_grouped": ( + {"styles": BUTTON, "props": {"kind": S.kind, "size": S.size}}, + emitted( + declaration=( + 'const sx_954f5c8b18 = stylex.create({ a0_0: {"color": "white", ' + '"paddingTop": "4px", "backgroundColor": "var(--ruby-9)", "height": ' + '"1em"}, a0_1: {"color": "white", "paddingTop": "4px", ' + '"backgroundColor": "var(--ruby-9)", "height": "2em", "fontWeight": ' + '700}, a0_2: {"color": "black", "opacity": 0.5, "height": "1em"}, ' + 'a0_3: {"color": "black", "opacity": 0.5, "height": "2em"}, a0: ' + '{"color": "black", "paddingTop": "4px"} });\n' + 'const sx_954f5c8b18_0 = { __proto__: null, "solid": { __proto__: ' + 'null, "1": stylex.props(sx_954f5c8b18.a0_0).className, "2": ' + 'stylex.props(sx_954f5c8b18.a0_1).className }, "soft": { __proto__: ' + 'null, "1": stylex.props(sx_954f5c8b18.a0_2).className, "2": ' + "stylex.props(sx_954f5c8b18.a0_3).className } };\n" + "const sx_954f5c8b18_0d = stylex.props(sx_954f5c8b18.a0).className;" + ), + lookups=("(sx_954f5c8b18_0[]?.[] ?? sx_954f5c8b18_0d)",), + imports=(RUBY,), + vars=( + "", + "", + ), + ), + ), + "variant_bound_with_var_value": ( + {"styles": SIZED, "props": {"kind": S.kind}}, + emitted( + declaration=( + 'const sx_7cb0d9b7b2 = stylex.create({ a0_0: {"width": "var(--v0)"}, ' + 'a0_1: {"width": "1px"} });\n' + 'const sx_7cb0d9b7b2_0 = { __proto__: null, "a": ' + 'stylex.props(sx_7cb0d9b7b2.a0_0).className, "b": ' + "stylex.props(sx_7cb0d9b7b2.a0_1).className };" + ), + lookups=('(sx_7cb0d9b7b2_0[] ?? "")',), + variables=('"--v0": () ?? "initial"',), + vars=( + "", + "", + ), + ), + ), + "whole_var": ( + {"styles": CARD, "style": S.styles}, + emitted( + declaration=( + 'const sx_1026d57c33 = stylex.create({ s: {"paddingTop": ' + '"var(--space-3)", "paddingRight": "var(--space-3)", ' + '"paddingBottom": "var(--space-3)", "paddingLeft": ' + '"var(--space-3)", "borderTopLeftRadius": "var(--radius-4)", ' + '"borderTopRightRadius": "var(--radius-4)", ' + '"borderBottomRightRadius": "var(--radius-4)", ' + '"borderBottomLeftRadius": "var(--radius-4)", "boxShadow": ' + '"var(--shadow-2)"} });\n' + "const sx_1026d57c33_c = " + "stylex.props(sx_1026d57c33.s).className;" + ), + classes="sx_1026d57c33_c", + imports=( + "$/reflex-ui/tokens/radius.stylex.js", + "$/reflex-ui/tokens/shadow.stylex.js", + "$/reflex-ui/tokens/space.stylex.js", + ), + inline="", + vars=("",), + ), + ), + "whole_var_alone": ( + {"styles": NO_STYLES, "style": S.styles}, + emitted( + inline="", + vars=("",), + ), + ), + "whole_var_after_styles": ( + {"styles": NO_STYLES, "style": [{"width": S.width}, S.styles]}, + emitted( + declaration=( + 'const sx_67b044120d = stylex.create({ s: {"width": "var(--v0)"} });\n' + "const sx_67b044120d_c = stylex.props(sx_67b044120d.s).className;" + ), + classes="sx_67b044120d_c", + variables=('"--v0": () ?? "initial"',), + inline="", + vars=( + "", + "", + ), + ), + ), +} + + +@pytest.mark.parametrize("case", CASES) +def test_emit_writes_the_source_of_each_kind_of_style(case: str): + arguments, expected = CASES[case] + assert comparable(emit(merge("rx.ui.card", **arguments))) == expected + + +def test_emit_names_a_declaration_after_its_content(): + """Equal styles share a declaration; different ones never share a name.""" + + def classes(style: dict[str, Any], name: str = "rx.ui.box") -> str | None: + return emit(merge(name, NO_STYLES, style=style)).classes + + top = {"top": "4px"} + assert classes(top) == classes(top, "rx.ui.flex") == "sx_d0020eea95_c" + assert len({classes(top), classes({"top": "5px"}), classes({"top": 4})}) == 3 + # The declaration of a bound prop does not depend on the Var it is bound to. + assert ( + emit(merge("rx.ui.button", BUTTON, {"tone": S.kind})).declaration + == emit(merge("rx.ui.button", BUTTON, {"tone": S.size})).declaration + ) + + +def test_inline_keeps_literals(): + style = {"top": "4px", "z_index": 2, "opacity": 0.5} + assert inline(merge("rx.ui.box", CARD, style=style), "rx.ui.box") == { + "paddingTop": "var(--space-3)", + "paddingRight": "var(--space-3)", + "paddingBottom": "var(--space-3)", + "paddingLeft": "var(--space-3)", + "borderTopLeftRadius": "var(--radius-4)", + "borderTopRightRadius": "var(--radius-4)", + "borderBottomRightRadius": "var(--radius-4)", + "borderBottomLeftRadius": "var(--radius-4)", + "boxShadow": "var(--shadow-2)", + "top": "4px", + "zIndex": 2, + "opacity": 0.5, + } + assert inline(merge("rx.ui.box", NO_STYLES), "rx.ui.box") == {} + + +@pytest.mark.parametrize( + ("arguments", "message"), + [ + ( + {"styles": NO_STYLES, "style": {"color": "red", "_hover": {"color": "x"}}}, + ( + 'rx.ui.box: the style "color" has conditions ("default", ":hover"), ' + "which a component rendered from state cannot apply: its code is " + "evaluated in the browser and never reaches the StyleX compiler. Use an " + "unconditional value there, or render the component in a page and show " + "it with rx.cond." + ), + ), + ( + {"styles": NO_STYLES, "style": {"color": S.width}}, + ( + 'rx.ui.box: the style "color" is bound to state, which a component ' + "rendered from state cannot apply: its code is evaluated in the browser " + "and never reaches the StyleX compiler. Use a literal value there, or " + "render the component in a page and show it with rx.cond." + ), + ), + ( + {"styles": NO_STYLES, "style": S.styles}, + ( + "rx.ui.box: the style is a Var, which a component rendered from state " + "cannot apply: its code is evaluated in the browser and never reaches " + "the StyleX compiler. Use a dict of literal values there, or render the " + "component in a page and show it with rx.cond." + ), + ), + ( + {"styles": BUTTON, "props": {"kind": S.kind, "size": S.size}}, + ( + 'rx.ui.box: the props "kind", "size" select a style and are bound to ' + "state, which a component rendered from state cannot apply: its code is " + "evaluated in the browser and never reaches the StyleX compiler. Give " + "them literal values there, or render the component in a page and show " + "it with rx.cond." + ), + ), + ], +) +def test_inline_rejects_what_an_inline_style_cannot_hold( + arguments: dict[str, Any], message: str +): + with pytest.raises(StyleError) as raised: + inline(merge("rx.ui.box", **arguments), "rx.ui.box") + assert str(raised.value) == message diff --git a/tests/units/reflex_components_ui/style/test_lower.py b/tests/units/reflex_components_ui/style/test_lower.py new file mode 100644 index 00000000000..eb57dbd5e67 --- /dev/null +++ b/tests/units/reflex_components_ui/style/test_lower.py @@ -0,0 +1,1456 @@ +"""Tests for lowering the styles a user writes into what StyleX compiles.""" + +from typing import Any + +import pytest +from reflex_base.breakpoints import breakpoints_values, set_breakpoints +from reflex_base.constants.colors import Color +from reflex_base.vars.base import LiteralVar, Var +from reflex_components_ui import tokens +from reflex_components_ui._radix_tokens import VAR_GROUPS +from reflex_components_ui.style import _css_props +from reflex_components_ui.style.lower import ( + _BORDERS, + _EXPANSIONS, + _LAYOUT, + _REFLEX_KEYS, + _REPLACES, + _UNSUPPORTED, + LAYOUT_PROPS, + VAR_MODULES, + Lowered, + StyleError, + apply_layer, + finish, + lower, + lower_layer, +) + +import reflex as rx + +RUBY = "$/reflex-ui/colors/ruby.stylex.js" +GRAY = "$/reflex-ui/tokens/gray.stylex.js" +ACCENT = "$/reflex-ui/tokens/accent.stylex.js" +SPACE = "$/reflex-ui/tokens/space.stylex.js" +XS = "@media screen and (min-width: 30em)" +SM = "@media screen and (min-width: 48em)" +MD = "@media screen and (min-width: 62em)" +LG = "@media screen and (min-width: 80em)" +XL = "@media screen and (min-width: 96em)" + + +class StyleState(rx.State): + """State whose fields are bound to styles.""" + + width: rx.Field[int] = rx.field(320) + scale: rx.Field[str] = rx.field("ruby") + style: rx.Field[dict[str, str]] = rx.field({}) + + +WIDTH = StyleState.width +SCALE = StyleState.scale + + +def test_generated_tables_cover_what_lowering_names(): + """Every property lowering expands to, replaces or sets is a known one.""" + known = set(_css_props.CSS_PROPS.values()) + named = { + *_EXPANSIONS, + *(prop for longhands, _ in _EXPANSIONS.values() for prop in longhands), + *_REPLACES, + *(prop for replaced in _REPLACES.values() for prop in replaced), + *(prop for targets in _REFLEX_KEYS.values() for prop in targets), + *_BORDERS, + *_UNSUPPORTED, + *( + f"{side}{part}" + for sides in _BORDERS.values() + for side in sides + for part in ("Width", "Style", "Color") + ), + *(prop for _, targets, _ in _LAYOUT.values() for prop in targets), + } + assert named - known == set() + assert {key: _css_props.CSS_PROPS.get(key) for key, _, _ in _LAYOUT.values()} == { + "padding": "padding", + "padding_x": None, + "padding_y": None, + "padding_top": "paddingTop", + "padding_right": "paddingRight", + "padding_bottom": "paddingBottom", + "padding_left": "paddingLeft", + "margin": "margin", + "margin_x": None, + "margin_y": None, + "margin_top": "marginTop", + "margin_right": "marginRight", + "margin_bottom": "marginBottom", + "margin_left": "marginLeft", + "gap": "gap", + "column_gap": "columnGap", + "row_gap": "rowGap", + "grid_template_columns": "gridTemplateColumns", + "grid_template_rows": "gridTemplateRows", + "flex_direction": "flexDirection", + "flex_wrap": "flexWrap", + "align_items": "alignItems", + "justify_content": "justifyContent", + "grid_auto_flow": "gridAutoFlow", + } + + +def test_generated_table_spells_properties_as_users_do(): + """A sample of the generated keys, vendor prefixes included.""" + sample = ( + "background_color", + "border_top_left_radius", + "webkit_font_smoothing", + "moz_osx_font_smoothing", + "z_index", + "float", + "theme", + ) + assert {key: _css_props.CSS_PROPS.get(key) for key in sample} == { + "background_color": "backgroundColor", + "border_top_left_radius": "borderTopLeftRadius", + "webkit_font_smoothing": "WebkitFontSmoothing", + "moz_osx_font_smoothing": "MozOsxFontSmoothing", + "z_index": "zIndex", + "float": "float", + "theme": None, + } + assert len(_css_props.CSS_PROPS) == 521 + assert _css_props.StyleProps is dict + + +@pytest.mark.parametrize( + ("style", "expected"), + [ + ({}, {}), + (None, {}), + ( + {"display": "flex", "z_index": 3, "line_height": 1.5, "color": "red"}, + {"display": "flex", "zIndex": 3, "lineHeight": 1.5, "color": "red"}, + ), + ( + {"backgroundColor": "red", "font-size": "2em", "--card-gap": "4px"}, + {"backgroundColor": "red", "fontSize": "2em", "--card-gap": "4px"}, + ), + ( + {"_webkit_font_smoothing": "antialiased", "webkit_appearance": "none"}, + {"WebkitFontSmoothing": "antialiased", "WebkitAppearance": "none"}, + ), + ( + {"width": LiteralVar.create("10px"), "order": LiteralVar.create(2)}, + {"width": "10px", "order": 2}, + ), + ({"color": "red", "width": None}, {"color": "red"}), + ], +) +def test_literal_values(style: Any, expected: dict[str, Any]): + """A literal value stays a literal under the camelCase name of its property. + + Args: + style: The style as written. + expected: The lowered properties. + """ + assert lower("rx.ui.card", style) == Lowered(expected) + + +def test_literal_values_keep_their_order(): + """The properties come out in the order they were written.""" + lowered = lower("rx.ui.card", {"width": "1px", "color": "red", "top": 0}) + assert list(lowered.style.items()) == [ + ("width", "1px"), + ("color", "red"), + ("top", 0), + ] + assert (lowered.imports, lowered.inline) == ((), None) + + +def test_state_var_values(): + """A value bound to state is kept as its Var, wherever it is written.""" + concatenated = LiteralVar.create(f"{WIDTH}px") + assert lower( + "rx.ui.card", + { + "width": WIDTH, + "height": f"{WIDTH}px", + "min_width": [WIDTH, "50%"], + "_hover": {"max_width": WIDTH}, + "padding": WIDTH, + "padding_x": WIDTH, + }, + ) == Lowered({ + "width": WIDTH, + "height": concatenated, + "minWidth": {"default": WIDTH, XS: "50%"}, + "maxWidth": {":hover": WIDTH}, + "padding": WIDTH, + "paddingLeft": WIDTH, + "paddingRight": WIDTH, + }) + + +def test_whole_dict_var_becomes_the_inline_style(): + """A Var holding a dict of styles is not lowered, only carried.""" + lowered = lower("rx.ui.card", StyleState.style) + assert lowered == Lowered({}, (), StyleState.style) + assert lowered.style == {} + assert lowered.inline is not None + assert lowered.inline.equals(StyleState.style) + assert lower("rx.ui.card", StyleState.style, {"p": "2"}) == Lowered( + { + "paddingTop": "var(--space-2)", + "paddingRight": "var(--space-2)", + "paddingBottom": "var(--space-2)", + "paddingLeft": "var(--space-2)", + }, + (SPACE,), + StyleState.style, + ) + + +@pytest.mark.parametrize( + ("style", "expected"), + [ + ( + {"color": "black", "_hover": {"color": "blue"}}, + {"color": {"default": "black", ":hover": "blue"}}, + ), + ( + {"_hover": {"color": "blue"}, "color": "black"}, + {"color": {"default": "black", ":hover": "blue"}}, + ), + ( + {":focus-visible": {"outline_style": "solid"}}, + {"outlineStyle": {":focus-visible": "solid"}}, + ), + ( + {"_focus_visible": {"color": "red"}, "_focusWithin": {"color": "blue"}}, + {"color": {":focus-visible": "red", ":focus-within": "blue"}}, + ), + ( + {"_before": {"content": '""'}, "_placeholder": {"color": "gray"}}, + {"content": {"::before": '""'}, "color": {"::placeholder": "gray"}}, + ), + ( + {"::-webkit-scrollbar": {"display": "none"}, "&:hover": {"top": 0}}, + {"display": {"::-webkit-scrollbar": "none"}, "top": {":hover": 0}}, + ), + ( + { + "[data-open]": {"opacity": 1}, + "&[data-disabled]": {"opacity": 0.5}, + ":not(:first-child)": {"opacity": 0}, + ":nth-child(2n + 1)": {"opacity": 0.2}, + }, + { + "opacity": { + "[data-open]": 1, + "[data-disabled]": 0.5, + ":not(:first-child)": 0, + ":nth-child(2n + 1)": 0.2, + } + }, + ), + ( + { + "@media (min-width: 768px)": {"color": "red"}, + "@container (min-width: 20em)": {"color": "blue"}, + "@supports (display: grid)": {"color": "green"}, + "@starting-style": {"color": "pink"}, + }, + { + "color": { + "@media (min-width: 768px)": "red", + "@container (min-width: 20em)": "blue", + "@supports (display: grid)": "green", + "@starting-style": "pink", + } + }, + ), + ( + {"_hover": {"color": "red", "_disabled": {"color": "gray"}}}, + {"color": {":hover": {"default": "red", ":disabled": "gray"}}}, + ), + ( + {"_hover": {"_disabled": {"color": "gray"}, "color": "red"}}, + {"color": {":hover": {"default": "red", ":disabled": "gray"}}}, + ), + ( + {"color": {"default": "black", ":hover": "blue", "_active": "red"}}, + {"color": {"default": "black", ":hover": "blue", ":active": "red"}}, + ), + ( + {"color": {":hover": {"default": "blue", "@media print": "black"}}}, + {"color": {":hover": {"default": "blue", "@media print": "black"}}}, + ), + ( + {"color": None, "_hover": {"color": "blue"}}, + {"color": {"default": None, ":hover": "blue"}}, + ), + ( + {"_hover": {"margin": "0 auto"}}, + { + "marginTop": {":hover": "0"}, + "marginRight": {":hover": "auto"}, + "marginBottom": {":hover": "0"}, + "marginLeft": {":hover": "auto"}, + }, + ), + ], +) +def test_condition_blocks(style: Any, expected: dict[str, Any]): + """A block of styles under a condition becomes per-property conditions. + + Args: + style: The style as written. + expected: The lowered properties. + """ + assert lower("rx.ui.card", style) == Lowered(expected) + + +@pytest.mark.parametrize( + ("style", "expected"), + [ + ({"width": ["100%"]}, {"width": "100%"}), + ({"width": ["100%", "50%"]}, {"width": {"default": "100%", XS: "50%"}}), + ( + {"width": ("1px", "2px", "3px", "4px", "5px", "6px")}, + { + "width": { + "default": "1px", + XS: "2px", + SM: "3px", + MD: "4px", + LG: "5px", + XL: "6px", + } + }, + ), + ({"width": [None, None, "50%"]}, {"width": {SM: "50%"}}), + ( + {"width": rx.breakpoints(initial="100%", sm="50%", xl="25%")}, + {"width": {"default": "100%", SM: "50%", XL: "25%"}}, + ), + ({"width": rx.breakpoints(md="50%")}, {"width": {MD: "50%"}}), + ( + {"width": rx.breakpoints(custom={"500px": "50%", "xs": "75%"})}, + { + "width": { + "@media screen and (min-width: 500px)": "50%", + XS: "75%", + } + }, + ), + ( + {"width": {"initial": "100%", "lg": "50%"}}, + {"width": {"default": "100%", LG: "50%"}}, + ), + ( + {"_hover": {"width": ["100%", "50%"]}}, + {"width": {":hover": {"default": "100%", XS: "50%"}}}, + ), + ( + {"width": ["100%", {"default": "50%", ":hover": "60%"}]}, + {"width": {"default": "100%", XS: {"default": "50%", ":hover": "60%"}}}, + ), + ( + {"padding_x": ["1em", "2em"]}, + { + "paddingLeft": {"default": "1em", XS: "2em"}, + "paddingRight": {"default": "1em", XS: "2em"}, + }, + ), + ( + {"gap": rx.breakpoints(initial="1em", sm="1em 2em")}, + { + "rowGap": {"default": "1em", SM: "1em"}, + "columnGap": {"default": "1em", SM: "2em"}, + }, + ), + ], +) +def test_responsive_values(style: Any, expected: dict[str, Any]): + """A responsive value becomes media queries on the five breakpoints. + + Args: + style: The style as written. + expected: The lowered properties. + """ + assert lower("rx.ui.card", style) == Lowered(expected) + + +def test_responsive_values_follow_the_configured_breakpoints(): + """The media queries are read from the breakpoints of the app.""" + original = tuple(breakpoints_values) + set_breakpoints(("10px", "20px", "30px", "40px", "50px")) + try: + lowered = lower( + "rx.ui.card", {"width": ["1px", "2px"], "top": rx.breakpoints(xl="0")} + ) + finally: + set_breakpoints(original) # pyright: ignore [reportArgumentType] + assert lowered == Lowered({ + "width": {"default": "1px", "@media screen and (min-width: 10px)": "2px"}, + "top": {"@media screen and (min-width: 50px)": "0"}, + }) + + +@pytest.mark.parametrize( + ("style", "expected", "imports"), + [ + ({"color": rx.color("ruby", 9)}, {"color": "var(--ruby-9)"}, (RUBY,)), + ({"color": rx.color("ruby", 3, True)}, {"color": "var(--ruby-a3)"}, (RUBY,)), + ( + {"color": LiteralVar.create(rx.color("gray", 11))}, + {"color": "var(--gray-11)"}, + (GRAY,), + ), + ({"color": rx.color("accent", 9)}, {"color": "var(--accent-9)"}, (ACCENT,)), + ( + {"outline": f"1px solid {rx.color('ruby', 6)}", "color": "var(--gray-a11)"}, + {"outline": "1px solid var(--ruby-6)", "color": "var(--gray-a11)"}, + (RUBY, GRAY), + ), + ( + { + "color": { + "default": rx.color("gray", 12), + ":hover": [rx.color("ruby", 9), rx.color("ruby", 10)], + } + }, + { + "color": { + "default": "var(--gray-12)", + ":hover": {"default": "var(--ruby-9)", XS: "var(--ruby-10)"}, + } + }, + (RUBY, GRAY), + ), + ( + {"border_color": rx.color("ruby", 6)}, + { + "borderTopColor": "var(--ruby-6)", + "borderRightColor": "var(--ruby-6)", + "borderBottomColor": "var(--ruby-6)", + "borderLeftColor": "var(--ruby-6)", + }, + (RUBY,), + ), + ( + {"color": "var(--my-color)", "width": "var(--space-4)"}, + {"color": "var(--my-color)", "width": "var(--space-4)"}, + (SPACE,), + ), + ( + {"color": rx.color(SCALE, 9)}, + {"color": LiteralVar.create(Color(SCALE, 9))}, + (), + ), + ], +) +def test_colors_and_tokens( + style: Any, expected: dict[str, Any], imports: tuple[str, ...] +): + """A color becomes its custom property and names the module of its scale. + + Args: + style: The style as written. + expected: The lowered properties. + imports: The modules the style needs. + """ + lowered = lower("rx.ui.card", style) + assert lowered == Lowered(expected, imports) + assert lowered.imports == imports + + +def test_var_modules_name_the_module_of_every_custom_property(): + """Each custom property Radix defines is found by its whole name.""" + assert VAR_MODULES["--ruby-9"] == RUBY + assert VAR_MODULES["--gray-9"] == GRAY + assert { + name: f"$/reflex-ui/{module}" + for module, names in VAR_GROUPS.values() + for name in names + } == VAR_MODULES + assert len(VAR_MODULES) == 1070 + assert lower( + "rx.ui.card", + { + "width": "calc(2 * var(--space-4))", + "flex_grow": "var(--scaling)", + "font_size": "var(--font-size-2, 14px)", + "line_height": "var( --line-height-2 )", + # Not custom properties of Radix Themes: an app may define them, + # and they import nothing, whatever word they start with. + "color": "var(--mine-1)", + "background_color": "var(--color-mine)", + "border_top_color": "var(--gray-13)", + "font_family": "var(--code-font)", + }, + ).imports == ( + "$/reflex-ui/tokens/scaling.stylex.js", + "$/reflex-ui/tokens/space.stylex.js", + "$/reflex-ui/tokens/typography.stylex.js", + ) + + +def _sides(prefix: str, suffix: str, *values: Any) -> dict[str, Any]: + """Build the four longhands of a box shorthand. + + Args: + prefix: What comes before the side. + suffix: What comes after it. + values: The top, right, bottom and left values. + + Returns: + The lowered properties. + """ + sides = ("Top", "Right", "Bottom", "Left") + return { + f"{prefix}{side}{suffix}": value + for side, value in zip(sides, values, strict=True) + } + + +@pytest.mark.parametrize( + ("style", "expected"), + [ + ({"margin": "0 auto"}, _sides("margin", "", "0", "auto", "0", "auto")), + ({"margin": "1em"}, _sides("margin", "", "1em", "1em", "1em", "1em")), + ({"margin": 4}, _sides("margin", "", 4, 4, 4, 4)), + ({"padding": "1px 2px 3px"}, _sides("padding", "", "1px", "2px", "3px", "2px")), + ( + {"padding": "1px 2px 3px 4px"}, + _sides("padding", "", "1px", "2px", "3px", "4px"), + ), + ( + {"padding": "calc(1px + 2px) max(1em, 4px)"}, + {"padding": "calc(1px + 2px) max(1em, 4px)"}, + ), + ( + {"padding": "calc(1px + 2px) min(1em 4px)"}, + _sides( + "padding", + "", + "calc(1px + 2px)", + "min(1em 4px)", + "calc(1px + 2px)", + "min(1em 4px)", + ), + ), + ({"padding": "var(--card-padding)"}, {"padding": "var(--card-padding)"}), + ({"padding": "1px 2px 3px 4px 5px"}, {"padding": "1px 2px 3px 4px 5px"}), + ({"margin": "0 !important"}, {"margin": "0 !important"}), + ( + {"inset": "0 auto"}, + {"top": "0", "right": "auto", "bottom": "0", "left": "auto"}, + ), + ( + {"border_width": "1px 2px"}, + _sides("border", "Width", "1px", "2px", "1px", "2px"), + ), + ( + {"border_style": "solid"}, + _sides("border", "Style", "solid", "solid", "solid", "solid"), + ), + ( + {"border_color": "rgb(0 0 0) red"}, + _sides("border", "Color", "rgb(0 0 0)", "red", "rgb(0 0 0)", "red"), + ), + ( + {"border_radius": "4px 8px"}, + { + "borderTopLeftRadius": "4px", + "borderTopRightRadius": "8px", + "borderBottomRightRadius": "4px", + "borderBottomLeftRadius": "8px", + }, + ), + ({"border_radius": "50% / 10%"}, {"borderRadius": "50% / 10%"}), + ({"gap": "1em"}, {"rowGap": "1em", "columnGap": "1em"}), + ({"gap": "1em 2em"}, {"rowGap": "1em", "columnGap": "2em"}), + ({"overflow": "hidden auto"}, {"overflowX": "hidden", "overflowY": "auto"}), + ( + {"margin_inline": "1em 2em", "padding_block": "3em"}, + { + "marginInlineStart": "1em", + "marginInlineEnd": "2em", + "paddingBlockStart": "3em", + "paddingBlockEnd": "3em", + }, + ), + ( + {"padding_x": "1em 2em", "margin_y": 0}, + { + "paddingLeft": "1em 2em", + "paddingRight": "1em 2em", + "marginTop": 0, + "marginBottom": 0, + }, + ), + ( + {"bg": "red", "bg_color": "blue", "paddingX": "1px", "margin-x": "2px"}, + { + "backgroundColor": "blue", + "backgroundImage": "none", + "paddingLeft": "1px", + "paddingRight": "1px", + "marginLeft": "2px", + "marginRight": "2px", + }, + ), + ( + {"margin_top": "1em", "margin": "0"}, + _sides("margin", "", "0", "0", "0", "0"), + ), + ( + {"margin": "0", "margin_top": "1em"}, + _sides("margin", "", "1em", "0", "0", "0"), + ), + ( + {"outline": "1px solid red", "transition": "all 0.2s", "flex": "1 1 0"}, + {"outline": "1px solid red", "transition": "all 0.2s", "flex": "1 1 0"}, + ), + ], +) +def test_shorthands(style: Any, expected: dict[str, Any]): + """A shorthand whose values can be told apart is expanded to longhands. + + Args: + style: The style as written. + expected: The lowered properties. + """ + assert lower("rx.ui.card", style) == Lowered(expected) + + +def _border(sides: tuple[str, ...], width: Any, style: Any, color: Any) -> dict: + """Build the longhands of a border shorthand. + + Args: + sides: The sides it sets, such as ``borderTop``. + width: The width of each side. + style: The style of each side. + color: The color of each side. + + Returns: + The lowered properties. + """ + parts = (("Width", width), ("Style", style), ("Color", color)) + return {f"{side}{part}": value for side in sides for part, value in parts} + + +ALL_SIDES = ("borderTop", "borderRight", "borderBottom", "borderLeft") + + +@pytest.mark.parametrize( + ("style", "expected", "imports"), + [ + ({"border": "1px solid red"}, _border(ALL_SIDES, "1px", "solid", "red"), ()), + ({"border": "red solid 1px"}, _border(ALL_SIDES, "1px", "solid", "red"), ()), + ( + {"border": f"1px solid {rx.color('gray', 6)}"}, + _border(ALL_SIDES, "1px", "solid", "var(--gray-6)"), + (GRAY,), + ), + ( + {"border": "calc(1px + 1px) dashed rgb(0 0 0 / 50%)"}, + _border(ALL_SIDES, "calc(1px + 1px)", "dashed", "rgb(0 0 0 / 50%)"), + (), + ), + ({"border": "none"}, _border(ALL_SIDES, "medium", "none", "currentcolor"), ()), + ({"border": 0}, _border(ALL_SIDES, 0, "none", "currentcolor"), ()), + ({"border": "thin"}, _border(ALL_SIDES, "thin", "none", "currentcolor"), ()), + ( + {"border": rx.color("ruby", 6)}, + _border(ALL_SIDES, "medium", "none", "var(--ruby-6)"), + (RUBY,), + ), + ( + {"border_top": "2px dotted", "borderLeft": ".5em solid blue"}, + { + **_border(("borderTop",), "2px", "dotted", "currentcolor"), + **_border(("borderLeft",), ".5em", "solid", "blue"), + }, + (), + ), + ( + {"border_right": "1px solid", "border_bottom": "1px solid"}, + _border(("borderRight", "borderBottom"), "1px", "solid", "currentcolor"), + (), + ), + ( + {"border_block": "1px solid", "border_inline": "2px solid"}, + { + **_border( + ("borderTop", "borderBottom"), "1px", "solid", "currentcolor" + ), + **_border( + ("borderInlineStart", "borderInlineEnd"), + "2px", + "solid", + "currentcolor", + ), + }, + (), + ), + ( + { + "border_block_start": "1px solid", + "border_block_end": "2px solid", + "border_inline_start": "3px solid", + "border_inline_end": "4px solid", + }, + { + **_border(("borderTop",), "1px", "solid", "currentcolor"), + **_border(("borderBottom",), "2px", "solid", "currentcolor"), + **_border(("borderInlineStart",), "3px", "solid", "currentcolor"), + **_border(("borderInlineEnd",), "4px", "solid", "currentcolor"), + }, + (), + ), + ( + {"border": "1px solid red", "border_top": None}, + { + **_border(ALL_SIDES[1:], "1px", "solid", "red"), + }, + (), + ), + ( + {"border": "1px solid red", "_hover": {"border_color": "blue"}}, + { + **_border( + ALL_SIDES, "1px", "solid", {"default": "red", ":hover": "blue"} + ), + }, + (), + ), + ( + {"background": "red", "bg": "blue"}, + {"backgroundColor": "blue", "backgroundImage": "none"}, + (), + ), + ( + {"bg": rx.color("ruby", 3), "_hover": {"background": "none"}}, + { + "backgroundColor": { + "default": "var(--ruby-3)", + ":hover": "transparent", + }, + "backgroundImage": {"default": "none", ":hover": "none"}, + }, + (RUBY,), + ), + ( + {"background": "var(--surface)"}, + {"backgroundColor": "var(--surface)", "backgroundImage": "none"}, + (), + ), + ( + {"background": "linear-gradient(90deg, red 0%, blue 100%)"}, + { + "backgroundColor": "transparent", + "backgroundImage": "linear-gradient(90deg, red 0%, blue 100%)", + }, + (), + ), + ( + {"background": ["URL(a.png)", "repeating-conic-gradient(red, blue)"]}, + { + "backgroundColor": {"default": "transparent", XS: "transparent"}, + "backgroundImage": { + "default": "URL(a.png)", + XS: "repeating-conic-gradient(red, blue)", + }, + }, + (), + ), + ({"background": None, "color": "red"}, {"color": "red"}, ()), + ], +) +def test_shorthands_stylex_does_not_compile( + style: Any, expected: dict[str, Any], imports: tuple[str, ...] +): + """The border and background shorthands are split, having no other form. + + Args: + style: The style as written. + expected: The lowered properties. + imports: The modules the style needs. + """ + assert lower("rx.ui.card", style) == Lowered(expected, imports) + + +@pytest.mark.parametrize( + ("layout", "expected"), + [ + ({"p": "4"}, _sides("padding", "", *["var(--space-4)"] * 4)), + ( + {"p": "0", "m": "-0"}, + {**_sides("padding", "", *["0"] * 4), **_sides("margin", "", *["0"] * 4)}, + ), + ({"m": "-2"}, _sides("margin", "", *["calc(-1 * var(--space-2))"] * 4)), + ( + {"m": "auto", "p": "10px", "pt": 3}, + { + **_sides("margin", "", *["auto"] * 4), + **_sides("padding", "", 3, "10px", "10px", "10px"), + }, + ), + ( + {"px": "1", "py": "2", "mx": "3", "my": "4"}, + { + "paddingLeft": "var(--space-1)", + "paddingRight": "var(--space-1)", + "paddingTop": "var(--space-2)", + "paddingBottom": "var(--space-2)", + "marginLeft": "var(--space-3)", + "marginRight": "var(--space-3)", + "marginTop": "var(--space-4)", + "marginBottom": "var(--space-4)", + }, + ), + ( + {"pt": "1", "pr": "2", "pb": "3", "pl": "4"}, + _sides("padding", "", *[f"var(--space-{step})" for step in "1234"]), + ), + ( + {"mt": "1", "mr": "2", "mb": "3", "ml": "4"}, + _sides("margin", "", *[f"var(--space-{step})" for step in "1234"]), + ), + ({"gap": "3"}, {"rowGap": "var(--space-3)", "columnGap": "var(--space-3)"}), + ({"spacing": "9"}, {"rowGap": "var(--space-9)", "columnGap": "var(--space-9)"}), + ({"gap": "10"}, {"rowGap": "10", "columnGap": "10"}), + ( + {"gap_x": "1", "gap_y": "2"}, + {"columnGap": "var(--space-1)", "rowGap": "var(--space-2)"}, + ), + ( + {"gap": ["1", "2"]}, + { + "rowGap": {"default": "var(--space-1)", XS: "var(--space-2)"}, + "columnGap": {"default": "var(--space-1)", XS: "var(--space-2)"}, + }, + ), + ( + {"p": rx.breakpoints(initial="1", md="4")}, + _sides( + "padding", + "", + *[{"default": "var(--space-1)", MD: "var(--space-4)"}] * 4, + ), + ), + ( + {"columns": "3", "rows": "2"}, + { + "gridTemplateColumns": "repeat(3, minmax(0, 1fr))", + "gridTemplateRows": "repeat(2, minmax(0, 1fr))", + }, + ), + ( + {"columns": {"initial": "1", "sm": "repeat(2, 10em)"}}, + { + "gridTemplateColumns": { + "default": "repeat(1, minmax(0, 1fr))", + SM: "repeat(2, 10em)", + } + }, + ), + ( + {"direction": "column", "wrap": "wrap", "flow": "row-dense"}, + { + "flexDirection": "column", + "flexWrap": "wrap", + "gridAutoFlow": "row dense", + }, + ), + ( + {"direction": ["column", "row"], "align": "start", "justify": "between"}, + { + "flexDirection": {"default": "column", XS: "row"}, + "alignItems": "flex-start", + "justifyContent": "space-between", + }, + ), + ( + {"align": ["end", "center"], "justify": {"initial": "end", "lg": "start"}}, + { + "alignItems": {"default": "flex-end", XS: "center"}, + "justifyContent": {"default": "flex-end", LG: "flex-start"}, + }, + ), + ({"direction": SCALE}, {"flexDirection": SCALE}), + ( + {"gap": LiteralVar.create("2"), "p": None}, + {"rowGap": "var(--space-2)", "columnGap": "var(--space-2)"}, + ), + ], +) +def test_layout_props(layout: dict[str, Any], expected: dict[str, Any]): + """A layout prop becomes the styles it stands for, at every breakpoint. + + Args: + layout: The layout props. + expected: The lowered properties. + """ + lowered = lower("rx.ui.flex", None, layout) + assert lowered.style == expected + # Only a step of the space scale needs a module. + assert lowered.imports == ((SPACE,) if "var(--space-" in repr(expected) else ()) + + +def test_layout_props_are_merged_under_the_style(): + """The style of the element wins over its layout props, by property.""" + assert lower( + "rx.ui.flex", + {"padding_top": "1px", "_hover": {"row_gap": "0"}, "margin": WIDTH}, + {"p": "2", "gap": "3", "mt": "1"}, + ) == Lowered( + { + "paddingTop": "1px", + "paddingRight": "var(--space-2)", + "paddingBottom": "var(--space-2)", + "paddingLeft": "var(--space-2)", + "rowGap": {"default": "var(--space-3)", ":hover": "0"}, + "columnGap": "var(--space-3)", + "margin": WIDTH, + }, + (SPACE,), + ) + assert ( + frozenset({ + "p", + "px", + "py", + "pt", + "pr", + "pb", + "pl", + "m", + "mx", + "my", + "mt", + "mr", + "mb", + "ml", + "gap", + "spacing", + "gap_x", + "gap_y", + "columns", + "rows", + "direction", + "wrap", + "align", + "justify", + "flow", + }) + == LAYOUT_PROPS + ) + + +@pytest.mark.parametrize( + ("name", "style", "layout", "message"), + [ + ( + "rx.ui.card", + {"& > div": {"color": "red"}}, + None, + ( + 'rx.ui.card: style key "& > div" is a nested selector, which rx.ui ' + "styles do not support. Style the child component directly, or keep " + "rx.card for this element." + ), + ), + ( + "rx.ui.card", + {"paddng": "1em"}, + None, + 'rx.ui.card: unknown CSS property "paddng". Did you mean "padding"?', + ), + ( + "rx.ui.stack", + {"& :where(.rx-Stack)": {"width": "100%"}}, + None, + ( + 'rx.ui.stack: style key "& :where(.rx-Stack)" is a nested selector, ' + "which rx.ui styles do not support. Style the child component " + "directly, or keep rx.stack for this element." + ), + ), + ( + "rx.ui.card", + {":hover > div": {"color": "red"}}, + None, + ( + 'rx.ui.card: style key ":hover > div" is a nested selector, which ' + "rx.ui styles do not support. Style the child component directly, " + "or keep rx.card for this element." + ), + ), + ( + "rx.ui.card", + {"[data-open] span": {"color": "red"}}, + None, + ( + 'rx.ui.card: style key "[data-open] span" is a nested selector, ' + "which rx.ui styles do not support. Style the child component " + "directly, or keep rx.card for this element." + ), + ), + ( + "rx.ui.card", + {".child": {"color": "red"}}, + None, + ( + 'rx.ui.card: style key ".child" is a nested selector, which rx.ui ' + "styles do not support. Style the child component directly, or keep " + "rx.card for this element." + ), + ), + ( + "rx.ui.card", + {"_hover": {"&::after, &::before": {"color": "red"}}}, + None, + ( + 'rx.ui.card: style key "&::after, &::before" is a nested selector, ' + "which rx.ui styles do not support. Style the child component " + "directly, or keep rx.card for this element." + ), + ), + ( + "rx.ui.card", + {"background_colour": "red"}, + None, + ( + 'rx.ui.card: unknown CSS property "background_colour". Did you mean ' + '"background_color"?' + ), + ), + ( + "rx.ui.card", + {"backgroundColr": "red"}, + None, + ( + 'rx.ui.card: unknown CSS property "backgroundColr". Did you mean ' + '"backgroundColor"?' + ), + ), + ( + "rx.ui.card", + {"font-sise": "red"}, + None, + 'rx.ui.card: unknown CSS property "font-sise". Did you mean "font_size"?', + ), + ( + "rx.ui.card", + {"xyzzy": "red"}, + None, + 'rx.ui.card: unknown CSS property "xyzzy".', + ), + ( + "rx.ui.card", + {"_hover": {"colr": "red"}}, + None, + 'rx.ui.card: unknown CSS property "colr". Did you mean "color"?', + ), + ( + "rx.ui.card", + {"_hovr": {"color": "red"}}, + None, + 'rx.ui.card: unknown pseudo-class "_hovr". Did you mean "_hover"?', + ), + ( + "rx.ui.card", + {"_zzzzzz": {"color": "red"}}, + None, + 'rx.ui.card: unknown pseudo-class "_zzzzzz".', + ), + ( + "rx.ui.card", + {"@keyframes spin": {"color": "red"}}, + None, + ( + 'rx.ui.card: style key "@keyframes spin" is an at-rule that rx.ui ' + "styles do not support. Use @media, @container, @supports or " + "@starting-style." + ), + ), + ( + "rx.ui.card", + {"_hover": StyleState.style}, + None, + ( + 'rx.ui.card: style key "_hover" is bound to state, but the styles ' + "under a condition are compiled ahead of time. Bind the values of " + "its properties instead." + ), + ), + ( + "rx.ui.card", + {"_hover": "red"}, + None, + ( + 'rx.ui.card: style key "_hover" is a condition, so its value must be ' + "a dict of styles, not str." + ), + ), + ( + "rx.ui.card", + {"_hover": rx.breakpoints(sm={"color": "red"})}, + None, + ( + 'rx.ui.card: style key "_hover" is a condition, so its value must be ' + "a dict of styles, not Breakpoints." + ), + ), + ( + "rx.ui.card", + {"color": {"default": "red", "hover": "blue"}}, + None, + ( + 'rx.ui.card: style "color" is given a value under "hover", which is ' + 'not a condition. Use "default", a pseudo-class such as ":hover", an ' + 'at-rule such as "@media (min-width: 48em)" or the name of a ' + "breakpoint." + ), + ), + ( + "rx.ui.card", + {"color": {"default": "red", 3: "blue"}}, + None, + ( + 'rx.ui.card: style "color" is given a value under "3", which is ' + 'not a condition. Use "default", a pseudo-class such as ":hover", an ' + 'at-rule such as "@media (min-width: 48em)" or the name of a ' + "breakpoint." + ), + ), + ( + "rx.ui.card", + {"width": ["1px", "2px", "3px", "4px", "5px", "6px", "7px"]}, + None, + ( + 'rx.ui.card: style "width" has 7 responsive values, but there are ' + "only 6 breakpoints." + ), + ), + ( + "rx.ui.card", + {"visibility": True}, + None, + ( + 'rx.ui.card: style "visibility" cannot take a value of type bool. ' + "Use a string, a number, a Var, a responsive list or a dict of " + "conditions." + ), + ), + ( + "rx.ui.card", + {"padding_x": [{"wat"}]}, + None, + ( + 'rx.ui.card: style "padding_x" cannot take a value of type set. Use ' + "a string, a number, a Var, a responsive list or a dict of " + "conditions." + ), + ), + ( + "rx.ui.card", + {3: "red"}, + None, + "rx.ui.card: a style key must be a string, not 3.", + ), + ( + "rx.ui.card", + {"border": WIDTH}, + None, + ( + 'rx.ui.card: style "border" is bound to state, but rx.ui styles ' + "split this shorthand into longhands at compile time. Bind its " + "width, style and color instead." + ), + ), + ( + "rx.ui.card", + {"border_top": "1px 2px"}, + None, + ( + 'rx.ui.card: style "border_top" has the value "1px 2px", which ' + "rx.ui styles cannot split into longhands. Set its width, style and " + "color instead." + ), + ), + ( + "rx.ui.card", + {"border": "1px solid red !important"}, + None, + ( + 'rx.ui.card: style "border" has the value "1px solid red ' + '!important", which rx.ui styles cannot split into longhands. Set ' + "its width, style and color instead." + ), + ), + ( + "rx.ui.card", + {"bg": "url(a.png) center / cover"}, + None, + ( + 'rx.ui.card: style "bg" has the value "url(a.png) center / cover", ' + "which rx.ui styles cannot split into longhands. Set " + "background_color, background_image and its other longhands instead." + ), + ), + ( + "rx.ui.card", + {"background": 3}, + None, + ( + 'rx.ui.card: style "background" has the value "3", which rx.ui ' + "styles cannot split into longhands. Set background_color, " + "background_image and its other longhands instead." + ), + ), + ( + "rx.ui.card", + {"background": SCALE}, + None, + ( + 'rx.ui.card: style "background" is bound to state, but rx.ui styles ' + "split this shorthand into longhands at compile time. Bind " + "background_color, background_image and its other longhands instead." + ), + ), + ( + "rx.ui.card", + {"animation": "spin 1s linear infinite"}, + None, + ( + 'rx.ui.card: style "animation" is a shorthand that rx.ui styles do ' + "not support. Set animation_name, animation_duration and its other " + "longhands instead." + ), + ), + ( + "rx.ui.card", + {"all": "unset"}, + None, + 'rx.ui.card: unknown CSS property "all".', + ), + ( + "rx.ui.flex", + None, + {"gap": SCALE}, + ( + 'rx.ui.flex: layout prop "gap" is bound to state, but its values are ' + 'read at compile time. Bind the "gap" style instead, which takes any ' + "CSS value." + ), + ), + ( + "rx.ui.flex", + None, + {"justify": ["start", SCALE]}, + ( + 'rx.ui.flex: layout prop "justify" is bound to state, but its values ' + 'are read at compile time. Bind the "justify_content" style instead, ' + "which takes any CSS value." + ), + ), + ( + "rx.ui.flex", + None, + {"gapp": "2"}, + 'rx.ui.flex: unknown layout prop "gapp". Did you mean "gap"?', + ), + ], +) +def test_errors(name: str, style: Any, layout: Any, message: str): + """A style that cannot be compiled is refused with what to do about it. + + Args: + name: The display name of the component. + style: The style as written. + layout: The layout props. + message: The whole error message. + """ + with pytest.raises(StyleError) as error: + lower(name, style, layout) + assert str(error.value) == message + assert isinstance(error.value, ValueError) + + +def test_layers_merge_by_property_and_the_last_one_wins(): + """A later style replaces a property, or adds conditions to it.""" + props, replaced = lower_layer( + "rx.ui.card", + { + "color": {"default": "black", ":hover": "blue"}, + "width": "1px", + "outline_color": "red", + "margin_top": "1px", + "top": {":hover": {"default": "1px", XS: "2px"}}, + "left": {":hover": {"default": "1px", XS: "2px"}}, + "opacity": 1, + }, + ) + assert replaced == () + later = lower_layer( + "rx.ui.card", + { + "color": "green", + "_focus": {"width": "2px"}, + "outline": WIDTH, + "margin": "var(--gap)", + "_hover": {"left": "3px", "_active": {"top": "4px"}}, + "opacity": None, + }, + ) + assert later[1] == (*_REPLACES["outline"], *_REPLACES["margin"]) + apply_layer(props, later) + assert finish(props) == Lowered({ + "color": "green", + "width": {"default": "1px", ":focus": "2px"}, + "outline": WIDTH, + "margin": "var(--gap)", + "top": {":hover": {"default": "1px", XS: "2px", ":active": "4px"}}, + "left": {":hover": "3px"}, + }) + assert finish({"color": None}) == Lowered({}) + assert finish({"color": None, "top": 0}, unset=True) == Lowered({ + "color": None, + "top": 0, + }) + + +def test_lowered_styles_compare_and_hash_by_what_they_compile_to(): + """Equal styles are one key, whatever the order of their properties.""" + first = lower("rx.ui.card", {"color": "red", "width": WIDTH, "_hover": {"top": 0}}) + second = lower("rx.ui.box", {"width": WIDTH, "_hover": {"top": 0}, "color": "red"}) + assert first == second + assert hash(first) == hash(second) + assert len({first, second}) == 1 + different = [ + lower("rx.ui.card", {"color": "red", "width": WIDTH, "_hover": {"top": 1}}), + lower("rx.ui.card", {"color": "red", "width": SCALE, "_hover": {"top": 0}}), + lower("rx.ui.card", {"color": "red", "width": WIDTH, "_focus": {"top": 0}}), + lower("rx.ui.card", {"color": "red", "width": WIDTH}), + Lowered(dict(first.style), (RUBY,)), + Lowered(dict(first.style), (), StyleState.style), + ] + assert [style == first for style in different] == [False] * 6 + assert first != dict(first.style) + assert lower("rx.ui.card", {}) is lower("rx.ui.card", None) + assert repr(lower("rx.ui.card", {"color": rx.color("ruby", 9)})) == ( + "Lowered({'color': 'var(--ruby-9)'}, " + "('$/reflex-ui/colors/ruby.stylex.js',), None)" + ) + + +def test_var_values_are_vars(): + """A Var in a lowered style is the Var that was written.""" + value = lower("rx.ui.card", {"width": WIDTH}).style["width"] + assert isinstance(value, Var) + assert value.equals(WIDTH) + + +@pytest.mark.parametrize( + ("style", "expected", "imports"), + [ + ( + {"padding": tokens.space[3]}, + _sides("padding", "", *["var(--space-3)"] * 4), + (SPACE,), + ), + ( + {"padding": f"{tokens.space[2]} {tokens.space[4]}"}, + _sides( + "padding", + "", + "var(--space-2)", + "var(--space-4)", + "var(--space-2)", + "var(--space-4)", + ), + (SPACE,), + ), + ( + {"margin": f"0 auto {tokens.space[1]}"}, + _sides("margin", "", "0", "auto", "var(--space-1)", "auto"), + (SPACE,), + ), + ( + {"gap": f"{tokens.space[1]} {tokens.space[2]}"}, + {"rowGap": "var(--space-1)", "columnGap": "var(--space-2)"}, + (SPACE,), + ), + ( + {"border_radius": tokens.radius[3]}, + { + "borderTopLeftRadius": "var(--radius-3)", + "borderTopRightRadius": "var(--radius-3)", + "borderBottomRightRadius": "var(--radius-3)", + "borderBottomLeftRadius": "var(--radius-3)", + }, + ("$/reflex-ui/tokens/radius.stylex.js",), + ), + ( + {"border_color": tokens.gray.a[6]}, + _sides("border", "Color", *["var(--gray-a6)"] * 4), + (GRAY,), + ), + ( + {"border": f"1px solid {tokens.accent[7]}"}, + _border(ALL_SIDES, "1px", "solid", "var(--accent-7)"), + (ACCENT,), + ), + ( + {"background": tokens.color.panel}, + {"backgroundColor": "var(--color-panel)", "backgroundImage": "none"}, + ("$/reflex-ui/tokens/color.stylex.js",), + ), + # A shadow is a list of layers and a font family a list of fonts: a + # shorthand that holds one is kept whole, as with any other property. + ( + {"padding": tokens.shadow[1]}, + {"padding": "var(--shadow-1)"}, + ("$/reflex-ui/tokens/shadow.stylex.js",), + ), + ( + {"margin": f"{tokens.space[1]} {tokens.default.font_family}"}, + {"margin": "var(--space-1) var(--default-font-family)"}, + (SPACE, "$/reflex-ui/tokens/typography.stylex.js"), + ), + ( + {"padding": f"{tokens.space[1]} var(--mine)"}, + {"padding": "var(--space-1) var(--mine)"}, + (SPACE,), + ), + ( + {"padding": f"calc({tokens.space[1]} * 2) {tokens.space[2]}"}, + {"padding": "calc(var(--space-1) * 2) var(--space-2)"}, + (SPACE,), + ), + ( + {"font_size": tokens.font_size[2], "box_shadow": tokens.shadow[3]}, + {"fontSize": "var(--font-size-2)", "boxShadow": "var(--shadow-3)"}, + ( + "$/reflex-ui/tokens/shadow.stylex.js", + "$/reflex-ui/tokens/typography.stylex.js", + ), + ), + ], +) +def test_design_tokens(style: Any, expected: dict[str, Any], imports: tuple[str, ...]): + """A token is its custom property: a shorthand gives one to each longhand. + + Args: + style: The style as written. + expected: The lowered properties. + imports: The modules the style needs. + """ + lowered = lower("rx.ui.card", style) + assert lowered == Lowered(expected, imports) + assert lowered.imports == imports diff --git a/tests/units/reflex_components_ui/style/test_merge.py b/tests/units/reflex_components_ui/style/test_merge.py new file mode 100644 index 00000000000..a445b37964a --- /dev/null +++ b/tests/units/reflex_components_ui/style/test_merge.py @@ -0,0 +1,548 @@ +"""Tests for merging the style table of a component with a user's style.""" + +import re +from typing import Any + +import pytest +from reflex_base.breakpoints import breakpoints_values, set_breakpoints +from reflex_base.vars.base import LiteralVar +from reflex_components_ui.style.lower import Lowered, StyleError +from reflex_components_ui.style.merge import ( + Alternatives, + ComponentStyles, + Merged, + merge, +) + +import reflex as rx + +RUBY = "$/reflex-ui/colors/ruby.stylex.js" +SPACE = "$/reflex-ui/tokens/space.stylex.js" +ACCENT = "$/reflex-ui/tokens/accent.stylex.js" +GRAY = "$/reflex-ui/tokens/gray.stylex.js" +# The module of each token the expected styles of these tests name. +TOKEN_MODULES = {"ruby": RUBY, "space": SPACE, "accent": ACCENT, "gray": GRAY} +XS = "@media screen and (min-width: 30em)" + + +class MergeState(rx.State): + """State whose fields are bound to props and styles.""" + + variant: rx.Field[str] = rx.field("solid") + size: rx.Field[str] = rx.field("1") + loading: rx.Field[bool] = rx.field(False) + style: rx.Field[dict[str, str]] = rx.field({}) + + +VARIANT = MergeState.variant +SIZE = MergeState.size +LOADING = MergeState.loading + +BUTTON: ComponentStyles = { + "base": { + "display": "inline-flex", + "color": "black", + "margin_top": "1px", + "outline_width": "1px", + }, + "variants": { + "variant": { + "solid": { + "background_color": { + "default": "var(--accent-9)", + ":hover": "var(--accent-10)", + }, + "color": "white", + }, + "soft": {"background_color": rx.color("ruby", 3)}, + "ghost": {"outline": "none"}, + }, + "size": { + "1": {"height": "var(--space-5)"}, + "2": {"height": "var(--space-6)", "_hover": {"color": "gray"}}, + }, + "loading": {"true": {"opacity": 0.5}}, + }, + "compound": [ + {"props": {"variant": "solid", "size": "2"}, "style": {"font_weight": "700"}}, + {"props": {"loading": "true"}, "style": {"cursor": "wait"}}, + ], + "parts": { + "icon": { + "base": {"width": "1em"}, + "variants": {"size": {"2": {"width": "2em"}}}, + "parts": {"dot": {"base": {"top": 0}}}, + }, + "label": {"base": {"flex_grow": 1}}, + }, +} + +BASE = { + "display": "inline-flex", + "color": "black", + "marginTop": "1px", + "outlineWidth": "1px", +} + + +def _lowered(style: dict[str, Any], inline: Any = None) -> Lowered: + """Build the lowered style a test expects, with the modules its values need. + + Args: + style: The lowered properties. + inline: A Var holding a whole dict of styles. + + Returns: + The lowered style, importing the module of every token it names. + """ + found = set(re.findall(r"var\(--([a-z]+)-", repr(style))) + return Lowered( + style, tuple(sorted([TOKEN_MODULES[word] for word in found])), inline + ) + + +SOLID_BACKGROUND = {"default": "var(--accent-9)", ":hover": "var(--accent-10)"} +DOT = Merged(Lowered({"top": 0})) +LABEL = Merged(Lowered({"flexGrow": 1})) +SMALL_PARTS = { + "icon": Merged(Lowered({"width": "1em"}), (), {"dot": DOT}), + "label": LABEL, +} +LARGE_PARTS = { + "icon": Merged(Lowered({"width": "2em"}), (), {"dot": DOT}), + "label": LABEL, +} + + +@pytest.mark.parametrize( + ("props", "style", "expected", "parts"), + [ + (None, None, BASE, SMALL_PARTS), + ({}, {}, BASE, SMALL_PARTS), + ( + {"variant": "unknown", "size": None, "disabled": True}, + None, + BASE, + SMALL_PARTS, + ), + ( + {"variant": "solid", "size": "1"}, + None, + { + **BASE, + "backgroundColor": SOLID_BACKGROUND, + "color": "white", + "height": "var(--space-5)", + }, + SMALL_PARTS, + ), + ( + {"variant": "solid", "size": "2", "loading": True}, + None, + { + **BASE, + "backgroundColor": SOLID_BACKGROUND, + "color": {"default": "white", ":hover": "gray"}, + "height": "var(--space-6)", + "opacity": 0.5, + "fontWeight": "700", + "cursor": "wait", + }, + LARGE_PARTS, + ), + ( + {"variant": "ghost", "size": 2, "loading": False}, + None, + { + "display": "inline-flex", + "color": {"default": "black", ":hover": "gray"}, + "marginTop": "1px", + "outline": "none", + "height": "var(--space-6)", + }, + LARGE_PARTS, + ), + ( + {"variant": LiteralVar.create("soft"), "loading": LiteralVar.create(True)}, + None, + { + **BASE, + "backgroundColor": "var(--ruby-3)", + "opacity": 0.5, + "cursor": "wait", + }, + SMALL_PARTS, + ), + ( + {"variant": "solid", "size": "2"}, + { + "color": "pink", + "_hover": {"background_color": "red"}, + "_focus": {"height": "1px"}, + "margin": "0", + "font_weight": None, + "width": ["1px", "2px"], + }, + { + "display": "inline-flex", + "color": "pink", + "marginTop": "0", + "marginRight": "0", + "marginBottom": "0", + "marginLeft": "0", + "outlineWidth": "1px", + "backgroundColor": {"default": "var(--accent-9)", ":hover": "red"}, + "height": {"default": "var(--space-6)", ":focus": "1px"}, + "width": {"default": "1px", XS: "2px"}, + }, + LARGE_PARTS, + ), + ( + {"variant": "solid"}, + { + "background_color": "red", + "outline": "2px solid", + "margin": MergeState.size, + }, + { + "display": "inline-flex", + "color": "white", + "backgroundColor": "red", + "outline": "2px solid", + "margin": SIZE, + }, + SMALL_PARTS, + ), + ], +) +def test_merge_order(props: Any, style: Any, expected: dict[str, Any], parts: Any): + """Base, variants, compound styles and the user style merge in that order. + + Args: + props: The props of the element. + style: The style the user wrote. + expected: The lowered properties of the element. + parts: The merged styles of its inner elements. + """ + merged = merge("rx.ui.button", BUTTON, props, style) + assert merged == Merged(_lowered(expected), (), parts) + assert merged.dynamic == () + assert list(merged.parts) == ["icon", "label"] + + +def test_layout_props_merge_between_the_table_and_the_style(): + """A layout prop wins over the table and loses to the user style.""" + assert merge( + "rx.ui.button", + BUTTON, + {"size": "1"}, + {"margin_left": "auto"}, + {"m": "2", "gap": "1"}, + ) == Merged( + _lowered({ + "display": "inline-flex", + "color": "black", + "marginTop": "var(--space-2)", + "marginRight": "var(--space-2)", + "marginBottom": "var(--space-2)", + "marginLeft": "auto", + "outlineWidth": "1px", + "height": "var(--space-5)", + "rowGap": "var(--space-1)", + "columnGap": "var(--space-1)", + }), + (), + SMALL_PARTS, + ) + + +def test_whole_dict_var_style_is_carried_with_the_table_styles(): + """A Var holding the user style leaves the table styles compiled.""" + merged = merge("rx.ui.button", BUTTON, {"size": "1"}, MergeState.style) + assert merged == Merged( + _lowered({**BASE, "height": "var(--space-5)"}, MergeState.style), + (), + SMALL_PARTS, + ) + assert merged != merge("rx.ui.button", BUTTON, {"size": "1"}) + + +def test_identical_inputs_give_one_hashable_result(): + """The emitter can share a declaration between elements that match.""" + plain = merge("rx.ui.button", BUTTON, {"variant": "solid", "size": "1"}) + assert merge("rx.ui.button", BUTTON, {"size": "1", "variant": "solid"}) is plain + assert merge("rx.ui.button", BUTTON, {"size": 1, "variant": "solid"}) is plain + + styled = [ + merge("rx.ui.button", BUTTON, {"size": "1"}, {"color": SIZE, "top": 0}), + merge("rx.ui.button", BUTTON, {"size": "1"}, {"top": 0, "color": SIZE}), + merge("rx.ui.button", BUTTON, {"size": SIZE}, {"color": SIZE, "top": 0}), + merge("rx.ui.button", BUTTON, {"size": SIZE}, {"color": SIZE, "top": 0}), + ] + assert styled[0] == styled[1] + assert styled[2] == styled[3] + assert styled[0] != styled[2] + assert styled[0] != plain + assert styled[0] != styled[0].style + assert [hash(merged) for merged in styled[:2]] == [hash(styled[0])] * 2 + assert len(set(styled)) == 2 + assert styled[2].dynamic[0] == styled[3].dynamic[0] + assert styled[2].dynamic[0] != styled[2] + assert len({styled[2].dynamic[0], styled[3].dynamic[0]}) == 1 + + +def test_state_bound_variant_returns_every_value_unresolved(): + """A prop bound to state gives one alternative per value of its variant.""" + merged = merge( + "rx.ui.button", + BUTTON, + {"variant": VARIANT, "size": "2"}, + {"color": "pink", "_hover": {"background_color": "red"}}, + ) + assert merged == Merged( + _lowered({ + **BASE, + "color": "pink", + "height": "var(--space-6)", + "backgroundColor": {":hover": "red"}, + }), + ( + Alternatives( + ("variant",), + (VARIANT,), + { + ("solid",): _lowered({ + "backgroundColor": { + "default": "var(--accent-9)", + ":hover": "red", + }, + "fontWeight": "700", + }), + ("soft",): _lowered({ + "backgroundColor": { + "default": "var(--ruby-3)", + ":hover": "red", + } + }), + ("ghost",): _lowered({"outline": "none", "outlineWidth": None}), + }, + ), + ), + LARGE_PARTS, + ) + assert merged.dynamic[0].props == ("variant",) + assert merged.dynamic[0].vars[0].equals(VARIANT) + assert list(merged.dynamic[0].values) == [("solid",), ("soft",), ("ghost",)] + assert merged.dynamic[0].values["ghost",].style == { + "outline": "none", + "outlineWidth": None, + } + + +def test_independent_state_bound_props_are_separate_alternatives(): + """Props that set different properties are picked one by one.""" + assert merge( + "rx.ui.button", BUTTON, {"variant": "soft", "size": SIZE, "loading": LOADING} + ) == Merged( + _lowered({**BASE, "backgroundColor": "var(--ruby-3)"}), + ( + Alternatives( + ("size",), + (SIZE,), + { + ("1",): _lowered({"height": "var(--space-5)"}), + ("2",): _lowered({ + "height": "var(--space-6)", + "color": {"default": "black", ":hover": "gray"}, + }), + }, + ), + Alternatives( + ("loading",), + (LOADING,), + {("true",): _lowered({"opacity": 0.5, "cursor": "wait"})}, + ), + ), + { + "icon": Merged( + _lowered({"width": "1em"}), + ( + Alternatives( + ("size",), (SIZE,), {("2",): _lowered({"width": "2em"})} + ), + ), + {"dot": DOT}, + ), + "label": LABEL, + }, + ) + + +def test_state_bound_props_that_depend_on_each_other_are_one_alternative(): + """Props that share a property or a compound style are picked together.""" + solid = {"backgroundColor": SOLID_BACKGROUND} + soft = _lowered({"backgroundColor": "var(--ruby-3)"}) + ghost = {"outline": "none", "outlineWidth": None} + assert merge( + "rx.ui.button", BUTTON, {"variant": VARIANT, "size": SIZE} + ).dynamic == ( + Alternatives( + ("variant", "size"), + (VARIANT, SIZE), + { + ("solid", "1"): _lowered({ + **solid, + "color": "white", + "height": "var(--space-5)", + }), + ("solid", "2"): _lowered({ + **solid, + "color": {"default": "white", ":hover": "gray"}, + "height": "var(--space-6)", + "fontWeight": "700", + }), + ("soft", "1"): _lowered({**soft.style, "height": "var(--space-5)"}), + ("soft", "2"): _lowered({ + **soft.style, + "height": "var(--space-6)", + "color": {"default": "black", ":hover": "gray"}, + }), + ("ghost", "1"): _lowered({**ghost, "height": "var(--space-5)"}), + ("ghost", "2"): _lowered({ + **ghost, + "height": "var(--space-6)", + "color": {"default": "black", ":hover": "gray"}, + }), + }, + ), + ) + + +def test_state_bound_prop_that_only_a_compound_style_reads(): + """The values a compound style names are the alternatives of its prop.""" + table: ComponentStyles = { + "base": {"color": "black"}, + "variants": {"size": {"1": {"top": 0}}}, + "compound": [ + {"props": {"size": "1", "tone": "loud"}, "style": {"color": "red"}}, + {"props": {"tone": "quiet"}, "style": {"color": "gray"}}, + ], + } + tone = MergeState.variant + assert merge("rx.ui.badge", table, {"size": "1", "tone": tone}) == Merged( + Lowered({"color": "black", "top": 0}), + ( + Alternatives( + ("tone",), + (tone,), + { + ("loud",): Lowered({"color": "red"}), + ("quiet",): Lowered({"color": "gray"}), + }, + ), + ), + ) + assert merge("rx.ui.badge", table, {"tone": tone}, {"color": "blue"}) == Merged( + Lowered({"color": "blue"}) + ) + assert repr(merge("rx.ui.badge", table, {"tone": "quiet"})) == ( + "Merged(Lowered({'color': 'gray'}, (), None), (), {})" + ) + assert repr(Alternatives(("tone",), (), {("loud",): Lowered({"top": 0})})) == ( + "Alternatives(('tone',), (), {('loud',): Lowered({'top': 0}, (), None)})" + ) + + +def test_table_is_lowered_again_when_the_breakpoints_change(): + """A table lowered before `set_breakpoints` does not keep the old widths.""" + table: ComponentStyles = {"base": {"width": ["1px", "2px"]}} + before = merge("rx.ui.box", table) + original = tuple(breakpoints_values) + set_breakpoints(("10px", "20px", "30px", "40px", "50px")) + try: + changed = merge("rx.ui.box", table) + finally: + set_breakpoints(original) # pyright: ignore [reportArgumentType] + assert before == Merged(Lowered({"width": {"default": "1px", XS: "2px"}})) + assert changed == Merged( + Lowered({ + "width": {"default": "1px", "@media screen and (min-width: 10px)": "2px"} + }) + ) + assert merge("rx.ui.box", table) == before + + +@pytest.mark.parametrize( + ("table", "style", "message"), + [ + ( + {"variant": {"size": {"1": {"top": 0}}}}, + None, + ( + 'rx.ui.card: unknown key "variant" in a style table. Use "base", ' + '"variants", "compound" or "parts".' + ), + ), + ( + {"variants": {"size": {"1": {"heght": "1em"}}}}, + None, + 'rx.ui.card: unknown CSS property "heght". Did you mean "height"?', + ), + ( + {"parts": {"thumb": {"base": {"& > div": {"top": 0}}}}}, + None, + ( + 'rx.ui.card: style key "& > div" is a nested selector, which rx.ui ' + "styles do not support. Style the child component directly, or keep " + "rx.card for this element." + ), + ), + ( + {"compound": [{"props": {"size": "1"}, "style": {"colr": "red"}}]}, + None, + 'rx.ui.card: unknown CSS property "colr". Did you mean "color"?', + ), + ( + {"base": {"top": 0}}, + {"paddng": "1em"}, + 'rx.ui.card: unknown CSS property "paddng". Did you mean "padding"?', + ), + ], +) +def test_errors(table: Any, style: Any, message: str): + """A table or a style that cannot be compiled is refused in full. + + Args: + table: The style table. + style: The style the user wrote. + message: The whole error message. + """ + with pytest.raises(StyleError) as error: + merge("rx.ui.card", table, None, style) + assert str(error.value) == message + + +def test_several_styles_are_merged_in_order(): + """Each style is a layer over the ones before it, and a Var is the inline one.""" + merged = merge( + "rx.ui.button", + {"base": {"color": "black", "padding_top": "1px"}}, + style=[ + {"color": "green", "_hover": {"color": "red"}}, + {}, + MergeState.style, + {"padding": "2px", "_hover": {"opacity": 0.5}}, + ], + ) + assert merged.style.style == { + "color": {"default": "green", ":hover": "red"}, + "paddingTop": "2px", + "paddingRight": "2px", + "paddingBottom": "2px", + "paddingLeft": "2px", + "opacity": {":hover": 0.5}, + } + assert merged.style.inline is MergeState.style + assert merge("rx.ui.button", {"base": {"color": "black"}}, style=[]) == merge( + "rx.ui.button", {"base": {"color": "black"}} + ) diff --git a/tests/units/reflex_components_ui/test__radix_tokens.py b/tests/units/reflex_components_ui/test__radix_tokens.py new file mode 100644 index 00000000000..264e1d3f471 --- /dev/null +++ b/tests/units/reflex_components_ui/test__radix_tokens.py @@ -0,0 +1,209 @@ +"""Tests for the generated list of the StyleX modules of reflex-components-ui. + +That the list is what its generator produces is checked by the javascript +package (``npm run generate:check``). These tests check that it describes the +javascript the package ships. +""" + +import re + +from reflex_components_radix.plugin import RADIX_THEMES_PACKAGE +from reflex_components_ui import _radix_tokens as tokens +from reflex_components_ui.constants import JS_SRC + +GRAYS = ("gray", "mauve", "olive", "sage", "sand", "slate") + +ACCENTS = ( + "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", +) + +SCALE_STEPS = ( + *(str(step) for step in range(1, 13)), + *(f"a{step}" for step in range(1, 13)), + "contrast", + "surface", + "indicator", + "track", +) + + +def _exports(module: str) -> list[str]: + """Read the names a generated javascript module exports. + + Args: + module: The module, relative to the javascript source. + + Returns: + The exported names, in the order the module defines them. + """ + return re.findall( + r"^export const (\w+) = ", (JS_SRC / module).read_text(), re.MULTILINE + ) + + +def test_generated_from_the_radix_themes_reflex_installs(): + """The version in the list is the one the Radix components install.""" + assert f"@radix-ui/themes@{tokens.RADIX_THEMES_VERSION}" == RADIX_THEMES_PACKAGE + + +def test_var_groups_are_the_exports_of_their_modules(): + """Every group is exported by the module it names, and no export is left out.""" + by_module: dict[str, list[str]] = {} + for name, (module, _) in tokens.VAR_GROUPS.items(): + by_module.setdefault(module, []).append(name) + generated = sorted( + path.relative_to(JS_SRC).as_posix() + for directory in ("colors", "tokens") + for path in (JS_SRC / directory).iterdir() + ) + assert sorted(by_module) == generated + assert {module: _exports(module) for module in by_module} == by_module + + +def test_color_scales_have_the_radix_steps(): + """A scale has twelve steps, twelve alpha steps and four functional colors.""" + scales = { + name: variables + for name, (module, variables) in tokens.VAR_GROUPS.items() + if module.startswith("colors/") + } + colors = sorted({*ACCENTS, *GRAYS} - {"gray"}) + assert sorted(scales) == sorted([*colors, "black", "white"]) + for name in colors: + assert sorted(scales[name]) == sorted( + f"--{name}-{step}" for step in SCALE_STEPS + ) + for name in ("black", "white"): + assert scales[name] == tuple(f"--{name}-a{step}" for step in range(1, 13)) + + +def test_themed_groups_keep_the_radix_names(): + """The variables a theme sets are the ones Radix components read.""" + assert sorted(tokens.VAR_GROUPS["accent"][1]) == sorted( + f"--accent-{step}" for step in SCALE_STEPS + ) + assert sorted(tokens.VAR_GROUPS["gray"][1]) == sorted( + f"--gray-{step}" for step in SCALE_STEPS + ) + assert tokens.VAR_GROUPS["scaling"] == ("tokens/scaling.stylex.js", ("--scaling",)) + assert tokens.VAR_GROUPS["radiusFactor"] == ( + "tokens/radius.stylex.js", + ("--radius-factor", "--radius-full", "--radius-thumb"), + ) + assert tokens.VAR_GROUPS["space"] == ( + "tokens/space.stylex.js", + tuple(f"--space-{step}" for step in range(1, 10)), + ) + + +def test_a_variable_belongs_to_one_group(): + """A custom property can be looked up without knowing its group.""" + names = [name for _, variables in tokens.VAR_GROUPS.values() for name in variables] + assert len(names) == len(set(names)) == 1070 + + +def test_themes_are_the_exports_of_their_modules(): + """Every value of every theme prop has a theme, in the module the list names.""" + assert { + name: (f"themes/accent/{name}.js", f"accent{name.capitalize()}") + for name in ACCENTS + } == tokens.ACCENT_THEMES + assert { + name: (f"themes/gray/{name}.js", f"gray{name.capitalize()}") for name in GRAYS + } == tokens.GRAY_THEMES + assert { + name: ("themes/radius.js", f"radius{name.capitalize()}") + for name in ("full", "large", "medium", "none", "small") + } == tokens.RADIUS_THEMES + assert { + f"{percent}%": ("themes/scaling.js", f"scaling{percent}") + for percent in (100, 105, 110, 90, 95) + } == tokens.SCALING_THEMES + assert tokens.PANEL_BACKGROUND_THEMES == { + "solid": ("themes/panel.js", "panelSolid"), + "translucent": ("themes/panel.js", "panelTranslucent"), + } + assert tokens.SCOPE_THEMES == ( + ("themes/scope.js", "spaceScope"), + ("themes/scope.js", "radiusScope"), + ("themes/scope.js", "typographyScope"), + ("themes/scope.js", "shadowScope"), + ("themes/scope.js", "colorScope"), + ) + assert tokens.FOCUS_THEME == ("themes/focus.js", "focusScope") + assert tokens.THEME_STYLES == ( + "themes/theme.js", + "theme", + ("light", "dark", "background", "root"), + ) + by_module: dict[str, list[str]] = {} + for module, name in ( + *tokens.ACCENT_THEMES.values(), + *tokens.GRAY_THEMES.values(), + *tokens.RADIUS_THEMES.values(), + *tokens.SCALING_THEMES.values(), + *tokens.PANEL_BACKGROUND_THEMES.values(), + *tokens.SCOPE_THEMES, + tokens.FOCUS_THEME, + tokens.THEME_STYLES[:2], + ): + by_module.setdefault(module, []).append(name) + generated = sorted( + path.relative_to(JS_SRC).as_posix() + for path in (JS_SRC / "themes").rglob("*.js") + ) + assert sorted(by_module) == generated + assert {module: _exports(module) for module in by_module} == by_module + + +def test_defaults_are_the_props_of_a_radix_theme(): + """A theme that is given nothing is the default Radix theme.""" + assert tokens.DEFAULTS == { + "accent_color": "indigo", + "gray_color": "auto", + "radius": "medium", + "scaling": "100%", + "panel_background": "translucent", + } + + +def test_every_accent_has_a_matching_gray(): + """The gray that ``auto`` stands for is a gray theme.""" + assert tuple(tokens.MATCHING_GRAY) == ACCENTS + assert set(tokens.MATCHING_GRAY.values()) == set(GRAYS) + assert { + accent: tokens.MATCHING_GRAY[accent] + for accent in ("gray", "indigo", "tomato", "jade", "grass", "amber") + } == { + "gray": "gray", + "indigo": "slate", + "tomato": "mauve", + "jade": "sage", + "grass": "olive", + "amber": "sand", + } diff --git a/tests/units/reflex_components_ui/test_api_parity.py b/tests/units/reflex_components_ui/test_api_parity.py new file mode 100644 index 00000000000..a1c36ace775 --- /dev/null +++ b/tests/units/reflex_components_ui/test_api_parity.py @@ -0,0 +1,179 @@ +"""The Python API of every rx.ui component is the Radix component's. + +``rx.button(...)`` becomes ``rx.ui.button(...)`` with the same arguments. An +intended difference is an ``[[api]]`` entry of the parity allowlist, with the +reason the migration guide gives for it. +""" + +import types +from typing import Any, Literal + +import reflex_components_ui +from reflex_base.components.component import Component +from reflex_base.event import EventHandler, no_args_event_spec +from reflex_base.vars.base import Var +from reflex_components_ui.base import UIComponent +from reflex_components_ui.layout.box import Box +from ui_parity import allowlist +from ui_parity.allowlist import Allowlist, ApiEntry +from ui_parity.api import ( + ApiDifference, + component_class, + diff_api, + type_shape, + unexplained, +) + +import reflex as rx + +# The names of the namespace that create a component: a theme of the plugin +# and the design tokens are no components. +COMPONENTS = sorted( + name + for name in reflex_components_ui.__all__ + if isinstance(getattr(reflex_components_ui, name), types.MethodType) +) + + +def differences(component: str) -> list[ApiDifference]: + """Compare a component of rx.ui with the one of the same name in rx. + + Args: + component: The name of the component. + + Returns: + The differences of their APIs. + """ + return diff_api( + component, + component_class(getattr(rx, component)), + component_class(getattr(reflex_components_ui, component)), + ) + + +def test_every_component_has_the_api_of_its_radix_counterpart(): + found = [item for name in COMPONENTS for item in differences(name)] + unlisted, stale = unexplained(found, allowlist.load()) + assert unlisted == [], ( + "rx.ui differs from rx: match the Radix component, or list the " + "difference under [[api]] in allowlist.toml with its reason." + ) + assert stale == [], "These [[api]] names are differences no more: remove them." + + +def wrapper(without: str | None = None) -> type[Component]: + """Fork the Radix box as a wave does: a wrapper with the same props. + + Args: + without: A prop to leave out of the wrapper. + + Returns: + The wrapper. + """ + reference = component_class(rx.box) + fields = reference.get_fields() + return type( + "Box", + (UIComponent,), + { + "__annotations__": { + name: fields[name].annotated_type + for name in reference.get_props() + if name != without + }, + "__module__": __name__, + }, + ) + + +def test_box_wrapper_with_every_prop_has_no_difference(): + assert diff_api("box", component_class(rx.box), wrapper()) == [] + + +def test_removing_a_prop_from_the_wrapper_is_a_difference(): + found = diff_api("box", component_class(rx.box), wrapper(without="title")) + assert found == [ + ApiDifference( + component="box", + kind="prop", + name="title", + reference="Var[str]", + candidate=None, + ) + ] + # The parity test fails on it: nothing lists the difference. + assert unexplained(found, Allowlist()) == (found, []) + + +def test_box_differs_only_by_the_props_the_allowlist_gives_a_reason_for(): + found = differences("box") + (entry,) = (item for item in allowlist.load().api if item.component == "box") + assert entry.kind == "prop" + assert [(item.kind, item.name, item.candidate) for item in found] == [ + ("prop", name, None) for name in entry.names + ] + + +class Reference(Component): + """A component as Radix has it.""" + + size: Var[Literal["1", "2", "3"]] + variant: Var[Literal["solid", "soft"]] + loading: Var[bool] + on_open_change: EventHandler[no_args_event_spec] + + +class Candidate(Component): + """Its fork: a size less, a renamed prop, another trigger.""" + + size: Var[Literal["2", "1"]] + variant: Var[Literal["soft", "solid"]] + busy: Var[bool] + on_toggle: EventHandler[no_args_event_spec] + + +def test_diff_api_finds_props_types_and_event_triggers(): + assert diff_api("thing", Reference, Candidate) == [ + ApiDifference("thing", "event", "on_open_change", "trigger", None), + ApiDifference("thing", "event", "on_toggle", None, "trigger"), + ApiDifference("thing", "prop", "busy", None, "Var[bool]"), + ApiDifference("thing", "prop", "loading", "Var[bool]", None), + ApiDifference( + "thing", + "type", + "size", + "Var[Literal['1', '2', '3']]", + "Var[Literal['1', '2']]", + ), + ] + + +def test_unexplained_separates_the_unlisted_from_the_stale(): + found = diff_api("thing", Reference, Candidate) + listed = ApiEntry( + component="thing", + kind="prop", + names=("busy", "loading", "color"), + reason="Renamed.", + ) + other = ApiEntry( + component="other", kind="event", names=("on_toggle",), reason="Another." + ) + assert unexplained(found, Allowlist(api=(listed, other))) == ( + [found[0], found[1], found[4]], + [(listed, "color"), (other, "on_toggle")], + ) + + +def test_type_shape_ignores_where_a_type_is_defined_and_its_order(): + responsive: Any = Var[Literal["2", "1"] | dict[str, Literal["1", "2"]]] + assert type_shape(responsive) == ( + "Var[Literal['1', '2'] | dict[str, Literal['1', '2']]]" + ) + assert type_shape(Var[int | None]) == "Var[None | int]" + assert type_shape(Box) == "Box" + + +def test_component_class_reads_a_factory_and_a_namespace(): + assert component_class(rx.ui.box) is Box + assert component_class(rx.select).__name__ == "HighLevelSelect" diff --git a/tests/units/reflex_components_ui/test_base.py b/tests/units/reflex_components_ui/test_base.py new file mode 100644 index 00000000000..2ca3bfa9639 --- /dev/null +++ b/tests/units/reflex_components_ui/test_base.py @@ -0,0 +1,899 @@ +"""Tests for reflex_components_ui.base.""" + +from collections.abc import Callable +from typing import Any, ClassVar, Literal + +import pytest +from reflex_base.components.component import Component +from reflex_base.components.memo import MEMOS +from reflex_base.config import get_config +from reflex_base.plugins import CompileContext +from reflex_base.utils.exceptions import ConfigError +from reflex_base.utils.serializers import serialize +from reflex_base.vars.base import Var +from reflex_components_ui import tokens +from reflex_components_ui.base import Part, UIComponent +from reflex_components_ui.plugin import UIPlugin +from reflex_components_ui.style import ComponentStyles, StyleError +from reflex_components_ui.themes import LiteralAccentColor, ThemeError + +import reflex as rx +from reflex.compiler import compiler + +# A page whose elements use the tokens of two modules, two of them equally. +PAGE = """import * as stylex from "@stylexjs/stylex" +import "$/reflex-ui/colors/jade.stylex.js" +import "$/reflex-ui/colors/ruby.stylex.js" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + + + +const sx_7e30cd30d8 = stylex.create({ s: {"color": "var(--ruby-9)", "top": "8px"} }); +const sx_7e30cd30d8_c = stylex.props(sx_7e30cd30d8.s).className; +const sx_f17eb59c2d = stylex.create({ s: {"backgroundColor": "var(--jade-3)"} }); +const sx_f17eb59c2d_c = stylex.props(sx_f17eb59c2d.s).className; + +function Component() { + + + return ( + jsx(Fragment,{},jsx("main",{},jsx("section",{className:sx_7e30cd30d8_c},"ruby"),jsx("section",{className:sx_7e30cd30d8_c},"again"),jsx("div",{className:sx_f17eb59c2d_c},"jade")),jsx("title",{}," | Index"),jsx("meta",{content:"",property:"og:image"},)) + ) +} +Component.displayName = "Component(/)"; + +export default Component; +""" + +# A page whose only element was moved into a module of its own. +MEMO_PAGE = """import {Button_button_f1bbe1600e526de2c75f843fcd30a1d1} from "$/utils/components/Button_button_f1bbe1600e526de2c75f843fcd30a1d1" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + + + + + +function Component() { + + + return ( + jsx(Fragment,{},jsx(Button_button_f1bbe1600e526de2c75f843fcd30a1d1,{},"hello"),jsx("title",{}," | Index"),jsx("meta",{content:"",property:"og:image"},)) + ) +} +Component.displayName = "Component(/)"; + +export default Component; +""" + +# The module that renders the element: its declaration, the table of its +# bound prop, the import of the tokens it uses and the state its styles read. +MEMO_MODULE = """ +import {isTrue,mergeSlotProps} from "$/utils/state" +import {useStateContext} from "$/utils/context-registry" +import * as stylex from "@stylexjs/stylex" +import "$/reflex-ui/colors/ruby.stylex.js" +import {jsx} from "@emotion/react" +import {Fragment,memo,useEffect} from "react" + + + +const sx_a860bb1ca1 = stylex.create({ s: {"width": "var(--v0)", "borderTopColor": "var(--ruby-9)"}, a0_0: {"color": "white", "backgroundColor": "black"}, a0_1: {"color": "black", "opacity": 0.5}, a0: {"color": "black"} }); +const sx_a860bb1ca1_c = stylex.props(sx_a860bb1ca1.s).className; +const sx_a860bb1ca1_0 = { __proto__: null, "solid": stylex.props(sx_a860bb1ca1.a0_0).className, "soft": stylex.props(sx_a860bb1ca1.a0_1).className }; +const sx_a860bb1ca1_0d = stylex.props(sx_a860bb1ca1.a0).className; + + +export const Button_button_f1bbe1600e526de2c75f843fcd30a1d1 = /*#__PURE__*/ (() => { +const Button_button_f1bbe1600e526de2c75f843fcd30a1d1 = memo(({children, ...rest}) => { + const reflex___state____state__tests___units___reflex_components_ui___test_base____base_test_state = useStateContext("reflex___state____state.tests___units___reflex_components_ui___test_base____base_test_state", ["kind_rx_state_", "color_rx_state_"]) + return( + jsx("button",{...mergeSlotProps(rest, ({ className:sx_a860bb1ca1_c + " " + (sx_a860bb1ca1_0[reflex___state____state__tests___units___reflex_components_ui___test_base____base_test_state.kind_rx_state_] ?? sx_a860bb1ca1_0d), style:({ "--v0": (reflex___state____state__tests___units___reflex_components_ui___test_base____base_test_state.color_rx_state_) ?? "initial" }) }))},children) + ) +}); +Button_button_f1bbe1600e526de2c75f843fcd30a1d1.displayName = "Button"; +return Button_button_f1bbe1600e526de2c75f843fcd30a1d1; +})(); +""" + +# The module of an rx.memo component, which is named after where it is defined. +RX_MEMO_MODULE = """ +import {isTrue} from "$/utils/state" +import * as stylex from "@stylexjs/stylex" +import "$/reflex-ui/colors/ruby.stylex.js" +import {jsx} from "@emotion/react" +import {Fragment,memo,useEffect} from "react" + + + +const sx_7e30cd30d8 = stylex.create({ s: {"color": "var(--ruby-9)", "top": "8px"} }); +const sx_7e30cd30d8_c = stylex.props(sx_7e30cd30d8.s).className; + + + + +export const RubyCard_87d7d58e = /*#__PURE__*/ (() => { +const RubyCard_87d7d58e = memo(({}) => { + + return( + jsx("section",{className:sx_7e30cd30d8_c},"ruby") + ) +}); +RubyCard_87d7d58e.displayName = "RubyCard"; +return RubyCard_87d7d58e; +})(); +""".replace("", " ") + +# What the browser evaluates for a component held in state. +DYNAMIC_MODULE = ( + "//__reflex_evaluate:[]\n" + "const React = window.__reflex.react;\n" + "\n" + "const {jsx} = window.__reflex['@emotion/react']\n" + "const {Fragment,useEffect} = window.__reflex['react']\n" + "const {pyOr} = window.__reflex['$/utils/state']\n" + "\n" + "export default function MySSRComponent () {\n" + " \n" + " return (\n" + ' (jsx("button", ({className:"p-8",style:({ ["color"] : "black", ' + '["opacity"] : 0.5, ["paddingTop"] : "4px", ["paddingRight"] : "4px", ' + '["paddingBottom"] : "4px", ["paddingLeft"] : "4px", ["zIndex"] : 2 })}), ' + '"hello"))\n' + " )\n" + "}" +) + + +class Plain(UIComponent): + """An element with no look of its own.""" + + +class Card(UIComponent): + """An element whose look has a condition.""" + + tag = "section" + + styles: ClassVar[ComponentStyles] = { + "base": {"color": {"default": "red", ":hover": "blue"}, "top": "8px"}, + } + + +class Button(UIComponent): + """An element with variants, a layout prop and an attribute.""" + + tag = "button" + + styles: ClassVar[ComponentStyles] = { + "base": {"color": "black"}, + "variants": { + "kind": { + "solid": {"color": "white", "background_color": "black"}, + "soft": {"opacity": 0.5}, + }, + "size": {"1": {"height": "1em"}, "2": {"height": "2em"}}, + }, + "compound": [ + {"props": {"kind": "solid", "size": "2"}, "style": {"font_weight": 700}}, + ], + } + + # Which look the button has. + kind: Var[Literal["solid", "soft"]] + + # How tall the button is. + size: Var[Literal["1", "2"]] + + # The space between the children. + gap: Var[str] + + # The tooltip of the element. + title: Var[str] + + +class Switch(UIComponent): + """An element with an inner element that the same props style.""" + + tag = "button" + + styles: ClassVar[ComponentStyles] = { + "base": {"width": "2em"}, + "parts": { + "track": {"base": {"display": "block"}}, + "thumb": { + "base": {"width": "1em"}, + "variants": {"size": {"2": {"width": "2em"}}}, + }, + }, + } + + # How large the switch is. + size: Var[Literal["1", "2"]] + + @classmethod + def create(cls, *children, **props) -> Component: + """Create the switch around its track and thumb. + + Args: + *children: The children of the component. + **props: The props of the component. + + Returns: + The component. + """ + return super().create( + Part.create( + Part.create(part="thumb", tag="span"), part="track", tag="span" + ), + *children, + **props, + ) + + +class BaseTestState(rx.State): + """State the styles, the props and the class names are bound to.""" + + color: rx.Field[str] = rx.field("red") + names: rx.Field[str] = rx.field("p-8") + kind: rx.Field[str] = rx.field("solid") + size: rx.Field[str] = rx.field("1") + styles: rx.Field[dict[str, str]] = rx.field(default_factory=dict) + + @rx.event + def noop(self): + """Do nothing.""" + + +S = BaseTestState + +# Styles a type checker refuses, typed loosely to reach the compiler. +MISSPELT: Any = {"paddng": "1em"} +NESTED: Any = {"& > div": {"color": "red"}} +NOT_A_STYLE: Any = ["color: red"] + + +def test_rendering_without_the_plugin_says_how_to_configure_it( + monkeypatch: pytest.MonkeyPatch, compile_page: Callable[..., CompileContext] +): + monkeypatch.setattr(get_config(), "plugins", []) + with pytest.raises(ConfigError) as raised: + compile_page(lambda: Card.create("hello")) + assert ( + str(raised.value) + == "rx.ui components need rx.plugins.UIPlugin() in rxconfig.py plugins." + ) + with pytest.raises(ConfigError) as raised: + Card.create("hello").render() + assert ( + str(raised.value) + == "rx.ui components need rx.plugins.UIPlugin() in rxconfig.py plugins." + ) + + +def test_element_without_styles_is_a_plain_element(ui_plugin: UIPlugin): + component = Plain.create("hello", class_name="p-8") + assert component.render() == { + "name": '"div"', + "props": ['className:"p-8"'], + "children": [{"contents": '"hello"'}], + } + assert component._get_all_custom_code() == {} + assert component._get_all_imports() == {} + + +def test_style_is_spread_from_a_declaration_and_never_a_css_prop(ui_plugin: UIPlugin): + """The user's style is merged over the component's, by property.""" + component = Card.create("hello", style={"top": "4px", "margin_top": 2}) + assert component._get_all_custom_code() == { + 'const sx_14c89d843a = stylex.create({ s: {"color": {"default": "red", ' + '":hover": "blue"}, "top": "4px", "marginTop": 2} });\n' + "const sx_14c89d843a_c = stylex.props(sx_14c89d843a.s).className;": None + } + assert component.render() == { + "name": '"section"', + "props": ["className:sx_14c89d843a_c"], + "children": [{"contents": '"hello"'}], + } + assert component._get_style() == {} + + +def test_keyword_arguments_are_props_events_attributes_or_styles(ui_plugin: UIPlugin): + """Only what is none of the first three is read as a CSS property. + + A prop the style table reads and a layout prop are styles too: neither is + an attribute of the element. + """ + component = Button.create( + "save", + kind="solid", + size="2", + gap="3", + title="Save", + id="save", + data_state="on", + aria_label="Save", + on_click=S.noop, + margin_top="1px", + style={"margin_top": "2px", "top": 0}, + ) + assert component._get_all_custom_code() == { + 'const sx_1027767e47 = stylex.create({ s: {"color": "white", ' + '"backgroundColor": "black", "height": "2em", "fontWeight": 700, "rowGap": ' + '"var(--space-3)", "columnGap": "var(--space-3)", "top": 0, "marginTop": ' + '"1px"} });\n' + "const sx_1027767e47_c = stylex.props(sx_1027767e47.s).className;": None + } + assert component.render()["props"] == [ + '"aria-label":"Save"', + "className:sx_1027767e47_c", + '"data-state":"on"', + 'id:"save"', + ( + 'onClick:((_e) => (addEvents([(ReflexEvent("reflex___state____state.' + 'tests___units___reflex_components_ui___test_base____base_test_state.noop", ' + "({ }), ({ })))], [_e], ({ }))))" + ), + "ref:ref_save", + 'title:"Save"', + ] + assert list(component.event_triggers) == ["on_click"] + assert component.style == {} + + +@pytest.mark.parametrize( + ("create", "message"), + [ + ( + lambda: Card.create(paddng="1em"), + 'rx.ui.card: unknown CSS property "paddng". Did you mean "padding"?', + ), + ( + lambda: Card.create(style=MISSPELT), + 'rx.ui.card: unknown CSS property "paddng". Did you mean "padding"?', + ), + ( + lambda: Card.create(style=NESTED), + ( + 'rx.ui.card: style key "& > div" is a nested selector, which rx.ui ' + "styles do not support. Style the child component directly, or keep " + "rx.card for this element." + ), + ), + ( + # A layout prop of another component is not one of this one. + lambda: Card.create(spacing="3"), + 'rx.ui.card: unknown CSS property "spacing". Did you mean "padding"?', + ), + ( + lambda: Card.create(style=NOT_A_STYLE), + ( + "rx.ui.card: style must be a dict of styles, a list of them or a " + "Var, not str." + ), + ), + ( + lambda: Button.create(gap=S.color), + ( + 'rx.ui.button: layout prop "gap" is bound to state, but its values ' + 'are read at compile time. Bind the "gap" style instead, which takes ' + "any CSS value." + ), + ), + ( + lambda: Card.create(background=S.color), + ( + 'rx.ui.card: style "background" is bound to state, but rx.ui styles ' + "split this shorthand into longhands at compile time. Bind " + "background_color, background_image and its other longhands instead." + ), + ), + ], +) +def test_style_that_cannot_be_compiled_is_an_error_where_it_is_written( + create: Callable[[], UIComponent], message: str +): + with pytest.raises(StyleError) as raised: + create() + assert str(raised.value) == message + + +def test_unknown_event_trigger_is_not_mistaken_for_a_style(): + with pytest.raises(ValueError) as raised: + Plain.create(on_paddng=S.noop) + assert str(raised.value) == ( + "The Plain does not take in an `on_paddng` event trigger. Valid triggers " + "for Plain: ['on_blur', 'on_click', 'on_context_menu', 'on_double_click', " + "'on_focus', 'on_mount', 'on_mouse_down', 'on_mouse_enter', " + "'on_mouse_leave', 'on_mouse_move', 'on_mouse_out', 'on_mouse_over', " + "'on_mouse_up', 'on_scroll', 'on_scroll_end', 'on_unmount']. If Plain is a " + "third party component make sure to add `on_paddng` to the component's " + "event triggers. visit " + "https://reflex.dev/docs/wrapping-react/guide/#event-triggers for more info." + ) + + +def test_styles_in_a_list_and_keywords_are_written_over_each_other( + ui_plugin: UIPlugin, +): + """A key replaces the same key, as in the style of any Reflex component. + + What is written last wins over a shorthand or a longhand written before + it, and a keyword argument is written after the ``style``. + """ + component = Plain.create( + style=[ + {"padding_top": "1px", "_hover": {"color": "red"}}, + {"padding": "2px", "_hover": {"opacity": 0.5}}, + {"padding_top": "3px"}, + ], + color="blue", + ) + assert component._get_all_custom_code() == { + 'const sx_1799fc9438 = stylex.create({ s: {"paddingTop": "3px", ' + '"paddingRight": "2px", "paddingBottom": "2px", "paddingLeft": "2px", ' + '"opacity": {":hover": 0.5}, "color": "blue"} });\n' + "const sx_1799fc9438_c = stylex.props(sx_1799fc9438.s).className;": None + } + + +def test_style_per_breakpoint_becomes_blocks_under_media_queries(ui_plugin: UIPlugin): + named = Plain.create( + style=rx.breakpoints(initial={"color": "red", "top": 0}, sm={"color": "blue"}) + ) + assert named._get_all_custom_code() == { + 'const sx_10c4c20799 = stylex.create({ s: {"color": {"default": "red", ' + '"@media screen and (min-width: 48em)": "blue"}, "top": 0} });\n' + "const sx_10c4c20799_c = stylex.props(sx_10c4c20799.s).className;": None + } + custom = Plain.create(style=rx.breakpoints({"0px": {"top": 0}, "40em": {"top": 1}})) + assert custom._get_all_custom_code() == { + 'const sx_8b8c48b483 = stylex.create({ s: {"top": {"@media screen and ' + '(min-width: 0px)": 0, "@media screen and (min-width: 40em)": 1}} });\n' + "const sx_8b8c48b483_c = stylex.props(sx_8b8c48b483.s).className;": None + } + + +def test_literal_class_names_are_joined_with_those_of_the_style(ui_plugin: UIPlugin): + """The element has one className: its own class names, then the constant.""" + component = Card.create(class_name=["p-8", "m-2"], custom_attrs={"role": "note"}) + assert component.render()["props"] == [ + 'className:"p-8 m-2 " + sx_262fdfab15_c', + 'role:"note"', + ] + + +def test_class_names_from_state_are_joined_with_those_of_the_style(ui_plugin: UIPlugin): + component = Card.create(class_name=S.names) + assert component.render()["props"] == [ + f'className:({S.names!s}) + " " + sx_262fdfab15_c' + ] + + +def test_value_bound_to_state_is_a_custom_property_of_the_element(ui_plugin: UIPlugin): + component = Card.create(width=S.color, class_name="p-8", style=S.styles) + assert component._get_all_custom_code() == { + 'const sx_bf234bb6b2 = stylex.create({ s: {"color": {"default": "red", ' + '":hover": "blue"}, "top": "8px", "width": "var(--v0)"} });\n' + "const sx_bf234bb6b2_c = stylex.props(sx_bf234bb6b2.s).className;": None + } + assert component.render()["props"] == [ + 'className:"p-8 " + sx_bf234bb6b2_c', + f'style:({{ "--v0": ({S.color!s}) ?? "initial", ...{S.styles!s} }})', + ] + # The Vars bring the hooks that read the state into the module. + assert [str(var) for var in component._get_vars()] == [ + str(S.color), + str(S.styles), + ] + + +def test_whole_style_from_state_is_the_inline_style(ui_plugin: UIPlugin): + component = Plain.create(style=S.styles) + assert component._get_all_custom_code() == {} + assert component.render()["props"] == [f"style:{S.styles!s}"] + + +# The styles of each value of the button's kind, and of a value that is none. +KIND_DECLARATION = ( + 'const sx_749372103b = stylex.create({ a0_0: {"color": "white", ' + '"backgroundColor": "black"}, a0_1: {"color": "black", "opacity": 0.5}, a0: ' + '{"color": "black"} });\n' + 'const sx_749372103b_0 = { __proto__: null, "solid": ' + 'stylex.props(sx_749372103b.a0_0).className, "soft": ' + "stylex.props(sx_749372103b.a0_1).className };\n" + "const sx_749372103b_0d = stylex.props(sx_749372103b.a0).className;" +) +KIND_LOOKUP = "(sx_749372103b_0[] ?? sx_749372103b_0d)" + + +@pytest.mark.parametrize( + ("props", "declaration", "rendered"), + [ + ({"kind": S.kind}, KIND_DECLARATION, [f"className:{KIND_LOOKUP}"]), + ( + {"kind": S.kind, "class_name": "p-8"}, + KIND_DECLARATION, + [f'className:"p-8 " + {KIND_LOOKUP}'], + ), + ( + {"kind": S.kind, "class_name": S.names}, + KIND_DECLARATION, + [f'className:() + " " + {KIND_LOOKUP}'], + ), + ( + # Props that a compound style combines are indexed together. + {"kind": S.kind, "size": S.size}, + ( + 'const sx_5874f5ad04 = stylex.create({ a0_0: {"color": "white", ' + '"backgroundColor": "black", "height": "1em"}, a0_1: {"color": ' + '"white", "backgroundColor": "black", "height": "2em", "fontWeight": ' + '700}, a0_2: {"color": "black", "opacity": 0.5, "height": "1em"}, ' + 'a0_3: {"color": "black", "opacity": 0.5, "height": "2em"}, a0: ' + '{"color": "black"} });\n' + 'const sx_5874f5ad04_0 = { __proto__: null, "solid": { __proto__: ' + 'null, "1": stylex.props(sx_5874f5ad04.a0_0).className, "2": ' + 'stylex.props(sx_5874f5ad04.a0_1).className }, "soft": { __proto__: ' + 'null, "1": stylex.props(sx_5874f5ad04.a0_2).className, "2": ' + "stylex.props(sx_5874f5ad04.a0_3).className } };\n" + "const sx_5874f5ad04_0d = stylex.props(sx_5874f5ad04.a0).className;" + ), + ["className:(sx_5874f5ad04_0[]?.[] ?? sx_5874f5ad04_0d)"], + ), + ], +) +def test_prop_bound_to_state_indexes_the_class_names_of_its_values( + ui_plugin: UIPlugin, props: dict[str, Any], declaration: str, rendered: list[str] +): + component = Button.create(**props) + assert component._get_all_custom_code() == {declaration: None} + assert component.render()["props"] == [ + prop + .replace("", str(S.kind)) + .replace("", str(S.size)) + .replace("", str(S.names)) + for prop in rendered + ] + + +def test_parts_are_styled_by_the_table_of_their_component(ui_plugin: UIPlugin): + """A part reads the props of its component, bound to state or not.""" + width = ( + 'const sx_95ab4202b0 = stylex.create({ s: {"width": "2em"} });\n' + "const sx_95ab4202b0_c = stylex.props(sx_95ab4202b0.s).className;" + ) + block = ( + 'const sx_1cb1fb1245 = stylex.create({ s: {"display": "block"} });\n' + "const sx_1cb1fb1245_c = stylex.props(sx_1cb1fb1245.s).className;" + ) + component = Switch.create("on", size="2") + # The switch and its thumb have the same style, and share its declaration. + assert component._get_all_custom_code() == {width: None, block: None} + assert component.render() == { + "name": '"button"', + "props": ["className:sx_95ab4202b0_c"], + "children": [ + { + "name": '"span"', + "props": ["className:sx_1cb1fb1245_c"], + "children": [ + { + "name": '"span"', + "props": ["className:sx_95ab4202b0_c"], + "children": [], + } + ], + }, + {"contents": '"on"'}, + ], + } + bound = Switch.create(size=S.size) + assert bound._get_all_custom_code() == { + width: None, + block: None, + ( + 'const sx_bd2235d0fb = stylex.create({ a0_0: {"width": "2em"}, a0: ' + '{"width": "1em"} });\n' + 'const sx_bd2235d0fb_0 = { __proto__: null, "2": ' + "stylex.props(sx_bd2235d0fb.a0_0).className };\n" + "const sx_bd2235d0fb_0d = stylex.props(sx_bd2235d0fb.a0).className;" + ): None, + } + thumb = bound.render()["children"][0]["children"][0] + assert thumb == { + "name": '"span"', + "props": [f"className:(sx_bd2235d0fb_0[{S.size!s}] ?? sx_bd2235d0fb_0d)"], + "children": [], + } + # The size is a style of the switch and its thumb, not an attribute. + assert bound.render()["props"] == ["className:sx_95ab4202b0_c"] + + +def test_part_outside_its_component_says_where_it_belongs(ui_plugin: UIPlugin): + with pytest.raises(StyleError) as raised: + Switch.create(Part.create(part="thum")) + assert str(raised.value) == ( + 'rx.ui.switch: its style table has no part "thum". Did you mean "thumb"?' + ) + with pytest.raises(StyleError) as raised: + Part.create(part="thumb", color="red") + assert str(raised.value) == ( + 'rx.ui.part: the part "thumb" takes its styles from the style table of its ' + "component. Style it there." + ) + stray = Plain.create(Part.create(part="thumb")) + message = ( + 'rx.ui.part: the part "thumb" is not in a component whose style table has ' + "it. Create it as a child of its component, or of another part of it." + ) + with pytest.raises(StyleError) as raised: + stray.render() + assert str(raised.value) == message + # The same holds where the component is evaluated in the browser. + with pytest.raises(StyleError) as raised: + serialize(stray) + assert str(raised.value) == message + + +def test_styles_of_the_app_apply_before_those_of_the_element(ui_plugin: UIPlugin): + component = Card.create(top="1px") + component._add_style_recursive({ + Card: rx.Style({"top": "2px", "color": "green", "_hover": {"left": 0}}) + }) + assert component._get_all_custom_code() == { + 'const sx_802fe7deea = stylex.create({ s: {"color": "green", "top": "1px", ' + '"left": {":hover": 0}} });\n' + "const sx_802fe7deea_c = stylex.props(sx_802fe7deea.s).className;": None + } + + +def test_page_declares_styles_and_imports_the_modules_of_their_tokens( + ui_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + def page(): + return rx.el.main( + Card.create("ruby", color=rx.color("ruby", 9)), + Card.create("again", color=rx.color("ruby", 9)), + Plain.create("jade", background_color=rx.color("jade", 3)), + ) + + assert compile_page(page).compiled_pages["/"].output_code == PAGE + + +def test_declaration_and_imports_follow_the_element_into_a_memo_module( + ui_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + """StyleX only folds a style declared in the module that renders it. + + A value bound to state makes the compiler move the element into a module + of its own: the declaration and the imports go there, and leave the page. + """ + ctx = compile_page( + lambda: Button.create( + "hello", + kind=S.kind, + width=S.color, + border_top_color=rx.color("ruby", 9), + ) + ) + assert ctx.compiled_pages["/"].output_code == MEMO_PAGE + ((_, memo_module),) = compiler.compile_memo_components( + tuple(ctx.auto_memo_components.values()) + )[0] + assert memo_module == MEMO_MODULE + + +def test_declaration_and_imports_follow_the_element_into_an_rx_memo_module( + ui_plugin: UIPlugin, preserve_memo_registries: None +): + @rx.memo + def ruby_card() -> rx.Component: + return Card.create("ruby", color=rx.color("ruby", 9)) + + ((_, memo_module),) = compiler.compile_memo_components(( + next(memo for memo in MEMOS.values() if memo.python_name == "ruby_card"), + ))[0] + assert memo_module == RX_MEMO_MODULE + + +def test_dynamic_component_falls_back_to_an_inline_style(): + """Code evaluated in the browser has no build, no plugin and no StyleX.""" + component = Button.create( + "hello", kind="soft", style={"padding": "4px", "z_index": 2}, class_name="p-8" + ) + assert serialize(component) == DYNAMIC_MODULE + + +@pytest.mark.parametrize( + ("create", "message"), + [ + ( + lambda: Card.create("hello"), + ( + 'rx.ui.card: the style "color" has conditions ("default", ":hover"), ' + "which a component rendered from state cannot apply: its code is " + "evaluated in the browser and never reaches the StyleX compiler. Use an " + "unconditional value there, or render the component in a page and show " + "it with rx.cond." + ), + ), + ( + lambda: Plain.create(width=S.color), + ( + 'rx.ui.plain: the style "width" is bound to state, which a component ' + "rendered from state cannot apply: its code is evaluated in the browser " + "and never reaches the StyleX compiler. Use a literal value there, or " + "render the component in a page and show it with rx.cond." + ), + ), + ( + lambda: Button.create(kind=S.kind), + ( + 'rx.ui.button: the props "kind" select a style and are bound to ' + "state, which a component rendered from state cannot apply: its code is " + "evaluated in the browser and never reaches the StyleX compiler. Give " + "them literal values there, or render the component in a page and show " + "it with rx.cond." + ), + ), + ], +) +def test_dynamic_component_cannot_have_a_style_that_needs_the_compiler( + create: Callable[[], UIComponent], message: str +): + with pytest.raises(StyleError) as raised: + serialize(create()) + assert str(raised.value) == message + + +class Chip(UIComponent): + """An element with a color of its own.""" + + tag = "span" + + styles: ClassVar[ComponentStyles] = { + "base": {"background_color": tokens.accent[9], "color": tokens.accent.contrast}, + } + + # The accent color of the element. + color_scheme: Var[LiteralAccentColor] + + +CHIP_PAGE = """import * as stylex from "@stylexjs/stylex" +import "$/reflex-ui/tokens/accent.stylex.js" +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentRed} from "$/reflex-ui/themes/accent/red.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {useRegisteredRef} from "$/utils/state" +import {accentGray} from "$/reflex-ui/themes/accent/gray.js" +import {Chip_span_a1f191971c1d0b090104807deb864e69} from "$/utils/components/Chip_span_a1f191971c1d0b090104807deb864e69" +import {Fragment,useEffect} from "react" +import {jsx} from "@emotion/react" + + + +const sx_8f99169642 = stylex.create({ s: {"backgroundColor": "var(--accent-9)", "color": "var(--accent-contrast)"} }); +const sx_8f99169642_c = stylex.props(sx_8f99169642.s).className; +const reflexUIClasses_01ac7ed29f = reflexUIClassName(accentRed, focusScope); +const reflexUIClasses_fe8edd03f8 = reflexUIClassName(accentGray); + +function Component() { +const ref_gray = useRegisteredRef("ref_gray"); + + return ( + jsx(Fragment,{},jsx("main",{},jsx("span",{className:sx_8f99169642_c},"theme"),jsx("span",{className:"p-8 " + sx_8f99169642_c + " " + reflexUIClasses_01ac7ed29f},"red"),jsx("span",{className:sx_8f99169642_c + " " + reflexUIClasses_01ac7ed29f},"red again"),jsx("span",{className:sx_8f99169642_c + " " + reflexUIClasses_fe8edd03f8,id:"gray",ref:ref_gray},"gray"),jsx(Chip_span_a1f191971c1d0b090104807deb864e69,{},"bound")),jsx("title",{}," | Index"),jsx("meta",{content:"",property:"og:image"},)) + ) +} +Component.displayName = "Component(/)"; + +export default Component; +""" + +BOUND_CHIP = """ +import {isTrue,mergeSlotProps} from "$/utils/state" +import {useStateContext} from "$/utils/context-registry" +import * as stylex from "@stylexjs/stylex" +import "$/reflex-ui/tokens/accent.stylex.js" +import {className as reflexUIClassName} from "$/reflex-ui/class-name.js" +import {accentAmber} from "$/reflex-ui/themes/accent/amber.js" +import {accentBlue} from "$/reflex-ui/themes/accent/blue.js" +import {accentBronze} from "$/reflex-ui/themes/accent/bronze.js" +import {accentBrown} from "$/reflex-ui/themes/accent/brown.js" +import {accentCrimson} from "$/reflex-ui/themes/accent/crimson.js" +import {accentCyan} from "$/reflex-ui/themes/accent/cyan.js" +import {accentGold} from "$/reflex-ui/themes/accent/gold.js" +import {accentGrass} from "$/reflex-ui/themes/accent/grass.js" +import {accentGray} from "$/reflex-ui/themes/accent/gray.js" +import {accentGreen} from "$/reflex-ui/themes/accent/green.js" +import {accentIndigo} from "$/reflex-ui/themes/accent/indigo.js" +import {accentIris} from "$/reflex-ui/themes/accent/iris.js" +import {accentJade} from "$/reflex-ui/themes/accent/jade.js" +import {accentLime} from "$/reflex-ui/themes/accent/lime.js" +import {accentMint} from "$/reflex-ui/themes/accent/mint.js" +import {accentOrange} from "$/reflex-ui/themes/accent/orange.js" +import {accentPink} from "$/reflex-ui/themes/accent/pink.js" +import {accentPlum} from "$/reflex-ui/themes/accent/plum.js" +import {accentPurple} from "$/reflex-ui/themes/accent/purple.js" +import {accentRed} from "$/reflex-ui/themes/accent/red.js" +import {accentRuby} from "$/reflex-ui/themes/accent/ruby.js" +import {accentSky} from "$/reflex-ui/themes/accent/sky.js" +import {accentTeal} from "$/reflex-ui/themes/accent/teal.js" +import {accentTomato} from "$/reflex-ui/themes/accent/tomato.js" +import {accentViolet} from "$/reflex-ui/themes/accent/violet.js" +import {accentYellow} from "$/reflex-ui/themes/accent/yellow.js" +import {focusScope} from "$/reflex-ui/themes/focus.js" +import {jsx} from "@emotion/react" +import {Fragment,memo,useEffect} from "react" + + + +const sx_8f99169642 = stylex.create({ s: {"backgroundColor": "var(--accent-9)", "color": "var(--accent-contrast)"} }); +const sx_8f99169642_c = stylex.props(sx_8f99169642.s).className; +const reflexUIColorSchemes = { __proto__: null, "amber": reflexUIClassName(accentAmber, focusScope), "blue": reflexUIClassName(accentBlue, focusScope), "bronze": reflexUIClassName(accentBronze, focusScope), "brown": reflexUIClassName(accentBrown, focusScope), "crimson": reflexUIClassName(accentCrimson, focusScope), "cyan": reflexUIClassName(accentCyan, focusScope), "gold": reflexUIClassName(accentGold, focusScope), "grass": reflexUIClassName(accentGrass, focusScope), "gray": reflexUIClassName(accentGray), "green": reflexUIClassName(accentGreen, focusScope), "indigo": reflexUIClassName(accentIndigo, focusScope), "iris": reflexUIClassName(accentIris, focusScope), "jade": reflexUIClassName(accentJade, focusScope), "lime": reflexUIClassName(accentLime, focusScope), "mint": reflexUIClassName(accentMint, focusScope), "orange": reflexUIClassName(accentOrange, focusScope), "pink": reflexUIClassName(accentPink, focusScope), "plum": reflexUIClassName(accentPlum, focusScope), "purple": reflexUIClassName(accentPurple, focusScope), "red": reflexUIClassName(accentRed, focusScope), "ruby": reflexUIClassName(accentRuby, focusScope), "sky": reflexUIClassName(accentSky, focusScope), "teal": reflexUIClassName(accentTeal, focusScope), "tomato": reflexUIClassName(accentTomato, focusScope), "violet": reflexUIClassName(accentViolet, focusScope), "yellow": reflexUIClassName(accentYellow, focusScope) }; + + +export const Chip_span_a1f191971c1d0b090104807deb864e69 = /*#__PURE__*/ (() => { +const Chip_span_a1f191971c1d0b090104807deb864e69 = memo(({children, ...rest}) => { + const reflex___state____state__tests___units___reflex_components_ui___test_base____base_test_state = useStateContext("reflex___state____state.tests___units___reflex_components_ui___test_base____base_test_state", ["color_rx_state_"]) + return( + jsx("span",{...mergeSlotProps(rest, ({ className:sx_8f99169642_c + " " + reflexUIColorSchemes[reflex___state____state__tests___units___reflex_components_ui___test_base____base_test_state.color_rx_state_] }))},children) + ) +}); +Chip_span_a1f191971c1d0b090104807deb864e69.displayName = "Chip"; +return Chip_span_a1f191971c1d0b090104807deb864e69; +})(); +""" + + +def test_color_scheme_is_the_accent_of_the_element( + ui_plugin: UIPlugin, compile_page: Callable[..., CompileContext] +): + """A literal color imports its accent; one bound to state imports them all.""" + + def page(): + return rx.el.main( + Chip.create("theme"), + Chip.create("red", color_scheme="red", class_name="p-8"), + Chip.create("red again", color_scheme="red"), + Chip.create("gray", color_scheme="gray", id="gray"), + Chip.create("bound", color_scheme=S.color), # pyright: ignore [reportArgumentType] + ) + + ctx = compile_page(page) + assert ctx.compiled_pages["/"].output_code == CHIP_PAGE + files, _ = compiler.compile_memo_components(ctx.auto_memo_components.values()) + assert [code for path, code in files if "Chip_span_" in path] == [BOUND_CHIP] + + +def test_color_scheme_must_be_an_accent_color(): + with pytest.raises(ThemeError) as raised: + Chip.create("hello", color_scheme="slate") # pyright: ignore [reportArgumentType] + assert str(raised.value) == ( + 'rx.ui.chip: unknown color_scheme "slate". The values are "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".' + ) + + +def test_color_scheme_is_a_css_property_of_a_component_without_the_prop( + ui_plugin: UIPlugin, +): + """Only a component that declares the prop reads it as an accent.""" + component = Plain.create("hello", color_scheme="dark") + assert component._get_all_custom_code() == { + 'const sx_b7c693ea0b = stylex.create({ s: {"colorScheme": "dark"} });\n' + "const sx_b7c693ea0b_c = stylex.props(sx_b7c693ea0b.s).className;": None + } + + +def test_dynamic_component_cannot_have_a_color_scheme(): + with pytest.raises(StyleError) as raised: + serialize(Chip.create("hello", color_scheme="red")) + assert str(raised.value) == ( + "rx.ui.chip: color_scheme cannot be applied to a component rendered " + "from state: its code is evaluated in the browser and never reaches " + "the StyleX compiler. Render the component in a page and show it with " + "rx.cond." + ) diff --git a/tests/units/reflex_components_ui/test_constants.py b/tests/units/reflex_components_ui/test_constants.py new file mode 100644 index 00000000000..b452e8a4992 --- /dev/null +++ b/tests/units/reflex_components_ui/test_constants.py @@ -0,0 +1,26 @@ +"""Tests for reflex_components_ui.constants.""" + +from pathlib import Path + +from reflex_components_ui.constants import JS_SRC, _js_src_dir + + +def test_js_src_dir_prefers_the_embedded_copy(tmp_path: Path): + """A built distribution carries the javascript inside the package.""" + root_dir = tmp_path / "site-packages" / "reflex_components_ui" + embedded = root_dir / "js" / "src" + embedded.mkdir(parents=True) + assert _js_src_dir(root_dir) == embedded + + +def test_js_src_dir_falls_back_to_the_checkout(tmp_path: Path): + """A source checkout reads the javascript package beside the python source.""" + package = tmp_path / "packages" / "reflex-components-ui" + root_dir = package / "src" / "reflex_components_ui" + root_dir.mkdir(parents=True) + assert _js_src_dir(root_dir) == package / "js" / "src" + + +def test_js_src_holds_the_javascript(): + """Whichever layout is installed, the constant resolves to real files.""" + assert (JS_SRC / "README.md").is_file() diff --git a/tests/units/reflex_components_ui/test_js_package.py b/tests/units/reflex_components_ui/test_js_package.py new file mode 100644 index 00000000000..50e9a4e96b6 --- /dev/null +++ b/tests/units/reflex_components_ui/test_js_package.py @@ -0,0 +1,71 @@ +"""Tests for the manifest of the javascript package reflex-components-ui embeds.""" + +import json +from pathlib import Path + +from reflex_base import constants +from reflex_components_radix.plugin import RADIX_THEMES_PACKAGE +from reflex_components_ui.constants import STYLEX_VERSION + +JS_PACKAGE = Path(__file__).parents[3] / "packages/reflex-components-ui/js" + +# StyleX is 0.x and has broken its output between patch releases, so every +# package of it moves together and by an exact pin: the version an app +# installs is the version the javascript package is developed against. + + +def test_stylex_packages_are_pinned_to_one_exact_version(): + """The manifest names no StyleX package at a range or a second version.""" + manifest = json.loads((JS_PACKAGE / "package.json").read_text()) + pins = { + name: pin + for group in ("dependencies", "devDependencies") + for name, pin in manifest[group].items() + if name.startswith("@stylexjs/") + } + assert pins == { + "@stylexjs/stylex": STYLEX_VERSION, + "@stylexjs/unplugin": STYLEX_VERSION, + "@stylexjs/eslint-plugin": STYLEX_VERSION, + } + + +def test_lockfile_installs_stylex_at_the_pinned_version(): + """What `npm ci` installs, the compiler behind the plugin included.""" + lock = json.loads((JS_PACKAGE / "package-lock.json").read_text()) + installed = { + path.removeprefix("node_modules/"): package["version"] + for path, package in lock["packages"].items() + if path.startswith("node_modules/@stylexjs/") + } + assert installed == { + "@stylexjs/babel-plugin": STYLEX_VERSION, + "@stylexjs/eslint-plugin": STYLEX_VERSION, + "@stylexjs/shared": STYLEX_VERSION, + "@stylexjs/stylex": STYLEX_VERSION, + "@stylexjs/unplugin": STYLEX_VERSION, + } + + +def test_radix_themes_is_the_version_reflex_installs(): + """The tokens are generated from the Radix Themes an app gets. + + A page that mixes Radix components with these ones shows one palette only + while both define the same values, so the generator reads the stylesheet of + the version the Radix components install, and no other. + """ + name, _, version = RADIX_THEMES_PACKAGE.rpartition("@") + manifest = json.loads((JS_PACKAGE / "package.json").read_text()) + lock = json.loads((JS_PACKAGE / "package-lock.json").read_text()) + assert name == "@radix-ui/themes" + assert manifest["devDependencies"][name] == version + assert lock["packages"][f"node_modules/{name}"]["version"] == version + + +def test_vite_is_the_version_reflex_installs(): + """The live tests build their pages with the Vite an app is built with.""" + version = constants.PackageJson.DEV_DEPENDENCIES["vite"] + manifest = json.loads((JS_PACKAGE / "package.json").read_text()) + lock = json.loads((JS_PACKAGE / "package-lock.json").read_text()) + assert manifest["devDependencies"]["vite"] == version + assert lock["packages"]["node_modules/vite"]["version"] == version diff --git a/tests/units/reflex_components_ui/test_plugin.py b/tests/units/reflex_components_ui/test_plugin.py new file mode 100644 index 00000000000..721fb782ce2 --- /dev/null +++ b/tests/units/reflex_components_ui/test_plugin.py @@ -0,0 +1,117 @@ +"""Tests for reflex_components_ui.plugin.""" + +from collections.abc import Callable +from pathlib import Path +from typing import Any + +import pytest +from reflex_base.plugins import VitePluginEntry +from reflex_components_ui.constants import JS_SRC +from reflex_components_ui.plugin import UIPlugin, add_base_stylesheet +from reflex_components_ui.themes import Theme, ThemeError + +import reflex as rx + + +def test_plugin_installs_the_style_compiler_for_the_build_only(): + plugin = UIPlugin() + assert plugin.get_frontend_development_dependencies() == [ + "@stylexjs/stylex@0.19.2", + "@stylexjs/unplugin@0.19.2", + "lightningcss@1.33.0", + ] + assert plugin.get_frontend_dependencies() == [] + + +def test_plugin_adds_the_wrapped_stylex_plugin_to_vite(): + assert UIPlugin().get_vite_plugins() == [ + VitePluginEntry( + imports=( + 'import reflexUIStylex from "./reflex-ui/vite-plugin-stylex.js"', + 'import { Features as lightningcssFeatures } from "lightningcss"', + ), + call="""reflexUIStylex("__reflex_global_styles", { + useCSSLayers: { prefix: "reflex-ui" }, + styleResolution: "application-order", + lightningcssOptions: { minify: true, exclude: lightningcssFeatures.LightDark }, + })""", + ) + ] + + +def test_plugin_writes_every_file_of_the_javascript_package(): + """The assets are the files under js/src, each where the app imports it.""" + shipped = { + path.relative_to(JS_SRC).as_posix(): path.read_text() + for path in JS_SRC.rglob("*") + if path.is_file() + } + # The files this plugin itself relies on; others come with the components. + assert {"README.md", "base.css", "vite-plugin-stylex.js"} <= shipped.keys() + assets = UIPlugin().get_static_assets() + assert [path for path, _ in assets] == [ + Path("reflex-ui") / name for name in sorted(shipped) + ] + assert { + path.relative_to("reflex-ui").as_posix(): content for path, content in assets + } == shipped + + +def test_plugin_imports_the_base_stylesheet_before_compile(): + modified = {} + + def add_save_task(task: Callable[..., Any], /, *args: Any, **kwargs: Any) -> None: + pytest.fail("the plugin writes no file of its own before a compile") + + UIPlugin().pre_compile( + add_save_task=add_save_task, + add_modify_task=modified.__setitem__, + radix_themes_plugin=None, + unevaluated_pages=[], + ) + assert modified == {"styles/__reflex_global_styles.css": add_base_stylesheet} + + +def test_base_stylesheet_is_imported_ahead_of_every_other_stylesheet(): + """Tailwind adds its import after the reset, so base.css goes before it.""" + root = ( + "@layer __reflex_base;\n" + "@import url('./__reflex_style_reset.css');\n" + "@import url('./tailwind.css');" + ) + with_base = ( + "@layer __reflex_base;\n" + "@import url('../reflex-ui/base.css');\n" + "@import url('./__reflex_style_reset.css');\n" + "@import url('./tailwind.css');" + ) + assert add_base_stylesheet(root) == with_base + assert add_base_stylesheet(with_base) == with_base + assert add_base_stylesheet("") == "@import url('../reflex-ui/base.css');" + + +def test_plugin_has_a_theme(): + assert UIPlugin().theme == Theme() + assert repr(UIPlugin()) == ( + "UIPlugin(theme=Theme(accent_color='blue', gray_color='auto', " + "radius='medium', scaling='100%', appearance='inherit', " + "panel_background='translucent', has_background=True))" + ) + + +def test_plugin_refuses_a_theme_of_radix_themes(): + """The two themes are easy to take for each other in rxconfig.py.""" + with pytest.raises(ThemeError) as error: + UIPlugin(theme=rx.theme(accent_color="indigo")) # pyright: ignore [reportArgumentType] + assert str(error.value) == ( + "rx.plugins.UIPlugin: theme must be an rx.ui.Theme(...), not Theme. The " + "theme of Radix Themes, rx.theme(...), goes to " + "rx.plugins.RadixThemesPlugin." + ) + with pytest.raises(ThemeError) as error: + UIPlugin(theme={"accent_color": "indigo"}) # pyright: ignore [reportArgumentType] + assert str(error.value) == ( + "rx.plugins.UIPlugin: theme must be an rx.ui.Theme(...), not dict. The " + "theme of Radix Themes, rx.theme(...), goes to " + "rx.plugins.RadixThemesPlugin." + ) diff --git a/tests/units/reflex_components_ui/test_themes.py b/tests/units/reflex_components_ui/test_themes.py new file mode 100644 index 00000000000..a86a31b1f3b --- /dev/null +++ b/tests/units/reflex_components_ui/test_themes.py @@ -0,0 +1,729 @@ +"""Tests for reflex_components_ui.themes.""" + +import dataclasses +import hashlib +from typing import Any, get_args + +import pytest +from reflex_base.utils.imports import ImportVar +from reflex_base.vars.base import LiteralVar +from reflex_components_ui import _radix_tokens, themes +from reflex_components_ui.themes import ( + Theme, + ThemeError, + ThemeStyles, + app_theme_styles, + color_scheme_styles, + theme_styles, +) + +import reflex as rx + +SCOPES = ("spaceScope", "radiusScope", "typographyScope", "shadowScope", "colorScope") +SCOPE_IMPORTS = ( + ("themes/scope.js", "colorScope", None), + ("themes/scope.js", "radiusScope", None), + ("themes/scope.js", "shadowScope", None), + ("themes/scope.js", "spaceScope", None), + ("themes/scope.js", "typographyScope", None), +) +FOCUS_IMPORT = ("themes/focus.js", "focusScope", None) +STYLES_IMPORT = ("themes/theme.js", "theme", "reflexUITheme") + +ACCENT_VALUES = ( + '"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"' +) + +ACCENT_IMPORTS = tuple( + (f"themes/accent/{name}.js", f"accent{name.capitalize()}", None) + for name in sorted(_radix_tokens.ACCENT_THEMES) +) +GRAY_IMPORTS = tuple( + (f"themes/gray/{name}.js", f"gray{name.capitalize()}", None) + for name in sorted(_radix_tokens.GRAY_THEMES) +) + + +class ThemeState(rx.State): + """State whose fields are bound to theme options.""" + + accent: rx.Field[str] = rx.field("red") + gray: rx.Field[str] = rx.field("sand") + radius: rx.Field[str] = rx.field("full") + scaling: rx.Field[str] = rx.field("90%") + panel: rx.Field[str] = rx.field("solid") + appearance: rx.Field[str] = rx.field("dark") + background: rx.Field[bool] = rx.field(True) + + +def test_literal_types_are_the_generated_themes(): + """A type checker accepts exactly the values a StyleX theme exists for.""" + assert sorted(get_args(themes.LiteralAccentColor)) == sorted( + _radix_tokens.ACCENT_THEMES + ) + assert sorted(get_args(themes.LiteralGrayColor)) == sorted([ + "auto", + *_radix_tokens.GRAY_THEMES, + ]) + assert sorted(get_args(themes.LiteralRadius)) == sorted(_radix_tokens.RADIUS_THEMES) + assert sorted(get_args(themes.LiteralScaling)) == sorted( + _radix_tokens.SCALING_THEMES + ) + assert sorted(get_args(themes.LiteralPanelBackground)) == sorted( + _radix_tokens.PANEL_BACKGROUND_THEMES + ) + module, export, styles = _radix_tokens.THEME_STYLES + assert (module, export) == STYLES_IMPORT[:2] + assert sorted(styles) == sorted([ + "root", + "background", + *(set(get_args(themes.LiteralAppearance)) - {"inherit"}), + ]) + assert { + "accent_color": get_args(themes.LiteralAccentColor), + "gray_color": get_args(themes.LiteralGrayColor), + "radius": get_args(themes.LiteralRadius), + "scaling": get_args(themes.LiteralScaling), + "appearance": ("inherit", "light", "dark"), + "panel_background": get_args(themes.LiteralPanelBackground), + } == themes.OPTIONS + + +def test_theme_defaults_are_the_ones_of_radix_but_for_the_accent(): + """Reflex has always made blue the accent, where Radix Themes has indigo.""" + assert dataclasses.asdict(Theme()) == { + **_radix_tokens.DEFAULTS, + "accent_color": "blue", + "appearance": "inherit", + "has_background": True, + } + assert _radix_tokens.DEFAULTS["accent_color"] == "indigo" + + +def test_theme_is_a_frozen_value(): + theme = Theme(accent_color="indigo", radius="large") + assert theme == Theme(radius="large", accent_color="indigo") + assert hash(theme) == hash(Theme(radius="large", accent_color="indigo")) + with pytest.raises(dataclasses.FrozenInstanceError): + theme.radius = "small" # pyright: ignore [reportAttributeAccessIssue] + + +@pytest.mark.parametrize( + ("options", "message"), + [ + ( + {"accent_color": "indgo"}, + ( + 'rx.ui.Theme: unknown accent_color "indgo". Did you mean "indigo"? ' + f"The values are {ACCENT_VALUES}." + ), + ), + ( + {"accent_color": "mauve"}, + f'rx.ui.Theme: unknown accent_color "mauve". The values are {ACCENT_VALUES}.', + ), + ( + {"gray_color": "slat"}, + ( + 'rx.ui.Theme: unknown gray_color "slat". Did you mean "slate"? The ' + 'values are "auto", "gray", "mauve", "slate", "sage", "olive", "sand".' + ), + ), + ( + {"radius": "big"}, + ( + 'rx.ui.Theme: unknown radius "big". The values are "none", "small", ' + '"medium", "large", "full".' + ), + ), + ( + {"scaling": 100}, + ( + "rx.ui.Theme: unknown scaling 100. The values are " + '"90%", "95%", "100%", "105%", "110%".' + ), + ), + ( + {"scaling": "100"}, + ( + 'rx.ui.Theme: unknown scaling "100". Did you mean "100%"? The values ' + 'are "90%", "95%", "100%", "105%", "110%".' + ), + ), + ( + {"appearance": "system"}, + ( + 'rx.ui.Theme: unknown appearance "system". The values are ' + '"inherit", "light", "dark".' + ), + ), + ( + {"panel_background": None}, + ( + "rx.ui.Theme: unknown panel_background None. The values are " + '"solid", "translucent".' + ), + ), + ( + {"has_background": "yes"}, + "rx.ui.Theme: has_background must be True or False, not 'yes'.", + ), + ( + {"accent_color": ThemeState.accent}, + ( + "rx.ui.Theme: accent_color is bound to state, but the theme of an " + "app is compiled ahead of time. Give it one of its values, or bind " + "the option of an rx.ui.theme(...) around the page." + ), + ), + ], +) +def test_theme_refuses_a_value_an_option_does_not_take( + options: dict[str, Any], message: str +): + """A mistake in rxconfig.py stops the app there, and says what to write. + + Args: + options: The options of the theme. + message: The whole error message. + """ + with pytest.raises(ThemeError) as error: + Theme(**options) + assert str(error.value) == message + + +HELPER_IMPORT = ("class-name.js", "className", "reflexUIClassName") + + +def _theme( + refs: tuple[str, ...], + imports: tuple[tuple[str, str, str | None], ...], +) -> ThemeStyles: + """Build what a theme element with literal options is expected to need. + + Args: + refs: The compiled styles after the scopes and the focus. + imports: The imports beside the ones every theme element has. + + Returns: + The expected styles: the class names are joined once, in a constant + named after the call that joins them. + """ + call = ( + '"reflex-ui-theme " + reflexUIClassName(' + + ", ".join((*SCOPES, "focusScope", *refs)) + + ")" + ) + name = "reflexUIClasses_" + hashlib.sha256(call.encode()).hexdigest()[:10] + return ThemeStyles( + classes=name, + imports=tuple( + sorted([ + *imports, + HELPER_IMPORT, + FOCUS_IMPORT, + *SCOPE_IMPORTS, + STYLES_IMPORT, + ]) + ), + declarations=(f"const {name} = {call};",), + ) + + +def test_app_theme_sets_every_option(): + """The element around an app depends on nothing outside it.""" + styles = app_theme_styles(Theme(accent_color="indigo", radius="large")) + assert styles == ThemeStyles( + classes="reflexUIClasses_35e01a8868", + imports=( + HELPER_IMPORT, + ("themes/accent/indigo.js", "accentIndigo", None), + FOCUS_IMPORT, + ("themes/gray/slate.js", "graySlate", None), + ("themes/panel.js", "panelTranslucent", None), + ("themes/radius.js", "radiusLarge", None), + ("themes/scaling.js", "scaling100", None), + *SCOPE_IMPORTS, + STYLES_IMPORT, + ), + declarations=( + ( + 'const reflexUIClasses_35e01a8868 = "reflex-ui-theme " + ' + "reflexUIClassName(spaceScope, radiusScope, typographyScope, " + "shadowScope, colorScope, focusScope, accentIndigo, graySlate, " + "radiusLarge, scaling100, panelTranslucent, reflexUITheme.root, " + "reflexUITheme.background);" + ), + ), + ) + assert app_theme_styles( + Theme( + accent_color="gray", + gray_color="olive", + radius="none", + scaling="110%", + appearance="dark", + panel_background="solid", + has_background=False, + ), + "sx_0123456789_o", + ) == _theme( + ( + "accentGray", + "grayOlive", + "radiusNone", + "scaling110", + "panelSolid", + "reflexUITheme.root", + "reflexUITheme.dark", + # The style of the element itself is last: it wins a property. + "sx_0123456789_o", + ), + ( + ("themes/accent/gray.js", "accentGray", None), + ("themes/gray/olive.js", "grayOlive", None), + ("themes/panel.js", "panelSolid", None), + ("themes/radius.js", "radiusNone", None), + ("themes/scaling.js", "scaling110", None), + ), + ) + + +def test_every_accent_has_the_gray_that_matches_it(): + """``auto`` is resolved when the app is compiled.""" + for accent, gray in _radix_tokens.MATCHING_GRAY.items(): + styles = app_theme_styles(Theme(accent_color=accent)) # pyright: ignore [reportArgumentType] + assert styles == _theme( + ( + f"accent{accent.capitalize()}", + f"gray{gray.capitalize()}", + "radiusMedium", + "scaling100", + "panelTranslucent", + "reflexUITheme.root", + "reflexUITheme.background", + ), + ( + (f"themes/accent/{accent}.js", f"accent{accent.capitalize()}", None), + (f"themes/gray/{gray}.js", f"gray{gray.capitalize()}", None), + ("themes/panel.js", "panelTranslucent", None), + ("themes/radius.js", "radiusMedium", None), + ("themes/scaling.js", "scaling100", None), + ), + ) + + +def _nested( + refs: tuple[str, ...], imports: tuple[tuple[str, str, str | None], ...] +) -> ThemeStyles: + """Build what a nested theme is expected to need. + + Args: + refs: The compiled styles of its options, then the ones of the + element after its root style. + imports: The imports beside the ones every theme element has. + + Returns: + The expected styles. + """ + after = tuple(ref for ref in refs if ref.startswith("reflexUITheme")) + before = refs[: len(refs) - len(after)] + return _theme((*before, "reflexUITheme.root", *after), imports) + + +RED = ("themes/accent/red.js", "accentRed", None) +MAUVE = ("themes/gray/mauve.js", "grayMauve", None) +OLIVE = ("themes/gray/olive.js", "grayOlive", None) +GRAY_ACCENT = ("themes/accent/gray.js", "accentGray", None) + + +@pytest.mark.parametrize( + ("options", "app_theme", "expected"), + [ + # Nothing set: the element only declares again what reads the theme. + ({}, Theme(), _nested((), ())), + # An accent keeps the gray around the element, as in Radix Themes. + ({"accent_color": "red"}, Theme(), _nested(("accentRed",), (RED,))), + ( + {"accent_color": "red", "gray_color": "olive"}, + Theme(), + _nested(("accentRed", "grayOlive"), (RED, OLIVE)), + ), + ( + {"accent_color": "red", "gray_color": "auto"}, + Theme(gray_color="sand"), + _nested(("accentRed", "grayMauve"), (RED, MAUVE)), + ), + # A gray alone, and the gray that matches the accent of the app. + ({"gray_color": "olive"}, Theme(), _nested(("grayOlive",), (OLIVE,))), + ( + {"gray_color": "auto"}, + Theme(accent_color="red"), + _nested(("grayMauve",), (MAUVE,)), + ), + # Under the gray accent, the accent is named again to follow the gray. + ( + {"gray_color": "olive"}, + Theme(accent_color="gray"), + _nested(("accentGray", "grayOlive"), (GRAY_ACCENT, OLIVE)), + ), + ( + {"radius": "full", "scaling": "90%", "panel_background": "solid"}, + Theme(), + _nested( + ("radiusFull", "scaling90", "panelSolid"), + ( + ("themes/radius.js", "radiusFull", None), + ("themes/scaling.js", "scaling90", None), + ("themes/panel.js", "panelSolid", None), + ), + ), + ), + # An appearance paints the background unless it is told not to. + ( + {"appearance": "dark"}, + Theme(), + _nested(("reflexUITheme.background", "reflexUITheme.dark"), ()), + ), + ( + {"appearance": "light", "has_background": False}, + Theme(), + _nested(("reflexUITheme.light",), ()), + ), + ({"appearance": "inherit"}, Theme(), _nested((), ())), + ( + {"has_background": True}, + Theme(), + _nested(("reflexUITheme.background",), ()), + ), + # A Var that holds a constant is the constant. + ( + { + "accent_color": LiteralVar.create("red"), + "appearance": LiteralVar.create("dark"), + "has_background": LiteralVar.create(False), + }, + Theme(), + _nested(("accentRed", "reflexUITheme.dark"), (RED,)), + ), + ], +) +def test_nested_theme_sets_what_it_is_given( + options: dict[str, Any], app_theme: Theme, expected: ThemeStyles +): + """A literal option imports the one StyleX theme it names. + + Args: + options: The options of the nested theme. + app_theme: The theme of the app. + expected: What the element needs. + """ + assert theme_styles("rx.ui.theme", **options, app_theme=app_theme) == expected + + +def _map(name: str, entries: dict[str, str]) -> str: + """Write the map an option bound to state is looked up in. + + Args: + name: The name of the map. + entries: The compiled style of each value. + + Returns: + The expected declaration. + """ + body = ", ".join(f'"{key}": {value}' for key, value in entries.items()) + return f"const {name} = {{ __proto__: null, {body} }};" + + +ACCENT_MAP = _map( + "reflexUIAccents", + { + name: f"accent{name.capitalize()}" + for name in sorted(_radix_tokens.ACCENT_THEMES) + }, +) + + +def test_accent_bound_to_state_imports_every_accent(): + """The page chooses among all of them when it renders.""" + accent = str(ThemeState.accent) + styles = theme_styles( + "rx.ui.theme", accent_color=ThemeState.accent, app_theme=Theme() + ) + assert styles.classes == ( + '"reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, ' + "typographyScope, shadowScope, colorScope, focusScope, " + f"reflexUIAccents[{accent}], reflexUITheme.root)" + ) + assert styles.imports == tuple( + sorted([ + HELPER_IMPORT, + *ACCENT_IMPORTS, + FOCUS_IMPORT, + *SCOPE_IMPORTS, + STYLES_IMPORT, + ]) + ) + assert styles.declarations == (ACCENT_MAP,) + assert [var.equals(ThemeState.accent) for var in styles.vars] == [True] + + # The gray that matches each accent is chosen the same way. + styles = theme_styles( + "rx.ui.theme", + accent_color=ThemeState.accent, + gray_color="auto", + app_theme=Theme(), + style="sx_0123456789_o", + ) + assert styles.classes == ( + '"reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, ' + "typographyScope, shadowScope, colorScope, focusScope, " + f"reflexUIAccents[{accent}], reflexUIMatchingGrays[{accent}], " + "reflexUITheme.root, sx_0123456789_o)" + ) + assert styles.imports == tuple( + sorted([ + HELPER_IMPORT, + *ACCENT_IMPORTS, + *GRAY_IMPORTS, + FOCUS_IMPORT, + *SCOPE_IMPORTS, + STYLES_IMPORT, + ]) + ) + assert styles.declarations == ( + ACCENT_MAP, + _map( + "reflexUIMatchingGrays", + { + name: f"gray{gray.capitalize()}" + for name, gray in sorted(_radix_tokens.MATCHING_GRAY.items()) + }, + ), + ) + + +def test_every_option_can_be_bound_to_state(): + state = ThemeState + styles = theme_styles( + "rx.ui.theme", + gray_color=state.gray, + radius=state.radius, + scaling=state.scaling, + panel_background=state.panel, + appearance=state.appearance, + has_background=state.background, + app_theme=Theme(), + ) + appearance = str(state.appearance) + assert styles.classes == ( + '"reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, ' + "typographyScope, shadowScope, colorScope, focusScope, " + f"reflexUIGrays[{state.gray!s}], reflexUIRadii[{state.radius!s}], " + f"reflexUIScalings[{state.scaling!s}], reflexUIPanels[{state.panel!s}], " + f"reflexUITheme.root, ({state.background!s}) && reflexUITheme.background, " + f"reflexUITheme[{appearance}])" + ) + assert styles.declarations == ( + _map( + "reflexUIGrays", + { + name: f"gray{name.capitalize()}" + for name in sorted(_radix_tokens.GRAY_THEMES) + }, + ), + ( + 'const reflexUIRadii = { __proto__: null, "full": radiusFull, ' + '"large": radiusLarge, "medium": radiusMedium, "none": radiusNone, ' + '"small": radiusSmall };' + ), + ( + 'const reflexUIScalings = { __proto__: null, "100%": scaling100, ' + '"105%": scaling105, "110%": scaling110, "90%": scaling90, ' + '"95%": scaling95 };' + ), + ( + 'const reflexUIPanels = { __proto__: null, "solid": panelSolid, ' + '"translucent": panelTranslucent };' + ), + ) + assert styles.imports == tuple( + sorted([ + HELPER_IMPORT, + *GRAY_IMPORTS, + FOCUS_IMPORT, + *( + ("themes/panel.js", name, None) + for name in ("panelSolid", "panelTranslucent") + ), + *( + ("themes/radius.js", f"radius{name}", None) + for name in ("Full", "Large", "Medium", "None", "Small") + ), + *( + ("themes/scaling.js", f"scaling{name}", None) + for name in ("100", "105", "110", "90", "95") + ), + *SCOPE_IMPORTS, + STYLES_IMPORT, + ]) + ) + assert [str(var) for var in styles.vars] == [ + str(state.gray), + str(state.radius), + str(state.scaling), + str(state.panel), + appearance, + str(state.background), + ] + + # An appearance bound to state paints the background when it is one. + styles = theme_styles("rx.ui.theme", appearance=state.appearance, app_theme=Theme()) + assert styles.classes == ( + '"reflex-ui-theme " + reflexUIClassName(spaceScope, radiusScope, ' + "typographyScope, shadowScope, colorScope, focusScope, " + f'reflexUITheme.root, ({appearance}) !== "inherit" && ' + f"reflexUITheme.background, reflexUITheme[{appearance}])" + ) + + +@pytest.mark.parametrize( + ("options", "app_theme", "message"), + [ + ( + {"accent_color": "rubby"}, + Theme(), + ( + 'rx.ui.theme: unknown accent_color "rubby". Did you mean "ruby"? ' + f"The values are {ACCENT_VALUES}." + ), + ), + ( + {"gray_color": "blue"}, + Theme(), + ( + 'rx.ui.theme: unknown gray_color "blue". The values are "auto", ' + '"gray", "mauve", "slate", "sage", "olive", "sand".' + ), + ), + ( + {"radius": "round"}, + Theme(), + ( + 'rx.ui.theme: unknown radius "round". The values are "none", ' + '"small", "medium", "large", "full".' + ), + ), + ( + {"appearance": "night"}, + Theme(), + ( + 'rx.ui.theme: unknown appearance "night". Did you mean "light"? The values are ' + '"inherit", "light", "dark".' + ), + ), + ( + {"has_background": 1}, + Theme(), + "rx.ui.theme: has_background must be True or False, not 1.", + ), + ( + {"gray_color": "auto"}, + None, + ( + 'rx.ui.theme: gray_color "auto" is the gray that matches an accent ' + "color. Give accent_color too, or name the gray." + ), + ), + ], +) +def test_nested_theme_refuses_a_value_an_option_does_not_take( + options: dict[str, Any], app_theme: Theme | None, message: str +): + """The error names the component and lists what the option takes. + + Args: + options: The options of the nested theme. + app_theme: The theme of the app. + message: The whole error message. + """ + with pytest.raises(ThemeError) as error: + theme_styles("rx.ui.theme", **options, app_theme=app_theme) + assert str(error.value) == message + + +def test_color_scheme_is_an_accent_on_one_element(): + """A component with a color imports its accent, and the focus that follows.""" + red = ThemeStyles( + classes="reflexUIClasses_01ac7ed29f", + imports=(HELPER_IMPORT, RED, FOCUS_IMPORT), + declarations=( + ( + "const reflexUIClasses_01ac7ed29f = " + "reflexUIClassName(accentRed, focusScope);" + ), + ), + ) + assert color_scheme_styles("rx.ui.button", "red") == red + assert color_scheme_styles("rx.ui.button", LiteralVar.create("red")) == red + # A gray component keeps the focus colors of the theme, as in Radix Themes. + assert color_scheme_styles("rx.ui.button", "gray") == ThemeStyles( + classes="reflexUIClasses_fe8edd03f8", + imports=(HELPER_IMPORT, GRAY_ACCENT), + declarations=( + "const reflexUIClasses_fe8edd03f8 = reflexUIClassName(accentGray);", + ), + ) + with pytest.raises(ThemeError) as error: + color_scheme_styles("rx.ui.button", "slate") + assert str(error.value) == ( + f'rx.ui.button: unknown color_scheme "slate". The values are {ACCENT_VALUES}.' + ) + + +def test_color_scheme_bound_to_state_indexes_a_table_of_class_names(): + """Every accent is imported, and joined with its focus when the module loads.""" + styles = color_scheme_styles("rx.ui.button", ThemeState.accent) + assert styles.classes == f"reflexUIColorSchemes[{ThemeState.accent!s}]" + assert styles.imports == tuple( + sorted([HELPER_IMPORT, *ACCENT_IMPORTS, FOCUS_IMPORT]) + ) + assert styles.declarations == ( + _map( + "reflexUIColorSchemes", + { + name: "reflexUIClassName(accentGray)" + if name == "gray" + else f"reflexUIClassName(accent{name.capitalize()}, focusScope)" + for name in sorted(_radix_tokens.ACCENT_THEMES) + }, + ), + ) + assert [var.equals(ThemeState.accent) for var in styles.vars] == [True] + + +def test_import_dict_names_the_modules_as_an_app_imports_them(): + assert color_scheme_styles("rx.ui.button", "red").import_dict() == { + "$/reflex-ui/class-name.js": [ + ImportVar(tag="className", alias="reflexUIClassName") + ], + "$/reflex-ui/themes/accent/red.js": [ImportVar(tag="accentRed")], + "$/reflex-ui/themes/focus.js": [ImportVar(tag="focusScope")], + } + assert theme_styles("rx.ui.theme", app_theme=Theme()).import_dict() == { + "$/reflex-ui/class-name.js": [ + ImportVar(tag="className", alias="reflexUIClassName") + ], + "$/reflex-ui/themes/focus.js": [ImportVar(tag="focusScope")], + "$/reflex-ui/themes/scope.js": [ + ImportVar(tag="colorScope"), + ImportVar(tag="radiusScope"), + ImportVar(tag="shadowScope"), + ImportVar(tag="spaceScope"), + ImportVar(tag="typographyScope"), + ], + "$/reflex-ui/themes/theme.js": [ImportVar(tag="theme", alias="reflexUITheme")], + } diff --git a/tests/units/reflex_components_ui/test_tokens.py b/tests/units/reflex_components_ui/test_tokens.py new file mode 100644 index 00000000000..5138ed8967b --- /dev/null +++ b/tests/units/reflex_components_ui/test_tokens.py @@ -0,0 +1,237 @@ +"""Tests for reflex_components_ui.tokens.""" + +import copy +from collections.abc import Callable +from typing import Any, get_args + +import pytest +from reflex_components_ui import tokens +from reflex_components_ui._radix_tokens import VAR_GROUPS +from reflex_components_ui.style.lower import Lowered, lower +from reflex_components_ui.tokens import TokenError + +import reflex as rx + +SCALES = get_args(tokens.LiteralColorScale) + +SCALE_NAMES = ( + "amber, blue, bronze, brown, crimson, cyan, gold, grass, green, indigo, " + "iris, jade, lime, mauve, mint, olive, orange, pink, plum, purple, red, " + "ruby, sage, sand, sky, slate, teal, tomato, violet, yellow" +) + + +def _all(group: Any) -> list[str]: + """List every token of a group, and of the groups inside it. + + Args: + group: A token, or a group of tokens. + + Returns: + The tokens. + """ + if isinstance(group, str): + return [group] + found = list(group._steps) + for name, value in vars(group).items(): + if name[0] != "_": + found.extend(_all(value)) + return found + + +def _every_token() -> list[str]: + """List every token an app can name. + + Returns: + The tokens of the module, then the ones of each color scale. + """ + found = [] + for name, value in vars(tokens).items(): + if name[0] != "_" and isinstance(value, (str, tokens._Tokens)): + found.extend(_all(value)) + for name in SCALES: + found.extend(_all(tokens.scale(name))) + return found + + +def test_tokens_are_the_custom_properties_of_radix_themes(): + """An app can name every custom property the modules define, and no other.""" + defined = [f"var({name})" for _, names in VAR_GROUPS.values() for name in names] + assert len(defined) == 1070 + found = _every_token() + assert sorted(found) == sorted(defined) + + +def test_color_scales_are_the_generated_ones(): + """The accent and the gray of the theme aside, a scale is a color module.""" + assert sorted(SCALES) == sorted( + name + for name, (module, names) in VAR_GROUPS.items() + if module.startswith("colors/") and len(names) == 28 + ) + + +def test_a_token_is_a_plain_string(): + """The examples of the documentation, and the type every style takes.""" + assert tokens.space[4] == "var(--space-4)" + assert tokens.radius[3] == "var(--radius-3)" + assert tokens.radius.full == "var(--radius-full)" + assert tokens.shadow[3] == "var(--shadow-3)" + assert tokens.accent[9] == "var(--accent-9)" + assert tokens.accent.a[3] == "var(--accent-a3)" + assert tokens.accent.contrast == "var(--accent-contrast)" + assert tokens.gray[11] == "var(--gray-11)" + assert tokens.focus.a[5] == "var(--focus-a5)" + assert tokens.font_size[2] == "var(--font-size-2)" + assert tokens.line_height[2] == "var(--line-height-2)" + assert tokens.letter_spacing[2] == "var(--letter-spacing-2)" + assert tokens.font_weight.bold == "var(--font-weight-bold)" + assert tokens.heading.line_height[9] == "var(--heading-line-height-9)" + assert tokens.default.font_family == "var(--default-font-family)" + assert tokens.code.padding_top == "var(--code-padding-top)" + assert tokens.color.panel_solid == "var(--color-panel-solid)" + assert tokens.cursor.slider_thumb_active == "var(--cursor-slider-thumb-active)" + assert tokens.panel.backdrop_filter == "var(--backdrop-filter-panel)" + assert tokens.black.a[12] == "var(--black-a12)" + assert tokens.scaling == "var(--scaling)" + assert tokens.scale("ruby")[9] == f"{rx.color('ruby', 9)}" + assert tokens.scale("ruby").a[3] == f"{rx.color('ruby', 3, True)}" + assert tokens.scale("ruby").track == "var(--ruby-track)" + assert tokens.scale("ruby") is tokens.scale("ruby") + assert {type(token) for token in _every_token()} == {str} + assert f"calc({tokens.space[4]} * 2)" == "calc(var(--space-4) * 2)" + + +def test_every_token_lowers_to_itself_and_imports_its_module(): + """A style names the module that defines each token it uses.""" + count = 0 + for module, names in VAR_GROUPS.values(): + for name in names: + token = f"var({name})" + assert lower("rx.ui.box", {"--probe": token}) == Lowered( + {"--probe": token}, (f"$/reflex-ui/{module}",) + ), name + count += 1 + assert count == len(_every_token()) + + +@pytest.mark.parametrize( + ("get", "message"), + [ + ( + lambda: tokens.space[10], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.space has no step 10. Its steps are 1 to 9.", + ), + ( + lambda: tokens.space[0], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.space has no step 0. Its steps are 1 to 9.", + ), + ( + lambda: tokens.space[-1], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.space has no step -1. Its steps are 1 to 9.", + ), + ( + lambda: tokens.space["4"], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.space has no step '4'. Its steps are 1 to 9.", + ), + ( + lambda: tokens.space[True], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.space has no step True. Its steps are 1 to 9.", + ), + ( + lambda: tokens.radius[7], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.radius has no step 7. Its steps are 1 to 6.", + ), + ( + lambda: tokens.accent.a[13], # pyright: ignore [reportArgumentType] + "rx.ui.tokens.accent.a has no step 13. Its steps are 1 to 12.", + ), + ( + lambda: tokens.scale("ruby").a[0], # pyright: ignore [reportArgumentType] + 'rx.ui.tokens.scale("ruby").a has no step 0. Its steps are 1 to 12.', + ), + ( + lambda: tokens.font_weight[1], + ( + "rx.ui.tokens.font_weight has no steps. Its tokens are bold, light, " + "medium, regular." + ), + ), + ( + lambda: tokens.black[3], + "rx.ui.tokens.black has no steps. Its tokens are a.", + ), + ( + lambda: tokens.accent.contrasst, # pyright: ignore [reportAttributeAccessIssue] + ( + 'rx.ui.tokens.accent has no token "contrasst". Did you mean ' + '"contrast"? Its tokens are a, contrast, indicator, surface, track, ' + "and the steps [1] to [12]." + ), + ), + ( + lambda: tokens.space.four, # pyright: ignore [reportAttributeAccessIssue] + ( + 'rx.ui.tokens.space has no token "four". Its tokens are the steps ' + "[1] to [9]." + ), + ), + ( + lambda: tokens.font_weight.semibold, # pyright: ignore [reportAttributeAccessIssue] + ( + 'rx.ui.tokens.font_weight has no token "semibold". Did you mean "bold"? Its tokens are ' + "bold, light, medium, regular." + ), + ), + ( + lambda: tokens.focus.contrast, # pyright: ignore [reportAttributeAccessIssue] + ( + 'rx.ui.tokens.focus has no token "contrast". Its tokens are a, and ' + "the steps [1] to [12]." + ), + ), + ( + lambda: tokens.scale("rubby"), # pyright: ignore [reportArgumentType] + ( + 'rx.ui.tokens.scale: unknown color scale "rubby". Did you mean ' + f'"ruby"? The scales are {SCALE_NAMES}.' + ), + ), + ( + lambda: tokens.scale("gray"), # pyright: ignore [reportArgumentType] + ( + 'rx.ui.tokens.scale: "gray" is not a color scale of its own, but ' + "the gray of the theme: use rx.ui.tokens.gray." + ), + ), + ( + lambda: tokens.scale(9), # pyright: ignore [reportArgumentType] + f"rx.ui.tokens.scale: unknown color scale 9. The scales are {SCALE_NAMES}.", + ), + ], +) +def test_a_token_that_does_not_exist_says_what_does( + get: Callable[[], str], message: str +): + """The same mistakes a type checker reports, where the app runs. + + Args: + get: Asks for the token. + message: The whole error message. + """ + with pytest.raises(TokenError) as error: + get() + assert str(error.value) == message + + +def test_token_error_is_what_python_expects_of_a_missing_name(): + """``hasattr`` and ``getattr`` with a default work, and so does copying.""" + assert not hasattr(tokens.accent, "contrasst") + assert getattr(tokens.accent, "contrasst", None) is None + assert issubclass(TokenError, (AttributeError, LookupError)) + assert copy.deepcopy(tokens.accent).a[3] == "var(--accent-a3)" + + +def test_tokens_are_a_name_of_the_ui_namespace(): + assert rx.ui.tokens is tokens + assert "tokens" in dir(rx.ui) diff --git a/tests/units/test_app.py b/tests/units/test_app.py index 588d3a87162..f2fed9c4e15 100644 --- a/tests/units/test_app.py +++ b/tests/units/test_app.py @@ -33,6 +33,7 @@ from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter from pytest_mock import MockerFixture from reflex_base import otel +from reflex_base.components.app_wraps import collect_subtree_app_wraps from reflex_base.components.component import Component from reflex_base.constants import Templates from reflex_base.constants.state import FIELD_MARKER @@ -84,6 +85,7 @@ ) from reflex.compiler.compiler import ( _compile_app, + _compile_contexts, _memoize_stateful_app_wraps, _read_stateful_pages_marker, _resolve_app_wrap_components, @@ -2703,6 +2705,8 @@ def test_app_wrap_compile_theme( app, web_dir = compilable_app mocker.patch("reflex.utils.prerequisites.get_web_dir", return_value=web_dir) app.theme = rx.theme(accent_color="plum") + # A toaster the app configures is in the chain whether or not a toast is sent. + app.toaster = rx.toast.provider() app._compile() app_js_contents = ( web_dir / constants.Dirs.PAGES / constants.PageNames.APP_ROOT @@ -3141,6 +3145,8 @@ def test_compile_writes_app_wrap_memo_components( app, web_dir = compilable_app app.add_page(rx.box("Index"), route="/") + # A toaster the app configures is in the chain whether or not a toast is sent. + app.toaster = rx.toast.provider() app._compile() # The overlay/toast app wraps are framework ``@memo`` functions, so they @@ -3357,6 +3363,149 @@ def test_event_provider_app_wrap_order(mocker: MockerFixture) -> None: assert state_index < event_loop_index < children_index +ERROR_BOUNDARY_MEMO_HASH = re.compile(r"(?<=Errorboundary_errorboundary_)[0-9a-f]{32}") + +# What every app root imports after the imports of its app wraps. +APP_ROOT_TEMPLATE_IMPORTS = [ + 'import {jsx} from "@emotion/react"', + 'import { defaultColorMode } from "$/utils/context";', + "import { ThemeProvider } from '$/utils/react-theme';", + "import { Layout as AppLayout } from './_document';", + "import { Outlet } from 'react-router';", + 'import * as React from "react";', + 'import * as emotion_react from "@emotion/react";', + 'import * as utils_context from "$/utils/context";', + 'import * as utils_context_registry from "$/utils/context-registry";', + 'import * as utils_state from "$/utils/state";', +] + + +def _imports(code: str) -> list[str]: + """Get the import statements of a compiled module. + + Args: + code: The source of the module. + + Returns: + Its import statements in order, with the hash that names the error + boundary memo replaced by a placeholder. + """ + return [ + ERROR_BOUNDARY_MEMO_HASH.sub("", line) + for line in code.splitlines() + if line.startswith("import ") + ] + + +def test_stateless_app_imports_no_backend_connection(mocker: MockerFixture) -> None: + """An app without state imports neither the socket nor the toaster. + + A toast call in a page adds the toaster, and nothing else. + """ + conf = rx.Config(app_name="testing") + mocker.patch("reflex_base.config._get_config", return_value=conf) + mocker.patch("reflex.compiler.compiler.is_prod_mode", return_value=True) + app = App(theme=None, enable_state=False) + app_wrap_imports = [ + 'import {Fragment,StrictMode,useEffect} from "react"', + 'import {EventLoopProvider,StateProvider} from "$/utils/context"', + ( + "import {Errorboundary_errorboundary_} " + 'from "$/utils/components/Errorboundary_errorboundary_"' + ), + ] + + assert _imports(compile_app_root_from_page_wraps(app, {})) == [ + *app_wrap_imports, + *APP_ROOT_TEMPLATE_IMPORTS, + ] + assert _imports(_compile_contexts(None, None)) == [ + 'import { useContext, useMemo, useState, createElement, useEffect } from "react"', + 'import { applyDelta, useEventLoop, refs } from "$/utils/state"', + ( + "import { ColorModeContext, UploadFilesContext, DispatchContext, " + "EventLoopContext, StateStoreContext, registerApp, eventLoop } " + 'from "$/utils/context-registry"' + ), + 'import { jsx } from "@emotion/react";', + ] + + toast_page = rx.el.button("Notify", on_click=rx.toast("Hello")) + toast_symbol = memo_paths.mirrored_symbol( + "MemoizedToastProvider", _compile_app.__module__ + ) + assert _imports( + compile_app_root_from_page_wraps(app, collect_subtree_app_wraps(toast_page)) + ) == [ + *app_wrap_imports, + f'import {{{toast_symbol}}} from "$/app_components/reflex/compiler/compiler"', + *APP_ROOT_TEMPLATE_IMPORTS, + ] + + +@pytest.mark.usefixtures("clean_registration_context") +def test_stateful_app_imports_the_backend_connection(mocker: MockerFixture) -> None: + """An app with state imports the socket, and plain notices for the toaster. + + A toaster the app configures takes the place of the plain notices. + """ + conf = rx.Config(app_name="testing") + mocker.patch("reflex_base.config._get_config", return_value=conf) + mocker.patch("reflex.compiler.compiler.is_prod_mode", return_value=True) + + # The only state of the app, so that no handler sends a toast. + class CountState(rx.State): + count: int = 0 + + @rx.event + def increment(self): + self.count += 1 + + app = App(theme=None) + app_wrap_imports = [ + 'import {Fragment,StrictMode,useEffect} from "react"', + 'import {EventLoopProvider,StateProvider} from "$/utils/context"', + ( + "import {Errorboundary_errorboundary_} " + 'from "$/utils/components/Errorboundary_errorboundary_"' + ), + ] + overlay_symbol = memo_paths.mirrored_symbol( + "DefaultOverlayComponents", default_overlay_component.__module__ + ) + overlay_import = f'import {{{overlay_symbol}}} from "$/app_components/reflex/app"' + + assert _imports(compile_app_root_from_page_wraps(app, {})) == [ + *app_wrap_imports, + 'import {refs} from "$/utils/state"', + 'import plainToast from "$/utils/helpers/plain_toast"', + overlay_import, + *APP_ROOT_TEMPLATE_IMPORTS, + ] + assert _imports(_compile_contexts(app._state, None)) == [ + 'import { useContext, useMemo, useState, createElement, useEffect } from "react"', + 'import { applyDelta, ReflexEvent, refs } from "$/utils/state"', + 'import { hydrateClientStorage, useEventLoop } from "$/utils/socket"', + ( + "import { ColorModeContext, UploadFilesContext, DispatchContext, " + "EventLoopContext, StateStoreContext, registerApp, eventLoop } " + 'from "$/utils/context-registry"' + ), + 'import { jsx } from "@emotion/react";', + ] + + app.toaster = rx.toast.provider() + toast_symbol = memo_paths.mirrored_symbol( + "MemoizedToastProvider", _compile_app.__module__ + ) + assert _imports(compile_app_root_from_page_wraps(app, {})) == [ + *app_wrap_imports, + f'import {{{toast_symbol}}} from "$/app_components/reflex/compiler/compiler"', + overlay_import, + *APP_ROOT_TEMPLATE_IMPORTS, + ] + + def test_minimal_static_app_wrap_omits_state_providers( mocker: MockerFixture, ) -> None: @@ -3619,6 +3768,8 @@ def page(): return Fragment1.create(Fragment3.create()) app.add_page(page) + # A toaster the app configures is in the chain whether or not a toast is sent. + app.toaster = rx.toast.provider() app._compile() app_js_contents = ( web_dir / constants.Dirs.PAGES / constants.PageNames.APP_ROOT @@ -5631,11 +5782,11 @@ def test_client_error_event_name_matches_handler(): def test_client_error_constants_match_frontend(): - """The socket event and error types are duplicated as literals in state.js. + """The socket event and error types are duplicated as literals in socket.js. Nothing at runtime keeps the two definitions in sync, so pin them here. """ - state_js = (Templates.Dirs.WEB_TEMPLATE / "utils/state.js").read_text() + state_js = (Templates.Dirs.WEB_TEMPLATE / "utils/socket.js").read_text() assert ( f'const CLIENT_ERROR_EVENT = "{constants.SocketEvent.CLIENT_ERROR}"' in state_js ) diff --git a/tests/units/test_build_config.py b/tests/units/test_build_config.py index cb2ae44c8f3..1ae255e7013 100644 --- a/tests/units/test_build_config.py +++ b/tests/units/test_build_config.py @@ -468,3 +468,132 @@ def test_frontend_package_is_where_the_build_hook_looks(): frontend = REFLEX_BASE.parent / "reflex-frontend" assert (frontend / "src" / "utils" / "state.js").is_file() assert (frontend / "package.json").is_file() + + +REFLEX_COMPONENTS_UI = REPO_ROOT / "packages" / "reflex-components-ui" +UI_JS_SRC = "reflex_components_ui/js/src" + + +@pytest.fixture +def reflex_components_ui_checkout(tmp_path: Path) -> Path: + """Lay out reflex-components-ui around its javascript package. + + The project is the real one — its build config and its hook — with a fixed + version, since a temporary directory has no tags to derive one from, and + without the stub generator, which other tests cover. + + Args: + tmp_path: The temporary directory. + + Returns: + The reflex-components-ui project root. + """ + root = tmp_path / "packages" / "reflex-components-ui" + (root / "src" / "reflex_components_ui").mkdir(parents=True) + (root / "src" / "reflex_components_ui" / "__init__.py").touch() + (root / "README.md").write_text("reflex-components-ui") + shutil.copy(REFLEX_COMPONENTS_UI / "hatch_build.py", root) + config = tomlkit.parse((REFLEX_COMPONENTS_UI / "pyproject.toml").read_text()) + config["project"]["version"] = "0.0.0" + config["project"]["dynamic"].remove("version") + del config["tool"]["hatch"]["version"] + del config["tool"]["hatch"]["build"]["hooks"]["reflex-pyi"] + (root / "pyproject.toml").write_text(tomlkit.dumps(config)) + + js = root / "js" + (js / "src" / "tokens").mkdir(parents=True) + (js / "src" / "tokens" / "space.stylex.js").write_text("// space") + (js / "src" / "base.css").write_text("/* base */") + (js / "tests").mkdir() + (js / "tests" / "lint.test.js").write_text("// test") + (js / "node_modules" / "eslint").mkdir(parents=True) + (js / "node_modules" / "eslint" / "index.js").write_text("// eslint") + (js / "package.json").write_text("{}") + return root + + +def test_reflex_components_ui_wheel_embeds_the_javascript( + reflex_components_ui_checkout: Path, tmp_path: Path +): + """A wheel carries the javascript package's `src`, and only that of it.""" + names = build_wheel(reflex_components_ui_checkout, tmp_path / "dist") + # The whole wheel: the javascript package's tests, manifest and installed + # dependencies, and the build hook, are not in it. + assert names == { + "reflex_components_ui/__init__.py", + f"{UI_JS_SRC}/base.css", + f"{UI_JS_SRC}/tokens/space.stylex.js", + "reflex_components_ui-0.0.0.dist-info/METADATA", + "reflex_components_ui-0.0.0.dist-info/RECORD", + "reflex_components_ui-0.0.0.dist-info/WHEEL", + } + + +def test_reflex_components_ui_wheel_builds_from_its_sdist( + reflex_components_ui_checkout: Path, tmp_path: Path +): + """The sdist carries `js/src` where the repository has it, and no tooling.""" + builder = SdistBuilder(str(reflex_components_ui_checkout)) + artifact = next(builder.build(directory=str(tmp_path / "dist"))) + with tarfile.open(artifact) as archive: + names = set(archive.getnames()) + archive.extractall(tmp_path / "unpacked", filter="data") + assert names == { + "reflex_components_ui-0.0.0/PKG-INFO", + "reflex_components_ui-0.0.0/README.md", + "reflex_components_ui-0.0.0/hatch_build.py", + "reflex_components_ui-0.0.0/pyproject.toml", + "reflex_components_ui-0.0.0/src/reflex_components_ui/__init__.py", + "reflex_components_ui-0.0.0/js/src/base.css", + "reflex_components_ui-0.0.0/js/src/tokens/space.stylex.js", + } + + unpacked = tmp_path / "unpacked" / "reflex_components_ui-0.0.0" + assert build_wheel(unpacked, tmp_path / "from-sdist") == build_wheel( + reflex_components_ui_checkout, tmp_path / "from-checkout" + ) + + +def test_reflex_components_ui_embeds_only_in_a_standard_wheel( + reflex_components_ui_checkout: Path, +): + """An editable install reads `js/src` in place, and an sdist ships it as it is.""" + root = reflex_components_ui_checkout + spec = importlib.util.spec_from_file_location( + "reflex_components_ui_hatch_build", root / "hatch_build.py" + ) + assert spec is not None + assert spec.loader is not None + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + builder = WheelBuilder(str(root)) + + def force_include(target: str, version: str) -> dict[str, str]: + hook = module.JavascriptBuildHook( + str(root), {}, builder.config, builder.metadata, "", target + ) + build_data = {"force_include": {}} + hook.initialize(version, build_data) + return build_data["force_include"] + + assert force_include("wheel", "editable") == {} + assert force_include("sdist", "standard") == {} + assert force_include("wheel", "standard") == {str(root / "js" / "src"): UI_JS_SRC} + + +def test_reflex_components_ui_refuses_to_build_without_javascript( + reflex_components_ui_checkout: Path, tmp_path: Path +): + """A wheel with no javascript could not compile a component.""" + js_src = reflex_components_ui_checkout / "js" / "src" + shutil.rmtree(js_src) + with pytest.raises(FileNotFoundError) as raised: + build_wheel(reflex_components_ui_checkout, tmp_path / "dist") + assert str(raised.value) == f"No javascript to embed: {js_src} does not exist." + + +def test_javascript_package_is_where_the_build_hook_looks(): + """The hook and the checkout fallback both assume this location.""" + js = REFLEX_COMPONENTS_UI / "js" + assert (js / "src" / "README.md").is_file() + assert (js / "package.json").is_file() diff --git a/tests/units/test_init.py b/tests/units/test_init.py new file mode 100644 index 00000000000..2371f8d4efa --- /dev/null +++ b/tests/units/test_init.py @@ -0,0 +1,77 @@ +"""Tests for the top-level reflex namespace.""" + +import importlib +import subprocess +import sys + +import pytest +import reflex_components_ui + +import reflex as rx + +UI_NOT_INSTALLED = ( + "`rx.ui` requires the reflex-components-ui package, which is not installed. " + "Install it with `pip install 'reflex[ui]'`." +) + + +@pytest.fixture +def unresolved_ui(monkeypatch: pytest.MonkeyPatch): + """Forget that `rx.ui` was resolved, so the next access imports it again. + + Args: + monkeypatch: The pytest monkeypatch fixture. + """ + monkeypatch.delitem(vars(rx), "ui", raising=False) + + +def test_ui_resolves_to_the_components_package(unresolved_ui: None): + assert rx.ui is reflex_components_ui + # Cached on the module, so later accesses skip __getattr__. + assert vars(rx)["ui"] is reflex_components_ui + + +def test_ui_is_listed(): + assert rx.__all__.count("ui") == 1 + assert dir(rx) == sorted(rx.__all__) + + +def test_importing_reflex_does_not_import_ui(): + """`rx.ui` costs nothing until it is used.""" + code = ( + "import sys, reflex\n" + "print('reflex_components_ui' in sys.modules)\n" + "reflex.ui\n" + "print('reflex_components_ui' in sys.modules)\n" + ) + result = subprocess.run( + [sys.executable, "-c", code], capture_output=True, text=True, check=True + ) + assert result.stdout == "False\nTrue\n" + + +def test_ui_without_the_extra_says_what_to_install( + unresolved_ui: None, monkeypatch: pytest.MonkeyPatch +): + # A None entry makes the import system report the module as not found. + monkeypatch.setitem(sys.modules, "reflex_components_ui", None) + with pytest.raises(ModuleNotFoundError) as raised: + rx.ui + assert str(raised.value) == UI_NOT_INSTALLED + assert raised.value.name == "reflex_components_ui" + assert "ui" not in vars(rx) + + +def test_ui_does_not_hide_a_missing_dependency_of_the_package( + unresolved_ui: None, monkeypatch: pytest.MonkeyPatch +): + """Only the package itself being absent means the extra is not installed.""" + error = ModuleNotFoundError("No module named 'other'", name="other") + + def import_module(name: str): + raise error + + monkeypatch.setattr(importlib, "import_module", import_module) + with pytest.raises(ModuleNotFoundError) as raised: + rx.ui + assert raised.value is error diff --git a/tests/units/test_ui_parity_script.py b/tests/units/test_ui_parity_script.py new file mode 100644 index 00000000000..3abece77137 --- /dev/null +++ b/tests/units/test_ui_parity_script.py @@ -0,0 +1,50 @@ +"""Tests for scripts/ui_parity.py, the one command of the rx.ui parity harness.""" + +import sys + +import pytest +from ui_parity import allowlist + +from scripts import ui_parity + +TESTS = "tests/integration/tests_playwright/test_ui_parity.py" + + +def test_pytest_command_runs_everything_in_one_engine_by_default(): + assert ui_parity.pytest_command([], ["chromium"], []) == [ + sys.executable, + "-m", + "pytest", + TESTS, + "-rs", + "--browser", + "chromium", + ] + + +def test_pytest_command_selects_components_and_engines(): + assert ui_parity.pytest_command( + ["box", "button"], ["chromium", "firefox", "webkit"], ["-x"] + ) == [ + sys.executable, + "-m", + "pytest", + TESTS, + "-rs", + "--browser", + "chromium", + "--browser", + "firefox", + "--browser", + "webkit", + "-k", + "-box] or -box- or -button] or -button- or test_run_time", + "-x", + ] + + +def test_differences_prints_the_allowlist(capsys: pytest.CaptureFixture[str]): + assert ui_parity.main(["differences"]) == 0 + assert capsys.readouterr().out == ( + allowlist.differences_markdown(allowlist.load()) + "\n" + ) diff --git a/tests/units/utils/test_frontend_skeleton.py b/tests/units/utils/test_frontend_skeleton.py index f3470a8ee70..452ae4c1aab 100644 --- a/tests/units/utils/test_frontend_skeleton.py +++ b/tests/units/utils/test_frontend_skeleton.py @@ -2,9 +2,14 @@ import json from pathlib import Path +from typing import Any import pytest from reflex_base import constants +from reflex_base.compiler.templates import vite_config_template +from reflex_base.config import Config +from reflex_base.plugins import Plugin, VitePluginEntry +from reflex_base.utils.exceptions import InvalidVitePluginError from reflex.utils import frontend_skeleton @@ -164,3 +169,164 @@ def test_update_package_json_overrides_matches_bun_format( assert frontend_skeleton.update_package_json_overrides() is True _assert_bun_format(package_json_path) + + +class _VitePlugins(Plugin): + """A plugin that contributes the Vite plugin entries it was created with.""" + + def __init__(self, *entries: Any): + """Store the entries to contribute. + + Args: + entries: What ``get_vite_plugins`` returns. + """ + self.entries = entries + + def get_vite_plugins(self, **context) -> Any: + """Contribute the stored entries. + + Args: + context: The context for the plugin. + + Returns: + The stored entries. + """ + return self.entries + + +class _OtherVitePlugins(_VitePlugins): + """A second plugin type, to tell plugins apart in an error.""" + + +_SHARED_IMPORT = 'import { Features } from "lightningcss"' +_FIRST = VitePluginEntry( + imports=['import first from "first-plugin"', _SHARED_IMPORT], + call="first(Features.Nesting)", +) +_SECOND = VitePluginEntry(imports=(_SHARED_IMPORT,), call="[second()]") +_THIRD = VitePluginEntry(call='{ name: "third" }') + + +def test_get_vite_plugins_follows_plugin_then_entry_order(): + """Entries come in ``rxconfig.py`` plugin order, then each plugin's own order.""" + plugins = [_VitePlugins(_SECOND, _THIRD), Plugin(), _OtherVitePlugins(_FIRST)] + + assert frontend_skeleton._get_vite_plugins(plugins) == [_SECOND, _THIRD, _FIRST] + assert frontend_skeleton._get_vite_plugins([Plugin()]) == [] + + +def test_compile_vite_config_renders_plugin_entries(): + """The compiled file is the template rendered with every plugin's entries.""" + config = Config( + app_name="test", plugins=[_VitePlugins(_FIRST), _OtherVitePlugins(_SECOND)] + ) + template_args = { + "base": "/", + "hmr": True, + "force_full_reload": False, + "experimental_hmr": False, + "sourcemap": False, + } + without_plugins = vite_config_template(**template_args) + rendered = frontend_skeleton._compile_vite_config(config) + + assert rendered == vite_config_template( + **template_args, vite_plugins=[_FIRST, _SECOND] + ) + assert rendered != without_plugins + assert ( + frontend_skeleton._compile_vite_config(Config(app_name="test")) + == without_plugins + ) + + +@pytest.mark.parametrize( + ("entry", "problem"), + [ + ( + ('import a from "a"', "a()"), + "is a tuple, not a VitePluginEntry", + ), + ( + VitePluginEntry(call=" "), + "has call=' ', which is not a JavaScript expression", + ), + ( + VitePluginEntry(call=None), # pyright: ignore[reportArgumentType] + "has call=None, which is not a JavaScript expression", + ), + ( + VitePluginEntry(call="a();\n"), + "has call='a();\\n', which must be an expression without a trailing ';'", + ), + ( + VitePluginEntry(call="a(),"), + "has call='a(),', which must be an expression without a trailing ','", + ), + ( + VitePluginEntry(imports='import a from "a"', call="a()"), + ( + "has imports='import a from \"a\"', which must be a sequence of " + "import statements, not a single string" + ), + ), + ( + VitePluginEntry(imports=['import a from "a"', "a"], call="a()"), + "has 'a' in imports, which is not an import statement", + ), + ( + VitePluginEntry(imports=['const a = await import("a")'], call="a()"), + ( + "has 'const a = await import(\"a\")' in imports, which is not an " + "import statement" + ), + ), + ( + VitePluginEntry(imports=['import("a")'], call="a()"), + "has 'import(\"a\")' in imports, which is not an import statement", + ), + ( + VitePluginEntry(imports=[b"import a"], call="a()"), # pyright: ignore[reportArgumentType] + "has b'import a' in imports, which is not an import statement", + ), + ], +) +def test_get_vite_plugins_rejects_malformed_entry(entry: Any, problem: str): + """A malformed entry fails the compile, naming the plugin and the entry. + + Args: + entry: The malformed entry. + problem: What the error says is wrong with it. + """ + plugins = [_VitePlugins(_FIRST), _OtherVitePlugins(_SECOND, entry)] + + with pytest.raises(InvalidVitePluginError) as err: + frontend_skeleton._get_vite_plugins(plugins) + + assert str(err.value) == ( + "_OtherVitePlugins.get_vite_plugins() returned an invalid entry: " + f"entry 1 {problem}." + ) + + +@pytest.mark.parametrize( + "statement", + [ + 'import a from "a"', + "import a, { b } from 'a';", + 'import{ a } from "a"', + 'import * as a from "a"', + 'import "a"', + "import'a'", + '\n import a from "a";\n', + ], +) +def test_get_vite_plugins_accepts_import_statement_forms(statement: str): + """Every static import form is accepted. + + Args: + statement: The import statement. + """ + entry = VitePluginEntry(imports=[statement], call="a()") + + assert frontend_skeleton._get_vite_plugins([_VitePlugins(entry)]) == [entry] diff --git a/uv.lock b/uv.lock index 038649eda0f..761d37b0549 100644 --- a/uv.lock +++ b/uv.lock @@ -25,11 +25,12 @@ exclude-newer-span = "P7D" [options.exclude-newer-package] reflex-components-plotly = false -reflex-components-react-player = false +reflex-hosting-cli = false reflex-components-moment = false reflex-components-sonner = false hatch-reflex-pyi = false pillow = "2026-10-21T00:00:00Z" +reflex-components-react-player = false reflex-components-gridjs = false reflex = false reflex-enterprise = false @@ -45,7 +46,7 @@ certifi = "2026-10-21T00:00:00Z" reflex-components-internal = false reflex-components-lucide = false reflex-components-radix = false -reflex-hosting-cli = false +reflex-components-ui = false [manifest] members = [ @@ -67,6 +68,7 @@ members = [ "reflex-components-react-player", "reflex-components-recharts", "reflex-components-sonner", + "reflex-components-ui", "reflex-docgen", "reflex-docs-app", "reflex-docs-bundle", @@ -1685,8 +1687,8 @@ name = "httpcore2" version = "2.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "h11", marker = "sys_platform != 'emscripten'" }, - { name = "truststore", marker = "sys_platform != 'emscripten'" }, + { name = "h11" }, + { name = "truststore" }, ] sdist = { url = "https://files.pythonhosted.org/packages/c0/61/afa9d6b7452f9eca73f73d45324eb0bb52f098fd5e6049bf6b8263be9b4e/httpcore2-2.16.0.tar.gz", hash = "sha256:c72cd0413563b17e1cd8354677dff887466f8ec2551679759e93126534428643", size = 69886, upload-time = "2026-10-21T07:09:45.31Z" } wheels = [ @@ -4086,6 +4088,9 @@ testing = [ { name = "selenium" }, { name = "uvicorn" }, ] +ui = [ + { name = "reflex-components-ui" }, +] [package.dev-dependencies] bench = [ @@ -4128,6 +4133,7 @@ dev = [ { name = "pyyaml" }, { name = "reflex-bench" }, { name = "reflex-build-sdk", extra = ["aiohttp", "httpx", "httpx2", "triggers"] }, + { name = "reflex-components-ui" }, { name = "reflex-docgen" }, { name = "reflex-otel" }, { name = "reflex-release" }, @@ -4174,6 +4180,7 @@ requires-dist = [ { name = "reflex-components-react-player", editable = "packages/reflex-components-react-player" }, { name = "reflex-components-recharts", editable = "packages/reflex-components-recharts" }, { name = "reflex-components-sonner", editable = "packages/reflex-components-sonner" }, + { name = "reflex-components-ui", marker = "extra == 'ui'", editable = "packages/reflex-components-ui" }, { name = "reflex-hosting-cli", editable = "packages/reflex-hosting-cli" }, { name = "rich", specifier = ">=13,<16" }, { name = "selenium", marker = "extra == 'testing'", specifier = ">=4.0.0,<5.0" }, @@ -4183,7 +4190,7 @@ requires-dist = [ { name = "uvicorn", marker = "extra == 'testing'", specifier = ">=0.34.0,<1.0" }, { name = "wrapt", specifier = ">=1.17.0,<2.6" }, ] -provides-extras = ["db", "pydantic", "testing"] +provides-extras = ["db", "pydantic", "testing", "ui"] [package.metadata.requires-dev] bench = [ @@ -4225,6 +4232,7 @@ dev = [ { name = "pyyaml" }, { name = "reflex-bench", editable = "packages/reflex-bench" }, { name = "reflex-build-sdk", extras = ["aiohttp", "httpx", "httpx2", "triggers"], editable = "packages/reflex-build-sdk" }, + { name = "reflex-components-ui", editable = "packages/reflex-components-ui" }, { name = "reflex-docgen", editable = "packages/reflex-docgen" }, { name = "reflex-otel", editable = "packages/reflex-otel" }, { name = "reflex-release", editable = "packages/reflex-release" }, @@ -4501,6 +4509,16 @@ requires-dist = [ { name = "reflex-components-lucide", editable = "packages/reflex-components-lucide" }, ] +[[package]] +name = "reflex-components-ui" +source = { editable = "packages/reflex-components-ui" } +dependencies = [ + { name = "reflex-base" }, +] + +[package.metadata] +requires-dist = [{ name = "reflex-base", editable = "packages/reflex-base" }] + [[package]] name = "reflex-docgen" source = { editable = "packages/reflex-docgen" }