UNPKG

@rjsf/utils

Version:
40 lines (39 loc) 2.58 kB
import { MouseEvent } from 'react'; import { DateElementProp } from './getDateElementProps.js'; import { DateObject, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from './types.js'; /** The Props for the `DateElement` component */ export type DateElementProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Pick<WidgetProps<T, S, F>, 'value' | 'name' | 'disabled' | 'readonly' | 'autofocus' | 'registry' | 'onBlur' | 'onFocus' | 'className'> & { /** The root id of the field */ rootId: string; /** The selector function for a specific prop within the `DateObject`, for a value */ select: (property: keyof DateObject, value: any) => void; /** The type of the date element */ type: DateElementProp['type']; /** The range for the date element */ range: DateElementProp['range']; }; /** The `DateElement` component renders one of the 6 date element selectors for an `AltDateWidget`, using the `select` * widget from the registry. * * @param props - The `DateElementProps` for the date element */ export declare function DateElement<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: DateElementProps<T, S, F>): import("react/jsx-runtime").JSX.Element; /** The result of a call to the `useAltDateWidgetProps()` hook */ export type UseAltDateWidgetResult = { /** The list of `DateElementProp` data to render for the `AltDateWidget` */ elements: DateElementProp[]; /** The callback that handles the changing of DateElement components */ handleChange: (property: keyof DateObject, value?: string) => void; /** The callback that will clear the `AltDateWidget` when a button is clicked */ handleClear: (event: MouseEvent) => void; /** The callback that will set the `AltDateWidget` to NOW when a button is clicked */ handleSetNow: (event: MouseEvent) => void; }; /** Hook which encapsulates the logic needed to render an `AltDateWidget` with optional `time` elements. It contains * the `state` of the current date(/time) selections in the widget. It returns a `UseAltDateWidgetResult` object * that contains the `elements: DateElementProp[]` and three callbacks needed to change one of the rendered `elements`, * and to handle the clicking of the `clear` and `setNow` buttons. * * @param props - The `WidgetProps` for the `AltDateWidget` */ export default function useAltDateWidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: WidgetProps<T, S, F>): UseAltDateWidgetResult;