feat: improve typescript comments (#1467)
This commit is contained in:
@@ -9,13 +9,30 @@ const ProcessingContext = createContext(false);
|
||||
const ModifiedContext = createContext(false);
|
||||
const FormFieldsContext = createSelectorContext<FormFieldsContextType>([{}, () => null]);
|
||||
|
||||
/**
|
||||
* Get the state of the form, can be used to submit & validate the form.
|
||||
*
|
||||
* @see https://payloadcms.com/docs/admin/hooks#useform
|
||||
*/
|
||||
const useForm = (): Context => useContext(FormContext);
|
||||
const useWatchForm = (): Context => useContext(FormWatchContext);
|
||||
const useFormSubmitted = (): boolean => useContext(SubmittedContext);
|
||||
const useFormProcessing = (): boolean => useContext(ProcessingContext);
|
||||
const useFormModified = (): boolean => useContext(ModifiedContext);
|
||||
|
||||
|
||||
/**
|
||||
* Get and set the value of a form field based on a selector
|
||||
*
|
||||
* @see https://payloadcms.com/docs/admin/hooks#useformfields
|
||||
*/
|
||||
const useFormFields = <Value = unknown>(selector: (context: FormFieldsContextType) => Value): Value => useContextSelector(FormFieldsContext, selector);
|
||||
|
||||
/**
|
||||
* Get the state of all form fields.
|
||||
*
|
||||
* @see https://payloadcms.com/docs/admin/hooks#useallformfields
|
||||
*/
|
||||
const useAllFormFields = (): FormFieldsContextType => useFullContext(FormFieldsContext);
|
||||
|
||||
export {
|
||||
|
||||
@@ -8,6 +8,11 @@ import { useOperation } from '../../utilities/OperationProvider';
|
||||
import useThrottledEffect from '../../../hooks/useThrottledEffect';
|
||||
import { UPDATE } from '../Form/types';
|
||||
|
||||
/**
|
||||
* Get and set the value of a form field.
|
||||
*
|
||||
* @see https://payloadcms.com/docs/admin/hooks#usefield
|
||||
*/
|
||||
const useField = <T extends unknown>(options: Options): FieldType<T> => {
|
||||
const {
|
||||
path,
|
||||
|
||||
Reference in New Issue
Block a user