@syncfusion/ej2-react-form-renderer 0.1.2-beta → 34.2.3

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.
Files changed (181) hide show
  1. package/README.md +88 -105
  2. package/diConfig.json +85 -0
  3. package/dist/ej2-react-form-renderer.min.js +10 -0
  4. package/dist/ej2-react-form-renderer.umd.min.js +11 -0
  5. package/dist/ej2-react-form-renderer.umd.min.js.map +1 -0
  6. package/dist/es6/ej2-react-form-renderer.es2015.js +37 -0
  7. package/dist/es6/ej2-react-form-renderer.es2015.js.map +1 -0
  8. package/form-renderer.d.ts +4 -0
  9. package/form-renderer.js +4 -0
  10. package/index.d.ts +2 -4
  11. package/index.js +2 -4
  12. package/license +6 -13
  13. package/package.json +19 -38
  14. package/src/form-renderer/formrenderer.component.d.ts +34 -0
  15. package/src/form-renderer/formrenderer.component.js +49 -0
  16. package/src/form-renderer/index.d.ts +1 -0
  17. package/src/form-renderer/index.js +1 -0
  18. package/src/global.js +1 -0
  19. package/src/index.d.ts +2 -6
  20. package/src/index.js +2 -6
  21. package/styles/bds-lite.css +1 -0
  22. package/styles/bds-lite.scss +1 -0
  23. package/styles/bds.css +1 -0
  24. package/styles/bds.scss +1 -0
  25. package/styles/bootstrap-dark-lite.css +1 -0
  26. package/styles/bootstrap-dark-lite.scss +1 -0
  27. package/styles/bootstrap-dark.css +1 -26
  28. package/styles/bootstrap-dark.scss +1 -0
  29. package/styles/bootstrap-lite.css +1 -0
  30. package/styles/bootstrap-lite.scss +1 -0
  31. package/styles/bootstrap.css +1 -26
  32. package/styles/bootstrap.scss +1 -0
  33. package/styles/bootstrap4-lite.css +1 -0
  34. package/styles/bootstrap4-lite.scss +1 -0
  35. package/styles/bootstrap4.css +1 -26
  36. package/styles/bootstrap4.scss +1 -0
  37. package/styles/bootstrap5-dark-lite.css +1 -0
  38. package/styles/bootstrap5-dark-lite.scss +1 -0
  39. package/styles/bootstrap5-dark.css +1 -26
  40. package/styles/bootstrap5-dark.scss +1 -0
  41. package/styles/bootstrap5-lite.css +1 -0
  42. package/styles/bootstrap5-lite.scss +1 -0
  43. package/styles/bootstrap5.3-lite.css +1 -0
  44. package/styles/bootstrap5.3-lite.scss +1 -0
  45. package/styles/bootstrap5.3.css +1 -26
  46. package/styles/bootstrap5.3.scss +1 -0
  47. package/styles/bootstrap5.css +1 -26
  48. package/styles/bootstrap5.scss +1 -0
  49. package/styles/fabric-dark-lite.css +1 -0
  50. package/styles/fabric-dark-lite.scss +1 -0
  51. package/styles/fabric-dark.css +1 -0
  52. package/styles/fabric-dark.scss +1 -0
  53. package/styles/fabric-lite.css +1 -0
  54. package/styles/fabric-lite.scss +1 -0
  55. package/styles/fabric.css +1 -0
  56. package/styles/fabric.scss +1 -0
  57. package/styles/fluent-dark-lite.css +1 -0
  58. package/styles/fluent-dark-lite.scss +1 -0
  59. package/styles/fluent-dark.css +1 -26
  60. package/styles/fluent-dark.scss +1 -0
  61. package/styles/fluent-lite.css +1 -0
  62. package/styles/fluent-lite.scss +1 -0
  63. package/styles/fluent.css +1 -26
  64. package/styles/fluent.scss +1 -0
  65. package/styles/fluent2-lite.css +1 -0
  66. package/styles/fluent2-lite.scss +1 -0
  67. package/styles/fluent2.css +1 -26
  68. package/styles/fluent2.scss +1 -0
  69. package/styles/form-renderer/bds.css +1 -0
  70. package/styles/form-renderer/bds.scss +1 -0
  71. package/styles/form-renderer/bootstrap-dark.css +1 -0
  72. package/styles/form-renderer/bootstrap-dark.scss +1 -0
  73. package/styles/form-renderer/bootstrap.css +1 -0
  74. package/styles/form-renderer/bootstrap.scss +1 -0
  75. package/styles/form-renderer/bootstrap4.css +1 -0
  76. package/styles/form-renderer/bootstrap4.scss +1 -0
  77. package/styles/form-renderer/bootstrap5-dark.css +1 -0
  78. package/styles/form-renderer/bootstrap5-dark.scss +1 -0
  79. package/styles/form-renderer/bootstrap5.3.css +1 -0
  80. package/styles/form-renderer/bootstrap5.3.scss +1 -0
  81. package/styles/form-renderer/bootstrap5.css +1 -0
  82. package/styles/form-renderer/bootstrap5.scss +1 -0
  83. package/styles/form-renderer/fabric-dark.css +1 -0
  84. package/styles/form-renderer/fabric-dark.scss +1 -0
  85. package/styles/form-renderer/fabric.css +1 -0
  86. package/styles/form-renderer/fabric.scss +1 -0
  87. package/styles/form-renderer/fluent-dark.css +1 -0
  88. package/styles/form-renderer/fluent-dark.scss +1 -0
  89. package/styles/form-renderer/fluent.css +1 -0
  90. package/styles/form-renderer/fluent.scss +1 -0
  91. package/styles/form-renderer/fluent2.css +1 -0
  92. package/styles/form-renderer/fluent2.scss +1 -0
  93. package/styles/form-renderer/highcontrast-light.css +1 -0
  94. package/styles/form-renderer/highcontrast-light.scss +1 -0
  95. package/styles/form-renderer/highcontrast.css +1 -0
  96. package/styles/form-renderer/highcontrast.scss +1 -0
  97. package/styles/form-renderer/material-dark.css +1 -0
  98. package/styles/form-renderer/material-dark.scss +1 -0
  99. package/styles/form-renderer/material.css +1 -0
  100. package/styles/form-renderer/material.scss +1 -0
  101. package/styles/form-renderer/material3-dark.css +1 -0
  102. package/styles/form-renderer/material3-dark.scss +1 -0
  103. package/styles/form-renderer/material3.css +1 -0
  104. package/styles/form-renderer/material3.scss +1 -0
  105. package/styles/form-renderer/tailwind-dark.css +1 -0
  106. package/styles/form-renderer/tailwind-dark.scss +1 -0
  107. package/styles/form-renderer/tailwind.css +1 -0
  108. package/styles/form-renderer/tailwind.scss +1 -0
  109. package/styles/form-renderer/tailwind3.css +1 -0
  110. package/styles/form-renderer/tailwind3.scss +1 -0
  111. package/styles/highcontrast-light-lite.css +1 -0
  112. package/styles/highcontrast-light-lite.scss +1 -0
  113. package/styles/highcontrast-light.css +1 -0
  114. package/styles/highcontrast-light.scss +1 -0
  115. package/styles/highcontrast-lite.css +1 -0
  116. package/styles/highcontrast-lite.scss +1 -0
  117. package/styles/highcontrast.css +1 -0
  118. package/styles/highcontrast.scss +1 -0
  119. package/styles/material-dark-lite.css +1 -0
  120. package/styles/material-dark-lite.scss +1 -0
  121. package/styles/material-dark.css +1 -26
  122. package/styles/material-dark.scss +1 -0
  123. package/styles/material-lite.css +1 -0
  124. package/styles/material-lite.scss +1 -0
  125. package/styles/material.css +1 -26
  126. package/styles/material.scss +1 -0
  127. package/styles/material3-dark-lite.css +1 -0
  128. package/styles/material3-dark-lite.scss +1 -0
  129. package/styles/material3-dark.css +1 -26
  130. package/styles/material3-dark.scss +1 -0
  131. package/styles/material3-lite.css +1 -0
  132. package/styles/material3-lite.scss +1 -0
  133. package/styles/material3.css +1 -26
  134. package/styles/material3.scss +1 -0
  135. package/styles/tailwind-dark-lite.css +1 -0
  136. package/styles/tailwind-dark-lite.scss +1 -0
  137. package/styles/tailwind-dark.css +1 -26
  138. package/styles/tailwind-dark.scss +1 -0
  139. package/styles/tailwind-lite.css +1 -0
  140. package/styles/tailwind-lite.scss +1 -0
  141. package/styles/tailwind.css +1 -26
  142. package/styles/tailwind.scss +1 -0
  143. package/styles/tailwind3-lite.css +1 -0
  144. package/styles/tailwind3-lite.scss +1 -0
  145. package/styles/tailwind3.css +1 -26
  146. package/styles/tailwind3.scss +1 -0
  147. package/src/CheckboxGroup.d.ts +0 -12
  148. package/src/CheckboxGroup.js +0 -49
  149. package/src/ConditionalRuleEngine.d.ts +0 -295
  150. package/src/ConditionalRuleEngine.js +0 -566
  151. package/src/CustomTabComponent.d.ts +0 -13
  152. package/src/CustomTabComponent.js +0 -35
  153. package/src/DataGridComponent.d.ts +0 -28
  154. package/src/DataGridComponent.js +0 -147
  155. package/src/FormRenderer.d.ts +0 -84
  156. package/src/FormRenderer.js +0 -707
  157. package/src/FormValidator.d.ts +0 -479
  158. package/src/FormValidator.js +0 -579
  159. package/src/MinMaxRuleEngine.d.ts +0 -95
  160. package/src/MinMaxRuleEngine.js +0 -361
  161. package/src/StaticHtmlRenderer.d.ts +0 -8
  162. package/src/StaticHtmlRenderer.js +0 -21
  163. package/src/expressions/DependencyTracker.d.ts +0 -30
  164. package/src/expressions/DependencyTracker.js +0 -128
  165. package/src/expressions/ExpressionEngine.d.ts +0 -81
  166. package/src/expressions/ExpressionEngine.js +0 -503
  167. package/src/expressions/ExpressionParser.d.ts +0 -39
  168. package/src/expressions/ExpressionParser.js +0 -270
  169. package/src/json-converter.d.ts +0 -171
  170. package/src/json-converter.js +0 -1209
  171. package/src/parser.d.ts +0 -99
  172. package/src/parser.js +0 -753
  173. package/src/renderFormField.d.ts +0 -21
  174. package/src/renderFormField.js +0 -226
  175. package/src/types/FormSchema.d.ts +0 -211
  176. package/src/types/FormSchema.js +0 -1
  177. package/src/utils.js +0 -408
  178. package/styles/bootstrap5.3-dark.css +0 -26
  179. package/styles/fluent2-dark.css +0 -26
  180. package/styles/form-renderer.base.css +0 -499
  181. package/styles/tailwind3-dark.css +0 -10
