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] Do not require date-fns in @mui/x-date-pickers-pro #5941

Merged
merged 1 commit into from
Aug 29, 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
@@ -1,5 +1,6 @@
import { TextFieldProps } from '@mui/material/TextField';
import { UseFieldProps, FieldSection, DefaultizedProps } from '@mui/x-date-pickers/internals';
import { DefaultizedProps } from '@mui/x-date-pickers/internals';
import { UseFieldProps, FieldSection } from '@mui/x-date-pickers/internals-fields';
import { DateRange } from '../internal/models';
import {
DateRangeValidationError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {
useUtils,
useDefaultDates,
parseNonNullablePickerDate,
} from '@mui/x-date-pickers/internals';
import {
useField,
FieldValueManager,
splitFormatIntoSections,
addPositionPropertiesToSections,
createDateStrFromSections,
useUtils,
useDefaultDates,
parseNonNullablePickerDate,
} from '@mui/x-date-pickers/internals';
} from '@mui/x-date-pickers/internals-fields';
import {
DateRangeFieldSection,
UseDateRangeFieldDefaultizedProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
unstable_useDateField as useDateField,
UseDateFieldProps,
} from '@mui/x-date-pickers/DateField';
import { useUtils, useValidation, UseFieldResponse } from '@mui/x-date-pickers/internals';
import { useUtils, useValidation } from '@mui/x-date-pickers/internals';
import { UseFieldResponse } from '@mui/x-date-pickers/internals-fields';
import { UseMultiInputDateRangeFieldProps } from './MultiInputDateRangeField.interfaces';
import { DateRange } from '../internal/models';
import { validateDateRange } from '../internal/hooks/validation/useDateRangeValidation';
Expand Down
15 changes: 15 additions & 0 deletions packages/x-date-pickers/src/internals-fields/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// We don't add those exports to the regular `@mui/x-date-pickers/internals`,
// Because they rely on date-fns, which is not used by all applications.
export {
useField,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that we should still look into removing the direct dependency of date-fns from useField.utls going forward 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think we all agree on that
I requires new methods in the adapter so it was not feasable for a simple POC
But the components can't be stable with hardcoded date-fns stuff

createDateStrFromSections,
addPositionPropertiesToSections,
splitFormatIntoSections,
} from '../internals/hooks/useField';
export type {
UseFieldProps,
UseFieldParams,
UseFieldResponse,
FieldValueManager,
FieldSection,
} from '../internals/hooks/useField';
13 changes: 0 additions & 13 deletions packages/x-date-pickers/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ export type { WrapperVariant } from './components/wrappers/WrapperVariantContext

export { DAY_MARGIN } from './constants/dimensions';

export {
useField,
createDateStrFromSections,
addPositionPropertiesToSections,
splitFormatIntoSections,
} from './hooks/useField';
export type {
UseFieldProps,
UseFieldParams,
UseFieldResponse,
FieldValueManager,
FieldSection,
} from './hooks/useField';
export { useMaskedInput } from './hooks/useMaskedInput';
export { usePickerState } from './hooks/usePickerState';
export type { PickerStateProps, PickerStatePickerProps } from './hooks/usePickerState';
Expand Down