Skip to content

Commit

Permalink
[pickers] Remove TSection and stictly type TValue
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Nov 15, 2024
1 parent d1ca6a4 commit 627900d
Show file tree
Hide file tree
Showing 200 changed files with 1,120 additions and 981 deletions.
1 change: 1 addition & 0 deletions docs/data/date-pickers/custom-layout/AddComponent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';

import Box from '@mui/material/Box';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
Expand Down
3 changes: 2 additions & 1 deletion docs/data/date-pickers/custom-layout/AddComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Dayjs } from 'dayjs';
import Box from '@mui/material/Box';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
Expand Down Expand Up @@ -57,7 +58,7 @@ function RestaurantHeader() {
);
}

function CustomLayout(props: PickersLayoutProps<false, DateView>) {
function CustomLayout(props: PickersLayoutProps<Dayjs | null, DateView>) {
const { toolbar, tabs, content, actionBar } = usePickerLayout(props);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from 'react';
import dayjs from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker';
import { PickersShortcutsItem } from '@mui/x-date-pickers/PickersShortcuts';
import { DateRange } from '@mui/x-date-pickers-pro/models';

const shortcutsItems: PickersShortcutsItem<true>[] = [
const shortcutsItems: PickersShortcutsItem<DateRange<Dayjs>>[] = [
{
label: 'This Week',
getValue: () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';

import Typography from '@mui/material/Typography';
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Dayjs } from 'dayjs';
import Typography from '@mui/material/Typography';
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
Expand All @@ -9,14 +10,14 @@ import {
FieldSelectedSections,
FieldRef,
} from '@mui/x-date-pickers/models';
import { RangePosition } from '@mui/x-date-pickers-pro/models';
import { DateRange, RangePosition } from '@mui/x-date-pickers-pro/models';
import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';

export default function ControlledSelectedSectionsSingleInputRangeField() {
const [selectedSections, setSelectedSections] =
React.useState<FieldSelectedSections>(null);
const inputRef = React.useRef<HTMLInputElement>(null);
const fieldRef = React.useRef<FieldRef<true>>(null);
const fieldRef = React.useRef<FieldRef<DateRange<Dayjs>>>(null);

const setSelectedSectionType = (
selectedSectionType: FieldSectionType,
Expand Down
3 changes: 2 additions & 1 deletion docs/data/date-pickers/shortcuts/AdvancedRangeShortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker';
import { PickersShortcutsItem } from '@mui/x-date-pickers/PickersShortcuts';
import { DateRange } from '@mui/x-date-pickers-pro/models';

const shortcutsItems: PickersShortcutsItem<true>[] = [
const shortcutsItems: PickersShortcutsItem<DateRange<Dayjs>>[] = [
{
label: 'Next Available Weekend',
getValue: ({ isValid }) => {
Expand Down
5 changes: 3 additions & 2 deletions docs/data/date-pickers/shortcuts/BasicRangeShortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from 'react';
import dayjs from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker';
import { PickersShortcutsItem } from '@mui/x-date-pickers/PickersShortcuts';
import { DateRange } from '@mui/x-date-pickers-pro/models';

const shortcutsItems: PickersShortcutsItem<true>[] = [
const shortcutsItems: PickersShortcutsItem<DateRange<Dayjs>>[] = [
{
label: 'This Week',
getValue: () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/data/date-pickers/shortcuts/BasicShortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import dayjs from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';
Expand All @@ -24,7 +24,7 @@ const getMonthWeekday = (
);
};

const shortcutsItems: PickersShortcutsItem<false>[] = [
const shortcutsItems: PickersShortcutsItem<Dayjs | null>[] = [
{
label: "New Year's Day",
getValue: () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/data/date-pickers/shortcuts/ChangeImportance.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import dayjs from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import Stack from '@mui/material/Stack';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
Expand Down Expand Up @@ -30,7 +30,7 @@ const getMonthWeekday = (
);
};

const shortcutsItems: PickersShortcutsItem<false>[] = [
const shortcutsItems: PickersShortcutsItem<Dayjs | null>[] = [
{
label: "New Year's Day",
getValue: () => {
Expand Down
7 changes: 4 additions & 3 deletions docs/data/date-pickers/shortcuts/CustomizedRangeShortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import dayjs from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import Chip from '@mui/material/Chip';
Expand All @@ -12,8 +12,9 @@ import {
PickersShortcutsItem,
PickersShortcutsProps,
} from '@mui/x-date-pickers/PickersShortcuts';
import { DateRange } from '@mui/x-date-pickers-pro/models';

const shortcutsItems: PickersShortcutsItem<true>[] = [
const shortcutsItems: PickersShortcutsItem<DateRange<Dayjs>>[] = [
{
label: 'This Week',
getValue: () => {
Expand Down Expand Up @@ -54,7 +55,7 @@ const shortcutsItems: PickersShortcutsItem<true>[] = [
{ label: 'Reset', getValue: () => [null, null] },
];

function CustomRangeShortcuts(props: PickersShortcutsProps<true>) {
function CustomRangeShortcuts(props: PickersShortcutsProps<DateRange<Dayjs>>) {
const { items, onChange, isValid, changeImportance = 'accept' } = props;

if (items == null || items.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions docs/data/date-pickers/shortcuts/DisabledDatesShortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import dayjs from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';
Expand All @@ -24,7 +24,7 @@ const getMonthWeekday = (
);
};

const shortcutsItems: PickersShortcutsItem<false>[] = [
const shortcutsItems: PickersShortcutsItem<Dayjs | null>[] = [
{
label: "New Year's Day",
getValue: () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/data/date-pickers/shortcuts/OnChangeShortcutLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getMonthWeekday = (
);
};

const shortcutsItems: PickersShortcutsItem<false>[] = [
const shortcutsItems: PickersShortcutsItem<Dayjs | null>[] = [
{
label: "New Year's Day",
getValue: () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';

import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Dayjs } from 'dayjs';
import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
Expand All @@ -21,7 +22,7 @@ import {
DatePickerToolbarProps,
} from '@mui/x-date-pickers/DatePicker';

function LayoutWithKeyboardView(props: PickersLayoutProps<false, DateView>) {
function LayoutWithKeyboardView(props: PickersLayoutProps<Dayjs | null, DateView>) {
const { value, onChange } = props;
const [showKeyboardView, setShowKeyboardView] = React.useState(false);

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/date-pickers/date-calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, selectionState: PickerSelectionState | undefined, selectedView: TView | undefined) => void",
"type": "function(value: TValue, selectionState: PickerSelectionState | undefined, selectedView: TView | undefined) => void",
"describedArgs": ["value", "selectionState", "selectedView"]
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/x/api/date-pickers/date-field.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClear": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/date-pickers/date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@
"onAccept": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClose": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/date-pickers/date-range-calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, selectionState: PickerSelectionState | undefined, selectedView: TView | undefined) => void",
"type": "function(value: TValue, selectionState: PickerSelectionState | undefined, selectedView: TView | undefined) => void",
"describedArgs": ["value", "selectionState", "selectedView"]
}
},
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/date-pickers/date-range-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@
"onAccept": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClose": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/x/api/date-pickers/date-time-field.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClear": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/date-pickers/date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@
"onAccept": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClose": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/date-pickers/date-time-range-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@
"onAccept": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClose": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/date-pickers/desktop-date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@
"onAccept": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(value: InferPickerValue<TIsRange>, context: FieldChangeHandlerContext<TError>) => void",
"type": "function(value: TValue, context: FieldChangeHandlerContext<TError>) => void",
"describedArgs": ["value", "context"]
}
},
"onClose": { "type": { "name": "func" } },
"onError": {
"type": { "name": "func" },
"signature": {
"type": "function(error: TError, value: InferPickerValue<TIsRange>) => void",
"type": "function(error: TError, value: TValue) => void",
"describedArgs": ["error", "value"]
}
},
Expand Down
Loading

0 comments on commit 627900d

Please sign in to comment.