Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add the slots concept introduction page #13881

Merged
merged 43 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bba88f4
[docs] Create a new page to introduce the concept of slots
flaviendelangle Jul 18, 2024
94aa4d9
Work
flaviendelangle Jul 19, 2024
543752d
Work
flaviendelangle Jul 19, 2024
623c2a0
Merge branch 'master' into docs-slots
flaviendelangle Jul 22, 2024
ddb585b
Merge branch 'master' into docs-slots
flaviendelangle Jul 24, 2024
9a0c5c7
Work
flaviendelangle Jul 24, 2024
64f9285
Work
flaviendelangle Jul 24, 2024
e7abea3
Work
flaviendelangle Jul 24, 2024
fafde82
Add success
flaviendelangle Jul 24, 2024
5c708f7
Fix tsconfig
flaviendelangle Jul 24, 2024
0b7a23c
Fix
flaviendelangle Jul 24, 2024
b5f3c0c
Fix
flaviendelangle Jul 24, 2024
f6ad8bf
Fix
flaviendelangle Jul 24, 2024
641f5bf
Work
flaviendelangle Jul 24, 2024
0178040
Fix
flaviendelangle Jul 24, 2024
634c38b
Work
flaviendelangle Jul 24, 2024
351c9b9
Work
flaviendelangle Jul 24, 2024
e271632
Fix
flaviendelangle Jul 24, 2024
98f8bcb
Fix
flaviendelangle Jul 24, 2024
a0c7d64
Merge
flaviendelangle Jul 26, 2024
33de46e
Merge branch 'master' into docs-slots
flaviendelangle Jul 26, 2024
00d4ce2
Empty
flaviendelangle Jul 26, 2024
1d3d471
Merge branch 'master' into docs-slots
flaviendelangle Jul 29, 2024
6b890ed
Update docs/data/common-concepts/custom-components/custom-components.md
flaviendelangle Jul 29, 2024
12b2b79
Update docs/data/common-concepts/custom-components/custom-components.md
flaviendelangle Jul 29, 2024
b11d368
Review: Andrew
flaviendelangle Jul 29, 2024
40ef425
Export utility type from charts and tree view
flaviendelangle Jul 30, 2024
fe2d73c
Merge
flaviendelangle Jul 30, 2024
aa7c2db
Merge
flaviendelangle Jul 30, 2024
8ce993f
Update docs/data/common-concepts/custom-components/custom-components.md
flaviendelangle Jul 31, 2024
9162e86
Update docs/data/common-concepts/custom-components/custom-components.md
flaviendelangle Jul 31, 2024
e754385
Add link to issues to module augmentation
flaviendelangle Aug 1, 2024
5b1ba84
Merge remote-tracking branch 'origin/docs-slots' into docs-slots
flaviendelangle Aug 1, 2024
a271973
Empty
flaviendelangle Aug 1, 2024
5be65d8
Merge
flaviendelangle Aug 2, 2024
e169e0a
Regen API
flaviendelangle Aug 2, 2024
66afe58
Fix
flaviendelangle Aug 12, 2024
fe1255c
Merge branch 'master' into docs-slots
flaviendelangle Aug 13, 2024
1be9063
Work
flaviendelangle Aug 13, 2024
b5af9de
Merge
flaviendelangle Aug 19, 2024
7575f07
Merge
flaviendelangle Sep 2, 2024
edcab4e
Merge branch 'master' into docs-slots
flaviendelangle Sep 4, 2024
4cba94a
Fix broken links
flaviendelangle Sep 4, 2024
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
13 changes: 13 additions & 0 deletions docs/data/common-concepts/custom-components/CustomSlot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import FlightTakeoffIcon from '@mui/icons-material/FlightTakeoff';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlot() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker slots={{ openPickerIcon: FlightTakeoffIcon }} />
</LocalizationProvider>
);
}
13 changes: 13 additions & 0 deletions docs/data/common-concepts/custom-components/CustomSlot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import FlightTakeoffIcon from '@mui/icons-material/FlightTakeoff';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlot() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker slots={{ openPickerIcon: FlightTakeoffIcon }} />
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<DatePicker slots={{ openPickerIcon: FlightTakeoffIcon }} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import FlightTakeoffIcon from '@mui/icons-material/FlightTakeoff';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlotAndSlotProps() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
slots={{ openPickerIcon: FlightTakeoffIcon }}
slotProps={{
openPickerIcon: {
color: 'primary',
},
}}
/>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import FlightTakeoffIcon from '@mui/icons-material/FlightTakeoff';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlotAndSlotProps() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
slots={{ openPickerIcon: FlightTakeoffIcon }}
slotProps={{
openPickerIcon: {
color: 'primary',
},
}}
/>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<DatePicker
slots={{ openPickerIcon: FlightTakeoffIcon }}
slotProps={{
openPickerIcon: {
color: 'primary',
},
}}
/>
18 changes: 18 additions & 0 deletions docs/data/common-concepts/custom-components/CustomSlotProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlotProps() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
slotProps={{
openPickerIcon: {
color: 'primary',
},
}}
/>
</LocalizationProvider>
);
}
18 changes: 18 additions & 0 deletions docs/data/common-concepts/custom-components/CustomSlotProps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlotProps() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
slotProps={{
openPickerIcon: {
color: 'primary',
},
}}
/>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<DatePicker
slotProps={{
openPickerIcon: {
color: 'primary',
},
}}
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlotPropsCallback() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
slotProps={{
openPickerIcon: (ownerState) => ({
color: ownerState.open ? 'secondary' : 'primary',
}),
}}
/>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomSlotPropsCallback() {
return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DatePicker
slotProps={{
openPickerIcon: (ownerState) => ({
color: ownerState.open ? 'secondary' : 'primary',
}),
}}
/>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<DatePicker
slotProps={{
openPickerIcon: (ownerState) => ({
color: ownerState.open ? 'secondary' : 'primary',
}),
}}
/>
63 changes: 63 additions & 0 deletions docs/data/common-concepts/custom-components/TypescriptCasting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import * as React from 'react';

import Stack from '@mui/material/Stack';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { DateCalendar } from '@mui/x-date-pickers/DateCalendar';

import { PickersCalendarHeader } from '@mui/x-date-pickers/PickersCalendarHeader';

function DisplayWeekNumberToggle({ value, onChange }) {
return (
<FormControlLabel
sx={{ ml: 2 }}
control={
<Switch
checked={value}
onChange={(event) => onChange(event.target.checked)}
/>
}
label="Display week number"
/>
);
}

function CustomCalendarHeader({
displayWeekNumber,
setDisplayWeekNumber,
...other
}) {
return (
<Stack>
<DisplayWeekNumberToggle
value={displayWeekNumber}
onChange={setDisplayWeekNumber}
/>
<PickersCalendarHeader {...other} />
</Stack>
);
}

export default function TypescriptCasting() {
const [displayWeekNumber, setDisplayWeekNumber] = React.useState(false);

return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DateCalendar
displayWeekNumber={displayWeekNumber}
// Cast the custom component to the type expected by the X component
slots={{
calendarHeader: CustomCalendarHeader,
}}
slotProps={{
calendarHeader: {
displayWeekNumber,
setDisplayWeekNumber,
},
}}
/>
</LocalizationProvider>
);
}
80 changes: 80 additions & 0 deletions docs/data/common-concepts/custom-components/TypescriptCasting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import * as React from 'react';
import { Dayjs } from 'dayjs';
import Stack from '@mui/material/Stack';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import {
DateCalendar,
DateCalendarSlots,
DateCalendarSlotProps,
} from '@mui/x-date-pickers/DateCalendar';
import { PropsFromSlot } from '@mui/x-date-pickers/models';
import { PickersCalendarHeader } from '@mui/x-date-pickers/PickersCalendarHeader';

