Skip to content

Commit 9e7ab4e

Browse files
authored
Merge pull request #9646 from marmelab/feat/Update-AccordionForm-and-AccordionFormPanel-docs
Update AccordionForm and AccordionFormPanel docs
2 parents e3d5cda + 9e4c310 commit 9e7ab4e

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

docs/AccordionForm.md

+28-15
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ Check [the `ra-form-layout` documentation](https://marmelab.com/ra-enterprise/mo
8484

8585
Here are all the props you can set on the `<AccordionForm>` component:
8686

87-
| Prop | Required | Type | Default | Description |
88-
| ------------------------ | -------- | ----------------- | ------- | ---------------------------------------------------------- |
89-
| `autoClose` | Optional | `boolean` | - | Set to `true` to close the current accordion when opening another one. |
90-
| `children` | Required | `ReactNode` | - | A list of `<AccordionForm.Panel>` elements. |
91-
| `defaultValues` | Optional | `object|function` | - | The default values of the record. |
92-
| `id` | Optional | `string` | - | The id of the underlying `<form>` tag. |
93-
| `noValidate` | Optional | `boolean` | - | Set to `true` to disable the browser's default validation. |
94-
| `onSubmit` | Optional | `function` | `save` | A callback to call when the form is submitted. |
95-
| `sanitize EmptyValues` | Optional | `boolean` | - | Set to `true` to remove empty values from the form state. |
96-
| `toolbar` | Optional | `ReactElement` | - | A custom toolbar element. |
97-
| `validate` | Optional | `function` | - | A function to validate the form values. |
98-
| `warnWhen UnsavedChanges` | Optional | `boolean` | - | Set to `true` to warn the user when leaving the form with unsaved changes. |
99-
87+
| Prop | Required | Type | Default | Description |
88+
| ------------------------- | -------- | ----------------- | ------- | ---------------------------------------------------------------------------- |
89+
| `autoClose` | Optional | `boolean` | - | Set to `true` to close the current accordion when opening another one. |
90+
| `children` | Required | `ReactNode` | - | A list of `<AccordionForm.Panel>` elements. |
91+
| `defaultValues` | Optional | `object|function` | - | The default values of the record. |
92+
| `id` | Optional | `string` | - | The id of the underlying `<form>` tag. |
93+
| `noValidate` | Optional | `boolean` | - | Set to `true` to disable the browser's default validation. |
94+
| `onSubmit` | Optional | `function` | `save` | A callback to call when the form is submitted. |
95+
| `sanitize EmptyValues` | Optional | `boolean` | - | Set to `true` to remove empty values from the form state. |
96+
| `toolbar` | Optional | `ReactElement` | - | A custom toolbar element. |
97+
| `validate` | Optional | `function` | - | A function to validate the form values. |
98+
| `warnWhen UnsavedChanges` | Optional | `boolean` | - | Set to `true` to warn the user when leaving the form with unsaved changes. |
99+
| `sx` | Optional | `Object` | - | An object containing the MUI style overrides to apply to the root component. |
100100

101101
Additional props are passed to `react-hook-form`'s [`useForm` hook](https://react-hook-form.com/docs/useform).
102102

@@ -335,7 +335,7 @@ export const UserCreate = () => (
335335

336336
## `warnWhenUnsavedChanges`
337337

338-
React-admin keeps track of the form state, so it can detect when the user leaves an `Edit` or `Create` page with unsaved changes. To avoid data loss, you can use this ability to ask the user to confirm before leaving a page with unsaved changes.
338+
React-admin keeps track of the form state, so it can detect when the user leaves an `Edit` or `Create` page with unsaved changes. To avoid data loss, you can use this ability to ask the user to confirm before leaving a page with unsaved changes.
339339

340340
![Warn About Unsaved Changes](./img/warn_when_unsaved_changes.png)
341341

@@ -353,6 +353,18 @@ export const TagEdit = () => (
353353

354354
**Warning**: This feature only works if you have a dependency on react-router 6.3.0 **at most**. The react-router team disabled this possibility in react-router 6.4, so `warnWhenUnsavedChanges` will silently fail with react-router 6.4 or later.
355355

356+
## `sx`: CSS API
357+
358+
The `<AccordionForm>` component accepts the usual `className` prop. You can also override the styles of the inner components thanks to the `sx` property. This property accepts the following subclasses:
359+
360+
| Rule name | Description |
361+
| ---------------------------- | ---------------------------------- |
362+
| `&.MuiBox-root` | Applied to the root component |
363+
| `&.MuiAccordion-root` | Applied to all the Accordions |
364+
| `&.Mui-expanded` | Applied to the expanded Accordions |
365+
| `&.MuiAccordionSummary-root` | Applied to the Accordion's title |
366+
| `&.MuiCollapse-root` | Applied to the Accordion's content |
367+
356368
## `<AccordionForm.Panel>`
357369

358370
The children of `<AccordionForm>` must be `<AccordionForm.Panel>` elements.
@@ -371,6 +383,7 @@ Here are all the props you can set on the `<AccordionForm.Panel>` component:
371383
| `defaultExpanded` | Optional | `boolean` | `false` | Set to true to have the accordion expanded by default (except if autoClose = true on the parent) |
372384
| `disabled` | Optional | `boolean` | `false` | If true, the accordion will be displayed in a disabled state. |
373385
| `square` | Optional | `boolean` | `false` | If true, rounded corners are disabled. |
386+
| `sx` | Optional | `Object` | - | An object containing the MUI style overrides to apply to the root component. |
374387

375388
```tsx
376389
import {
@@ -520,7 +533,7 @@ Check [the `<AutoSave>` component](./AutoSave.md) documentation for more details
520533

521534
## Role-Based Access Control (RBAC)
522535

523-
Fine-grained permissions control can be added by using the [`<AccordionForm>`](./AuthRBAC.md#accordionform), [`<AccordionFormPanel>`](./AuthRBAC.md#accordionform) and [`<AccordionSection>`](./AuthRBAC.md#accordionsection) components provided by the `@react-admin/ra-enterprise` package.
536+
Fine-grained permissions control can be added by using the [`<AccordionForm>`](./AuthRBAC.md#accordionform), [`<AccordionFormPanel>`](./AuthRBAC.md#accordionform) and [`<AccordionSection>`](./AuthRBAC.md#accordionsection) components provided by the `@react-admin/ra-enterprise` package.
524537

525538
{% raw %}
526539
```tsx

0 commit comments

Comments
 (0)