/* * Copyright 2026 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 */ import { Button, Cell, Checkbox, Column, ComboBox, Input, Label, ListBox, ListBoxItem, Popover, ResizableTableContainer, Row, Switch, Table, TableBody, TableHeader, TableLayout, TextField, Virtualizer } from 'react-aria-components'; import { CellTableFixture, DataTableFixture, OptionContent, OptionList, SelectFixture } from './collections'; import {createRoot} from 'react-dom/client'; import {DndFixture} from './dnd'; import {InfiniteTableFixture, ReorderFixture} from './workflows'; import {measurement} from './measure'; import {MeasuredTableFixture} from './measured-table'; import {MutationFixture, ProjectNode, TreeFixture, VariableFixture} from './advanced-collections'; import React, {useState} from 'react'; import {sizes} from '../scenarios.mjs'; import './styles.css'; const params = new URLSearchParams(location.search); const fixture = params.get('fixture') ?? 'listbox'; const size = Number(params.get('size') ?? sizes[fixture]); const delay = Number(params.get('delay') ?? 0); const delayMode = params.get('delayMode') ?? 'sync'; const items = Array.from({length: size}, (_, i) => ({ id: `item-${i}`, index: i, name: `Record ${i}`, owner: `Team ${i % 12}`, status: i % 3 === 0 ? 'Review' : 'Active', amount: `$${100 + i}`, date: 'Oct 14, 2026', category: `Category ${i % 8}` })); // Local payloads are prepared before mounting, as if the data has already arrived. const projectRecords = ['variable', 'collection'].includes(fixture) ? items.map(item => ({ id: item.id, name: item.name, description: fixture === 'variable' ? 'Review the project requirements, coordinate with the design team, and prepare the next release. ' .repeat(1 + (item.index % 3)) .trim() : `${item.owner} · ${item.status}` })) : []; const nextPage = fixture === 'collection' ? Array.from({length: size / 2}, (_, i) => ({ id: `item-${size + i}`, name: `Record ${size + i}`, description: 'Next page · Active' })) : []; const replacement = fixture === 'collection' ? projectRecords.map((item, i) => ({ ...item, id: `replacement-${i}`, name: `New record ${i}` })) : []; const projects: ProjectNode[] = fixture === 'tree' ? Array.from({length: 20}, (_, i) => ({ id: `project-${i}`, name: `Project ${i}`, children: Array.from({length: size / 20}, (_, j) => ({ id: `file-${i}-${j}`, name: `File ${i}-${j}` })) })) : []; // Mount calibration delays the update itself; other modes are injected by measure.ts. function withCalibration(update: () => void) { if (!['sync', 'deferred', 'layout'].includes(delayMode)) { update(); return; } if (delayMode === 'deferred' && delay > 0) { setTimeout(update, delay); return; } let end = performance.now() + delay; let probe: HTMLDivElement | undefined; if (delayMode === 'layout' && delay) { probe = document.createElement('div'); probe.className = 'layout-probe'; document.body.append(probe); } let n = 0; while (performance.now() < end) { if (probe) { probe.style.width = `${100 + (n++ % 100)}px`; probe.getBoundingClientRect(); } } probe?.remove(); update(); } function ListFixture() { let [revision, setRevision] = useState(0); return ( <> {revision} {item => ( {item.name} {item.owner} · {item.status} )} ); } function ComboFixture({virtualized = false}: {virtualized?: boolean}) { let [query, setQuery] = useState(''); let filtered = items.filter(item => item.name.toLowerCase().includes(query.toLowerCase())); return (
{query} {(item: (typeof items)[number]) => ( )}
); } function TableFixture() { let [rows, setRows] = useState(items); let [selected, setSelected] = useState('0'); return ( <> {selected} setSelected(keys === 'all' ? 'all' : String(keys.size))} data-bench="records-table"> Name Owner Status Amount Updated Category {row => ( {row.name} {row.owner} {row.status} {row.amount} {row.date} {row.category} )}
); } function FormFixture() { let [name, setName] = useState(''); return ( <>
{items.map((item, i) => i % 3 === 0 ? ( ) : i % 3 === 1 ? ( Include team {i} ) : ( Notify team {i} ) )}
{name} ); } // Keep the table element stable so resizing exercises the container's ResizeObserver // and context updates, without also replacing the table's children from its parent. const resizableTable = ( {['name', 'owner', 'status', 'amount', 'date', 'category'].map(key => ( {key} ))} {row => ( {row.name} {row.owner} {row.status} {row.amount} {row.date} {row.category} )}
); function ResizeFixture() { let [narrow, setNarrow] = useState(false); return ( <> {resizableTable} ); } function App() { let [mounted, setMounted] = useState(false); return (

React Aria · production benchmark

{fixture}

{mounted && (fixture === 'listbox' ? ( ) : fixture === 'combobox' ? ( ) : fixture === 'combobox-virtual' ? ( ) : fixture === 'select' ? ( ) : fixture === 'select-virtual' ? ( ) : fixture === 'table-data' ? ( ) : fixture === 'table-cells' ? ( ) : fixture === 'table-measured' ? ( ) : fixture === 'variable' ? ( ) : fixture === 'collection' ? ( ) : fixture === 'tree' ? ( ) : fixture === 'table' ? ( ) : fixture === 'resize' ? ( ) : fixture === 'dnd' ? ( ) : fixture === 'reorder' ? ( ) : fixture === 'infinite' ? ( ) : ( ))}
); } let root = createRoot(document.getElementById('root')!); let revision = 0; const bench = { ...measurement, info: {production: process.env.NODE_ENV === 'production', react: React.version, fixture, size}, async reset() { measurement.clear(); root.render(); await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())) ); } }; declare global { interface Window { __bench: typeof bench; } } window.__bench = bench; bench.reset();