function DisplayWeekNumberToggle({
value,
onChange,
}: {
value: boolean;
onChange: (value: boolean) => void;
}) {
return (
<FormControlLabel
sx={{ ml: 2 }}
control={
<Switch
checked={value}
onChange={(event) => onChange(event.target.checked)}
/>
}
label="Display week number"
/>
);
}

interface CustomCalendarHeaderProps
extends PropsFromSlot<DateCalendarSlots<Dayjs>['calendarHeader']> {
displayWeekNumber: boolean;
setDisplayWeekNumber: (displayWeekNumber: boolean) => void;
}

function CustomCalendarHeader({
displayWeekNumber,
setDisplayWeekNumber,
...other
}: CustomCalendarHeaderProps) {
return (
<Stack>
<DisplayWeekNumberToggle
value={displayWeekNumber}
onChange={setDisplayWeekNumber}
/>
<PickersCalendarHeader {...other} />
</Stack>
);
}

export default function TypescriptCasting() {
const [displayWeekNumber, setDisplayWeekNumber] = React.useState(false);

return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DateCalendar
displayWeekNumber={displayWeekNumber}
// Cast the custom component to the type expected by the X component
slots={{
calendarHeader:
CustomCalendarHeader as DateCalendarSlots<Dayjs>['calendarHeader'],
}}
slotProps={{
calendarHeader: {
displayWeekNumber,
setDisplayWeekNumber,
} as DateCalendarSlotProps<Dayjs>['calendarHeader'],
}}
/>
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<DateCalendar
displayWeekNumber={displayWeekNumber}
// Cast the custom component to the type expected by the X component
slots={{
calendarHeader:
CustomCalendarHeader as DateCalendarSlots<Dayjs>['calendarHeader'],
}}
slotProps={{
calendarHeader: {
displayWeekNumber,
setDisplayWeekNumber,
} as DateCalendarSlotProps<Dayjs>['calendarHeader'],
}}
/>
Loading