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

[pickers] Rename ClockPicker into TimeClock #6851

Merged
merged 7 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import dayjs from 'dayjs';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { ClockPicker } from '@mui/x-date-pickers/ClockPicker';
import { TimeClock } from '@mui/x-date-pickers/TimeClock';

export default function SubComponentsTimeCalendars() {
const [value, setValue] = React.useState(dayjs('2022-04-07T10:15'));

return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<ClockPicker value={value} onChange={(newValue) => setValue(newValue)} />
<TimeClock value={value} onChange={(newValue) => setValue(newValue)} />
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import dayjs, { Dayjs } from 'dayjs';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { ClockPicker } from '@mui/x-date-pickers/ClockPicker';
import { TimeClock } from '@mui/x-date-pickers/TimeClock';

export default function SubComponentsTimeCalendars() {
const [value, setValue] = React.useState<Dayjs | null>(dayjs('2022-04-07T10:15'));

return (
<LocalizationProvider dateAdapter={AdapterDayjs}>
<ClockPicker value={value} onChange={(newValue) => setValue(newValue)} />
<TimeClock value={value} onChange={(newValue) => setValue(newValue)} />
</LocalizationProvider>
);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<LocalizationProvider dateAdapter={AdapterDayjs}>
<ClockPicker value={value} onChange={(newValue) => setValue(newValue)} />
<TimeClock value={value} onChange={(newValue) => setValue(newValue)} />
</LocalizationProvider>
26 changes: 12 additions & 14 deletions docs/data/migration/migration-pickers-v5/migration-pickers-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,31 +192,26 @@ The `locale` prop of the `LocalizationProvider` component have been renamed `ada

### Rename the view components

The view components allowing to pick a date or parts of a date without an input have been renamed to better fit their usage:
The view components allowing to pick a time, a date or parts of a date without an input have been renamed to better fit their usage:

```diff
-<CalendarPicker {...props} />
+<DateCalendar {...props} />
```

```diff
-<DayPicker {...props} />
+<DayCalendar {...props} />
```

```diff
-<CalendarPickerSkeleton {...props} />
+<DayCalendarSkeleton {...props} />
```

```diff
-<MonthPicker {...props} />
+<MonthCalendar {...props} />
```

```diff
-<YearPicker {...props} />
+<YearCalendar {...props} />

-<ClockPicker {...props} />
+<TimeClock {...props} />
```

Component names in the theme have changed as well:
Expand All @@ -236,24 +231,27 @@ Component names in the theme have changed as well:

-MuiYearPicker: {
+MuiYearCalendar: {

-MuiClockPicker: {
+MuiTimeClock: {
```

### Rename `date` prop to `value` on view components

The `date` prop has been renamed `value` on `MonthPicker`, `YearPicker`, `ClockPicker` and `CalendarPicker`:
The `date` prop has been renamed `value` on `MonthCalendar`, `YearCalendar`, `TimeClock` and `DateCalendar` (components renamed in previous section):

```diff
-<MonthPicker date={dayjs()} onChange={handleMonthChange} />
+<MonthPicker value={dayjs()} onChange={handleMonthChange} />
+<MonthCalendar value={dayjs()} onChange={handleMonthChange} />

-<YearPicker date={dayjs()} onChange={handleYearChange} />
+<YearPicker value={dayjs()} onChange={handleYearChange} />
+<YearCalendar value={dayjs()} onChange={handleYearChange} />

-<ClockPicker date={dayjs()} onChange={handleTimeChange} />
+<ClockPicker value={dayjs()} onChange={handleTimeChange} />
+<TimeClock value={dayjs()} onChange={handleTimeChange} />

-<CalendarPicker date={dayjs()} onChange={handleDateChange} />
+<CalendarPicker value={dayjs()} onChange={handleDateChange} />
+<DateCalendar value={dayjs()} onChange={handleDateChange} />
```

### Rename remaining `private` components
Expand Down
2 changes: 1 addition & 1 deletion docs/data/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ const pages: MuiPage[] = [
title: 'API Reference',
children: [
{ pathname: '/x/api/date-pickers', title: 'Index' },
{ pathname: '/x/api/date-pickers/clock-picker', title: 'ClockPicker' },
{ pathname: '/x/api/date-pickers/date-calendar', title: 'DateCalendar' },
{ pathname: '/x/api/date-pickers/date-picker', title: 'DatePicker' },
{
Expand Down Expand Up @@ -263,6 +262,7 @@ const pages: MuiPage[] = [
title: 'StaticDateTimePicker',
},
{ pathname: '/x/api/date-pickers/static-time-picker', title: 'StaticTimePicker' },
{ pathname: '/x/api/date-pickers/time-clock', title: 'TimeClock' },
{ pathname: '/x/api/date-pickers/time-picker', title: 'TimePicker' },
{ pathname: '/x/api/date-pickers/year-calendar', title: 'YearCalendar' },
],
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/date-pickers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

## Components

- [ClockPicker](/x/api/date-pickers/clock-picker/)
- [DateCalendar](/x/api/date-pickers/date-calendar/)
- [DatePicker](/x/api/date-pickers/date-picker/)
- [DateRangePicker](/x/api/date-pickers/date-range-picker/)
Expand All @@ -26,5 +25,6 @@
- [StaticDateRangePicker](/x/api/date-pickers/static-date-range-picker/)
- [StaticDateTimePicker](/x/api/date-pickers/static-date-time-picker/)
- [StaticTimePicker](/x/api/date-pickers/static-time-picker/)
- [TimeClock](/x/api/date-pickers/time-clock/)
- [TimePicker](/x/api/date-pickers/time-picker/)
- [YearCalendar](/x/api/date-pickers/year-calendar/)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import ApiPage from 'docsx/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './clock-picker.json';
import jsonPageContent from './time-clock.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
Expand All @@ -12,7 +12,7 @@ Page.getInitialProps = () => {
const req = require.context(
'docsx/translations/api-docs/date-pickers',
false,
/\/clock-picker(-[a-z]{2})?\.json$/,
/\/time-clock(-[a-z]{2})?\.json$/,
);
const descriptions = mapApiPageTranslations(req);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
"PreviousIconButton": { "default": "IconButton", "type": { "name": "elementType" } },
"RightArrowIcon": { "default": "ArrowRight", "type": { "name": "elementType" } }
},
"name": "ClockPicker",
"styles": { "classes": ["root", "arrowSwitcher"], "globalClasses": {}, "name": "MuiClockPicker" },
"name": "TimeClock",
"styles": { "classes": ["root", "arrowSwitcher"], "globalClasses": {}, "name": "MuiTimeClock" },
"spread": false,
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/x-date-pickers/src/ClockPicker/ClockPicker.tsx",
"filename": "/packages/x-date-pickers/src/TimeClock/TimeClock.tsx",
"inheritance": null,
"demos": "<ul></ul>",
"packages": ["@mui/x-date-pickers-pro", "@mui/x-date-pickers"]
Expand Down
5 changes: 0 additions & 5 deletions packages/x-date-pickers/src/ClockPicker/ClockPicker.spec.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions packages/x-date-pickers/src/DateTimePicker/shared.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { useThemeProps } from '@mui/material/styles';
import { useDefaultDates, useUtils } from '../internals/hooks/useUtils';
import { ExportedClockPickerProps } from '../ClockPicker/ClockPicker';
import { ExportedTimeClockProps } from '../TimeClock/TimeClock';
import { ExportedDateCalendarProps } from '../DateCalendar/DateCalendar';
import { DateTimeValidationError } from '../internals/hooks/validation/useDateTimeValidation';
import { ValidationCommonProps } from '../internals/hooks/validation/useValidation';
Expand Down Expand Up @@ -51,7 +51,7 @@ export interface BaseDateTimePickerSlotsComponentsProps<TDate>
}

export interface BaseDateTimePickerProps<TDate>
extends ExportedClockPickerProps<TDate>,
extends ExportedTimeClockProps<TDate>,
ExportedDateCalendarProps<TDate>,
BasePickerProps<TDate | null, TDate>,
ValidationCommonProps<DateTimeValidationError, TDate | null>,
Expand Down
14 changes: 7 additions & 7 deletions packages/x-date-pickers/src/NextDateTimePicker/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
ExportedDateCalendarProps,
} from '../DateCalendar/DateCalendar';
import {
ClockPickerSlotsComponent,
ClockPickerSlotsComponentsProps,
ExportedClockPickerProps,
} from '../ClockPicker/ClockPicker';
TimeClockSlotsComponent,
TimeClockSlotsComponentsProps,
ExportedTimeClockProps,
} from '../TimeClock/TimeClock';
import { BaseNextPickerProps } from '../internals/models/props/basePickerProps';
import { applyDefaultDate } from '../internals/utils/date-utils';
import {
Expand All @@ -34,7 +34,7 @@ import { DateTimeValidationError } from '../internals/hooks/validation/useDateTi

export interface BaseNextDateTimePickerSlotsComponent<TDate>
extends DateCalendarSlotsComponent<TDate>,
ClockPickerSlotsComponent {
TimeClockSlotsComponent {
/**
* Tabs enabling toggling between date and time pickers.
* @default DateTimePickerTabs
Expand All @@ -49,7 +49,7 @@ export interface BaseNextDateTimePickerSlotsComponent<TDate>

export interface BaseNextDateTimePickerSlotsComponentsProps<TDate>
extends DateCalendarSlotsComponentsProps<TDate>,
ClockPickerSlotsComponentsProps {
TimeClockSlotsComponentsProps {
/**
* Props passed down to the tabs component.
*/
Expand All @@ -66,7 +66,7 @@ export interface BaseNextDateTimePickerProps<TDate>
'views' | 'openTo'
>,
Omit<ExportedDateCalendarProps<TDate>, 'onViewChange'>,
ExportedClockPickerProps<TDate> {
ExportedTimeClockProps<TDate> {
/**
* 12h/24h view for hour selection clock.
* @default `utils.is12HourCycleInCurrentLocale()`
Expand Down
16 changes: 8 additions & 8 deletions packages/x-date-pickers/src/NextTimePicker/shared.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { useThemeProps } from '@mui/material/styles';
import { DefaultizedProps, MakeOptional } from '../internals/models/helpers';
import { ClockPickerView } from '../ClockPicker';
import { ClockPickerView } from '../TimeClock';
import { useUtils } from '../internals/hooks/useUtils';
import {
ClockPickerSlotsComponent,
ClockPickerSlotsComponentsProps,
ExportedClockPickerProps,
} from '../ClockPicker/ClockPicker';
TimeClockSlotsComponent,
TimeClockSlotsComponentsProps,
ExportedTimeClockProps,
} from '../TimeClock/TimeClock';
import { BaseNextPickerProps } from '../internals/models/props/basePickerProps';
import { BaseTimeValidationProps } from '../internals/hooks/validation/models';
import { LocalizedComponent, PickersInputLocaleText } from '../locales/utils/pickersLocaleTextApi';
Expand All @@ -18,15 +18,15 @@ import {
} from '../TimePicker/TimePickerToolbar';
import { TimeValidationError } from '../internals/hooks/validation/useTimeValidation';

export interface BaseNextTimePickerSlotsComponent<TDate> extends ClockPickerSlotsComponent {
export interface BaseNextTimePickerSlotsComponent<TDate> extends TimeClockSlotsComponent {
/**
* Custom component for the toolbar rendered above the views.
* @default TimePickerToolbar
*/
Toolbar?: React.JSXElementConstructor<TimePickerToolbarProps<TDate>>;
}

export interface BaseNextTimePickerSlotsComponentsProps extends ClockPickerSlotsComponentsProps {
export interface BaseNextTimePickerSlotsComponentsProps extends TimeClockSlotsComponentsProps {
toolbar?: ExportedTimePickerToolbarProps;
}

Expand All @@ -35,7 +35,7 @@ export interface BaseNextTimePickerProps<TDate>
BaseNextPickerProps<TDate | null, TDate, ClockPickerView, TimeValidationError>,
'views' | 'openTo'
>,
ExportedClockPickerProps<TDate> {
ExportedTimeClockProps<TDate> {
/**
* 12h/24h view for hour selection clock.
* @default `utils.is12HourCycleInCurrentLocale()`
Expand Down
5 changes: 5 additions & 0 deletions packages/x-date-pickers/src/TimeClock/TimeClock.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as React from 'react';
import { TimeClock } from '@mui/x-date-pickers/TimeClock';

// External components are generic
<TimeClock<Date> view="hours" value={null} onChange={(date) => date?.getDate()} />;
Loading