/*
* 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,
Dialog,
DialogTrigger,
Heading,
Input,
Key,
Label,
ListBox,
ListBoxItem,
ListLayout,
Menu,
MenuItem,
MenuTrigger,
Modal,
ModalOverlay,
Popover,
Row,
Select,
SelectValue,
SortDescriptor,
Table,
TableBody,
TableHeader,
Text,
TextField,
Virtualizer
} from 'react-aria-components';
import React, {ReactNode, useMemo, useState} from 'react';
interface RecordItem {
id: string;
index: number;
name: string;
owner: string;
status: string;
amount: string;
date: string;
category: string;
}
export function OptionContent({item}: {item: RecordItem}) {
return (
{item.name}
{item.owner} · {item.status}
);
}
// Large option lists are virtualized with fixed-height rows, as applications would.
export function OptionList({virtualized, children}: {virtualized: boolean; children: ReactNode}) {
return virtualized ? (
{children}
) : (
children
);
}
export function SelectFixture({
items,
virtualized = false
}: {
items: RecordItem[];
virtualized?: boolean;
}) {
// Controlled, as an application form would be, so choosing re-renders the owner.
let [value, setValue] = useState(null);
return (
);
}
export function DataTableFixture({items}: {items: RecordItem[]}) {
let [query, setQuery] = useState('');
let [sort, setSort] = useState({column: 'name', direction: 'ascending'});
// Sorting and filtering preserve record identities, as a local data view would.
let rows = useMemo(
() =>
items
.filter(item => item.name.includes(query))
.sort((a, b) => (a.index - b.index) * (sort.direction === 'ascending' ? 1 : -1)),
[items, query, sort]
);
return (
<>