@progress/kendo-react-form
Version:
React Form is a small and fast package for form state management with zero dependencies. KendoReact Form package
275 lines (274 loc) • 6.84 kB
TypeScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { default as PropTypes } from 'prop-types';
import { FieldValidatorType } from './interfaces/FieldValidator.js';
import { FormProps } from './interfaces/FormProps.js';
import { KeyValue } from './interfaces/KeyValue.js';
import * as React from 'react';
/**
* Represents the [KendoReact Form component](https://www.telerik.com/kendo-react-ui/components/form).
*
* @example
* ```jsx
* export const FormInput = (fieldRenderProps) => {
* const onValueChange = React.useCallback(
* (event) => fieldRenderProps.onChange(event.target.value),
* [fieldRenderProps.onChange]
* );
* return (
* <input
* className={'k-input'}
* value={fieldRenderProps.value}
* onChange={onValueChange}
* />
* );
* };
*
* export const App = () => {
* const handleSubmit = (dataItem) => alert(JSON.stringify(dataItem));
* return (
* <Form
* initialValues={{title: ''}}
* onSubmit={handleSubmit}
* render={(formRenderProps) => (
* <div>
* <Field name={'title'} component={FormInput} />
* <Button
* disabled={!formRenderProps.allowSubmit}
* onClick={formRenderProps.onSubmit}
* >
* Submit
* </Button>
* </div>
* )}
* />
* );
* };
* ```
*/
export declare class Form extends React.Component<FormProps, {}> {
/**
* @hidden
*/
static displayName: string;
/**
* @hidden
*/
static propTypes: {
initialValues: PropTypes.Requireable<any>;
onSubmit: PropTypes.Requireable<(...args: any[]) => any>;
onSubmitClick: PropTypes.Requireable<(...args: any[]) => any>;
render: PropTypes.Validator<(...args: any[]) => any>;
id: PropTypes.Requireable<string>;
};
private _key?;
private _touched;
private _visited;
private _modified;
private _validatorsByField;
private _values;
private _fields;
private _unmounted;
private _submitted;
private readonly showLicenseWatermark;
private readonly licenseMessage?;
/**
* @hidden
*/
private _accumulatorTimeout;
/**
* @hidden
*/
get touched(): KeyValue<boolean>;
/**
* @hidden
*/
set touched(value: KeyValue<boolean>);
/**
* @hidden
*/
get visited(): KeyValue<boolean>;
/**
* @hidden
*/
set visited(value: KeyValue<boolean>);
/**
* @hidden
*/
get modified(): KeyValue<boolean>;
/**
* @hidden
*/
set modified(value: KeyValue<boolean>);
/**
* @hidden
*/
get validatorsByField(): KeyValue<(FieldValidatorType | FieldValidatorType[] | undefined)[]>;
/**
* @hidden
*/
set validatorsByField(value: KeyValue<(FieldValidatorType | FieldValidatorType[] | undefined)[]>);
/**
* @hidden
*/
get values(): KeyValue<any>;
/**
* @hidden
*/
set values(value: KeyValue<any>);
/**
* @hidden
*/
get fields(): string[];
/**
* @hidden
*/
get formErrors(): KeyValue<string> | undefined;
/**
* @hidden
*/
get errors(): KeyValue<string>;
/**
* @hidden
*/
constructor(props: FormProps);
/**
* @hidden
*/
componentWillUnmount(): void;
/**
* @hidden
*/
isValid: () => boolean;
/**
* @hidden
*/
accumulatedForceUpdate: () => void;
/**
* @hidden
*/
resetForm: () => void;
/**
* Method for resetting the form state outside the form component.
*
* > Use `onReset` only if you cannot achieve the desired behavior through the Field component or by FormRenderProps.
*/
onReset: () => void;
/**
* @hidden
*/
addField: (field: string) => void;
/**
* @hidden
*/
onSubmit: (event: React.SyntheticEvent<any>) => void;
/**
* Method for emiting changes to a specific field outside the form component.
*
* > Use `onChange` only if you cannot achieve the desired behavior through the Field component by FormRenderProps.
*/
onChange: (name: string, options: {
value: any;
}) => void;
/**
* @hidden
*/
onFocus: (name: string, skipForceUpdate?: boolean) => void;
/**
* @hidden
*/
onBlur: (name: string, skipForceUpdate?: boolean) => void;
/**
* @hidden
*/
onFieldRegister: (name: string, validator: FieldValidatorType | FieldValidatorType[] | undefined) => () => void;
/**
* @hidden
*/
isFormValid: (errors: KeyValue<any>) => boolean;
/**
* @hidden
*/
isFormModified: (modified: KeyValue<boolean>, fields: string[]) => boolean;
/**
* @hidden
*/
isFormHasNotTouched: (touched: KeyValue<boolean>, fields: string[]) => boolean;
/**
* @hidden
*/
isFormTouched: (touched: KeyValue<boolean>, fields: string[]) => boolean;
/**
* @hidden
*/
isFormVisited: (visited: KeyValue<boolean>, fields: string[]) => boolean;
/**
* @hidden
*/
valueGetter: (fieldName: string) => any;
/**
* @hidden
*/
valueSetter: (fieldName: string, value: any) => any;
/**
* @hidden
*/
onArrayAction: (name: string) => void;
/**
* @hidden
*/
onInsert: (name: string, options: {
value: any;
index: number;
}) => void;
/**
* @hidden
*/
onUnshift: (name: string, options: {
value: any;
}) => void;
/**
* @hidden
*/
onPush: (name: string, options: {
value: any;
}) => void;
/**
* @hidden
*/
onPop: (name: string) => any;
/**
* @hidden
*/
onRemove: (name: string, options: {
index: number;
}) => any;
/**
* @hidden
*/
onReplace: (name: string, options: {
value: any;
index: number;
}) => void;
/**
* @hidden
*/
onMove: (name: string, options: {
prevIndex: number;
nextIndex: number;
}) => void;
/**
* @hidden
*/
render(): React.JSX.Element;
}
/**
* Represent the `ref` of the Form component.
*/
export interface FormHandle extends Pick<Form, keyof Form> {
}