@@ -1,479 +0,0 @@
1
- import * as React from 'react';
2
- import { type FormHTMLAttributes } from 'react';
3
- export declare const VALIDATION_REGEX: {
4
- [key: string]: RegExp;
5
- };
6
- /**
7
- * Specifies the possible value types for form fields.
8
- */
9
- export type FormValueType = string | number | boolean | Date | File | FileList | string[] | number[] | React.ReactNode | null | undefined;
10
- /**
11
- * Defines the structure for a validation rule in the form system.
12
- *
13
- * A ValidationRule is a two-part array containing:
14
- * - A validation condition (as boolean, RegExp, number, function, etc.)
15
- * - An optional custom error message to show when validation fails
16
- *
17
- * The first element's type depends on the specific rule:
18
- * - For boolean rules (like 'required'): true/false
19
- * - For pattern rules (like 'email', 'regex'): RegExp object
20
- * - For range rules: number or number[] (min/max values)
21
- * - For equality checks: string (field name to compare with)
22
- * - For custom validation: () => boolean function
23
- *
24
- * ```tsx
25
- * const requiredRule: ValidationRule = [true, 'This field is required'];
26
- * ```
27
- */
28
- export type ValidationRule = [boolean | RegExp | number | number[] | string | Date | (() => boolean), string?];
29
- /**
30
- * Defines the comprehensive set of validation rules that can be applied to form fields.
31
- *
32
- * This interface outlines all available validation types that can be configured for
33
- * each field in the form. Each validation type accepts a ValidationRule containing
34
- * both the validation criteria and an optional custom error message.
35
- */
36
- export interface FieldValidationRules {
37
- /**
38
- * Validates that the field has a non-empty value. When configured with [true], the field cannot be empty, null, or undefined.
39
- *
40
- * ```tsx
41
- * required: [true, 'This field must be filled in']
42
- * ```
43
- */
44
- required?: ValidationRule;
45
- /**
46
- * Validates that the input conforms to a standard email address format. Checks for proper formatting with @ symbol and domain structure.
47
- *
48
- * ```tsx
49
- * email: [true, 'Please enter a valid email address']
50
- * ```
51
- */
52
- email?: ValidationRule;
53
- /**
54
- * Validates that the input is a properly formatted URL. Checks for proper protocol, domain structure, and path format.
55
- *
56
- * ```tsx
57
- * url: [true, 'Please enter a valid website URL']
58
- * ```
59
- */
60
- url?: ValidationRule;
61
- /**
62
- * Validates that the input can be parsed as a valid date. Uses Date.parse() to validate the string can be converted to a date.
63
- *
64
- * ```tsx
65
- * date: [true, 'Please enter a valid date']
66
- * ```
67
- */
68
- date?: ValidationRule;
69
- /**
70
- * Validates that the input follows ISO date format (YYYY-MM-DD). Ensures strict compliance with the ISO date standard.
71
- *
72
- * ```tsx
73
- * dateIso: [true, 'Date must be in YYYY-MM-DD format']
74
- * ```
75
- */
76
- dateIso?: ValidationRule;
77
- /**
78
- * Validates that the input contains a valid numeric value. Ensures the field can be converted to a number without errors.
79
- *
80
- * ```tsx
81
- * number: [true, 'Please enter a number']
82
- * ```
83
- */
84
- number?: ValidationRule;
85
- /**
86
- * Validates that the input contains only numeric digits (0-9). Rejects inputs containing decimal points, signs, letter characters or spaces.
87
- *
88
- * ```tsx
89
- * digits: [true, 'Please enter only numeric digits']
90
- * ```
91
- */
92
- digits?: ValidationRule;
93
- /**
94
- * Validates that the input is a valid credit card number. Checks length (13-16 digits) and applies Luhn algorithm validation.
95
- *
96
- * ```tsx
97
- * creditCard: [true, 'Invalid credit card number']
98
- * ```
99
- */
100
- creditCard?: ValidationRule;
101
- /**
102
- * Validates that a string has at least the specified minimum length. Takes a number as the first parameter in the validation rule.
103
- *
104
- * ```tsx
105
- * minLength: [6, 'Must be at least 6 characters long']
106
- * ```
107
- */
108
- minLength?: ValidationRule;
109
- /**
110
- * Validates that a string doesn't exceed the specified maximum length. Takes a number as the first parameter in the validation rule.
111
- *
112
- * ```tsx
113
- * maxLength: [100, 'Cannot exceed 100 characters']
114
- * ```
115
- */
116
- maxLength?: ValidationRule;
117
- /**
118
- * Validates that a string's length falls within the specified range. Takes an array of two numbers [min, max] as the first parameter.
119
- *
120
- * ```tsx
121
- * rangeLength: [[8, 16], 'Must be between 8 and 16 characters']
122
- * ```
123
- */
124
- rangeLength?: ValidationRule;
125
- /**
126
- * Validates that a numeric value is at least the specified minimum. Takes a number as the first parameter in the validation rule.
127
- *
128
- * ```tsx
129
- * min: [18, 'Value must be at least 18']
130
- * ```
131
- */
132
- min?: ValidationRule;
133
- /**
134
- * Validates that a numeric value doesn't exceed the specified maximum. Takes a number as the first parameter in the validation rule.
135
- *
136
- * ```tsx
137
- * max: [100, 'Value cannot exceed 100']
138
- * ```
139
- */
140
- max?: ValidationRule;
141
- /**
142
- * Validates that a numeric value falls within the specified range. Takes an array of two numbers [min, max] as the first parameter.
143
- *
144
- * ```tsx
145
- * range: [[1, 10], 'Value must be between 1 and 10']
146
- * ```
147
- */
148
- range?: ValidationRule;
149
- /**
150
- * Validates that the input matches the specified regular expression pattern. Takes a RegExp object or a string pattern as the first parameter.
151
- *
152
- * ```tsx
153
- * regex: [/^[A-Z][a-z]+$/, 'Must start with capital letter followed by lowercase letters']
154
- * ```
155
- */
156
- regex?: ValidationRule;
157
- /**
158
- * Validates that the input conforms to a standard telephone number format. Checks for proper formatting of phone numbers with optional country code.
159
- *
160
- * ```tsx
161
- * tel: [true, 'Please enter a valid phone number']
162
- * ```
163
- */
164
- tel?: ValidationRule;
165
- /**
166
- * Validates that the field's value exactly matches another field's value. Takes the name of another field as the first parameter.
167
- *
168
- * ```tsx
169
- * equalTo: ['password', 'Passwords must match']
170
- * ```
171
- */
172
- equalTo?: ValidationRule;
173
- /**
174
- * Allows for completely custom validation logic as a function.
175
- *
176
- * This function receives the field value and should return either:
177
- * - A string containing an error message if validation fails
178
- * - null if validation passes
179
- *
180
- * ```tsx
181
- * customValidator: (value) => {
182
- * if (typeof value === 'string' && !value.includes('@company.com')) {
183
- * return 'Email must be a company email';
184
- * }
185
- * return null;
186
- * }
187
- * ```
188
- */
189
- customValidator?: (value: FormValueType) => string | null;
190
- }
191
- /**
192
- * Defines the complete validation schema for a form by mapping field names to their validation rules.
193
- *
194
- * This interface creates a dictionary where each key is a field name and each value
195
- * is an object containing all validation rules that apply to that field. The ValidationRules
196
- * object is passed to the Form component to establish the validation criteria for the entire form.
197
- *
198
- * ```tsx
199
- * const validationSchema: ValidationRules = {
200
- * username: {
201
- * required: [true, 'Username is required'],
202
- * minLength: [3, 'Username must be at least 3 characters']
203
- * },
204
- *
205
- * email: {
206
- * required: [true, 'Email is required'],
207
- * email: [true, 'Please enter a valid email address']
208
- * }
209
- * };
210
- * ```
211
- */
212
- export interface ValidationRules {
213
- [fieldName: string]: FieldValidationRules;
214
- }
215
- /**
216
- * Specifies the state and callback properties provided by the Form component.
217
- *
218
- * The FormState interface provides comprehensive access to the form's state
219
- * and behavior through the onFormStateChange callback. It allows parent components
220
- * to build custom form UIs with full access to validation state, field values, and form event handlers.
221
- */
222
- export interface FormState {
223
- /**
224
- * Specifies the current values for all form fields indexed by field name.
225
- * Access individual values using: values.fieldName
226
- *
227
- * ```tsx
228
- * const username = formState.values.username;
229
- * ```
230
- */
231
- values: Record<string, FormValueType>;
232
- /**
233
- * Specifies the current validation errors for all fields indexed by field name.
234
- * Fields without errors won't appear in this object.
235
- *
236
- */
237
- errors: Record<string, string>;
238
- /**
239
- * Specifies which fields in the form are valid (have no validation errors).
240
- *
241
- */
242
- valid: Record<string, boolean>;
243
- /**
244
- * Specifies if the form can be submitted. True when all fields are valid;
245
- * otherwise, all fields are marked as touched when attempted to submit.
246
- */
247
- allowSubmit: boolean;
248
- /**
249
- * Specifies if the form has been submitted at least once.
250
- * True after a submission attempt regardless of validation result.
251
- */
252
- submitted: boolean;
253
- /**
254
- * Specifies which fields in the form have been modified from their initial values.
255
- *
256
- */
257
- modified: Record<string, boolean>;
258
- /**
259
- * Specifies which fields have been touched (blurred after interaction).
260
- * Useful for determining when to display validation messages.
261
- *
262
- */
263
- touched: Record<string, boolean>;
264
- /**
265
- * Specifies which fields have been visited (received focus).
266
- *
267
- */
268
- visited: Record<string, boolean>;
269
- /**
270
- * Specifies a dictionary of field names for easy access to form fields.
271
- *
272
- */
273
- fieldNames: Record<string, string>;
274
- /**
275
- * Specifies the callback function to handle field value changes.
276
- * Use this instead of directly modifying input elements.
277
- *
278
- * @param name - The name of the field to update
279
- * @param options - Object containing the new value for the field.
280
- * @event onChange
281
- */
282
- onChange(name: string, options: {
283
- value: FormValueType;
284
- }): void;
285
- /**
286
- * Specifies the callback function for when a field loses focus.
287
- *
288
- * @param fieldName - The name of the field that lost focus.
289
- * @event onBlur
290
- */
291
- onBlur(fieldName: string): void;
292
- /**
293
- * Specifies the callback function for when a field receives focus.
294
- * Records the field as visited.
295
- *
296
- * @param fieldName - The name of the field that received focus.
297
- * @event onFocus
298
- */
299
- onFocus(fieldName: string): void;
300
- /**
301
- * Specifies the callback function to reset the form to its initial state.
302
- * Clears all values, errors, and interaction states.
303
- *
304
- * @event onFormReset
305
- */
306
- onFormReset(): void;
307
- /**
308
- * Specifies the callback function to submit the form.
309
- * Can be used with a submit button's onClick event.
310
- *
311
- * @param event - The synthetic event from the form submission.
312
- * @event onSubmit
313
- */
314
- onSubmit(event: React.SyntheticEvent): void;
315
- }
316
- /**
317
- * Specifies initial values for form fields. Maps field names to their default values when the form loads.
318
- *
319
- * ```tsx
320
- * const initialValues: FormInitialValues = {
321
- * username: 'john_doe'
322
- * };
323
- * ```
324
- */
325
- export interface FormInitialValues {
326
- [fieldName: string]: FormValueType;
327
- }
328
- /**
329
- * Specifies the props interface for the Form component.
330
- */
331
- export interface FormProps {
332
- /**
333
- * Specifies the validation rules for each form field. This object defines constraints that form fields must satisfy.
334
- */
335
- rules: ValidationRules;
336
- /**
337
- * Specifies the callback fired when form is submitted and all validation rules pass.
338
- *
339
- * @param {Record<string, FormValueType>} data - Specifies the form data containing all field values
340
- * @event onSubmit
341
- */
342
- onSubmit?: (data: Record<string, FormValueType>) => void;
343
- /**
344
- * Specifies the callback fired when form state changes.
345
- * This can be used to access form state from parent components for custom UI rendering.
346
- *
347
- * @param {FormState} formState - The current state of the form
348
- * @event onFormStateChange
349
- */
350
- onFormStateChange?: (formState: FormState) => void;
351
- /**
352
- * Specifies the initial values for form fields. These values populate the form.
353
- *
354
- * @default -
355
- */
356
- initialValues?: FormInitialValues;
357
- /**
358
- * Specifies whether to trigger validation on every input change. When true, validation occurs on each keystroke, providing immediate feedback.
359
- *
360
- * @default false
361
- */
362
- validateOnChange?: boolean;
363
- }
364
- /**
365
- * Specifies the FormValidator interface for imperative methods.
366
- */
367
- export interface IFormValidator extends FormProps {
368
- /**
369
- * Validates the entire form against all defined rules.
370
- *
371
- * @returns {boolean} - Returns true if the form is valid, false otherwise.
372
- */
373
- validate(): boolean;
374
- /**
375
- * Resets the form to its initial state, clearing all values, errors, and interaction states.
376
- *
377
- * @returns {void}
378
- */
379
- reset(): void;
380
- /**
381
- * Validates a specific field against its defined rules.
382
- *
383
- * @param {string} fieldName - Specifies the name of the field to validate
384
- * @returns {boolean} - Returns true if the field is valid, false otherwise
385
- */
386
- validateField(fieldName: string): boolean;
387
- /**
388
- * Provides access to the underlying HTML form element.
389
- *
390
- * @private
391
- */
392
- element?: HTMLFormElement;
393
- }
394
- type FormComponentProps = FormProps & Omit<FormHTMLAttributes<HTMLFormElement>, 'onSubmit'>;
395
- /**
396
- * Provides a form component with built-in validation functionality. Manages form state tracking,
397
- * field validation, and submission handling.
398
- *
399
- * ```typescript
400
- * import { Form, FormField, FormState } from '@syncfusion/react-inputs';
401
- *
402
- * const [formState, setFormState] = useState<FormState>();
403
- *
404
- * <Form
405
- * rules={{ username: { required: [true, 'Username is required'] } }}
406
- * onSubmit={data => console.log(data)}
407
- * onFormStateChange={setFormState} >
408
- * <FormField name="username">
409
- * <input
410
- * name="username"
411
- * value={(formState?.values.username || '') as string}
412
- * onChange={(e) => formState?.onChange('username', { value: e.target.value })}
413
- * onBlur={() => formState?.onBlur('username')}
414
- * onFocus={() => formState?.onFocus('username')}
415
- * />
416
- * {formState?.errors?.username && (<div className="error">{formState.errors.username}</div>)}
417
- * </FormField>
418
- * <button type="submit">Submit</button>
419
- * </Form>
420
- * ```
421
- */
422
- export declare const Form: React.ForwardRefExoticComponent<FormComponentProps & React.RefAttributes<IFormValidator>>;
423
- /**
424
- * Specifies the properties for the FormField component.
425
- */
426
- export interface FormFieldProps {
427
- /**
428
- * Specifies the name of the field that must match a key in the rules object. This is required for proper validation.
429
- */
430
- name: string;
431
- /**
432
- * Specifies the children content for the form field. Children should include the actual form control elements like inputs, textarea, etc.
433
- */
434
- children: React.ReactNode;
435
- /**
436
- * Specifies field-level validation rules that apply only to this specific field. These rules override any form-level rules
437
- * with the same name defined in the Form component's rules. This allows for field-specific validation that takes
438
- * precedence over form-wide defaults.
439
- *
440
- * @default undefined
441
- */
442
- rules?: FieldValidationRules;
443
- }
444
- /**
445
- * Specifies a component that connects form inputs with validation rules. The FormField component provides
446
- * an easy way to integrate form controls with the Form validation system, handling state management and
447
- * validation automatically.
448
- *
449
- * ```typescript
450
- * const [formState, setFormState] = useState<FormState>();
451
- *
452
- * <Form
453
- * rules={{
454
- * username: { required: [true, 'Username is required'] }
455
- * }}
456
- * onSubmit={data => console.log(data)}
457
- * onFormStateChange={setFormState}
458
- * >
459
- * <FormField name="username">
460
- * <input
461
- * name="username"
462
- * value={formState?.values.username || ''}
463
- * onChange={(e) => formState?.onChange('username', { value: e.target.value })}
464
- * onBlur={() => formState?.onBlur('username')}
465
- * onFocus={() => formState?.onFocus('username')}
466
- * />
467
- * {formState?.touched?.username && formState?.errors?.username && (
468
- * <div className="error">{formState.errors.username}</div>
469
- * )}
470
- * </FormField>
471
- * <button type="submit">Submit</button>
472
- * </Form>
473
- * ```
474
- *
475
- * @param {IFormFieldProps} props - Specifies the form field configuration properties
476
- * @returns {React.ReactNode} - Returns the children with access to form validation context
477
- */
478
- export declare const FormField: React.FC<FormFieldProps>;
479
- export {};