Skip to content

Commit 2baa897

Browse files
authored
Merge pull request #11222 from marmelab/v5.14.5
V5.14.5
2 parents ffbc184 + 8de5d16 commit 2baa897

File tree

53 files changed

+1664
-561
lines changed

Some content is hidden

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

53 files changed

+1664
-561
lines changed

.agents/skills/i18n/SKILL.md

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.

Agents.md

Lines changed: 32 additions & 251 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,26 @@
22

33
React-admin is a comprehensive frontend framework for building B2B and admin applications on top of REST/GraphQL APIs, using TypeScript, React, and Material UI. It's an open-source project maintained by Marmelab that provides a complete solution for B2B applications with data-driven interfaces.
44

5-
## Architecture & Design Patterns
6-
7-
### Key Principles
5+
## Design Principles
86

97
- Designed for Single-Page Application (SPA) architecture
10-
- Provider-based abstraction for data fetching, auth, and i18n
11-
- "Batteries included but removable" - everything is replaceable
12-
- User Experience and Developer Experience are equally important
13-
- Backward compatibility prioritized over new features
14-
- Composition over Configuration - Use React patterns, not custom DSLs
15-
- Minimal API Surface - If it can be done in React, don't add to core
16-
- Standing on Giants' Shoulders - Use best-in-class libraries, don't reinvent the wheel
17-
18-
### Provider Pattern
19-
20-
React-admin uses adapters called "providers" for external integrations:
21-
22-
```typescript
23-
// Data Provider - abstracts API calls
24-
dataProvider.getList('posts', {
25-
pagination: { page: 1, perPage: 5 },
26-
sort: { field: 'title', order: 'ASC' },
27-
filter: { author_id: 12 }
28-
})
29-
30-
// Auth Provider - handles authentication
31-
authProvider.checkAuth()
32-
authProvider.login({ username, password })
33-
authProvider.getPermissions()
34-
35-
// i18n Provider - manages translations
36-
i18nProvider.translate('ra.action.save')
37-
```
38-
39-
### Hook-Based API
40-
41-
All functionality exposed through hooks following React patterns:
42-
43-
```typescript
44-
// Data hooks
45-
const { data, isLoading } = useGetList('posts', {
46-
pagination: { page: 1, perPage: 10 }
47-
});
48-
49-
// State management hooks
50-
const [filters, setFilters] = useFilterState();
51-
const [page, setPage] = usePaginationState();
52-
53-
// Auth hooks
54-
const { permissions } = usePermissions();
55-
const canAccess = useCanAccess({ resource: 'posts', action: 'edit' });
56-
```
57-
58-
### Headless Core
59-
60-
The `ra-core` package contains all logic without UI. UI components are in separate packages like `ra-ui-materialui`. This allows:
61-
62-
- Custom UIs using core hooks and controllers
63-
- Swapping UI libraries without changing core logic
8+
- Backward compatibility over new features — avoid breaking changes
9+
- Minimal API surface — if it can be done in a few lines of React, don't add it to core
10+
- Provider pattern — data fetching, auth, and i18n are abstracted behind swappable provider adapters (`dataProvider`, `authProvider`, `i18nProvider`)
11+
- Headless core — `ra-core` contains all logic without UI; `ra-ui-materialui` provides the Material UI layer. This separation is intentional — don't couple logic to UI
12+
- Controller-view separation — controllers in `ra-core/src/controller/` expose business logic via hooks; views in `ra-ui-materialui/src/` handle rendering
13+
- Context: pull, don't push — components expose data to descendants via context + custom hooks, not prop drilling. Every component that fetches data or defines callbacks creates a context for it
14+
- `useEvent()` internal hook — use this for memoized event handlers instead of `useCallback`
6415

65-
### Controller-View Separation
16+
## Anti-Patterns
6617

