import { Breadcrumb, BreadcrumbItem, BreadcrumbPage, } from "@/components/admin/breadcrumb"; import type { ListBaseProps, ListControllerResult, RaRecord } from "ra-core"; import { FilterContext, ListBase, Translate, useGetResourceLabel, useHasDashboard, useResourceContext, useResourceDefinition, useTranslate, } from "ra-core"; import type { ReactElement, ReactNode } from "react"; import { Link } from "react-router"; import { cn } from "@/lib/utils"; import { CreateButton } from "@/components/admin/create-button"; import { ExportButton } from "@/components/admin/export-button"; import { ListPagination } from "@/components/admin/list-pagination"; import { FilterButton, FilterForm } from "@/components/admin/filter-form"; /** * A complete list page with breadcrumb, title, filters, and pagination. * * It fetches a list of records from the data provider (via ra-core hooks), * puts them in a ListContext, renders a default layout (breadcrumb, title, * action buttons, inline filters, pagination), then renders its children * (usually a ). * * @see {@link https://marmelab.com/shadcn-admin-kit/docs/list/ List documentation} * * @example * import { DataTable, List } from "@/components/admin"; * * export const UserList = () => ( * * * * * * * * * * * * * ); */ export const List = ( props: ListProps, ) => { const { debounce, disableAuthentication, disableSyncWithLocation, exporter, filter, filterDefaultValues, loading, perPage, queryOptions, resource, sort, storeKey, ...rest } = props; return ( debounce={debounce} disableAuthentication={disableAuthentication} disableSyncWithLocation={disableSyncWithLocation} exporter={exporter} filter={filter} filterDefaultValues={filterDefaultValues} loading={loading} perPage={perPage} queryOptions={queryOptions} resource={resource} sort={sort} storeKey={storeKey} > {...rest} /> ); }; export interface ListProps extends ListBaseProps, ListViewProps {} /** * The view component for List pages with layout and UI. * * @internal */ export const ListView = ( props: ListViewProps, ) => { const { disableBreadcrumb, filters, pagination = defaultPagination, title, children, actions, } = props; const translate = useTranslate(); const resource = useResourceContext(); if (!resource) { throw new Error( "The ListView component must be used within a ResourceContextProvider", ); } const getResourceLabel = useGetResourceLabel(); const resourceLabel = getResourceLabel(resource, 2); const finalTitle = title !== undefined ? title : translate("ra.page.list", { name: resourceLabel, }); const { hasCreate } = useResourceDefinition({ resource }); const hasDashboard = useHasDashboard(); return ( <> {!disableBreadcrumb && ( {hasDashboard && ( Home )} {resourceLabel} )}

{finalTitle}

{actions ?? (
{filters && filters.length > 0 ? : null} {hasCreate ? : null} {}
)}
{children}
{pagination}
); }; const defaultPagination = ; export interface ListViewProps { children?: ReactNode; disableBreadcrumb?: boolean; render?: (props: ListControllerResult) => ReactNode; actions?: ReactElement | false; filters?: ReactNode[]; pagination?: ReactNode; title?: ReactNode | string | false; className?: string; }