@progress/kendo-react-form 7.2.4-develop.3 → 7.3.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Field.js +8 -0
- package/Field.mjs +71 -0
- package/FieldArray.js +8 -0
- package/FieldArray.mjs +74 -0
- package/FieldWrapper.js +8 -0
- package/FieldWrapper.mjs +24 -0
- package/Form.js +8 -0
- package/Form.mjs +247 -0
- package/FormContext.js +8 -0
- package/FormContext.mjs +13 -0
- package/FormElement.js +8 -0
- package/FormElement.mjs +42 -0
- package/dist/cdn/js/kendo-react-form.js +8 -5
- package/index.d.mts +724 -5
- package/index.d.ts +724 -22
- package/index.js +8 -5
- package/index.mjs +21 -412
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +2 -2
- package/Field.d.ts +0 -14
- package/FieldArray.d.ts +0 -11
- package/FieldWrapper.d.ts +0 -32
- package/Form.d.ts +0 -272
- package/FormContext.d.ts +0 -54
- package/FormElement.d.ts +0 -56
- package/interfaces/FieldArrayProps.d.ts +0 -32
- package/interfaces/FieldArrayRenderProps.d.ts +0 -93
- package/interfaces/FieldProps.d.ts +0 -43
- package/interfaces/FieldRenderProps.d.ts +0 -10
- package/interfaces/FieldValidator.d.ts +0 -18
- package/interfaces/FormProps.d.ts +0 -56
- package/interfaces/FormRenderProps.d.ts +0 -78
- package/interfaces/FormSubmitClickEvent.d.ts +0 -27
- package/interfaces/FormValidator.d.ts +0 -14
- package/interfaces/KeyValue.d.ts +0 -10
- package/package-metadata.d.ts +0 -9
package/index.d.mts
CHANGED
|
@@ -1,5 +1,724 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import { FieldRenderPropsBase } from '@progress/kendo-react-common';
|
|
9
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
10
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import * as React_2 from 'react';
|
|
13
|
+
import { RefAttributes } from 'react';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the Field component that is used inside the KendoReact Form component.
|
|
17
|
+
* It uses `name` property to access field value and meta information from Form state.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Field: {
|
|
20
|
+
(props: FieldProps): React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>> | null;
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the FieldArray component that is used inside the KendoReact Form component.
|
|
26
|
+
* It provides methods via render props for common array manipulations.
|
|
27
|
+
*/
|
|
28
|
+
export declare const FieldArray: React_2.FunctionComponent<FieldArrayProps>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Represents the props of the FieldArray component that is used inside the KendoReact Form component.
|
|
32
|
+
*/
|
|
33
|
+
export declare interface FieldArrayProps {
|
|
34
|
+
/**
|
|
35
|
+
* The name of the field in the Form state.
|
|
36
|
+
*/
|
|
37
|
+
name: string;
|
|
38
|
+
/**
|
|
39
|
+
* Can be set to a React component.
|
|
40
|
+
* [`FieldArrayRenderProps`]({% slug api_form_fieldarrayrenderprops %}).
|
|
41
|
+
*/
|
|
42
|
+
component: React.ComponentType<any>;
|
|
43
|
+
/**
|
|
44
|
+
* The validation functions for the FieldArray level.
|
|
45
|
+
* Currently, `validator` supports only synchronous functions.
|
|
46
|
+
*/
|
|
47
|
+
validator?: FieldValidatorType | FieldValidatorType[];
|
|
48
|
+
/**
|
|
49
|
+
* The React elements that are passed as children to the rendered component.
|
|
50
|
+
*/
|
|
51
|
+
children?: any;
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
[customProp: string]: any;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Represents the props that are passed to the component which is rendered by FieldArray.
|
|
60
|
+
*/
|
|
61
|
+
export declare interface FieldArrayRenderProps {
|
|
62
|
+
/**
|
|
63
|
+
* Represents the current value of the FieldArray
|
|
64
|
+
* ([see example]({% slug custom_components_form %}#toc-using-basic-properties)).
|
|
65
|
+
*/
|
|
66
|
+
value: any;
|
|
67
|
+
/**
|
|
68
|
+
* Represents the error message that is returned by the validator.
|
|
69
|
+
* The FieldArray is considered valid if the `validationMessage` field is empty.
|
|
70
|
+
*/
|
|
71
|
+
validationMessage: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Indicates if the field is touched.
|
|
74
|
+
* The touched state is set to `true` when the `onBlur` callback is called.
|
|
75
|
+
*/
|
|
76
|
+
touched: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Indicates if the field is modified.
|
|
79
|
+
* The modified state is set to `true` when the `onChange` callback for the current field is called for first time.
|
|
80
|
+
*/
|
|
81
|
+
modified: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Indicates if the field is visited.
|
|
84
|
+
* The visited state is set to `true` when the `onFocus` callback is called.
|
|
85
|
+
*/
|
|
86
|
+
visited: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A calculated property based on whether `validationMessage` is present and the `touched` state is set to `true`.
|
|
89
|
+
*/
|
|
90
|
+
valid: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Represents the children that are passed to the FieldArray.
|
|
93
|
+
*/
|
|
94
|
+
children: any;
|
|
95
|
+
/**
|
|
96
|
+
* The name of the field in the Form state.
|
|
97
|
+
*/
|
|
98
|
+
name: string;
|
|
99
|
+
/**
|
|
100
|
+
* A callback to add a value to the beginning of the array.
|
|
101
|
+
*/
|
|
102
|
+
onUnshift: (options: {
|
|
103
|
+
value: any;
|
|
104
|
+
}) => number;
|
|
105
|
+
/**
|
|
106
|
+
* A callback to add a value to the end of the array.
|
|
107
|
+
*/
|
|
108
|
+
onPush: (options: {
|
|
109
|
+
value: any;
|
|
110
|
+
}) => void;
|
|
111
|
+
/**
|
|
112
|
+
* A callback to insert value at given index of the array.
|
|
113
|
+
*/
|
|
114
|
+
onInsert: (options: {
|
|
115
|
+
value: any;
|
|
116
|
+
index: number;
|
|
117
|
+
}) => void;
|
|
118
|
+
/**
|
|
119
|
+
* A callback to remove a value from the end of the array. The value is returned.
|
|
120
|
+
*/
|
|
121
|
+
onPop: () => any;
|
|
122
|
+
/**
|
|
123
|
+
* A callback to remove a value from given index of the array.
|
|
124
|
+
*/
|
|
125
|
+
onRemove: (options: {
|
|
126
|
+
index: number;
|
|
127
|
+
}) => any;
|
|
128
|
+
/**
|
|
129
|
+
* A callback to replace value at given index of the array.
|
|
130
|
+
*/
|
|
131
|
+
onReplace: (options: {
|
|
132
|
+
value: any;
|
|
133
|
+
index: number;
|
|
134
|
+
}) => void;
|
|
135
|
+
/**
|
|
136
|
+
* A callback to move a value from one index to another. Useful for drag and drop reordering.
|
|
137
|
+
*/
|
|
138
|
+
onMove: (options: {
|
|
139
|
+
prevIndex: number;
|
|
140
|
+
nextIndex: number;
|
|
141
|
+
}) => void;
|
|
142
|
+
/**
|
|
143
|
+
* @hidden
|
|
144
|
+
*/
|
|
145
|
+
[customProp: string]: any;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Represents the props of the Field component that is used inside the KendoReact Form component.
|
|
150
|
+
*/
|
|
151
|
+
export declare interface FieldProps {
|
|
152
|
+
/**
|
|
153
|
+
* The name of the field in the Form state.
|
|
154
|
+
* Supports nested fields in the `user.age` and `users[index].name` formats.
|
|
155
|
+
*/
|
|
156
|
+
name: string;
|
|
157
|
+
/**
|
|
158
|
+
* Can be set to a React component or to the name of an HTML element,
|
|
159
|
+
* for example, `input`, `select`, and `textarea`.
|
|
160
|
+
* The props that are passed to component are the
|
|
161
|
+
* [`FieldRenderProps`]({% slug api_form_fieldrenderprops %}).
|
|
162
|
+
*/
|
|
163
|
+
component: string | React.ComponentType<any>;
|
|
164
|
+
/**
|
|
165
|
+
* The validation functions for the Field level.
|
|
166
|
+
* Currently, `validator` supports only synchronous functions.
|
|
167
|
+
* Using the array overload with inline array will cause an infinite loop - in this case use a `useMemo` hook to memoize the array.
|
|
168
|
+
*/
|
|
169
|
+
validator?: FieldValidatorType | FieldValidatorType[];
|
|
170
|
+
/**
|
|
171
|
+
* The React elements that are passed as children to the rendered component.
|
|
172
|
+
*/
|
|
173
|
+
children?: any;
|
|
174
|
+
/**
|
|
175
|
+
* Called when underlying editor triggers it's `onChange` event and the Form update it's internal state.
|
|
176
|
+
* Useful for updating related fields.
|
|
177
|
+
* > The `Form` listens to this editor event and automatically keeps it's internal state up to date.
|
|
178
|
+
* That why this event should be used only for executing custom logic.
|
|
179
|
+
*/
|
|
180
|
+
onChange?: (event: any) => void;
|
|
181
|
+
/**
|
|
182
|
+
* @hidden
|
|
183
|
+
*/
|
|
184
|
+
[customProp: string]: any;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Represents the props that are passed to the component which is rendered by Field.
|
|
189
|
+
*/
|
|
190
|
+
export declare interface FieldRenderProps extends FieldRenderPropsBase {
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The validator function for the Field component. The function arguments are:
|
|
195
|
+
*
|
|
196
|
+
* * value - The current value of the field.
|
|
197
|
+
* * valueGetter - Function which can be used to get other fields value.
|
|
198
|
+
* Usable when validator depends on more than one field. Supports field paths.
|
|
199
|
+
* * fieldProps - Props of the Field component. Currently contains only the `name` prop.
|
|
200
|
+
* Usable when one validator is used across multiple fields.
|
|
201
|
+
*
|
|
202
|
+
* Returns `string` to signify error or `undefined` to signify validation success.
|
|
203
|
+
*/
|
|
204
|
+
export declare type FieldValidatorType = (value: any, valueGetter: (name: string) => any, fieldProps: {
|
|
205
|
+
name: string;
|
|
206
|
+
}) => string | undefined;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Represents the KendoReact FieldWrapper component.
|
|
210
|
+
* It's designed to wrap the field editor, Label, Hint and Error components.
|
|
211
|
+
* The FieldWrapper supports only single editor inside it.
|
|
212
|
+
*/
|
|
213
|
+
export declare const FieldWrapper: React_2.FunctionComponent<FieldWrapperProps>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Represents the props of the KendoReact FieldWrapper component.
|
|
217
|
+
*/
|
|
218
|
+
export declare interface FieldWrapperProps {
|
|
219
|
+
/**
|
|
220
|
+
* @hidden
|
|
221
|
+
*/
|
|
222
|
+
children: any;
|
|
223
|
+
/**
|
|
224
|
+
* The styles that are applied to the FieldWrapper.
|
|
225
|
+
*/
|
|
226
|
+
style?: React_2.CSSProperties;
|
|
227
|
+
/**
|
|
228
|
+
* Sets a class of the FieldWrapper DOM element.
|
|
229
|
+
*/
|
|
230
|
+
className?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Specifies the direction of the content.
|
|
233
|
+
*/
|
|
234
|
+
dir?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** @hidden */
|
|
238
|
+
export declare const Form: ForwardRefExoticComponent<FormProps & RefAttributes<any>>;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Represents the [KendoReact Form component]({% slug overview_form %}).
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```jsx
|
|
245
|
+
* export const FormInput = (fieldRenderProps) => {
|
|
246
|
+
* const onValueChange = React.useCallback(
|
|
247
|
+
* (event) => fieldRenderProps.onChange(event.target.value),
|
|
248
|
+
* [fieldRenderProps.onChange]
|
|
249
|
+
* );
|
|
250
|
+
* return (
|
|
251
|
+
* <input
|
|
252
|
+
* className={'k-input'}
|
|
253
|
+
* value={fieldRenderProps.value}
|
|
254
|
+
* onChange={onValueChange}
|
|
255
|
+
* />
|
|
256
|
+
* );
|
|
257
|
+
* };
|
|
258
|
+
*
|
|
259
|
+
* export const App = () => {
|
|
260
|
+
* const handleSubmit = (dataItem) => alert(JSON.stringify(dataItem));
|
|
261
|
+
* return (
|
|
262
|
+
* <Form
|
|
263
|
+
* initialValues={{title: ''}}
|
|
264
|
+
* onSubmit={handleSubmit}
|
|
265
|
+
* render={(formRenderProps) => (
|
|
266
|
+
* <div>
|
|
267
|
+
* <Field name={'title'} component={FormInput} />
|
|
268
|
+
* <button
|
|
269
|
+
* className="k-button"
|
|
270
|
+
* disabled={!formRenderProps.allowSubmit}
|
|
271
|
+
* onClick={formRenderProps.onSubmit}
|
|
272
|
+
* >
|
|
273
|
+
* Submit
|
|
274
|
+
* </button>
|
|
275
|
+
* </div>
|
|
276
|
+
* )}
|
|
277
|
+
* />
|
|
278
|
+
* );
|
|
279
|
+
* };
|
|
280
|
+
*
|
|
281
|
+
* ReactDOM.render(<App />, document.querySelector('my-app'));
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
export declare class FormClassComponent extends React_2.Component<FormProps, {}> {
|
|
285
|
+
/**
|
|
286
|
+
* @hidden
|
|
287
|
+
*/
|
|
288
|
+
static displayName: string;
|
|
289
|
+
/**
|
|
290
|
+
* @hidden
|
|
291
|
+
*/
|
|
292
|
+
static propTypes: {
|
|
293
|
+
initialValues: PropTypes.Requireable<any>;
|
|
294
|
+
onSubmit: PropTypes.Requireable<(...args: any[]) => any>;
|
|
295
|
+
onSubmitClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
296
|
+
render: PropTypes.Validator<(...args: any[]) => any>;
|
|
297
|
+
id: PropTypes.Requireable<string>;
|
|
298
|
+
};
|
|
299
|
+
private _key?;
|
|
300
|
+
private _touched;
|
|
301
|
+
private _visited;
|
|
302
|
+
private _modified;
|
|
303
|
+
private _validatorsByField;
|
|
304
|
+
private _values;
|
|
305
|
+
private _fields;
|
|
306
|
+
private _unmounted;
|
|
307
|
+
private _submitted;
|
|
308
|
+
/**
|
|
309
|
+
* @hidden
|
|
310
|
+
*/
|
|
311
|
+
private _accumulatorTimeout;
|
|
312
|
+
/**
|
|
313
|
+
* @hidden
|
|
314
|
+
*/
|
|
315
|
+
get touched(): KeyValue<boolean>;
|
|
316
|
+
/**
|
|
317
|
+
* @hidden
|
|
318
|
+
*/
|
|
319
|
+
set touched(value: KeyValue<boolean>);
|
|
320
|
+
/**
|
|
321
|
+
* @hidden
|
|
322
|
+
*/
|
|
323
|
+
get visited(): KeyValue<boolean>;
|
|
324
|
+
/**
|
|
325
|
+
* @hidden
|
|
326
|
+
*/
|
|
327
|
+
set visited(value: KeyValue<boolean>);
|
|
328
|
+
/**
|
|
329
|
+
* @hidden
|
|
330
|
+
*/
|
|
331
|
+
get modified(): KeyValue<boolean>;
|
|
332
|
+
/**
|
|
333
|
+
* @hidden
|
|
334
|
+
*/
|
|
335
|
+
set modified(value: KeyValue<boolean>);
|
|
336
|
+
/**
|
|
337
|
+
* @hidden
|
|
338
|
+
*/
|
|
339
|
+
get validatorsByField(): KeyValue<(FieldValidatorType | FieldValidatorType[] | undefined)[]>;
|
|
340
|
+
/**
|
|
341
|
+
* @hidden
|
|
342
|
+
*/
|
|
343
|
+
set validatorsByField(value: KeyValue<(FieldValidatorType | FieldValidatorType[] | undefined)[]>);
|
|
344
|
+
/**
|
|
345
|
+
* @hidden
|
|
346
|
+
*/
|
|
347
|
+
get values(): KeyValue<any>;
|
|
348
|
+
/**
|
|
349
|
+
* @hidden
|
|
350
|
+
*/
|
|
351
|
+
set values(value: KeyValue<any>);
|
|
352
|
+
/**
|
|
353
|
+
* @hidden
|
|
354
|
+
*/
|
|
355
|
+
get fields(): string[];
|
|
356
|
+
/**
|
|
357
|
+
* @hidden
|
|
358
|
+
*/
|
|
359
|
+
get formErrors(): KeyValue<string> | undefined;
|
|
360
|
+
/**
|
|
361
|
+
* @hidden
|
|
362
|
+
*/
|
|
363
|
+
get errors(): KeyValue<string>;
|
|
364
|
+
/**
|
|
365
|
+
* @hidden
|
|
366
|
+
*/
|
|
367
|
+
constructor(props: FormProps);
|
|
368
|
+
/**
|
|
369
|
+
* @hidden
|
|
370
|
+
*/
|
|
371
|
+
componentWillUnmount(): void;
|
|
372
|
+
/**
|
|
373
|
+
* @hidden
|
|
374
|
+
*/
|
|
375
|
+
isValid: () => boolean;
|
|
376
|
+
/**
|
|
377
|
+
* @hidden
|
|
378
|
+
*/
|
|
379
|
+
accumulatedForceUpdate: () => void;
|
|
380
|
+
/**
|
|
381
|
+
* @hidden
|
|
382
|
+
*/
|
|
383
|
+
resetForm: () => void;
|
|
384
|
+
/**
|
|
385
|
+
* Method for resetting the form state outside the form component.
|
|
386
|
+
*
|
|
387
|
+
* > Use `onReset` only if you cannot achieve the desired behavior through the Field component or by FormRenderProps.
|
|
388
|
+
*/
|
|
389
|
+
onReset: () => void;
|
|
390
|
+
/**
|
|
391
|
+
* @hidden
|
|
392
|
+
*/
|
|
393
|
+
addField: (field: string) => void;
|
|
394
|
+
/**
|
|
395
|
+
* @hidden
|
|
396
|
+
*/
|
|
397
|
+
onSubmit: (event: React_2.SyntheticEvent<any>) => void;
|
|
398
|
+
/**
|
|
399
|
+
* Method for emiting changes to a specific field outside the form component.
|
|
400
|
+
*
|
|
401
|
+
* > Use `onChange` only if you cannot achieve the desired behavior through the Field component by FormRenderProps.
|
|
402
|
+
*/
|
|
403
|
+
onChange: (name: string, options: {
|
|
404
|
+
value: any;
|
|
405
|
+
}) => void;
|
|
406
|
+
/**
|
|
407
|
+
* @hidden
|
|
408
|
+
*/
|
|
409
|
+
onFocus: (name: string, skipForceUpdate?: boolean) => void;
|
|
410
|
+
/**
|
|
411
|
+
* @hidden
|
|
412
|
+
*/
|
|
413
|
+
onBlur: (name: string, skipForceUpdate?: boolean) => void;
|
|
414
|
+
/**
|
|
415
|
+
* @hidden
|
|
416
|
+
*/
|
|
417
|
+
onFieldRegister: (name: string, validator: FieldValidatorType | FieldValidatorType[] | undefined) => () => void;
|
|
418
|
+
/**
|
|
419
|
+
* @hidden
|
|
420
|
+
*/
|
|
421
|
+
isFormValid: (errors: KeyValue<any>) => boolean;
|
|
422
|
+
/**
|
|
423
|
+
* @hidden
|
|
424
|
+
*/
|
|
425
|
+
isFormModified: (modified: KeyValue<boolean>, fields: string[]) => boolean;
|
|
426
|
+
/**
|
|
427
|
+
* @hidden
|
|
428
|
+
*/
|
|
429
|
+
isFormHasNotTouched: (touched: KeyValue<boolean>, fields: string[]) => boolean;
|
|
430
|
+
/**
|
|
431
|
+
* @hidden
|
|
432
|
+
*/
|
|
433
|
+
isFormTouched: (touched: KeyValue<boolean>, fields: string[]) => boolean;
|
|
434
|
+
/**
|
|
435
|
+
* @hidden
|
|
436
|
+
*/
|
|
437
|
+
isFormVisited: (visited: KeyValue<boolean>, fields: string[]) => boolean;
|
|
438
|
+
/**
|
|
439
|
+
* @hidden
|
|
440
|
+
*/
|
|
441
|
+
valueGetter: (fieldName: string) => any;
|
|
442
|
+
/**
|
|
443
|
+
* @hidden
|
|
444
|
+
*/
|
|
445
|
+
valueSetter: (fieldName: string, value: any) => any;
|
|
446
|
+
/**
|
|
447
|
+
* @hidden
|
|
448
|
+
*/
|
|
449
|
+
onArrayAction: (name: string) => void;
|
|
450
|
+
/**
|
|
451
|
+
* @hidden
|
|
452
|
+
*/
|
|
453
|
+
onInsert: (name: string, options: {
|
|
454
|
+
value: any;
|
|
455
|
+
index: number;
|
|
456
|
+
}) => void;
|
|
457
|
+
/**
|
|
458
|
+
* @hidden
|
|
459
|
+
*/
|
|
460
|
+
onUnshift: (name: string, options: {
|
|
461
|
+
value: any;
|
|
462
|
+
}) => void;
|
|
463
|
+
/**
|
|
464
|
+
* @hidden
|
|
465
|
+
*/
|
|
466
|
+
onPush: (name: string, options: {
|
|
467
|
+
value: any;
|
|
468
|
+
}) => void;
|
|
469
|
+
/**
|
|
470
|
+
* @hidden
|
|
471
|
+
*/
|
|
472
|
+
onPop: (name: string) => any;
|
|
473
|
+
/**
|
|
474
|
+
* @hidden
|
|
475
|
+
*/
|
|
476
|
+
onRemove: (name: string, options: {
|
|
477
|
+
index: number;
|
|
478
|
+
}) => any;
|
|
479
|
+
/**
|
|
480
|
+
* @hidden
|
|
481
|
+
*/
|
|
482
|
+
onReplace: (name: string, options: {
|
|
483
|
+
value: any;
|
|
484
|
+
index: number;
|
|
485
|
+
}) => void;
|
|
486
|
+
/**
|
|
487
|
+
* @hidden
|
|
488
|
+
*/
|
|
489
|
+
onMove: (name: string, options: {
|
|
490
|
+
prevIndex: number;
|
|
491
|
+
nextIndex: number;
|
|
492
|
+
}) => void;
|
|
493
|
+
/**
|
|
494
|
+
* @hidden
|
|
495
|
+
*/
|
|
496
|
+
render(): JSX_2.Element;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Represents the KendoReact FormElement component.
|
|
501
|
+
* It's small wrapper around HTML form element which automatically attach the
|
|
502
|
+
* Form component's `onSubmit` render prop and Kendo CSS classes.
|
|
503
|
+
* Other props are passed to the DOM node.
|
|
504
|
+
*/
|
|
505
|
+
export declare const FormElement: React_2.FunctionComponent<FormElementProps>;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Represent the `ref` of the FormElement component.
|
|
509
|
+
*/
|
|
510
|
+
export declare interface FormElementHandle {
|
|
511
|
+
props: FormElementProps;
|
|
512
|
+
element: HTMLFormElement | null;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Represents the props of the KendoReact FormElement component.
|
|
517
|
+
*/
|
|
518
|
+
export declare interface FormElementProps {
|
|
519
|
+
/**
|
|
520
|
+
* @hidden
|
|
521
|
+
*/
|
|
522
|
+
children: any;
|
|
523
|
+
/**
|
|
524
|
+
* The styles that are applied to the form DOM element.
|
|
525
|
+
*/
|
|
526
|
+
style?: React_2.CSSProperties;
|
|
527
|
+
/**
|
|
528
|
+
* Sets a class of the form DOM element.
|
|
529
|
+
*/
|
|
530
|
+
className?: string;
|
|
531
|
+
/**
|
|
532
|
+
* If set to `true` enable the horizontal layout of the form editors.
|
|
533
|
+
*/
|
|
534
|
+
horizontal?: boolean;
|
|
535
|
+
/**
|
|
536
|
+
* @hidden
|
|
537
|
+
*/
|
|
538
|
+
[customProp: string]: any;
|
|
539
|
+
/**
|
|
540
|
+
* Configures the `size` of the Form.
|
|
541
|
+
*
|
|
542
|
+
* The available options are:
|
|
543
|
+
* - small
|
|
544
|
+
* - medium
|
|
545
|
+
* - large
|
|
546
|
+
* - null—Does not set a size `className`.
|
|
547
|
+
*
|
|
548
|
+
* @default `medium`
|
|
549
|
+
*/
|
|
550
|
+
size?: null | 'small' | 'medium' | 'large';
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Represent the `ref` of the Form component.
|
|
555
|
+
*/
|
|
556
|
+
export declare interface FormHandle extends Pick<FormClassComponent, keyof FormClassComponent> {
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Represents the props of the KendoReact Form component.
|
|
561
|
+
*/
|
|
562
|
+
export declare interface FormProps {
|
|
563
|
+
/**
|
|
564
|
+
* The initial field values of the Form.
|
|
565
|
+
*
|
|
566
|
+
* > When you initialize the Form felds, set initial values to them. Otherwise, some
|
|
567
|
+
* components might throw errors related to switching from uncontrolled to controlled mode.
|
|
568
|
+
*/
|
|
569
|
+
initialValues?: {
|
|
570
|
+
[name: string]: any;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* The validation function for the Form level.
|
|
574
|
+
* Should return key-value pair where the key is the field path and the value is the error message.
|
|
575
|
+
* Nested fields are supported, e.g.: 'users[0].name'.
|
|
576
|
+
* You can use the same field path to access the value from the
|
|
577
|
+
* values object using the `getter` function from the `kendo-react-common` package.
|
|
578
|
+
* Currently, `validator` supports only synchronous functions.
|
|
579
|
+
*/
|
|
580
|
+
validator?: FormValidatorType;
|
|
581
|
+
/**
|
|
582
|
+
* The submission handler for the Form.
|
|
583
|
+
* Called when at least one field has been modified, the user pressed the **Submit** button, and the form validation was successful.
|
|
584
|
+
*/
|
|
585
|
+
onSubmit?: (values: {
|
|
586
|
+
[name: string]: any;
|
|
587
|
+
}, event?: React.SyntheticEvent<any>) => void;
|
|
588
|
+
/**
|
|
589
|
+
* Called every time the user presses the **Submit** button.
|
|
590
|
+
* Useful in advanced scenarios when you need to handle every submit event, even when the form is invalid or not modified state.
|
|
591
|
+
*/
|
|
592
|
+
onSubmitClick?: (event: FormSubmitClickEvent) => void;
|
|
593
|
+
/**
|
|
594
|
+
* The Form content that will be rendered.
|
|
595
|
+
*/
|
|
596
|
+
render: (props: FormRenderProps) => any;
|
|
597
|
+
/**
|
|
598
|
+
* Set this to `true` to allow the form submit without modifed fields.
|
|
599
|
+
*/
|
|
600
|
+
ignoreModified?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* @hidden
|
|
603
|
+
* This prop comes from the `withId` HOC and is used internally by the Form.
|
|
604
|
+
* It replaces the previously used guid() function and generates an `id` of the Form.
|
|
605
|
+
*/
|
|
606
|
+
id?: string;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Represents the props that are passed to the `render` option component of the Form.
|
|
611
|
+
*/
|
|
612
|
+
export declare interface FormRenderProps {
|
|
613
|
+
/**
|
|
614
|
+
* A callback for submitting the Form.
|
|
615
|
+
* Can be passed to the `onClick` property of the **Submit** button.
|
|
616
|
+
*/
|
|
617
|
+
onSubmit: (event: React.SyntheticEvent<any>) => void;
|
|
618
|
+
/**
|
|
619
|
+
* A callback for emiting changes to a specific field without using the Field component
|
|
620
|
+
* ([see example]({% slug common_scenarios_form %}#toc-changing-the-field-value)).
|
|
621
|
+
*
|
|
622
|
+
* > Use `onChange` only if you cannot achieve the desired behavior through the Field component.
|
|
623
|
+
*/
|
|
624
|
+
onChange: (name: string, options: {
|
|
625
|
+
value: any;
|
|
626
|
+
}) => void;
|
|
627
|
+
/**
|
|
628
|
+
* A callback for resetting the Form.
|
|
629
|
+
*/
|
|
630
|
+
onFormReset: () => void;
|
|
631
|
+
/**
|
|
632
|
+
* The key-value pair containing the current errors by field path, combined from both field and form level validators.
|
|
633
|
+
*/
|
|
634
|
+
errors: KeyValue<string>;
|
|
635
|
+
/**
|
|
636
|
+
* Indicates if the Form is valid.
|
|
637
|
+
* If any field is invalid, `valid` is set to `false`.
|
|
638
|
+
*/
|
|
639
|
+
valid: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Indicates if the Form is touched.
|
|
642
|
+
* If any field is touched, `touched` is set to `true`.
|
|
643
|
+
* The touched state of field is set to `true` when the `onBlur`
|
|
644
|
+
* callback of the Field component is called or when the user tries to submit the form.
|
|
645
|
+
*/
|
|
646
|
+
touched: boolean;
|
|
647
|
+
/**
|
|
648
|
+
* Indicates if the Form is visited.
|
|
649
|
+
* If any field is visited, `visited` is set to `true`.
|
|
650
|
+
* The visited state of field is set to `true` when the `onFocus`
|
|
651
|
+
* callback of the Field component is called or when the user tries to submit the form.
|
|
652
|
+
*/
|
|
653
|
+
visited: boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Indicates if the Form is modified.
|
|
656
|
+
* If any field is modified, `modified` is set to `true`.
|
|
657
|
+
* The modified state of field is set to `true` when the `onChange`
|
|
658
|
+
* callback of the Field component is called for first time.
|
|
659
|
+
*/
|
|
660
|
+
modified: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* Indicates if the Form is successfuly submitted.
|
|
663
|
+
* Useful for detecting if user is leaving the form before saving changes.
|
|
664
|
+
*/
|
|
665
|
+
submitted: boolean;
|
|
666
|
+
/**
|
|
667
|
+
* Indicates if the Form is ready to be submitted.
|
|
668
|
+
* * If `allowSubmit` is set to `true` and the Form is valid, the user will be able to submit the form.
|
|
669
|
+
* * If `allowSubmit` is set to `true` and the Form is not valid, the user will be able to set the `touched` and `visited` state of all fields to `true`.
|
|
670
|
+
* `touched` and `visited` state to true.
|
|
671
|
+
*
|
|
672
|
+
* Useful for toggling the disabled state of the **Submit** button.
|
|
673
|
+
*/
|
|
674
|
+
allowSubmit: boolean;
|
|
675
|
+
/**
|
|
676
|
+
* A callback for getting the value of a field without using the Field component
|
|
677
|
+
* ([see example]({% slug common_scenarios_form %}#toc-reading-the-field-state)).
|
|
678
|
+
* Useful for creating and modifying the UI based on the field values.
|
|
679
|
+
*/
|
|
680
|
+
valueGetter: (name: string) => any;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* The FormSubmitClick event.
|
|
685
|
+
*/
|
|
686
|
+
export declare interface FormSubmitClickEvent {
|
|
687
|
+
/**
|
|
688
|
+
* Contains the current values of the form.
|
|
689
|
+
*/
|
|
690
|
+
values: {
|
|
691
|
+
[name: string]: any;
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* The native event.
|
|
695
|
+
*/
|
|
696
|
+
event?: React.SyntheticEvent<any>;
|
|
697
|
+
/**
|
|
698
|
+
* Represents the validity state of the form.
|
|
699
|
+
*/
|
|
700
|
+
isValid: boolean;
|
|
701
|
+
/**
|
|
702
|
+
* Represents the modified state of the form.
|
|
703
|
+
*/
|
|
704
|
+
isModified: boolean;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* The validator function for the Form component.
|
|
709
|
+
*
|
|
710
|
+
* * values - The current values of the form.
|
|
711
|
+
* * valueGetter - Function which can be used to get field value. Supports field paths.
|
|
712
|
+
*
|
|
713
|
+
* Returns key-value pair with errors if such are present. The key is the field path, where the value is the error message.
|
|
714
|
+
*/
|
|
715
|
+
export declare type FormValidatorType = (values: any, valueGetter: (name: string) => any) => KeyValue<string> | undefined;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
*
|
|
719
|
+
*/
|
|
720
|
+
export declare interface KeyValue<ValueType> {
|
|
721
|
+
[name: string]: ValueType;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export { }
|