67-
- Controllers in `ra-core/src/controller/` handle business logic
68-
- Views in `ra-ui-materialui/src/` handle rendering
69-
- Controllers provide data and callbacks via hooks
70-
71-
### Context: Pull, Don’t Push
72-
73-
Communication between components can be challenging, especially in large React applications, where passing props down several levels can become cumbersome. React-admin addresses this issue using a pull model, where components expose props to their descendants via a context, and descendants can consume these props using custom hooks.
74-
75-
Whenever a react-admin component fetches data or defines a callback, it creates a context and places the data and callback in it.
18+
- No `React.cloneElement()` — it breaks composition
19+
- No children inspection — violates React patterns (exception: Datagrid)
20+
- No features achievable in pure React — keep the API surface small
21+
- No comments when code is self-explanatory
7622

7723
## Codebase Organization
7824

79-
### Monorepo Structure
80-
8125
```
8226
react-admin/
8327
├── packages/ # Lerna-managed packages
@@ -98,16 +42,7 @@ react-admin/
9842
└── scripts/ # Build scripts
9943
```
10044

101-
### Key ra-core Directories
102-
103-
- `src/auth/` - Authentication and authorization (54 files)
104-
- `src/controller/` - CRUD controllers and state management
105-
- `src/dataProvider/` - Data fetching and caching logic (70 files)
106-
- `src/form/` - Form handling (31 files)
107-
- `src/routing/` - Navigation and routing (26 files)
108-
- `src/i18n/` - Internationalization (30 files)
109-
110-
### Package Dependencies
45+
## Package Dependencies
11146

11247
- **Core**: React 18.3+, TypeScript 5.8+, lodash 4.17+, inflection 3.0+
11348
- **Routing**: React Router 6.28+
@@ -116,190 +51,36 @@ react-admin/
11651
- **UI Components**: Material UI 5.16+
11752
- **Testing**: Jest 29.5+, Testing Library, Storybook, Cypress
11853

119-
## Development Practices
120-
121-
### TypeScript Requirements
122-
123-
- **Strict mode enabled** - no implicit any
124-
- **Complete type exports** - all public APIs must be typed
125-
- **Generic types** for flexibility in data providers and resources
126-
- **JSDoc comments** for better IDE support
127-
128-
```typescript
129-
// GOOD - Properly typed with generics
130-
export const useGetOne = <RecordType extends RaRecord = any>(
131-
resource: string,
132-
options?: UseGetOneOptions<RecordType>
133-
): UseGetOneResult<RecordType> => { ... }
134-
135-
// BAD - Using any without constraint
136-
export const useGetOne = (resource: any, options?: any): any => { ... }
137-
```
138-
139-
### Component Patterns
140-
141-
1. **Composition over configuration** - Use React composition patterns
142-
2. **Smart defaults** - Components should work out-of-the-box
143-
3. **Controlled and uncontrolled** modes supported
144-
4. **Props pass-through** - Spread additional props to root element
145-
146-
```jsx
147-
// Component composition example
148-
export const MyField = ({ source, ...props }) => {
149-
const record = useRecordContext();
150-
return (
151-
<TextField
152-
{...props} // Pass through all additional props
153-
value={record?.[source]}
154-
/>
155-
);
156-
};
157-
```
158-
159-
### File Organization
160-
- **Feature-based structure** within packages (not type-based)
161-
- **Co-location** - Tests (`.spec.tsx`) and stories (`.stories.tsx`) next to components
162-
- **Index exports** - Each directory has an index.ts exporting public API
163-
- **Flat structure** within features - avoid unnecessary nesting
164-
165-
### Documentation
166-
167-
Every new feature or API change must be documented. The documentation consists of Markdown files located in the `/docs/` directory and built with Jekyll, one file per component or hook.
168-
169-
All documentation files must include:
170-
171-
- A brief description of the component or hook
172-
- Usage examples
173-
- List of props or parameters (required props first, then in alphabetical order)
174-
- Detailed usage for each prop/parameter (in alphabetical order)
175-
- Recipes and advanced usage examples if applicable
176-
177-
Headless hooks and components (the ones in `ra-core`) are also documented in the `/docs_headless/` directory.
178-
179-
### Pre-commit Hooks
180-
181-
- Automatic test execution for modified files
182-
- Prettier formatting check
183-
- ESLint validation
184-
- TypeScript compilation
54+
## Testing
18555

