Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/ra-ui-materialui/src/field/ArrayField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,34 @@ export const Filter = () => (
</TestMemoryRouter>
);

export const Label = () => (
<TestMemoryRouter>
<SimpleShowLayout record={{ id: 123, books }}>
<ArrayField source="books" label="List of Books">
<SingleFieldList linkType={false}>
<ChipField source="title" />
</SingleFieldList>
</ArrayField>
</SimpleShowLayout>
</TestMemoryRouter>
);

interface Author {
id: number;
name: string;
books: { id: number; title: string }[];
}

export const Generic = () => (
<TestMemoryRouter>
<ArrayField<Author> source="books">
<SingleFieldList linkType={false}>
<ChipField source="title" />
</SingleFieldList>
</ArrayField>
</TestMemoryRouter>
);

const SortButton = () => {
const { setSort } = useListContext();
return (
Expand Down
7 changes: 6 additions & 1 deletion packages/ra-ui-materialui/src/field/ArrayField.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { ArrayFieldBase, type ArrayFieldBaseProps } from 'ra-core';

import type { FieldProps } from './types';
Expand All @@ -23,7 +24,11 @@ import type { FieldProps } from './types';
*
* @see useListContext
*/
export const ArrayField = ArrayFieldBase;
export const ArrayField = <
RecordType extends Record<string, any> = Record<string, any>,
>(
props: ArrayFieldProps<RecordType>
) => <ArrayFieldBase<RecordType> {...props} />;

export interface ArrayFieldProps<
RecordType extends Record<string, any> = Record<string, any>,
Expand Down
Loading