@delightui/components 0.1.162-alpha.4 → 0.1.162
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/dist/cjs/components/atoms/Checkbox/Checkbox.d.ts +1 -1
- package/dist/cjs/components/atoms/Checkbox/Checkbox.presenter.d.ts +1 -1
- package/dist/cjs/components/atoms/CheckboxItem/CheckboxItem.d.ts +1 -1
- package/dist/cjs/components/atoms/CheckboxItem/CheckboxItem.presenter.d.ts +2 -2
- package/dist/cjs/components/atoms/CustomToggle/CustomToggle.d.ts +1 -1
- package/dist/cjs/components/atoms/Input/Input.d.ts +1 -1
- package/dist/cjs/components/atoms/Input/Input.presenter.d.ts +2 -2
- package/dist/cjs/components/atoms/Password/Password.presenter.d.ts +2 -2
- package/dist/cjs/components/atoms/RadioButton/RadioButton.d.ts +1 -1
- package/dist/cjs/components/atoms/RadioButtonItem/RadioButtonItem.d.ts +1 -1
- package/dist/cjs/components/atoms/RadioButtonItem/RadioButtonItem.presenter.d.ts +2 -2
- package/dist/cjs/components/atoms/TextArea/TextArea.d.ts +1 -1
- package/dist/cjs/components/atoms/TextArea/TextArea.presenter.d.ts +1 -1
- package/dist/cjs/components/atoms/Toggle/Toggle.d.ts +1 -1
- package/dist/cjs/components/atoms/Toggle/Toggle.presenter.d.ts +2 -2
- package/dist/cjs/components/atoms/ToggleButton/ToggleButton.d.ts +1 -1
- package/dist/cjs/components/molecules/FormField/FormField.d.ts +2 -28
- package/dist/cjs/components/molecules/FormField/FormField.presenter.d.ts +8 -17
- package/dist/cjs/components/molecules/FormField/FormField.types.d.ts +52 -115
- package/dist/cjs/components/molecules/FormField/FormField.utils.d.ts +11 -8
- package/dist/cjs/components/molecules/FormField/index.d.ts +2 -1
- package/dist/cjs/components/molecules/Search/Search.d.ts +1 -1
- package/dist/cjs/components/molecules/Search/Search.presenter.d.ts +2 -2
- package/dist/cjs/components/molecules/Select/Select.presenter.d.ts +4 -4
- package/dist/cjs/components/organisms/Form/DropzoneFormExample.d.ts +6 -0
- package/dist/cjs/components/organisms/Form/Form.d.ts +1 -22
- package/dist/cjs/components/organisms/Form/Form.types.d.ts +93 -64
- package/dist/cjs/components/organisms/Form/Form.utils.d.ts +2 -0
- package/dist/cjs/components/organisms/Form/FormContext.d.ts +5 -0
- package/dist/cjs/components/organisms/Form/UpdatedFormExample.d.ts +23 -0
- package/dist/cjs/components/organisms/Form/{examples/UseFormExample.d.ts → UseFormExample.d.ts} +3 -0
- package/dist/cjs/components/organisms/Form/index.d.ts +4 -7
- package/dist/cjs/components/organisms/Form/useForm.d.ts +50 -0
- package/dist/cjs/library.js +3 -3
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/atoms/Checkbox/Checkbox.d.ts +1 -1
- package/dist/esm/components/atoms/Checkbox/Checkbox.presenter.d.ts +1 -1
- package/dist/esm/components/atoms/CheckboxItem/CheckboxItem.d.ts +1 -1
- package/dist/esm/components/atoms/CheckboxItem/CheckboxItem.presenter.d.ts +2 -2
- package/dist/esm/components/atoms/CustomToggle/CustomToggle.d.ts +1 -1
- package/dist/esm/components/atoms/Input/Input.d.ts +1 -1
- package/dist/esm/components/atoms/Input/Input.presenter.d.ts +2 -2
- package/dist/esm/components/atoms/Password/Password.presenter.d.ts +2 -2
- package/dist/esm/components/atoms/RadioButton/RadioButton.d.ts +1 -1
- package/dist/esm/components/atoms/RadioButtonItem/RadioButtonItem.d.ts +1 -1
- package/dist/esm/components/atoms/RadioButtonItem/RadioButtonItem.presenter.d.ts +2 -2
- package/dist/esm/components/atoms/TextArea/TextArea.d.ts +1 -1
- package/dist/esm/components/atoms/TextArea/TextArea.presenter.d.ts +1 -1
- package/dist/esm/components/atoms/Toggle/Toggle.d.ts +1 -1
- package/dist/esm/components/atoms/Toggle/Toggle.presenter.d.ts +2 -2
- package/dist/esm/components/atoms/ToggleButton/ToggleButton.d.ts +1 -1
- package/dist/esm/components/molecules/FormField/FormField.d.ts +2 -28
- package/dist/esm/components/molecules/FormField/FormField.presenter.d.ts +8 -17
- package/dist/esm/components/molecules/FormField/FormField.types.d.ts +52 -115
- package/dist/esm/components/molecules/FormField/FormField.utils.d.ts +11 -8
- package/dist/esm/components/molecules/FormField/index.d.ts +2 -1
- package/dist/esm/components/molecules/Search/Search.d.ts +1 -1
- package/dist/esm/components/molecules/Search/Search.presenter.d.ts +2 -2
- package/dist/esm/components/molecules/Select/Select.presenter.d.ts +4 -4
- package/dist/esm/components/organisms/Form/DropzoneFormExample.d.ts +6 -0
- package/dist/esm/components/organisms/Form/Form.d.ts +1 -22
- package/dist/esm/components/organisms/Form/Form.types.d.ts +93 -64
- package/dist/esm/components/organisms/Form/Form.utils.d.ts +2 -0
- package/dist/esm/components/organisms/Form/FormContext.d.ts +5 -0
- package/dist/esm/components/organisms/Form/UpdatedFormExample.d.ts +23 -0
- package/dist/esm/components/organisms/Form/{examples/UseFormExample.d.ts → UseFormExample.d.ts} +3 -0
- package/dist/esm/components/organisms/Form/index.d.ts +4 -7
- package/dist/esm/components/organisms/Form/useForm.d.ts +50 -0
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +232 -270
- package/docs/components/molecules/FormField.md +34 -129
- package/docs/components/organisms/Form.md +162 -858
- package/package.json +1 -4
- package/dist/cjs/components/molecules/FormField/useSafeController.d.ts +0 -14
- package/dist/cjs/components/molecules/FormField/useSafeFormContext.d.ts +0 -8
- package/dist/cjs/components/organisms/Form/Form.presenter.d.ts +0 -290
- package/dist/cjs/components/organisms/Form/examples/DropzoneFormExample.d.ts +0 -6
- package/dist/cjs/components/organisms/Form/examples/UpdatedFormExample.d.ts +0 -2
- package/dist/cjs/components/organisms/Form/useAutosave.d.ts +0 -10
- package/dist/esm/components/molecules/FormField/useSafeController.d.ts +0 -14
- package/dist/esm/components/molecules/FormField/useSafeFormContext.d.ts +0 -8
- package/dist/esm/components/organisms/Form/Form.presenter.d.ts +0 -290
- package/dist/esm/components/organisms/Form/examples/DropzoneFormExample.d.ts +0 -6
- package/dist/esm/components/organisms/Form/examples/UpdatedFormExample.d.ts +0 -2
- package/dist/esm/components/organisms/Form/useAutosave.d.ts +0 -10
- package/docs/FORM_MIGRATION_GUIDE.md +0 -631
- /package/dist/cjs/components/organisms/Form/{examples/AutosaveFormExample.d.ts → AutosaveFormExample.d.ts} +0 -0
- /package/dist/esm/components/organisms/Form/{examples/AutosaveFormExample.d.ts → AutosaveFormExample.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import React__default, { ImgHTMLAttributes, SyntheticEvent, HTMLAttributes, ReactNode, MouseEvent, InputHTMLAttributes, TextareaHTMLAttributes, ComponentType, LiHTMLAttributes, CSSProperties,
|
|
4
|
-
import { FieldValues, Path, PathValue, UseFormProps } from 'react-hook-form';
|
|
3
|
+
import React__default, { ImgHTMLAttributes, SyntheticEvent, HTMLAttributes, ReactNode, MouseEvent, FormHTMLAttributes, Ref, InputHTMLAttributes, TextareaHTMLAttributes, ComponentType, LiHTMLAttributes, CSSProperties, TableHTMLAttributes, TdHTMLAttributes, ReactElement, AriaRole, KeyboardEventHandler } from 'react';
|
|
5
4
|
import { LinkProps } from 'react-router-dom';
|
|
6
5
|
import { Plugin } from 'flatpickr/dist/types/options';
|
|
7
6
|
import FlatPickr, { DateTimePickerProps } from 'react-flatpickr';
|
|
@@ -189,20 +188,201 @@ interface IconButtonProps extends Omit<ButtonProps, 'leadingIcon' | 'trailingIco
|
|
|
189
188
|
declare const IconButton: (props: IconButtonProps) => react_jsx_runtime.JSX.Element;
|
|
190
189
|
|
|
191
190
|
/**
|
|
192
|
-
* Type representing allowed
|
|
191
|
+
* Type representing the allowed values for form fields
|
|
193
192
|
*/
|
|
194
|
-
type FieldValue = string | number | Date | boolean | File |
|
|
193
|
+
type FieldValue = string | number | Date | boolean | File | Array<string | number | Date | File>;
|
|
195
194
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
195
|
+
* Type representing the form values as a partial record of field names to field values
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const formState: FormState = {
|
|
199
|
+
* name: 'John Doe',
|
|
200
|
+
* age: 30,
|
|
201
|
+
* dob: new Date('1990-01-01')
|
|
202
|
+
* };
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
type FormState<T extends FieldValue = FieldValue> = Partial<Record<string, T>>;
|
|
206
|
+
/**
|
|
207
|
+
* Type representing the form errors as a partial record of field names to error messages
|
|
208
|
+
*/
|
|
209
|
+
type FormErrors<T extends FormState = FormState> = Partial<Record<keyof T, string>>;
|
|
210
|
+
/**
|
|
211
|
+
* Type representing a validation function for a form field
|
|
212
|
+
* It takes an error setter function and the field value (optional) and returns a boolean indicating if the value is valid
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* const nameValidator: FieldValidationFunction = (setError, value) => {
|
|
216
|
+
* if (!value) {
|
|
217
|
+
* setError('Name is required');
|
|
218
|
+
* return false;
|
|
219
|
+
* }
|
|
220
|
+
* return true;
|
|
221
|
+
* };
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
type FieldValidationFunction<T extends FieldValue = FieldValue> = (setError: (message: string) => void, value?: T) => boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Type representing the required fields in a form
|
|
227
|
+
* It's a partial record of field names to a boolean indicating if the field is required
|
|
228
|
+
*/
|
|
229
|
+
type RequiredFields<T extends FormState = FormState> = Partial<Record<keyof T, boolean>>;
|
|
230
|
+
/**
|
|
231
|
+
* Type representing the validation functions for each field in a form
|
|
232
|
+
* It's a partial record of field names to validation functions (or undefined)
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const nameValidator: FieldValidationFunction = (setError, value) => {
|
|
236
|
+
* if (!value) {
|
|
237
|
+
* setError('Name is required');
|
|
238
|
+
* return false;
|
|
239
|
+
* }
|
|
240
|
+
* return true;
|
|
241
|
+
* };
|
|
242
|
+
* const fieldValidators: FieldValidators = {
|
|
243
|
+
* name: nameValidator,
|
|
244
|
+
* age: undefined,
|
|
245
|
+
* };
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
type FieldValidators<T extends FormState = FormState> = Partial<Record<keyof T, FieldValidationFunction | undefined>>;
|
|
249
|
+
/**
|
|
250
|
+
* Type representing a function that handles form state changes
|
|
251
|
+
* It takes the new form state and an error setter function and doesn't return anything
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const handleFormStateChange: FormStateChangeHandler = (state, setError) => {
|
|
255
|
+
* // Validate form state and set errors
|
|
256
|
+
* if (!state.name) {
|
|
257
|
+
* setError('name', 'Name is required');
|
|
258
|
+
* }
|
|
259
|
+
* };
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
type FormStateChangeHandler<T extends FormState = FormState> = (state: T, setError: (field: keyof T, errorMessage: string) => void) => void;
|
|
263
|
+
/**
|
|
264
|
+
* Type representing a function that validates the entire form
|
|
265
|
+
* It takes the form values and an error setter function and returns a boolean indicating if the form is valid
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const validateForm: FormValidator = (state, setError) => {
|
|
269
|
+
* let isValid = true;
|
|
270
|
+
* if (!state.name) {
|
|
271
|
+
* setError('name', 'Name is required');
|
|
272
|
+
* isValid = false;
|
|
273
|
+
* }
|
|
274
|
+
* if (!state.age || typeof state.age !== 'number') {
|
|
275
|
+
* setError('age', 'Age must be a number');
|
|
276
|
+
* isValid = false;
|
|
277
|
+
* }
|
|
278
|
+
* return isValid;
|
|
279
|
+
* };
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
type FormValidator<T extends FormState = FormState> = (state: T, setError: (field: keyof T, errorMessage: string) => void) => boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Type representing a function that handles form submission.
|
|
285
|
+
* It takes updated form state and a function to set error messages for specific fields.
|
|
286
|
+
*
|
|
287
|
+
* @template T - The type of the form state, defaulting to `FormState`.
|
|
288
|
+
*
|
|
289
|
+
* @param {T} values - The updated form state values.
|
|
290
|
+
* @param {(field: keyof T, errorMessage: string) => void} setError - A function to set error messages for specific fields.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const handleFormSubmit: FormSubmitHandler = (values, setError) => {
|
|
295
|
+
* // Submit form data
|
|
296
|
+
* console.log(values);
|
|
297
|
+
* };
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
type FormSubmitHandler<T extends FormState = FormState> = (values: T, setError: (field: keyof T, errorMessage: string) => void) => void;
|
|
301
|
+
type FormProps = Omit<FormHTMLAttributes<HTMLFormElement>, 'onSubmit'> & {
|
|
302
|
+
formRef?: Ref<HTMLFormElement>;
|
|
303
|
+
};
|
|
304
|
+
type FormContextValues<T extends FormState = FormState> = {
|
|
305
|
+
formRef?: Ref<HTMLFormElement>;
|
|
306
|
+
formState?: T;
|
|
307
|
+
updateFieldValue: (name: string, value: FieldValue) => void;
|
|
308
|
+
formErrors: FormErrors<T>;
|
|
309
|
+
updateFieldError: (name: keyof T, errorMessage: string) => void;
|
|
310
|
+
onFormSubmit: React__default.FormEventHandler<HTMLFormElement>;
|
|
311
|
+
updateFieldValidators: (name: keyof T, validate?: FieldValidationFunction) => void;
|
|
312
|
+
updateRequiredFields: (name: keyof T, required?: boolean) => void;
|
|
313
|
+
resetForm: () => void;
|
|
314
|
+
};
|
|
315
|
+
type FormProviderProps<T extends FormState = FormState> = {
|
|
316
|
+
formRef?: Ref<HTMLFormElement>;
|
|
317
|
+
children?: React__default.ReactNode;
|
|
318
|
+
formState?: T;
|
|
319
|
+
onFormStateChange?: FormStateChangeHandler<T>;
|
|
320
|
+
formValidator?: FormValidator<T>;
|
|
321
|
+
onSubmit?: FormSubmitHandler<T>;
|
|
322
|
+
validateOnChange?: boolean;
|
|
323
|
+
autosave?: boolean;
|
|
324
|
+
autosaveDelayMs?: number;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Props for the FormField component.
|
|
329
|
+
*/
|
|
330
|
+
type FormFieldProps = HTMLAttributes<HTMLDivElement> & {
|
|
331
|
+
/**
|
|
332
|
+
* Name of the form field
|
|
333
|
+
*/
|
|
334
|
+
name: string;
|
|
335
|
+
/**
|
|
336
|
+
* Label for the form field
|
|
337
|
+
*/
|
|
338
|
+
label?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Children for the form field
|
|
341
|
+
*/
|
|
342
|
+
children: React.ReactNode;
|
|
343
|
+
/**
|
|
344
|
+
* Message for the form field
|
|
345
|
+
*/
|
|
346
|
+
message?: string;
|
|
347
|
+
/**
|
|
348
|
+
* There is a message/error for the form field
|
|
349
|
+
*/
|
|
350
|
+
hasMessage?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Info icon for the form field
|
|
353
|
+
*/
|
|
354
|
+
infoIcon?: React.ReactNode;
|
|
355
|
+
/**
|
|
356
|
+
* Indicates if the form field is required
|
|
357
|
+
*/
|
|
358
|
+
required?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Validation function for the form field
|
|
361
|
+
*/
|
|
362
|
+
validate?: FieldValidationFunction;
|
|
363
|
+
/**
|
|
364
|
+
* Indicates if the form field is disabled
|
|
365
|
+
*/
|
|
366
|
+
disabled?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Indicates if the form field is invalid
|
|
369
|
+
*/
|
|
370
|
+
invalid?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Id for the form field
|
|
373
|
+
*/
|
|
374
|
+
id?: string;
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Props that must be implemented by all form field components that are controlled inputs
|
|
198
378
|
*/
|
|
199
379
|
type ControlledFormComponentProps<T extends FieldValue> = {
|
|
200
380
|
/**
|
|
201
|
-
*
|
|
381
|
+
* the initial value for the field
|
|
202
382
|
*/
|
|
203
383
|
initialValue?: T;
|
|
204
384
|
/**
|
|
205
|
-
*
|
|
385
|
+
* the initial value for the field
|
|
206
386
|
*/
|
|
207
387
|
checked?: boolean;
|
|
208
388
|
/**
|
|
@@ -234,113 +414,6 @@ type ControlledFormComponentProps<T extends FieldValue> = {
|
|
|
234
414
|
*/
|
|
235
415
|
id?: string;
|
|
236
416
|
};
|
|
237
|
-
/**
|
|
238
|
-
* Field-level validation function
|
|
239
|
-
* Returns error message string if invalid, undefined if valid
|
|
240
|
-
*/
|
|
241
|
-
type FieldValidationFunction<TValue = FieldValue> = (value: TValue) => string | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Field-level async validation function
|
|
244
|
-
* Returns error message string if invalid, undefined if valid
|
|
245
|
-
*/
|
|
246
|
-
type AsyncFieldValidationFunction<TValue = FieldValue> = (value: TValue) => Promise<string | undefined>;
|
|
247
|
-
/**
|
|
248
|
-
* @deprecated This type is deprecated and maintained for backwards compatibility only.
|
|
249
|
-
* Use the new FieldValidationFunction signature that returns error messages instead.
|
|
250
|
-
*
|
|
251
|
-
* Type representing a validation function for a form field
|
|
252
|
-
* It takes an error setter function and the field value (optional) and returns a boolean indicating if the value is valid
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* const nameValidator: LegacyFieldValidationFunction = (setError, value) => {
|
|
256
|
-
* if (!value) {
|
|
257
|
-
* setError('Name is required');
|
|
258
|
-
* return false;
|
|
259
|
-
* }
|
|
260
|
-
* return true;
|
|
261
|
-
* };
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
type LegacyFieldValidationFunction<T extends FieldValue = FieldValue> = (setError: (message: string) => void, value?: T) => boolean;
|
|
265
|
-
/**
|
|
266
|
-
* @deprecated This type is deprecated and maintained for backwards compatibility only.
|
|
267
|
-
* Use the new AsyncFieldValidationFunction signature that returns error messages instead.
|
|
268
|
-
*
|
|
269
|
-
* Type representing an async validation function for a form field
|
|
270
|
-
* It takes an error setter function and the field value (optional) and returns a Promise<boolean> indicating if the value is valid
|
|
271
|
-
*/
|
|
272
|
-
type LegacyAsyncFieldValidationFunction<T extends FieldValue = FieldValue> = (setError: (message: string) => void, value?: T) => Promise<boolean>;
|
|
273
|
-
/**
|
|
274
|
-
* FormField component props for use within a Form
|
|
275
|
-
*/
|
|
276
|
-
type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends Path<TFieldValues> = Path<TFieldValues>> = Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'children'> & {
|
|
277
|
-
/** Field name (must match form value key) - type-safe */
|
|
278
|
-
name: TName;
|
|
279
|
-
/** Field label */
|
|
280
|
-
label?: string;
|
|
281
|
-
/** Display name for validation messages (defaults to label or name) */
|
|
282
|
-
displayName?: string;
|
|
283
|
-
/**
|
|
284
|
-
* Child component - will be cloned with injected props:
|
|
285
|
-
* value, onValueChange, onBlur, ref, disabled, invalid, required, id, name
|
|
286
|
-
*/
|
|
287
|
-
children: ReactNode;
|
|
288
|
-
/** Field is required */
|
|
289
|
-
required?: boolean;
|
|
290
|
-
/** Sync validation function (supports both new and legacy signatures) */
|
|
291
|
-
validate?: FieldValidationFunction<PathValue<TFieldValues, TName>> | LegacyFieldValidationFunction<PathValue<TFieldValues, TName>>;
|
|
292
|
-
/** Async validation function (supports both new and legacy signatures) */
|
|
293
|
-
asyncValidate?: AsyncFieldValidationFunction<PathValue<TFieldValues, TName>> | LegacyAsyncFieldValidationFunction<PathValue<TFieldValues, TName>>;
|
|
294
|
-
/** Default value for this field */
|
|
295
|
-
defaultValue?: PathValue<TFieldValues, TName>;
|
|
296
|
-
/** Info message to display */
|
|
297
|
-
message?: string;
|
|
298
|
-
/** Disabled state */
|
|
299
|
-
disabled?: boolean;
|
|
300
|
-
/** External invalid state */
|
|
301
|
-
invalid?: boolean;
|
|
302
|
-
/** Info icon element */
|
|
303
|
-
infoIcon?: ReactNode;
|
|
304
|
-
/** Field ID - for the input element */
|
|
305
|
-
id?: string;
|
|
306
|
-
/** @deprecated Legacy prop for backwards compatibility - use message prop instead */
|
|
307
|
-
hasMessage?: boolean;
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* Standalone FormField props (works without Form context)
|
|
311
|
-
*/
|
|
312
|
-
type StandaloneFieldProps<TValue extends FieldValue = FieldValue> = Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'children' | 'onChange'> & {
|
|
313
|
-
/** Field name */
|
|
314
|
-
name: string;
|
|
315
|
-
/** Field label */
|
|
316
|
-
label?: string;
|
|
317
|
-
/** Display name for validation messages */
|
|
318
|
-
displayName?: string;
|
|
319
|
-
/** Child component to render */
|
|
320
|
-
children: ReactNode;
|
|
321
|
-
/** Field is required */
|
|
322
|
-
required?: boolean;
|
|
323
|
-
/** Sync validation function (supports both new and legacy signatures) */
|
|
324
|
-
validate?: FieldValidationFunction<TValue> | LegacyFieldValidationFunction<TValue>;
|
|
325
|
-
/** Async validation function (supports both new and legacy signatures) */
|
|
326
|
-
asyncValidate?: AsyncFieldValidationFunction<TValue> | LegacyAsyncFieldValidationFunction<TValue>;
|
|
327
|
-
/** Controlled value */
|
|
328
|
-
value?: TValue;
|
|
329
|
-
/** Controlled onChange */
|
|
330
|
-
onChange?: (value: TValue) => void;
|
|
331
|
-
/** External error */
|
|
332
|
-
error?: string;
|
|
333
|
-
/** Info message */
|
|
334
|
-
message?: string;
|
|
335
|
-
/** Disabled state */
|
|
336
|
-
disabled?: boolean;
|
|
337
|
-
/** Info icon element */
|
|
338
|
-
infoIcon?: ReactNode;
|
|
339
|
-
/** Field ID - for the input element */
|
|
340
|
-
id?: string;
|
|
341
|
-
/** @deprecated Legacy prop for backwards compatibility - use message prop instead */
|
|
342
|
-
hasMessage?: boolean;
|
|
343
|
-
};
|
|
344
417
|
|
|
345
418
|
/**
|
|
346
419
|
* Enum for different input types.
|
|
@@ -1346,32 +1419,7 @@ type DatePickerProps = Omit<DatePickerBaseSharedProps, 'noCalendar' | 'inline'>
|
|
|
1346
1419
|
|
|
1347
1420
|
declare const DatePicker: (props: DatePickerProps) => react_jsx_runtime.JSX.Element;
|
|
1348
1421
|
|
|
1349
|
-
|
|
1350
|
-
* Smart FormField component that works both inside and outside Form context
|
|
1351
|
-
*
|
|
1352
|
-
* Usage inside Form:
|
|
1353
|
-
* ```tsx
|
|
1354
|
-
* <Form defaultValues={{ email: '' }}>
|
|
1355
|
-
* <FormField name="email" label="Email" required>
|
|
1356
|
-
* <Input placeholder="Enter email" />
|
|
1357
|
-
* </FormField>
|
|
1358
|
-
* </Form>
|
|
1359
|
-
* ```
|
|
1360
|
-
*
|
|
1361
|
-
* Usage standalone:
|
|
1362
|
-
* ```tsx
|
|
1363
|
-
* <FormField
|
|
1364
|
-
* name="email"
|
|
1365
|
-
* label="Email"
|
|
1366
|
-
* value={email}
|
|
1367
|
-
* onChange={setEmail}
|
|
1368
|
-
* required
|
|
1369
|
-
* >
|
|
1370
|
-
* <Input placeholder="Enter email" />
|
|
1371
|
-
* </FormField>
|
|
1372
|
-
* ```
|
|
1373
|
-
*/
|
|
1374
|
-
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends Path<TFieldValues> = Path<TFieldValues>>(props: FormFieldProps<TFieldValues, TName> | StandaloneFieldProps) => react_jsx_runtime.JSX.Element;
|
|
1422
|
+
declare const FormField: (props: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
1375
1423
|
|
|
1376
1424
|
type GridProps = HTMLAttributes<HTMLDivElement> & {
|
|
1377
1425
|
columns?: number;
|
|
@@ -1816,113 +1864,6 @@ type RadioGroupProps = ControlledFormComponentProps<string | number> & {
|
|
|
1816
1864
|
|
|
1817
1865
|
declare const RadioGroup: (props: RadioGroupProps) => react_jsx_runtime.JSX.Element;
|
|
1818
1866
|
|
|
1819
|
-
/**
|
|
1820
|
-
* Form submission handler
|
|
1821
|
-
*/
|
|
1822
|
-
type FormSubmitHandler<TFormValues extends FieldValues = FieldValues> = (values: TFormValues) => void | Promise<void>;
|
|
1823
|
-
/**
|
|
1824
|
-
* @deprecated This type is deprecated and maintained for backwards compatibility only.
|
|
1825
|
-
* Use the new FormSubmitHandler signature without setError instead.
|
|
1826
|
-
*
|
|
1827
|
-
* Type representing a function that handles form submission.
|
|
1828
|
-
* It takes updated form state and a function to set error messages for specific fields.
|
|
1829
|
-
*
|
|
1830
|
-
* @template T - The type of the form state, defaulting to FieldValues.
|
|
1831
|
-
*
|
|
1832
|
-
* @param {T} values - The updated form state values.
|
|
1833
|
-
* @param {(field: keyof T, errorMessage: string) => void} setError - A function to set error messages for specific fields.
|
|
1834
|
-
*
|
|
1835
|
-
* @example
|
|
1836
|
-
* ```typescript
|
|
1837
|
-
* const handleFormSubmit: LegacyFormSubmitHandler = (values, setError) => {
|
|
1838
|
-
* // Submit form data
|
|
1839
|
-
* console.log(values);
|
|
1840
|
-
* };
|
|
1841
|
-
* ```
|
|
1842
|
-
*/
|
|
1843
|
-
type LegacyFormSubmitHandler<T extends FieldValues = FieldValues> = (values: T, setError: (field: keyof T, errorMessage: string) => void) => void | Promise<void>;
|
|
1844
|
-
/**
|
|
1845
|
-
* @deprecated This type is deprecated and maintained for backwards compatibility only.
|
|
1846
|
-
* Use React Hook Form's built-in validation or field-level validation instead.
|
|
1847
|
-
*
|
|
1848
|
-
* Type representing a function that handles form state changes
|
|
1849
|
-
* It takes the new form state and an error setter function and doesn't return anything
|
|
1850
|
-
* @example
|
|
1851
|
-
* ```typescript
|
|
1852
|
-
* const handleFormStateChange: FormStateChangeHandler = (state, setError) => {
|
|
1853
|
-
* // Validate form state and set errors
|
|
1854
|
-
* if (!state.name) {
|
|
1855
|
-
* setError('name', 'Name is required');
|
|
1856
|
-
* }
|
|
1857
|
-
* };
|
|
1858
|
-
* ```
|
|
1859
|
-
*/
|
|
1860
|
-
type FormStateChangeHandler<T extends FieldValues = FieldValues> = (state: T, setError: (field: keyof T, errorMessage: string) => void) => void;
|
|
1861
|
-
/**
|
|
1862
|
-
* @deprecated This type is deprecated and maintained for backwards compatibility only.
|
|
1863
|
-
* Use React Hook Form's resolver or field-level validation instead.
|
|
1864
|
-
*
|
|
1865
|
-
* Type representing a function that validates the entire form
|
|
1866
|
-
* It takes the form values and an error setter function and returns a boolean indicating if the form is valid
|
|
1867
|
-
* @example
|
|
1868
|
-
* ```typescript
|
|
1869
|
-
* const validateForm: FormValidator = (state, setError) => {
|
|
1870
|
-
* let isValid = true;
|
|
1871
|
-
* if (!state.name) {
|
|
1872
|
-
* setError('name', 'Name is required');
|
|
1873
|
-
* isValid = false;
|
|
1874
|
-
* }
|
|
1875
|
-
* if (!state.age || typeof state.age !== 'number') {
|
|
1876
|
-
* setError('age', 'Age must be a number');
|
|
1877
|
-
* isValid = false;
|
|
1878
|
-
* }
|
|
1879
|
-
* return isValid;
|
|
1880
|
-
* };
|
|
1881
|
-
* ```
|
|
1882
|
-
*/
|
|
1883
|
-
type FormValidator<T extends FieldValues = FieldValues> = (state: T, setError: (field: keyof T, errorMessage: string) => void) => boolean;
|
|
1884
|
-
/**
|
|
1885
|
-
* Form component props
|
|
1886
|
-
*/
|
|
1887
|
-
type FormProps<TFormValues extends FieldValues = FieldValues> = Omit<FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'ref'> & {
|
|
1888
|
-
/** Initial form values (uncontrolled mode) */
|
|
1889
|
-
defaultValues?: UseFormProps<TFormValues>['defaultValues'];
|
|
1890
|
-
/** Form submission handler - receives typed form values (supports both new and legacy signatures) */
|
|
1891
|
-
onSubmit?: FormSubmitHandler<TFormValues> | LegacyFormSubmitHandler<TFormValues>;
|
|
1892
|
-
/** Enable autosave functionality */
|
|
1893
|
-
autosave?: boolean;
|
|
1894
|
-
/** Autosave debounce delay in milliseconds */
|
|
1895
|
-
autosaveDelayMs?: number;
|
|
1896
|
-
/** RHF validation mode */
|
|
1897
|
-
mode?: UseFormProps<TFormValues>['mode'];
|
|
1898
|
-
/** Additional RHF options */
|
|
1899
|
-
formOptions?: Omit<UseFormProps<TFormValues>, 'defaultValues' | 'mode'>;
|
|
1900
|
-
/** Ref to the form element */
|
|
1901
|
-
formRef?: React.Ref<HTMLFormElement>;
|
|
1902
|
-
/**
|
|
1903
|
-
* @deprecated Use defaultValues instead. This prop is maintained for backwards compatibility only.
|
|
1904
|
-
* Alias for defaultValues - initial form values
|
|
1905
|
-
*/
|
|
1906
|
-
formState?: UseFormProps<TFormValues>['defaultValues'];
|
|
1907
|
-
/**
|
|
1908
|
-
* @deprecated Use React Hook Form's useWatch hook or field-level validation instead.
|
|
1909
|
-
* This prop is maintained for backwards compatibility only.
|
|
1910
|
-
* Callback fired whenever form values change
|
|
1911
|
-
*/
|
|
1912
|
-
onFormStateChange?: FormStateChangeHandler<TFormValues>;
|
|
1913
|
-
/**
|
|
1914
|
-
* @deprecated Use React Hook Form's resolver or field-level validation instead.
|
|
1915
|
-
* This prop is maintained for backwards compatibility only.
|
|
1916
|
-
* Custom validator function for the entire form
|
|
1917
|
-
*/
|
|
1918
|
-
formValidator?: FormValidator<TFormValues>;
|
|
1919
|
-
};
|
|
1920
|
-
/**
|
|
1921
|
-
* @deprecated Use FormProps instead
|
|
1922
|
-
* Legacy alias for backwards compatibility
|
|
1923
|
-
*/
|
|
1924
|
-
type FormProviderProps<TFormValues extends FieldValues = FieldValues> = Omit<FormProps<TFormValues>, 'className' | 'style' | 'formRef'>;
|
|
1925
|
-
|
|
1926
1867
|
/**
|
|
1927
1868
|
* Props for the Option component, extending LiHTMLAttributes<HTMLLIElement>.
|
|
1928
1869
|
* Represents an option within a Select component.
|
|
@@ -2505,35 +2446,56 @@ type DropzoneContentProps = {
|
|
|
2505
2446
|
declare const DropzoneContent: (props: DropzoneContentProps) => react_jsx_runtime.JSX.Element;
|
|
2506
2447
|
|
|
2507
2448
|
/**
|
|
2508
|
-
*
|
|
2449
|
+
* Custom hook to access form context values.
|
|
2450
|
+
* Provides direct access to all form state management functions and values.
|
|
2509
2451
|
*
|
|
2510
|
-
*
|
|
2511
|
-
*
|
|
2512
|
-
* <Form defaultValues={{ name: '' }} onSubmit={handleSubmit}>
|
|
2513
|
-
* <FormField name="name" label="Name">
|
|
2514
|
-
* <Input />
|
|
2515
|
-
* </FormField>
|
|
2516
|
-
* <Button actionType="submit">Submit</Button>
|
|
2517
|
-
* </Form>
|
|
2518
|
-
* ```
|
|
2452
|
+
* @throws {Error} If used outside of a Form component
|
|
2453
|
+
* @returns {FormContextValues} Object containing form state and control functions
|
|
2519
2454
|
*
|
|
2520
|
-
*
|
|
2455
|
+
* @example
|
|
2521
2456
|
* ```tsx
|
|
2522
|
-
*
|
|
2523
|
-
*
|
|
2524
|
-
*
|
|
2457
|
+
* const MyCustomField = () => {
|
|
2458
|
+
* const {
|
|
2459
|
+
* formState,
|
|
2460
|
+
* formErrors,
|
|
2461
|
+
* updateFieldValue,
|
|
2462
|
+
* resetForm
|
|
2463
|
+
* } = useForm();
|
|
2464
|
+
*
|
|
2465
|
+
* return (
|
|
2466
|
+
* <div>
|
|
2467
|
+
* <input
|
|
2468
|
+
* value={formState.myField || ''}
|
|
2469
|
+
* onChange={(e) => updateFieldValue('myField', e.target.value)}
|
|
2470
|
+
* />
|
|
2471
|
+
* {formErrors.myField && <span>{formErrors.myField}</span>}
|
|
2472
|
+
* </div>
|
|
2473
|
+
* );
|
|
2474
|
+
* };
|
|
2525
2475
|
* ```
|
|
2526
2476
|
*/
|
|
2527
|
-
declare const
|
|
2528
|
-
|
|
2477
|
+
declare const useForm: <T extends FormState = Partial<Record<string, FieldValue>>>() => FormContextValues<T>;
|
|
2529
2478
|
/**
|
|
2530
|
-
*
|
|
2531
|
-
*
|
|
2479
|
+
* Type-safe version of useForm that returns properly typed form context
|
|
2480
|
+
*
|
|
2481
|
+
* @example
|
|
2482
|
+
* ```tsx
|
|
2483
|
+
* interface MyFormData {
|
|
2484
|
+
* name: string;
|
|
2485
|
+
* email: string;
|
|
2486
|
+
* age: number;
|
|
2487
|
+
* }
|
|
2532
2488
|
*
|
|
2533
|
-
*
|
|
2534
|
-
*
|
|
2489
|
+
* const MyComponent = () => {
|
|
2490
|
+
* const form = useFormTyped<MyFormData>();
|
|
2491
|
+
* // form.formState is now typed as MyFormData
|
|
2492
|
+
* // form.formErrors is now typed as FormErrors<MyFormData>
|
|
2493
|
+
* };
|
|
2494
|
+
* ```
|
|
2535
2495
|
*/
|
|
2536
|
-
declare const
|
|
2496
|
+
declare const useFormTyped: <T extends FormState>() => FormContextValues<T>;
|
|
2497
|
+
|
|
2498
|
+
declare const Form: <T extends FormState>(props: FormProviderProps<T> & FormProps) => react_jsx_runtime.JSX.Element;
|
|
2537
2499
|
|
|
2538
2500
|
type TableProps = TableHTMLAttributes<HTMLTableElement> & {
|
|
2539
2501
|
/**
|
|
@@ -2894,4 +2856,4 @@ declare const NotificationContext: React__default.Context<NotificationContextVal
|
|
|
2894
2856
|
declare const NotificationProvider: React__default.FC<NotificationProviderProps>;
|
|
2895
2857
|
declare const useNotification: () => NotificationContextValue;
|
|
2896
2858
|
|
|
2897
|
-
export { type AccessibilityActions, type AccessibilityProps, Accordion, AccordionDetails, AccordionGroup, AccordionSummary, ActionCard, type ActionCardProps, ActionImage, type ActionImageProps,
|
|
2859
|
+
export { type AccessibilityActions, type AccessibilityProps, Accordion, AccordionDetails, AccordionGroup, AccordionSummary, ActionCard, type ActionCardProps, ActionImage, type ActionImageProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Breakpoint, type BreakpointProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Card, type CardProps, Checkbox, CheckboxItem, type CheckboxItemProps, type CheckboxLabelAlignmentEnum, type CheckboxProps, type CheckboxSizeEnum, type CheckboxTypeEnum, Chip, ChipInput, type ChipInputProps, type ChipProps, ConditionalView, type ConditionalViewProps, ContextMenu, type ContextMenuProps, type CustomTimePickerConfig, CustomToggle, type CustomToggleProps, DateInput, type DateInputProps, DatePicker, type DatePickerProps, SortableItem as DraggableItem, SortableTrigger as DraggableItemTrigger, Dropzone, DropzoneClear, DropzoneContent, type DropzoneContentProps, type DropzoneContentTypeEnum, DropzoneFilename, DropzoneFilename as DropzonePreview, type DropzoneProps, DropzoneSupportedFormats as DropzoneReject, DropzoneTrigger as DropzoneRoot, DropzoneSupportedFormats, DropzoneTrigger, type FieldValidationFunction, type FieldValidators, type FieldValue, Form, type FormContextValues, type FormErrors, FormField, type FormFieldProps, type FormProps, type FormProviderProps, type FormState, type FormStateChangeHandler, type FormSubmitHandler, type FormValidator, Grid, GridItem, type GridItemProps, GridList, type GridListProps, type GridProps, Icon, IconButton, type IconButtonProps, type IconButtonStyleEnum, type IconProps, type IconSizeEnum, type IconStyleEnum, Image, type ImageFitEnum, type ImageProps, Input, type InputProps, type InputTypeEnum, List, ListItem, type ListItemProps$1 as ListItemProps, type ListProps, Modal, type ModalComponentProps, ModalFooter, type ModalFooterProps, ModalHeader, type ModalHeaderProps, type ModalProps, ModalProvider, type ModalProviderProps, Nav, NavItem, type NavItemProps, NavLink, type NavLinkProps, type NavProps, type Notification, type NotificationContainerProps, NotificationContext, type NotificationOffset, type NotificationPosition, NotificationProvider, type NotificationTrigger, Option, type OptionLike, type OptionLikeKey, type OptionProps, type OverlayDirectionEnum, Pagination, PaginationNumberField, type PaginationNumberFieldProps, type PaginationProps, Password, Popover, type PopoverHandle, type PopoverProps, ProgressBar, type ProgressBarProps, RadioButton, RadioButtonItem, type RadioButtonItemProps, type RadioButtonLabelAlignmentEnum, type RadioButtonProps, type RadioButtonSizeEnum, RadioGroup, type RadioGroupProps, RenderStateView, type RenderStateViewProps, RepeaterList, type RepeaterListProps, type RequiredFields, ResponsiveComponent, type ResponsiveComponentProps, Search, type SearchCallback, type SearchStyleEnum as SearchModeEnum, type SearchProps, Select, SelectListItem, type SelectListItemProps, type SelectProps, SelectProvider, SlideOutPanel, type SlideOutPanelDirectionEnum, type SlideOutPanelProps, type SlideOutPanelSizeEnum, Slider, type SliderProps, Spinner, type SpinnerProps, TabContent, type TabContentProps, TabItem, type TabItemProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHeader, TableHeaderCell, type TableHeaderCellProps, type TableHeaderProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, Text, TextArea, type TextAreaProps, type TextDecorationEnum, type TextProps, type TextTypeEnum, type TextWeightEnum, ThemeContext, type ThemeContextType, ThemeProvider, type ThemeProviderProps, Toggle, ToggleButton, type ToggleButtonProps, type ToggleLabelAlignmentEnum, type ToggleProps, Tooltip, type TooltipProps, type TriggerNotificationPayload, type UploadedFileMetadata, type UseModalReturn, WrapTextNodes, type WrapTextNodesProps, applyPropsToChildren, getClickAccessibilityProps, mergeRefs, useDebounce, useDropzoneContext, useForm, useFormTyped, useInflateView, useModal, useNotification, useSelectContext, useTab };
|