56+
All changes must include tests.
18657

187-
### Development Workflow
188-
```bash
189-
# Initial setup
190-
make install # Install all dependencies
191-
192-
# After making changes
193-
make build # Build packages (TypeScript compilation)
194-
make test # run unit and e2e tests
195-
196-
# Before pushing changes
197-
make lint # Check code quality
198-
make prettier # Format code
199-
```
58+
- Stories: every component needs `*.stories.tsx` covering all props. Use FakeRest for mock data. Make data realistic — stories are used for screenshots and visual testing
59+
- Unit/integration tests: `*.spec.tsx` files should reuse the component's stories as test cases. Assert on user-visible output (text, interactions), not implementation details or HTML attributes
60+
- E2E (Cypress): kept minimal, targeting `examples/simple/`. Only for critical user paths
20061

201-
### Pull Request Process
62+
## Documentation
20263

203-
1. **Target branch**: `next` for features, `master` for bug fixes or documentation changes
204-
2. **Required checks**:
205-
- All tests passing (`make test`)
206-
- Linting clean (`make lint`)
207-
- Prettier formatted (`make prettier`)
208-
- TypeScript compiles (`yarn typecheck`)
64+
Every new feature or API change must be documented.
20965

210-
3. **Commit Messages**: Clear, descriptive messages focusing on "why"
211-
```
212-
fix: Prevent duplicate API calls in useGetList hook
213-
feat: Add support for custom row actions in Datagrid
214-
docs: Clarify dataProvider response format
215-
```
216-
217-
4. **Documentation**: Update relevant docs for API changes
218-
5. **Title**: Start with a verb (Add / Fix / Update / Remove), prefix with `[Doc]` or `[TypeScript]` if the change only concerns doc or types.
219-
220-
### Common Make Commands
221-
```bash
222-
make # Show all available commands
223-
make install # Install dependencies
224-
make build # Build all packages (CJS + ESM)
225-
make test # Run all tests
226-
make lint # Check code quality
227-
make prettier # Format code
228-
make run-simple # Run simple example
229-
make run-demo # Run demo application
230-
```
66+
- `/docs/` (Jekyll) — one Markdown file per component or hook. Each file must include: description, usage examples, props/parameters list (required first, then alphabetical), detailed usage per prop, and recipes if applicable
67+
- `/docs_headless/` (Astro + Starlight) — documents headless hooks and components from `ra-core`
23168

232-
### Performance Considerations
69+
## Pull Requests
23370

234-
- Use `React.memo()` for expensive components
235-
- Leverage `useMemo()` and `useCallback()` appropriately
236-
- Use `useEvent()` (an internal hook) for memoized event handlers
237-
- Implement pagination for large datasets
238-
- Use query caching via React Query
239-
240-
### Accessibility
241-
242-
- Follow WCAG guidelines
243-
- Ensure keyboard navigation works
244-
- Provide proper ARIA labels
245-
- Test with screen readers
246-
247-
### Browser Support
248-
- Modern browsers only (Chrome, Firefox, Safari, Edge)
249-
- No IE11 support
250-
- ES5 compilation target for compatibility
251-
252-
## Misc
253-
254-
- **Don't use `React.cloneElement()`** - it breaks composition
255-
- **Don't inspect children** - violates React patterns (exception: Datagrid)
256-
- **Don't add comments** when code is self-explanatory
257-
- **Don't add features** achievable in a few lines with pure React
258-
- **Don't skip tests** - they run automatically on commit
259-
- **Don't force push** to main/master branches
260-
261-
## Testing Requirements
262-
263-
All developments must include tests to ensure code quality and prevent regressions.
264-
265-
### Storybook
266-
267-
- **Location**: Stories alongside components as `*.stories.tsx`
268-
- **Coverage**: All components must have stories demonstrating usage for all props
269-
- **Mocking**: Use jest mocks sparingly, prefer integration tests
270-
- **Data**: Use mock data providers (e.g., FakeRest) for stories. Make realistic data scenarios as the stories are also used for screenshots and visual testing.
271-
272-
### Unit & Integration Testing (Jest)
273-
274-
- **Location**: Tests alongside source files as `*.spec.tsx`
275-
- **Test Cases**: Reuse the component's stories as test cases
276-
- **Assertions**: Use testing-library to render and assert on elements. Don't test implementation details or HTML attributes, use assertions based on user interactions and visible output.
277-
- **Commands**:
278-
```bash
279-
make test-unit # Run all unit and functional tests
280-
npx jest [pattern] # Run specific tests
71+
- Target branch: `next` for features, `master` for bug fixes or documentation
72+
- Title: start with a verb (Add / Fix / Update / Remove). Prefix with `[Doc]` or `[TypeScript]` if the change only concerns docs or types
73+
- Commit messages: conventional commits focusing on "why"
28174
```
282-
283-
### E2E Testing (Cypress)
284-
285-
Kept minimal to critical user paths due to maintenance overhead.
286-
287-
- **Location**: `cypress/` directory
288-
- **Target**: Simple example app (`examples/simple/`)
289-
- **Coverage**: Critical user paths and interactions
290-
- **Commands**:
291-
292-
```bash
293-
make test-e2e # Run in CI mode
294-
# or for local testing with GUI:
295-
make run-simple # Start test app with vite
296-
make test-e2e-local # Run e2e tests with GUI
75+
fix: Prevent duplicate API calls in useGetList hook
76+
feat: Add support for custom row actions in Datagrid
77+
docs: Clarify dataProvider response format
29778
```
29879

