Skip to content

Commit

Permalink
[pickers] Avoid deeper than 2nd level imports (#11588)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Jan 5, 2024
1 parent 8153169 commit 306e62e
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 21 deletions.
7 changes: 2 additions & 5 deletions docs/src/modules/components/PickersPlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ import {
} from '@mui/x-date-pickers/StaticDateTimePicker';
import { DateOrTimeView } from '@mui/x-date-pickers/models';
import { PickersShortcutsItem } from '@mui/x-date-pickers/PickersShortcuts';
import { DateRange } from '@mui/x-date-pickers-pro/internals/models';
import { DateRange } from '@mui/x-date-pickers-pro';
import { DesktopDateRangePicker } from '@mui/x-date-pickers-pro/DesktopDateRangePicker';
import { MobileDateRangePicker } from '@mui/x-date-pickers-pro/MobileDateRangePicker';
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker';
// eslint-disable-next-line no-restricted-imports
import { isDatePickerView } from '@mui/x-date-pickers/internals/utils/date-utils';
// eslint-disable-next-line no-restricted-imports
import { isTimeView } from '@mui/x-date-pickers/internals/utils/time-utils';
import { isDatePickerView, isTimeView } from '@mui/x-date-pickers/internals';

function RadioGroupControl({
label,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { SlotComponentProps } from '@mui/base/utils';
import TextField from '@mui/material/TextField';
import { FieldsTextFieldProps } from '@mui/x-date-pickers/internals/models/fields';
import { FieldsTextFieldProps } from '@mui/x-date-pickers/internals';
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
import {
UseDateTimeRangeFieldDefaultizedProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { SlotComponentProps } from '@mui/base/utils';
import TextField from '@mui/material/TextField';
import { FieldsTextFieldProps } from '@mui/x-date-pickers/internals/models/fields';
import { FieldsTextFieldProps } from '@mui/x-date-pickers/internals';
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
import { UseTimeRangeFieldDefaultizedProps, UseTimeRangeFieldProps } from '../internals/models';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals';
import { DateRangeCalendar, DateRangeCalendarProps } from '../DateRangeCalendar';

export interface DateRangeViewRendererProps<TDate, TView extends DateOrTimeViewWithMeridiem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
InferError,
ExportedBaseToolbarProps,
BaseFieldProps,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import {
DesktopRangePickerAdditionalViewProps,
UseDesktopRangePickerParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
BaseNonStaticPickerProps,
UsePickerValueNonStaticProps,
UsePickerViewsNonStaticProps,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import {
ExportedPickersLayoutSlots,
ExportedPickersLayoutSlotProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import useEventCallback from '@mui/utils/useEventCallback';
import useForkRef from '@mui/utils/useForkRef';
import { BaseSingleInputFieldProps, FieldSelectedSections } from '@mui/x-date-pickers/models';
import { UseClearableFieldSlots, UseClearableFieldSlotProps } from '@mui/x-date-pickers/hooks';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import { PickersInputLocaleText } from '@mui/x-date-pickers/locales';
import {
BaseFieldProps,
Expand All @@ -17,6 +16,7 @@ import {
WrapperVariant,
UsePickerProps,
getActiveElement,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import {
BaseMultiInputFieldProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
InferError,
ExportedBaseToolbarProps,
useLocaleText,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import useId from '@mui/utils/useId';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import {
MobileRangePickerAdditionalViewProps,
UseMobileRangePickerParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
BaseNonStaticPickerProps,
UsePickerValueNonStaticProps,
UsePickerViewsNonStaticProps,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import {
ExportedPickersLayoutSlots,
ExportedPickersLayoutSlotProps,
} from '@mui/x-date-pickers/PickersLayout';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import { DateRange, RangeFieldSection, BaseRangeNonStaticPickerProps } from '../../models';
import { UseRangePositionProps, UseRangePositionResponse } from '../useRangePosition';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import clsx from 'clsx';
import { styled } from '@mui/material/styles';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { PickersLayout, PickersLayoutSlotProps } from '@mui/x-date-pickers/PickersLayout';
import { usePicker, DIALOG_WIDTH, ExportedBaseToolbarProps } from '@mui/x-date-pickers/internals';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import {
usePicker,
DIALOG_WIDTH,
ExportedBaseToolbarProps,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import {
UseStaticRangePickerParams,
UseStaticRangePickerProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
UsePickerParams,
ExportedBaseToolbarProps,
StaticOnlyPickerProps,
DateOrTimeViewWithMeridiem,
} from '@mui/x-date-pickers/internals';
import {
ExportedPickersLayoutSlots,
ExportedPickersLayoutSlotProps,
} from '@mui/x-date-pickers/PickersLayout';
import { DateOrTimeViewWithMeridiem } from '@mui/x-date-pickers/internals/models';
import { DateRange } from '../../models/range';
import { UseRangePositionProps } from '../useRangePosition';
import { RangeFieldSection } from '../../models/fields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
describeValue,
} from 'test/utils/pickers';
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock';
import { formatMeridiem } from '@mui/x-date-pickers/internals/utils/date-utils';
import { formatMeridiem } from '@mui/x-date-pickers/internals';

describe('<MultiSectionDigitalClock /> - Describes', () => {
const { render, clock } = createPickerRenderer({ clock: 'fake' });
Expand Down
18 changes: 16 additions & 2 deletions packages/x-date-pickers/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export {
useLocaleText,
useNow,
} from './hooks/useUtils';
export type { ExportedUseViewsOptions } from './hooks/useViews';
export type { ExportedUseViewsOptions, UseViewsOptions } from './hooks/useViews';
export { useViews } from './hooks/useViews';
export { useValidation } from './hooks/useValidation';
export type { ValidationProps, Validator, InferError } from './hooks/useValidation';
export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
Expand All @@ -101,9 +102,15 @@ export type {
BasePickerInputProps,
BaseNonStaticPickerProps,
} from './models/props/basePickerProps';
export type { BaseClockProps, DesktopOnlyTimePickerProps } from './models/props/clock';
export type { BaseTabsProps, ExportedBaseTabsProps } from './models/props/tabs';
export type { BaseToolbarProps, ExportedBaseToolbarProps } from './models/props/toolbar';
export type { DefaultizedProps, MakeOptional } from './models/helpers';
export type { WrapperVariant } from './models/common';
export type {
WrapperVariant,
TimeViewWithMeridiem,
DateOrTimeViewWithMeridiem,
} from './models/common';
export type {
BaseDateValidationProps,
BaseTimeValidationProps,
Expand All @@ -120,7 +127,11 @@ export {
replaceInvalidDateByNull,
areDatesEqual,
getTodayDate,
isDatePickerView,
mergeDateAndTime,
formatMeridiem,
} from './utils/date-utils';
export { resolveTimeViewsResponse } from './utils/date-time-utils';
export { splitFieldInternalAndForwardedProps } from './utils/fields';
export { getDefaultReferenceDate } from './utils/getDefaultReferenceDate';
export {
Expand All @@ -134,6 +145,7 @@ export { extractValidationProps } from './utils/validation/extractValidationProp
export { validateDate } from './utils/validation/validateDate';
export { validateDateTime } from './utils/validation/validateDateTime';
export { validateTime } from './utils/validation/validateTime';
export { applyDefaultViewProps } from './utils/views';
export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';

export { DayCalendar } from '../DateCalendar/DayCalendar';
Expand All @@ -146,3 +158,5 @@ export type {

export type { ExportedDateCalendarProps } from '../DateCalendar/DateCalendar.types';
export { useCalendarState } from '../DateCalendar/useCalendarState';

export { isTimeView } from './utils/time-utils';
2 changes: 1 addition & 1 deletion packages/x-date-pickers/src/internals/models/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DateView, TimeView } from '@mui/x-date-pickers/models/views';
import { DateView, TimeView } from '../../models/views';

export type WrapperVariant = 'mobile' | 'desktop' | null;

Expand Down
2 changes: 1 addition & 1 deletion test/utils/pickers/viewHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fireTouchChangedEvent, userEvent, screen } from '@mui-internal/test-utils';
import { getClockTouchEvent, formatFullTimeValue } from 'test/utils/pickers';
import { MuiPickersAdapter, TimeView } from '@mui/x-date-pickers/models';
import { formatMeridiem } from '@mui/x-date-pickers/internals/utils/date-utils';
import { formatMeridiem } from '@mui/x-date-pickers/internals';

type TDate = any;

Expand Down

0 comments on commit 306e62e

Please sign in to comment.