-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pickers] Create the new picker's
ownerState
object (#14889)
- Loading branch information
1 parent
19d2255
commit a005076
Showing
8 changed files
with
69 additions
and
15 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
25 changes: 25 additions & 0 deletions
25
packages/x-date-pickers/src/internals/hooks/usePicker/usePickerOwnerState.ts
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,25 @@ | ||
import * as React from 'react'; | ||
import { FieldSection, PickerOwnerState } from '../../../models'; | ||
import type { UsePickerProps } from './usePicker.types'; | ||
import { UsePickerValueResponse } from './usePickerValue.types'; | ||
|
||
interface UsePickerOwnerStateParameters<TValue> { | ||
props: UsePickerProps<TValue, any, any, any, any, any>; | ||
pickerValueResponse: UsePickerValueResponse<TValue, FieldSection, any>; | ||
} | ||
|
||
export function usePickerOwnerState<TValue>( | ||
parameters: UsePickerOwnerStateParameters<TValue>, | ||
): PickerOwnerState<TValue> { | ||
const { props, pickerValueResponse } = parameters; | ||
|
||
return React.useMemo( | ||
() => ({ | ||
value: pickerValueResponse.viewProps.value, | ||
open: pickerValueResponse.open, | ||
disabled: props.disabled ?? false, | ||
readOnly: props.readOnly ?? false, | ||
}), | ||
[pickerValueResponse.viewProps.value, pickerValueResponse.open, props.disabled, props.readOnly], | ||
); | ||
} |
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