import * as React from 'react'; import { SxProps } from '@mui/system'; import { Theme } from '@mui/material/styles'; import { UseViewsOptions } from '../useViews'; import type { UsePickerValueViewsResponse } from './usePickerValue.types'; import { DateOrTimeViewWithMeridiem } from '../../models'; import { TimezoneProps } from '../../../models'; interface PickerViewsRendererBaseExternalProps extends Omit, 'openTo' | 'viewRenderers'> { } export type PickerViewsRendererProps, TAdditionalProps extends {}> = TExternalProps & TAdditionalProps & UsePickerValueViewsResponse & { view: TView; views: readonly TView[]; focusedView: TView | null; onFocusedViewChange: (viewToFocus: TView, hasFocus: boolean) => void; }; type PickerViewRenderer, TAdditionalProps extends {}> = (props: PickerViewsRendererProps) => React.ReactNode; export type PickerViewRendererLookup, TAdditionalProps extends {}> = { [K in TView]: PickerViewRenderer | null; }; /** * Props used to handle the views that are common to all pickers. */ export interface UsePickerViewsBaseProps, TAdditionalProps extends {}> extends Omit, 'onChange' | 'onFocusedViewChange' | 'focusedView'>, TimezoneProps { /** * If `true`, the picker and text field are disabled. * @default false */ disabled?: boolean; /** * If `null`, the section will only have field editing. * If `undefined`, internally defined view will be the used. */ viewRenderers: PickerViewRendererLookup; /** * If `true`, disable heavy animations. * @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13 */ reduceAnimations?: boolean; /** * The date used to generate the new value when both `value` and `defaultValue` are empty. * @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`. */ referenceDate?: TDate; } /** * Props used to handle the views of the pickers. */ export interface UsePickerViewsNonStaticProps { /** * If `true`, the open picker button will not be rendered (renders only the field). * @default false */ disableOpenPicker?: boolean; } /** * Props used to handle the value of the pickers. */ export interface UsePickerViewsProps, TAdditionalProps extends {}> extends UsePickerViewsBaseProps { className?: string; sx?: SxProps; } export interface UsePickerViewParams, TAdditionalProps extends {}> { props: TExternalProps; propsFromPickerValue: UsePickerValueViewsResponse; additionalViewProps: TAdditionalProps; inputRef?: React.RefObject; autoFocusView: boolean; } export interface UsePickerViewsResponse { /** * Indicates if the the picker has at least one view that should be rendered in UI. */ hasUIView: boolean; renderCurrentView: () => React.ReactNode; shouldRestoreFocus: () => boolean; layoutProps: UsePickerViewsLayoutResponse; } export interface UsePickerViewsLayoutResponse { view: TView | null; onViewChange: (view: TView) => void; views: readonly TView[]; } /** * Manage the views of all the pickers: * - Handles the view switch * - Handles the switch between UI views and field views * - Handles the focus management when switching views */ export declare const usePickerViews: , TAdditionalProps extends {}>({ props, propsFromPickerValue, additionalViewProps, inputRef, autoFocusView, }: UsePickerViewParams) => UsePickerViewsResponse; export {};