-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid root exporting
DayRangeValidationProps
- Loading branch information
Showing
7 changed files
with
54 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { | ||
BaseDateValidationProps, | ||
MakeOptional, | ||
UseFieldInternalProps, | ||
} from '@mui/x-date-pickers/internals'; | ||
import { PickerValidDate } from '@mui/x-date-pickers/models'; | ||
import { RangeFieldSection, RangeFieldSeparatorProps } from './fields'; | ||
import { DateRangeValidationError } from './validation'; | ||
import { DateRange } from './range'; | ||
|
||
/** | ||
* Props used to validate a day value in range pickers. | ||
*/ | ||
export interface DayRangeValidationProps<TDate extends PickerValidDate> { | ||
/** | ||
* Disable specific date. | ||
* | ||
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance. | ||
* | ||
* @template TDate | ||
* @param {TDate} day The date to test. | ||
* @param {string} position The date to test, 'start' or 'end'. | ||
* @returns {boolean} Returns `true` if the date should be disabled. | ||
*/ | ||
shouldDisableDate?: (day: TDate, position: 'start' | 'end') => boolean; | ||
} | ||
|
||
export interface UseDateRangeFieldProps< | ||
TDate extends PickerValidDate, | ||
TEnableAccessibleFieldDOMStructure extends boolean, | ||
> extends MakeOptional< | ||
Omit< | ||
UseFieldInternalProps< | ||
DateRange<TDate>, | ||
TDate, | ||
RangeFieldSection, | ||
TEnableAccessibleFieldDOMStructure, | ||
DateRangeValidationError | ||
>, | ||
'unstableFieldRef' | ||
>, | ||
'format' | ||
>, | ||
RangeFieldSeparatorProps, | ||
DayRangeValidationProps<TDate>, | ||
BaseDateValidationProps<TDate> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,7 @@ | ||
import { | ||
BaseDateValidationProps, | ||
MakeOptional, | ||
UseFieldInternalProps, | ||
} from '@mui/x-date-pickers/internals'; | ||
import { PickerValidDate } from '@mui/x-date-pickers/models'; | ||
import { RangeFieldSection, RangeFieldSeparatorProps } from './fields'; | ||
import { DateRangeValidationError } from './validation'; | ||
|
||
export type DateRange<TDate extends PickerValidDate> = [TDate | null, TDate | null]; | ||
|
||
export type NonEmptyDateRange<TDate extends PickerValidDate> = [TDate, TDate]; | ||
|
||
export type RangePosition = 'start' | 'end'; | ||
|
||
/** | ||
* Props used to validate a day value in range pickers. | ||
*/ | ||
export interface DayRangeValidationProps<TDate extends PickerValidDate> { | ||
/** | ||
* Disable specific date. | ||
* | ||
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance. | ||
* | ||
* @template TDate | ||
* @param {TDate} day The date to test. | ||
* @param {string} position The date to test, 'start' or 'end'. | ||
* @returns {boolean} Returns `true` if the date should be disabled. | ||
*/ | ||
shouldDisableDate?: (day: TDate, position: 'start' | 'end') => boolean; | ||
} | ||
|
||
export interface UseDateRangeFieldProps< | ||
TDate extends PickerValidDate, | ||
TEnableAccessibleFieldDOMStructure extends boolean, | ||
> extends MakeOptional< | ||
Omit< | ||
UseFieldInternalProps< | ||
DateRange<TDate>, | ||
TDate, | ||
RangeFieldSection, | ||
TEnableAccessibleFieldDOMStructure, | ||
DateRangeValidationError | ||
>, | ||
'unstableFieldRef' | ||
>, | ||
'format' | ||
>, | ||
RangeFieldSeparatorProps, | ||
DayRangeValidationProps<TDate>, | ||
BaseDateValidationProps<TDate> {} |