// This file is part of Shadcn Admin Kit (https://github.com/marmelab/shadcn-admin-kit) 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.ts"; import { CreateButton } from "@/components/admin/create-button"; import { ExportButton } from "@/components/admin/export-button"; import { ListPagination } from "@/components/admin/list-pagination"; import { FilterForm } from "@/components/admin/filter-form.tsx"; 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 {} 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 ?? (
{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; }