Skip to content

Commit 3769674

Browse files
committed
Merge remote-tracking branch 'origin/master' into next
2 parents 5be07b0 + 6310f5a commit 3769674

71 files changed

Lines changed: 1365 additions & 516 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## 5.13.6
4+
5+
* [Doc] Update link to marmelab blog ([#11117](https://github.com/marmelab/react-admin/pull/11117)) ([WiXSL](https://github.com/WiXSL))
6+
* [Doc] Update `<AutoPersistInStore>` documentation ([#11110](https://github.com/marmelab/react-admin/pull/11110)) ([djhi](https://github.com/djhi))
7+
* [Doc] Update Soft Delete headless documentation ([#11109](https://github.com/marmelab/react-admin/pull/11109)) ([jonathanarnault](https://github.com/jonathanarnault))
8+
* [Doc] Fix `Validation` section position ([#11107](https://github.com/marmelab/react-admin/pull/11107)) ([WiXSL](https://github.com/WiXSL))
9+
* Bump h3 from 1.15.4 to 1.15.5 ([#11116](https://github.com/marmelab/react-admin/pull/11116)) ([dependabot[bot]](https://github.com/apps/dependabot))
10+
* Bump devalue from 5.5.0 to 5.6.2 ([#11115](https://github.com/marmelab/react-admin/pull/11115)) ([dependabot[bot]](https://github.com/apps/dependabot))
11+
12+
## 5.13.5
13+
14+
* Fix `<Form>` ignores `resetOptions` when record changes ([#11099](https://github.com/marmelab/react-admin/pull/11099)) ([Jszigeti](https://github.com/Jszigeti))
15+
* Fix `<ColumnsSelector>` cannot hide `<DataTable.Col>` items with no `source` ([#11088](https://github.com/marmelab/react-admin/pull/11088)) ([fzaninotto](https://github.com/fzaninotto))
16+
* [Doc] Clarify validation prop usage on `<ReferenceInput>` / `<ReferenceArrayInput>` ([#11104](https://github.com/marmelab/react-admin/pull/11104)) ([WiXSL](https://github.com/WiXSL))
17+
* [Doc] Add tutorial for React Router Framework ([#11100](https://github.com/marmelab/react-admin/pull/11100)) ([djhi](https://github.com/djhi))
18+
* [Doc] Update `<DatagridAG>` docs following `ra-datagrid-ag` 7.0.0 release ([#11097](https://github.com/marmelab/react-admin/pull/11097)) ([slax57](https://github.com/slax57))
19+
* [Doc] Update `AdapterDateFns` imports for MUIX v8 ([#11090](https://github.com/marmelab/react-admin/pull/11090)) ([djhi](https://github.com/djhi))
20+
* [Doc] Document `<FilterValue>` ([#11086](https://github.com/marmelab/react-admin/pull/11086)) ([djhi](https://github.com/djhi))
21+
* [chore] Fix security vulnerabilities in `qs` and `systeminformation` ([#11103](https://github.com/marmelab/react-admin/pull/11103)) ([slax57](https://github.com/slax57))
22+
* Bump react-router from 6.28.1 to 6.30.2 ([#11106](https://github.com/marmelab/react-admin/pull/11106)) ([dependabot[bot]](https://github.com/apps/dependabot))
23+
* Bump storybook from 8.6.11 to 8.6.15 ([#11098](https://github.com/marmelab/react-admin/pull/11098)) ([dependabot[bot]](https://github.com/apps/dependabot))
24+
325
## 5.13.4
426

527
* Fix `useAugmentedForm` resets the form one too many time ([#11085](https://github.com/marmelab/react-admin/pull/11085)) ([slax57](https://github.com/slax57))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A frontend Framework for building single-page applications running in the browser on top of REST/GraphQL APIs, using TypeScript, [React](https://facebook.github.io/react/) and [Material Design](https://material.io/). Open sourced and maintained by [marmelab](https://marmelab.com/).
44

5-
[Home page](https://marmelab.com/react-admin/) - [Documentation](https://marmelab.com/react-admin/documentation.html) - [Examples](#examples) - [Blog](https://marmelab.com/en/blog/#react-admin) - [Releases](https://github.com/marmelab/react-admin/releases) - [Support](#support)
5+
[Home page](https://marmelab.com/react-admin/) - [Documentation](https://marmelab.com/react-admin/documentation.html) - [Examples](#examples) - [Blog](https://marmelab.com/blog/tags/react-admin) - [Releases](https://github.com/marmelab/react-admin/releases) - [Support](#support)
66

77
[![react-admin-demo](https://marmelab.com/react-admin/img/react-admin-demo-still.png)](https://www.youtube.com/watch?v=bJEo1O1oT6o)
88

cypress/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "yarn node ./start.js"
88
},
99
"devDependencies": {
10-
"cypress": "^15.0.0",
10+
"cypress": "^15.8.1",
1111
"cypress-vite": "^1.7.0",
12-
"express": "^4.20.0"
12+
"express": "^4.22.1"
1313
}
1414
}

docs/AdvancedTutorials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "Advanced Tutorials"
55

66
# Advanced Tutorials
77

8-
If you want to learn the best practices of react-admin development by example, you've come to the right place. This page lists the advanced tutorials we've published on [the react-admin blog](https://marmelab.com/en/blog/#react-admin).
8+
If you want to learn the best practices of react-admin development by example, you've come to the right place. This page lists the advanced tutorials we've published on [the react-admin blog](https://marmelab.com/blog/tags/react-admin).
99

1010
* 2025-01: [Handling Relationships in React Admin](https://marmelab.com/blog/2025/02/06/handling-relationships-in-react-admin.html)
1111
* 2025-01: [How to build a CMS with React-Admin](https://marmelab.com/blog/2025/01/24/how-to-build-a-cms-with-react-admin.html)

docs/AutoPersistInStore.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ It works both on create and edit forms.
4141

4242
## Props
4343

44-
| Prop | Required | Type | Default | Description |
44+
| Prop | Required | Type | Default | Description |
4545
| --------------------- | -------- | ---------- | -------------------------------------------------------- | --------------------------------------------------------------------- |
46-
| `getStoreKey` | - | `function` | - | Function to use your own store key. |
47-
| `notificationMessage` | - | `string` | "Applied previous unsaved changes" | Notification message to inform users that their previously saved changes have been applied. |
46+
| `getStoreKey` | - | `function` | - | Function to use your own store key. |
47+
| `notification` | - | `ReactNode` | `<AutoPersist Notification>` | The element used to show the notification, that allows users to reset the form. |
48+
| `notification Message` | - | `string` | "Applied previous unsaved changes" | Notification message to inform users that their previously saved changes have been applied. |
4849

4950
## `getStoreKey`
5051

@@ -68,6 +69,43 @@ You can override this key by passing a custom function as the `getStoreKey` prop
6869
/>
6970
```
7071

72+
## `notification`
73+
74+
When `<AutoPersistInStore>` component applies the changes from the store to a form, react-admin informs users with a notification.
75+
This notification also provides them a way to revert the changes from the store.
76+
77+
You can make your own element and pass it using the `notification` prop:
78+
79+
```tsx
80+
import { Translate, useCloseNotification, useEvent } from 'react-admin';
81+
import { AutoPersistInStore, useAutoPersistInStoreContext } from '@react-admin/ra-form-layout';
82+
import { Alert } from '@mui/material';
83+
84+
const MyAutoPersistInStore = () => (
85+
<AutoPersistInStore notification={<AutoPersistNotification />} />
86+
);
87+
88+
const AutoPersistNotification = () => {
89+
const closeNotification = useCloseNotification();
90+
const { reset } = useAutoPersistInStoreContext();
91+
92+
const cancel = useEvent((event: React.MouseEvent) => {
93+
event.preventDefault();
94+
reset();
95+
closeNotification();
96+
});
97+
98+
return (
99+
<Alert
100+
severity="info"
101+
action={<Button label="ra.action.cancel" onClick={cancel} />}
102+
>
103+
<Translate i18nKey="ra-form-layout.auto_persist_in_store.applied_changes" />
104+
</Alert>
105+
);
106+
};
107+
```
108+
71109
## `notificationMessage`
72110

73111
When `<AutoPersistInStore>` component applies the changes from the store to a form, react-admin informs users with a notification.

docs/AutocompleteArrayInput.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ If you need to *fetch* the options from another resource, you're actually editin
126126
</ReferenceArrayInput>
127127
```
128128

129+
**Tip**: If you need validation (e.g. `required()`), put the `validate` prop on the child `<AutocompleteArrayInput>`. `<ReferenceArrayInput>` doesn't accept validation props.
130+
129131
You can also pass an *array of strings* for the choices:
130132

131133
```jsx
@@ -839,4 +841,3 @@ const CreateTag = () => {
839841
};
840842
```
841843
{% endraw %}
842-

docs/AutocompleteInput.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,19 +764,22 @@ const CompanyInput = () => {
764764
As this is a common task, react-admin provides a shortcut to do the same in a declarative way: [`<ReferenceInput>`](./ReferenceInput.md):
765765

766766
```jsx
767-
import { ReferenceInput, AutocompleteInput } from 'react-admin';
767+
import { ReferenceInput, AutocompleteInput, required } from 'react-admin';
768768

769769
const CompanyInput = () => (
770770
<ReferenceInput reference="companies" source="company_id">
771771
<AutocompleteInput
772772
label="Company"
773773
source="company_id"
774774
optionText="name"
775+
validate={required()}
775776
/>
776777
</ReferenceInput>
777778
);
778779
```
779780

781+
**Tip**: If you need validation (e.g. `required()`), put the `validate` prop on the child input (`<AutocompleteInput>`). `<ReferenceInput>` doesn't accept validation props.
782+
780783
`<ReferenceInput>` is a headless component that:
781784

782785
- fetches a list of records with `dataProvider.getList()` and `dataProvider.getOne()`, using the `reference` prop for the resource,

docs/Community.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ If your problem is related to a library used by react-admin, you should ask for
8888

8989
The Marmelab blog has more than 70 articles about react-admin:
9090

91-
* [https://marmelab.com/en/blog/#react-admin](https://marmelab.com/en/blog/#react-admin)
91+
* [https://marmelab.com/blog/tags/react-admin](https://marmelab.com/blog/tags/react-admin)
9292

9393
You'll find tutorials, tips and tricks, version highlights, real-world use cases, and more. Come back often, we publish new articles every week!
9494

docs/DatagridAG.md

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ If you need to use these features, you can use the [`<DatagridAGClient>`](#datag
247247
| `cellRenderer` | Optional | String, Function or Element | | Allows to use a custom component to render the cell content |
248248
| `columnDefs` | Required | Array | n/a | The columns definitions |
249249
| `defaultColDef` | Optional | Object | | The default column definition (applied to all columns) |
250+
| `defaultSort` | Optional | Object | | The default sort to apply when clearing all sort |
250251
| `getAgGridFilters` | Optional | Function | | A function mapping react-admin filters to ag-grid filters |
251252
| `getRaFilters` | Optional | Function | | A function mapping ag-grid filters to react-admin filters |
252253
| `mutationOptions` | Optional | Object | | The mutation options |
@@ -301,7 +302,7 @@ In a column definition, you can use the `cellEditor` field to specify a custom c
301302

302303
In addition to that, `<DatagridAG>` supports using [React Admin inputs](./Inputs.md) as `cellEditor`, such as [`<TextInput>`](./TextInput.md) or even [`<ReferenceInput>`](./ReferenceInput.md).
303304

304-
This allows to leverage all the power of react-admin inputs in your grid, for example to edit a reference.
305+
This allows to leverage all the power of react-admin inputs in your grid, including validation, for example to edit a reference.
305306

306307
To use a React Admin input as `cellEditor`, you need to pass it as a *React Element*:
307308

@@ -433,7 +434,36 @@ const StyledListbox = styled('ul')({
433434

434435
**Tip:** Using a custom `cellEditor` works great in combination with a custom [`cellRenderer`](#cellrenderer).
435436

436-
**Note:** React Admin inputs used ad `cellEditor` do not (yet) support form validation.
437+
You might want to always use React Admin inputs to edit your columns to leverage the validators with builtin i18n support:
438+
439+
```tsx
440+
import { List, TextInput, ReferenceInput, AutocompleteInput, required } from 'react-admin';
441+
import { DatagridAG } from '@react-admin/ra-datagrid-ag';
442+
443+
export const CommentList = () => {
444+
const columnDefs = [
445+
{
446+
field: 'title',
447+
cellEditor: (
448+
<TextInput source="title" validate={required()} />
449+
),
450+
},
451+
{
452+
field: 'post_id',
453+
cellEditor: (
454+
<ReferenceInput source="post_id" reference="posts">
455+
<AutocompleteInput validate={required()} />
456+
</ReferenceInput>
457+
),
458+
},
459+
];
460+
return (
461+
<List>
462+
<DatagridAG columnDefs={columnDefs} />
463+
</List>
464+
);
465+
};
466+
```
437467

438468
### `cellRenderer`
439469

@@ -560,6 +590,33 @@ export const PostList = () => {
560590

561591
![DatagridAG defaultColDef](./img/DatagridAG-PostList.png)
562592

593+
### `defaultSort`
594+
595+
The `defaultSort` prop allows you to define what sort settings to apply when users clear the sort on a column.
596+
597+
{% raw %}
598+
```tsx
599+
import React from 'react';
600+
import { List } from 'react-admin';
601+
import { DatagridAG } from '@react-admin/ra-datagrid-ag';
602+
603+
export const PostList = () => {
604+
const columnDefs = [
605+
// Passing null allows users to clear the sort
606+
{ field: 'title', sortingOrder: ['asc', 'desc', null] },
607+
{ field: 'published_at', sortingOrder: ['asc', 'desc', null] },
608+
{ field: 'body', sortingOrder: ['asc', 'desc', null] },
609+
];
610+
611+
return (
612+
<List>
613+
<DatagridAG columnDefs={columnDefs} defaultSort={{ field: 'id', order: 'ASC' }} />
614+
</List>
615+
);
616+
};
617+
```
618+
{% endraw %}
619+
563620
### `getAgGridFilters`
564621

565622
You can use the `getAgGridFilters` prop to provide a function that transforms the filters from the dataProvider to the ag-grid format.
@@ -1943,7 +2000,7 @@ In a column definition, you can use the `cellEditor` field to specify a custom c
19432000

19442001
In addition to that, `<DatagridAGClient>` supports using [React Admin inputs](./Inputs.md) as `cellEditor`, such as [`<TextInput>`](./TextInput.md) or even [`<ReferenceInput>`](./ReferenceInput.md).
19452002

1946-
This allows to leverage all the power of react-admin inputs in your grid, for example to edit a reference.
2003+
This allows to leverage all the power of react-admin inputs in your grid, including validation, for example to edit a reference.
19472004

19482005
To use a React Admin input as `cellEditor`, you need to pass it as a *React Element*:
19492006

@@ -2075,7 +2132,36 @@ const StyledListbox = styled('ul')({
20752132

20762133
**Tip:** Using a custom `cellEditor` works great in combination with a custom [`cellRenderer`](#cellrenderer-1).
20772134

2078-
**Note:** React Admin inputs used ad `cellEditor` do not (yet) support form validation.
2135+
You might want to always use React Admin inputs to edit your columns to leverage the validators with builtin i18n support:
2136+
2137+
```tsx
2138+
import { List, TextInput, ReferenceInput, AutocompleteInput, required } from 'react-admin';
2139+
import { DatagridAGClient } from '@react-admin/ra-datagrid-ag';
2140+
2141+
export const CommentList = () => {
2142+
const columnDefs = [
2143+
{
2144+
field: 'title',
2145+
cellEditor: (
2146+
<TextInput source="title" validate={required()} />
2147+
),
2148+
},
2149+
{
2150+
field: 'post_id',
2151+
cellEditor: (
2152+
<ReferenceInput source="post_id" reference="posts">
2153+
<AutocompleteInput validate={required()} />
2154+
</ReferenceInput>
2155+
),
2156+
},
2157+
];
2158+
return (
2159+
<List perPage={10000} pagination={false}>
2160+
<DatagridAGClient columnDefs={columnDefs} />
2161+
</List>
2162+
);
2163+
};
2164+
```
20792165

20802166
### `cellRenderer`
20812167

docs/DualListInput.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ If you need to *fetch* the options from another resource, you're actually editin
134134
</ReferenceArrayInput>
135135
```
136136

137+
**Tip**: If you need validation (e.g. `required()`), put the `validate` prop on the child `<DualListInput>`. `<ReferenceArrayInput>` doesn't accept validation props.
138+
137139
If you have an *array of values* for the options, turn it into an array of objects with the `id` and `name` properties:
138140

139141
```jsx

0 commit comments

Comments
 (0)