299-
### Static Analysis
80+
## Static Analysis
30081

30182
```bash
30283
make lint # ESLint checks
84+
make typecheck # TypeScript type checking
30385
make prettier # Prettier formatting
304-
make build # TypeScript type checking
30586
```

CHANGELOG.md

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

3+
## 5.14.5
4+
5+
* Add ArrayFieldBase component ([#11191](https://github.com/marmelab/react-admin/pull/11191)) ([WiXSL](https://github.com/WiXSL))
6+
* [Fix] Prevent stale nested field values when re-adding items in SimpleFormIterator ([#11201](https://github.com/marmelab/react-admin/pull/11201)) ([WiXSL](https://github.com/WiXSL))
7+
* Fix `useCreate` fails to update the cache when `id` equals 0 ([#11199](https://github.com/marmelab/react-admin/pull/11199)) ([ThieryMichel](https://github.com/ThieryMichel))
8+
* Fix mutation hooks types ([#11024](https://github.com/marmelab/react-admin/pull/11024)) ([djhi](https://github.com/djhi))
9+
* [Doc] Add ArrayFieldBase headless documentation ([#11192](https://github.com/marmelab/react-admin/pull/11192)) ([WiXSL](https://github.com/WiXSL))
10+
* [chore] Fix headless docs build ([#11188](https://github.com/marmelab/react-admin/pull/11188)) ([slax57](https://github.com/slax57))
11+
* Bump path-to-regexp from 0.1.12 to 0.1.13 ([#11210](https://github.com/marmelab/react-admin/pull/11210)) ([dependabot[bot]](https://github.com/apps/dependabot))
12+
* Bump handlebars from 4.7.7 to 4.7.9 ([#11206](https://github.com/marmelab/react-admin/pull/11206)) ([dependabot[bot]](https://github.com/apps/dependabot))
13+
* Bump astro from 5.15.9 to 5.18.1 ([#11205](https://github.com/marmelab/react-admin/pull/11205)) ([dependabot[bot]](https://github.com/apps/dependabot))
14+
* Bump picomatch from 2.3.1 to 2.3.2 ([#11203](https://github.com/marmelab/react-admin/pull/11203)) ([dependabot[bot]](https://github.com/apps/dependabot))
15+
* Bump smol-toml from 1.5.2 to 1.6.1 ([#11202](https://github.com/marmelab/react-admin/pull/11202)) ([dependabot[bot]](https://github.com/apps/dependabot))
16+
* Bump flatted from 3.3.3 to 3.4.2 ([#11197](https://github.com/marmelab/react-admin/pull/11197)) ([dependabot[bot]](https://github.com/apps/dependabot))
17+
* Bump h3 from 1.15.8 to 1.15.9 ([#11196](https://github.com/marmelab/react-admin/pull/11196)) ([dependabot[bot]](https://github.com/apps/dependabot))
18+
* Bump h3 from 1.15.5 to 1.15.8 ([#11194](https://github.com/marmelab/react-admin/pull/11194)) ([dependabot[bot]](https://github.com/apps/dependabot))
19+
* Bump devalue from 5.6.3 to 5.6.4 ([#11189](https://github.com/marmelab/react-admin/pull/11189)) ([dependabot[bot]](https://github.com/apps/dependabot))
20+
* Fix tar security alerts ([#11215](https://github.com/marmelab/react-admin/pull/11215)) ([WiXSL](https://github.com/WiXSL))
21+
* Fix markdown-it security alert ([#11214](https://github.com/marmelab/react-admin/pull/11214)) ([WiXSL](https://github.com/WiXSL))
22+
* Fix minimatch security alerts ([#11213](https://github.com/marmelab/react-admin/pull/11213)) ([WiXSL](https://github.com/WiXSL))
23+
* Fix ejs dependabot alert ([#11211](https://github.com/marmelab/react-admin/pull/11211)) ([WiXSL](https://github.com/WiXSL))
24+
* Fix picomatch dependabot alert ([#11212](https://github.com/marmelab/react-admin/pull/11212)) ([WiXSL](https://github.com/WiXSL))
25+
326
## 5.14.4
427

528
* Fix SavedQuery when `disableSyncWithLocation` is set ([#11173](https://github.com/marmelab/react-admin/pull/11173)) ([ThieryMichel](https://github.com/ThieryMichel))

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@Agents.md

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ update-package-exports: ## Update the package.json "exports" field for all packa
131131

132132
build: build-ra-core build-ra-router-tanstack build-ra-data-fakerest build-ra-ui-materialui build-ra-data-json-server build-ra-data-local-forage build-ra-data-local-storage build-ra-data-simple-rest build-ra-data-graphql build-ra-data-graphql-simple build-ra-input-rich-text build-data-generator build-ra-language-english build-ra-language-french build-ra-i18n-i18next build-ra-i18n-polyglot build-react-admin build-ra-no-code build-create-react-admin update-package-exports ## compile ES6 files to JS
133133

134+
typecheck: ## check TypeScript types
135+
@yarn typecheck
136+
134137
doc: ## compile doc as html and launch doc web server
135138
@yarn doc
136139

docs/ArrayField.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ storybook_path: ra-ui-materialui-fields-arrayfield--basic
1212

1313
`<ArrayField>` creates a [`ListContext`](./useListContext.md) with the field value, and renders its children components - usually iterator components like [`<DataTable>`](./DataTable.md) or [`<SingleFieldList>`](./SingleFieldList.md).
1414

15+
`<ArrayField>` is the Material UI export of the headless [`<ArrayFieldBase>`](https://marmelab.com/ra-core/arrayfieldbase/) component from `ra-core`.
16+
1517
## Usage
1618

1719
`<ArrayField>` is ideal for collections of objects, e.g. `tags` and `backlinks` in the following `post` object:

docs/Translation.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,14 @@ The following components take advantage of browser localization:
340340
- [`<DateRangeInput>`](./DateRangeInput.md)
341341
- [ `<NumberField>`](./NumberField.md)
342342
- [`<NumberInput>`](./NumberInput.md)
343-
- [`<TimeInput>`](./TimeInput.md)
343+
- [`<TimeInput>`](./TimeInput.md)
344+
345+
## Agent Skill
346+
347+
React-admin provides a specialized agent skill to help you translate your application. Install it in your repository with the [`skills`](https://skills.sh/) command:
348+
349+
```bash
350+
npx skills add marmelab/react-admin --skill i18n
351+
```
352+
353+
This works with OpenCode, Claude Code, Codex, Cursor, and many more.

0 commit comments

Comments
 (0)