Skip to content

Commit 6b1ed7c

Browse files
committed
remove useless section
1 parent 8179efd commit 6b1ed7c

File tree

1 file changed

+0
-113
lines changed

1 file changed

+0
-113
lines changed

docs/ShowDialog.md

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -344,116 +344,3 @@ const CompanyShow = () => (
344344
```
345345

346346
Check [the `<ShowInDialogButton>` component](./ShowInDialogButton.md) for more details.
347-
348-
## Standalone Usage
349-
350-
`<ShowDialog>` also offer the ability to work standalone, without using the Router's location.
351-
352-
To allow for standalone usage, they require the following props:
353-
354-
- `isOpen`: a boolean holding the open/close state
355-
- `open`: a function that will be called when a component needs to open the dialog (e.g. a button)
356-
- `close`: a function that will be called when a component needs to close the dialog (e.g. the dialog's close button)
357-
358-
**Tip:** These props are exactly the same as what is stored inside a `FormDialogContext`. This means that you can also rather provide your own `FormDialogContext` with these values, and render your dialog component inside it, to activate standalone mode.
359-
360-
Below is an example of an `<Show>` page, including a 'create a new customer' button, that opens a fully controlled `<ShowDialog>`.
361-
362-
<video controls autoplay playsinline muted loop>
363-
<source src="https://react-admin-ee.marmelab.com/assets/FullyControlledCreateDialog.mp4" type="video/mp4"/>
364-
Your browser does not support the video tag.
365-
</video>
366-
367-
<!-- TODO: verify in a story -->
368-
{% raw %}
369-
370-
```tsx
371-
import React, { useCallback, useState } from 'react';
372-
import {
373-
Button,
374-
Datagrid,
375-
DateField,
376-
Show,
377-
ReferenceManyField,
378-
SelectField,
379-
SelectInput,
380-
SimpleForm,
381-
TextField,
382-
TextInput,
383-
useRecordContext,
384-
} from 'react-admin';
385-
import { ShowDialog } from '@react-admin/ra-form-layout';
386-
387-
const sexChoices = [
388-
{ id: 'male', name: 'Male' },
389-
{ id: 'female', name: 'Female' },
390-
];
391-
392-
const CustomerForm = (props: any) => (
393-
<SimpleShowLayout {...props}>
394-
<TextField source="first_name"/>
395-
<TextField source="last_name"/>
396-
<DateField source="dob" label="born"/>
397-
<SelectField source="sex" choices={sexChoices} />
398-
</SimpleShowLayout>
399-
);
400-
401-
const EmployerSimpleFormWithFullyControlledDialogs = () => {
402-
const record = useRecordContext();
403-
404-
const [isShowDialogOpen, setIsShowDialogOpen] = useState(false);
405-
const openShowDialog = useCallback(() => {
406-
setIsShowDialogOpen(true);
407-
}, []);
408-
const closeShowDialog = useCallback(() => {
409-
setIsShowDialogOpen(false);
410-
}, []);
411-
412-
return (
413-
<SimpleFormLayout>
414-
<TextField source="name" />
415-
<TextField source="address" />
416-
<TextField source="city" />
417-
<ReferenceManyField
418-
label="Customers"
419-
reference="customers"
420-
target="employer_id"
421-
>
422-
<Datagrid>
423-
<TextField source="id" />
424-
<TextField source="first_name" />
425-
<TextField source="last_name" />
426-
<DateField source="dob" label="born" />
427-
<SelectField source="sex" choices={sexChoices} />
428-
<Button
429-
label="show customer"
430-
onClick={() => openShowDialog()}
431-
size="medium"
432-
variant="contained"
433-
sx={{ mb: 4 }}
434-
/>
435-
</Datagrid>
436-
</ReferenceManyField>
437-
438-
<ShowDialog
439-
fullWidth
440-
maxWidth="md"
441-
isOpen={isShowDialogOpen}
442-
open={openShowDialog}
443-
close={closeShowDialog}
444-
resource="customers"
445-
>
446-
<CustomerForm />
447-
</ShowDialog>
448-
</SimpleFormLayout>
449-
);
450-
};
451-
452-
const EmployerShow = () => (
453-
<Show>
454-
<EmployerSimpleFormWithFullyControlledDialogs />
455-
</Show>
456-
);
457-
```
458-
459-
{% endraw %}

0 commit comments

Comments
 (0)