@gnwebsoft/ui 3.0.1 → 3.0.4
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/README.md +688 -0
- package/dist/chunk-4H3AFH7A.js +505 -0
- package/dist/chunk-DE62KYFK.js +122 -0
- package/dist/chunk-DEPJRTVT.js +1 -0
- package/dist/chunk-EBRUE2WR.cjs +493 -0
- package/dist/chunk-FD57PCAC.cjs +1 -0
- package/dist/chunk-H3GQLELL.js +2025 -0
- package/dist/chunk-MVPLBJRK.cjs +1 -0
- package/dist/chunk-OJF67RNM.js +1 -0
- package/dist/chunk-OT7COE7R.cjs +2025 -0
- package/dist/chunk-R2YK4LTT.cjs +122 -0
- package/dist/chunk-U6SDYCWF.js +493 -0
- package/dist/chunk-ZC7FGYL2.cjs +505 -0
- package/dist/components/index.cjs +25 -0
- package/dist/components/index.d.cts +752 -0
- package/dist/components/index.d.ts +664 -15
- package/dist/components/index.js +25 -24
- package/dist/enhanced-z-I7EHVS.d.cts +134 -0
- package/dist/enhanced-z-I7EHVS.d.ts +134 -0
- package/dist/hooks/index.cjs +12 -0
- package/dist/hooks/index.d.cts +95 -0
- package/dist/hooks/index.d.ts +82 -4
- package/dist/hooks/index.js +12 -7
- package/dist/index.cjs +127 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +127 -54
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +241 -0
- package/dist/types/index.d.ts +205 -20
- package/dist/types/index.js +2 -1
- package/dist/utils/index.cjs +45 -0
- package/dist/utils/index.d.cts +366 -0
- package/dist/utils/index.d.ts +317 -9
- package/dist/utils/index.js +45 -22
- package/dist/wrappers/index.cjs +54 -0
- package/dist/wrappers/index.d.cts +1684 -0
- package/dist/wrappers/index.d.ts +1601 -118
- package/dist/wrappers/index.js +54 -8
- package/package.json +145 -88
- package/dist/AsyncSelectPayload-Cz4bgak0.d.mts +0 -10
- package/dist/AsyncSelectPayload-Cz4bgak0.d.ts +0 -10
- package/dist/chunk-2JFL7TS5.mjs +0 -0
- package/dist/chunk-6BGQA4BQ.js +0 -1
- package/dist/chunk-6JZ35VQJ.js +0 -19
- package/dist/chunk-7M2VOCYN.js +0 -1
- package/dist/chunk-BWQUYXUW.mjs +0 -1634
- package/dist/chunk-D3J7MWAU.js +0 -1634
- package/dist/chunk-EVPUCTZA.mjs +0 -0
- package/dist/chunk-FSU3H777.mjs +0 -473
- package/dist/chunk-GFSTK7KN.mjs +0 -19
- package/dist/chunk-I7EIUZKK.js +0 -332
- package/dist/chunk-JKUOV3MN.js +0 -473
- package/dist/chunk-RQS44YC7.mjs +0 -332
- package/dist/components/index.d.mts +0 -103
- package/dist/components/index.mjs +0 -24
- package/dist/hooks/index.d.mts +0 -17
- package/dist/hooks/index.mjs +0 -7
- package/dist/index.d.mts +0 -16
- package/dist/index.mjs +0 -54
- package/dist/types/index.d.mts +0 -56
- package/dist/types/index.mjs +0 -1
- package/dist/utils/index.d.mts +0 -58
- package/dist/utils/index.mjs +0 -22
- package/dist/wrappers/index.d.mts +0 -201
- package/dist/wrappers/index.mjs +0 -8
|
@@ -0,0 +1,1684 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FieldValues, FieldPath, Control, FieldError, PathValue, UseControllerProps, UseControllerReturn } from 'react-hook-form';
|
|
3
|
+
import { GridProps, TextFieldVariants, SxProps, AutocompleteRenderInputParams, CheckboxProps, FormControlLabelProps, Theme, TextFieldProps, IconButtonProps, FormLabelProps, RadioProps, ChipTypeMap, AutocompleteProps, TextField } from '@mui/material';
|
|
4
|
+
import React$1, { ReactNode, ChangeEvent } from 'react';
|
|
5
|
+
import { PickerValidDate, DateValidationError, PickerChangeHandlerContext, DatePickerSlotProps, DatePickerProps, TimeValidationError, TimePickerSlotProps, TimePickerProps } from '@mui/x-date-pickers';
|
|
6
|
+
import { useLocalizationContext } from '@mui/x-date-pickers/internals';
|
|
7
|
+
import { F as FieldType } from '../enhanced-z-I7EHVS.cjs';
|
|
8
|
+
|
|
9
|
+
interface AsyncSelect2Payload {
|
|
10
|
+
query: string | null;
|
|
11
|
+
initialValues?: Array<string | number> | null;
|
|
12
|
+
}
|
|
13
|
+
interface Option2Item {
|
|
14
|
+
value: string | number;
|
|
15
|
+
label: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface AsyncMultiSelect2Props<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
|
|
19
|
+
name: TName;
|
|
20
|
+
control?: Control<TFieldValues>;
|
|
21
|
+
gridProps?: GridProps;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
initialValues?: Array<string | number> | null;
|
|
25
|
+
queryFn: (payload: AsyncSelect2Payload) => Promise<Option2Item[]>;
|
|
26
|
+
variant?: TextFieldVariants;
|
|
27
|
+
sx?: SxProps;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
debounceMs?: number;
|
|
30
|
+
loadingText?: string;
|
|
31
|
+
noOptionsText?: string;
|
|
32
|
+
renderInput?: (params: AutocompleteRenderInputParams) => React$1.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare const AsyncMultiSelect2: {
|
|
36
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ gridProps, ...props }: AsyncMultiSelect2Props<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props for the CheckboxElement component.
|
|
42
|
+
*
|
|
43
|
+
* @template TFieldValues - The form values type
|
|
44
|
+
* @template TName - The field name type
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
interface CheckboxElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<CheckboxProps, "name" | "checked" | "value" | "onChange"> {
|
|
49
|
+
/**
|
|
50
|
+
* The field name in the form
|
|
51
|
+
* @example "acceptTerms" | "user.isActive"
|
|
52
|
+
*/
|
|
53
|
+
name: TName;
|
|
54
|
+
/**
|
|
55
|
+
* The form control instance from react-hook-form
|
|
56
|
+
*/
|
|
57
|
+
control?: Control<TFieldValues>;
|
|
58
|
+
/**
|
|
59
|
+
* Label text to display next to the checkbox
|
|
60
|
+
* @example "I agree to the terms and conditions"
|
|
61
|
+
*/
|
|
62
|
+
label?: FormControlLabelProps["label"];
|
|
63
|
+
/**
|
|
64
|
+
* Additional props for the FormControlLabel component
|
|
65
|
+
*/
|
|
66
|
+
labelProps?: Omit<FormControlLabelProps, "label" | "control">;
|
|
67
|
+
/**
|
|
68
|
+
* Grid layout props for the wrapper Grid component
|
|
69
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
70
|
+
*/
|
|
71
|
+
gridProps?: GridProps;
|
|
72
|
+
/**
|
|
73
|
+
* Helper text to display below the checkbox
|
|
74
|
+
*/
|
|
75
|
+
helperText?: ReactNode;
|
|
76
|
+
/**
|
|
77
|
+
* Custom error parser function
|
|
78
|
+
* @param error - The field error from react-hook-form
|
|
79
|
+
* @returns Formatted error message
|
|
80
|
+
*/
|
|
81
|
+
parseError?: (error: FieldError) => ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Value transformation functions for custom data handling.
|
|
84
|
+
*
|
|
85
|
+
* The component expects boolean values by default.
|
|
86
|
+
* Use transform functions for custom conversion logic when working with non-boolean form data.
|
|
87
|
+
*/
|
|
88
|
+
transform?: {
|
|
89
|
+
/**
|
|
90
|
+
* Transform the field value for display in the checkbox.
|
|
91
|
+
* If not provided, the value is converted to boolean using !!value.
|
|
92
|
+
* @param value - The current field value
|
|
93
|
+
* @returns The transformed boolean value for checkbox display
|
|
94
|
+
*/
|
|
95
|
+
input?: (value: PathValue<TFieldValues, TName>) => boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Transform the checkbox state back to the desired field value.
|
|
98
|
+
* If not provided, the boolean checked state is used directly.
|
|
99
|
+
* @param checked - The checkbox checked state
|
|
100
|
+
* @returns The transformed value to store in the form
|
|
101
|
+
*/
|
|
102
|
+
output?: (checked: boolean) => PathValue<TFieldValues, TName>;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Custom onChange handler that works alongside the form controller
|
|
106
|
+
* @param event - The checkbox change event
|
|
107
|
+
* @param checked - The new checked state
|
|
108
|
+
*/
|
|
109
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Custom sx props for styling
|
|
112
|
+
*/
|
|
113
|
+
sx?: SxProps<Theme>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A react-hook-form integrated Checkbox component with automatic validation and grid layout.
|
|
118
|
+
*
|
|
119
|
+
* This component provides a fully integrated checkbox input that works seamlessly with react-hook-form,
|
|
120
|
+
* including automatic validation, error handling, value transformation, and optional Grid wrapper for responsive layouts.
|
|
121
|
+
*
|
|
122
|
+
* Features:
|
|
123
|
+
* - Full react-hook-form integration with useController
|
|
124
|
+
* - Automatic error display with custom parsing support
|
|
125
|
+
* - Value transformation with useTransform hook for boolean values
|
|
126
|
+
* - Customizable label and positioning
|
|
127
|
+
* - Grid layout wrapper with responsive design
|
|
128
|
+
* - TypeScript type safety with generic constraints
|
|
129
|
+
* - Disabled state support with proper theming
|
|
130
|
+
* - Helper text support for additional context
|
|
131
|
+
* - Custom error parsing for internationalization
|
|
132
|
+
* - Simple boolean value handling with optional custom transforms
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* Basic usage:
|
|
136
|
+
* ```tsx
|
|
137
|
+
* <CheckboxElement
|
|
138
|
+
* control={control}
|
|
139
|
+
* name="acceptTerms"
|
|
140
|
+
* label="I agree to the terms and conditions"
|
|
141
|
+
* />
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* With validation and helper text:
|
|
146
|
+
* ```tsx
|
|
147
|
+
* <CheckboxElement
|
|
148
|
+
* control={control}
|
|
149
|
+
* name="newsletter"
|
|
150
|
+
* label="Subscribe to newsletter"
|
|
151
|
+
* helperText="You can unsubscribe at any time"
|
|
152
|
+
* rules={{ required: 'Please accept to continue' }}
|
|
153
|
+
* />
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* Custom grid layout and styling:
|
|
158
|
+
* ```tsx
|
|
159
|
+
* <CheckboxElement
|
|
160
|
+
* control={control}
|
|
161
|
+
* name="isPublic"
|
|
162
|
+
* label="Make this public"
|
|
163
|
+
* gridProps={{ size: { xs: 12, md: 6 } }}
|
|
164
|
+
* labelProps={{ sx: { fontWeight: 'bold' } }}
|
|
165
|
+
* sx={{ color: 'primary.main' }}
|
|
166
|
+
* />
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* With value transformation (string to boolean):
|
|
171
|
+
* ```tsx
|
|
172
|
+
* <CheckboxElement
|
|
173
|
+
* control={control}
|
|
174
|
+
* name="status"
|
|
175
|
+
* label="Active"
|
|
176
|
+
* transform={{
|
|
177
|
+
* input: (value) => value === 'active',
|
|
178
|
+
* output: (checked) => checked ? 'active' : 'inactive'
|
|
179
|
+
* }}
|
|
180
|
+
* />
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* Simple boolean field:
|
|
185
|
+
* ```tsx
|
|
186
|
+
* <CheckboxElement
|
|
187
|
+
* control={control}
|
|
188
|
+
* name="isEnabled"
|
|
189
|
+
* label="Enable feature"
|
|
190
|
+
* />
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* Custom error parsing for internationalization:
|
|
195
|
+
* ```tsx
|
|
196
|
+
* <CheckboxElement
|
|
197
|
+
* control={control}
|
|
198
|
+
* name="terms"
|
|
199
|
+
* label="Accept Terms"
|
|
200
|
+
* parseError={(error) => t(`validation.${error.type}`, { field: 'Terms' })}
|
|
201
|
+
* />
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @template TFieldValues - The form values type
|
|
205
|
+
* @template TName - The field name type
|
|
206
|
+
*
|
|
207
|
+
* @param props - Component props
|
|
208
|
+
* @returns React element with optional Grid wrapper
|
|
209
|
+
*
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
212
|
+
declare const CheckboxElement: {
|
|
213
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ gridProps, ...props }: CheckboxElementProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
214
|
+
displayName: string;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
type CheckboxGroupProps$1<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends number[] = number[]> = Omit<CheckboxProps, "name"> & {
|
|
218
|
+
name: TName;
|
|
219
|
+
control?: Control<TFieldValues>;
|
|
220
|
+
label?: FormControlLabelProps["label"];
|
|
221
|
+
labelProps?: Omit<FormControlLabelProps, "label" | "control">;
|
|
222
|
+
gridProps?: GridProps;
|
|
223
|
+
options: Array<{
|
|
224
|
+
Value: number;
|
|
225
|
+
Label: string;
|
|
226
|
+
}>;
|
|
227
|
+
};
|
|
228
|
+
declare const CheckboxGroup: {
|
|
229
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends number[] = number[]>({ gridProps, ...props }: CheckboxGroupProps$1<TFieldValues, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
230
|
+
displayName: string;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
type PrimitiveValue$1 = string | number | boolean;
|
|
234
|
+
type OptionObject$1<TValueKey extends string = string, TLabelKey extends string = string, TDisabledKey extends string = string> = Record<TValueKey, PrimitiveValue$1> & Record<TLabelKey, string> & Partial<Record<TDisabledKey, boolean>> & Record<string, unknown>;
|
|
235
|
+
/**
|
|
236
|
+
* Props for the CheckboxGroup component.
|
|
237
|
+
*
|
|
238
|
+
* @template TFieldValues - The form values type
|
|
239
|
+
* @template TName - The field name type
|
|
240
|
+
* @template TOption - The option object type
|
|
241
|
+
* @template TValueKey - The key for option values
|
|
242
|
+
* @template TLabelKey - The key for option labels
|
|
243
|
+
* @template TDisabledKey - The key for option disabled state
|
|
244
|
+
*
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
interface CheckboxGroupProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TOption extends OptionObject$1<TValueKey, TLabelKey, TDisabledKey> = OptionObject$1, TValueKey extends keyof TOption & string = "Value", TLabelKey extends keyof TOption & string = "Label", TDisabledKey extends keyof TOption & string = "disabled"> extends Omit<CheckboxProps, "name" | "checked" | "value" | "onChange"> {
|
|
248
|
+
/**
|
|
249
|
+
* The field name in the form
|
|
250
|
+
* @example "selectedItems" | "user.preferences"
|
|
251
|
+
*/
|
|
252
|
+
name: TName;
|
|
253
|
+
/**
|
|
254
|
+
* The form control instance from react-hook-form
|
|
255
|
+
*/
|
|
256
|
+
control?: Control<TFieldValues>;
|
|
257
|
+
/**
|
|
258
|
+
* Array of options to display as checkboxes
|
|
259
|
+
*/
|
|
260
|
+
options: TOption[];
|
|
261
|
+
/**
|
|
262
|
+
* Label text to display above the checkbox group
|
|
263
|
+
* @example "Select your preferences"
|
|
264
|
+
*/
|
|
265
|
+
label?: ReactNode;
|
|
266
|
+
/**
|
|
267
|
+
* Additional props for each FormControlLabel component
|
|
268
|
+
*/
|
|
269
|
+
labelProps?: Omit<FormControlLabelProps, "label" | "control">;
|
|
270
|
+
/**
|
|
271
|
+
* Grid layout props for the wrapper Grid component
|
|
272
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
273
|
+
*/
|
|
274
|
+
gridProps?: GridProps;
|
|
275
|
+
/**
|
|
276
|
+
* Helper text to display below the checkbox group
|
|
277
|
+
*/
|
|
278
|
+
helperText?: ReactNode;
|
|
279
|
+
/**
|
|
280
|
+
* Custom error parser function
|
|
281
|
+
* @param error - The field error from react-hook-form
|
|
282
|
+
* @returns Formatted error message
|
|
283
|
+
*/
|
|
284
|
+
parseError?: (error: FieldError) => ReactNode;
|
|
285
|
+
/**
|
|
286
|
+
* Key in the option object that contains the value
|
|
287
|
+
* @defaultValue "Value"
|
|
288
|
+
*/
|
|
289
|
+
valueKey?: TValueKey;
|
|
290
|
+
/**
|
|
291
|
+
* Key in the option object that contains the label
|
|
292
|
+
* @defaultValue "Label"
|
|
293
|
+
*/
|
|
294
|
+
labelKey?: TLabelKey;
|
|
295
|
+
/**
|
|
296
|
+
* Key in the option object that contains the disabled state
|
|
297
|
+
* @defaultValue "disabled"
|
|
298
|
+
*/
|
|
299
|
+
disabledKey?: TDisabledKey;
|
|
300
|
+
/**
|
|
301
|
+
* Whether to display checkboxes in a single row
|
|
302
|
+
* @defaultValue false
|
|
303
|
+
*/
|
|
304
|
+
row?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Value transformation functions for custom data handling
|
|
307
|
+
* Supports arrays of string, boolean, or number values
|
|
308
|
+
*/
|
|
309
|
+
transform?: {
|
|
310
|
+
/**
|
|
311
|
+
* Transform the field value for display in the checkboxes
|
|
312
|
+
* @param value - The current field value (array of values)
|
|
313
|
+
* @returns The transformed value to display
|
|
314
|
+
*/
|
|
315
|
+
input?: (value: PathValue<TFieldValues, TName>) => Array<TOption[TValueKey]>;
|
|
316
|
+
/**
|
|
317
|
+
* Transform the checkbox selections back to the field value
|
|
318
|
+
* @param selectedValues - Array of selected option values
|
|
319
|
+
* @returns The transformed value to store in the form
|
|
320
|
+
*/
|
|
321
|
+
output?: (selectedValues: Array<TOption[TValueKey]>) => PathValue<TFieldValues, TName>;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Custom onChange handler that works alongside the form controller
|
|
325
|
+
* @param selectedValues - Array of selected option values
|
|
326
|
+
* @param selectedOptions - Array of selected option objects
|
|
327
|
+
*/
|
|
328
|
+
onChange?: (selectedValues: Array<TOption[TValueKey]>, selectedOptions: TOption[]) => void;
|
|
329
|
+
/**
|
|
330
|
+
* Custom sx props for styling
|
|
331
|
+
*/
|
|
332
|
+
sx?: SxProps<Theme>;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Branded type for validated date values to ensure type safety
|
|
337
|
+
* @template TDate - The date type (from date adapter)
|
|
338
|
+
*/
|
|
339
|
+
type ValidatedDate<TDate extends PickerValidDate = PickerValidDate> = TDate & {
|
|
340
|
+
readonly __brand: 'ValidatedDate';
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Transformation functions for date values with strict typing
|
|
344
|
+
* @template TFieldValues - The form values type
|
|
345
|
+
* @template TName - The field name type
|
|
346
|
+
* @template TValue - The transformed value type
|
|
347
|
+
*/
|
|
348
|
+
interface DateTransform<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate> {
|
|
349
|
+
/**
|
|
350
|
+
* Transform the stored field value for display in the date picker
|
|
351
|
+
* @param value - The current field value from react-hook-form
|
|
352
|
+
* @returns The transformed value to display in the picker
|
|
353
|
+
*/
|
|
354
|
+
input?: (value: PathValue<TFieldValues, TName>) => TValue | null;
|
|
355
|
+
/**
|
|
356
|
+
* Transform the picker value back to the form field value
|
|
357
|
+
* @param value - The selected date value from the picker
|
|
358
|
+
* @param context - Additional context from the picker change handler
|
|
359
|
+
* @returns The transformed value to store in the form
|
|
360
|
+
*/
|
|
361
|
+
output?: (value: TValue | null, context: PickerChangeHandlerContext<DateValidationError>) => PathValue<TFieldValues, TName>;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Configuration options for date picker validation
|
|
365
|
+
* @template TDate - The date type (from date adapter)
|
|
366
|
+
*/
|
|
367
|
+
interface DatePickerValidationConfig<TDate extends PickerValidDate = PickerValidDate> {
|
|
368
|
+
/** Minimum allowed date */
|
|
369
|
+
minDate?: TDate;
|
|
370
|
+
/** Maximum allowed date */
|
|
371
|
+
maxDate?: TDate;
|
|
372
|
+
/** Function to disable specific dates */
|
|
373
|
+
shouldDisableDate?: (date: TDate) => boolean;
|
|
374
|
+
/** Custom validation error messages */
|
|
375
|
+
errorMessages?: {
|
|
376
|
+
invalidDate?: string;
|
|
377
|
+
minDate?: string;
|
|
378
|
+
maxDate?: string;
|
|
379
|
+
disabledDate?: string;
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Slot props for customizing date picker subcomponents with strict typing
|
|
384
|
+
* @template TEnableAccessibleFieldDOMStructure - Whether accessible field DOM structure is enabled
|
|
385
|
+
*/
|
|
386
|
+
interface TypedDatePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean = false> extends Omit<DatePickerSlotProps<TEnableAccessibleFieldDOMStructure>, "textField"> {
|
|
387
|
+
textField?: Partial<TextFieldProps> & {
|
|
388
|
+
/** Custom input component */
|
|
389
|
+
InputComponent?: React.ComponentType<any>;
|
|
390
|
+
/** Additional input props with type safety */
|
|
391
|
+
inputProps?: TextFieldProps["inputProps"] & Record<string, unknown>;
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Core props for the DatePickerElement component with enhanced type safety
|
|
396
|
+
* @template TFieldValues - The form values type
|
|
397
|
+
* @template TName - The field name type
|
|
398
|
+
* @template TValue - The transformed value type
|
|
399
|
+
* @template TEnableAccessibleFieldDOMStructure - Whether accessible field DOM structure is enabled
|
|
400
|
+
*/
|
|
401
|
+
interface DatePickerElementCoreProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false> {
|
|
402
|
+
/**
|
|
403
|
+
* The field name in the form - must be a valid path in TFieldValues
|
|
404
|
+
* @example "birthDate" | "user.dateOfBirth" | "settings.startDate"
|
|
405
|
+
*/
|
|
406
|
+
name: TName;
|
|
407
|
+
/**
|
|
408
|
+
* Whether the field is required for form validation
|
|
409
|
+
* @defaultValue false
|
|
410
|
+
*/
|
|
411
|
+
required?: boolean;
|
|
412
|
+
/**
|
|
413
|
+
* Validation rules for react-hook-form with type-safe field reference
|
|
414
|
+
*/
|
|
415
|
+
rules?: UseControllerProps<TFieldValues, TName>["rules"];
|
|
416
|
+
/**
|
|
417
|
+
* The form control instance from useForm() hook
|
|
418
|
+
*/
|
|
419
|
+
control?: Control<TFieldValues>;
|
|
420
|
+
/**
|
|
421
|
+
* Custom error message parser with proper typing for both form and date validation errors
|
|
422
|
+
* @param error - The validation error (either from react-hook-form or date picker)
|
|
423
|
+
* @returns Custom error message or React component
|
|
424
|
+
*/
|
|
425
|
+
parseError?: (error: FieldError | DateValidationError) => ReactNode;
|
|
426
|
+
/**
|
|
427
|
+
* Value transformation functions for converting between form and picker formats
|
|
428
|
+
*/
|
|
429
|
+
transform?: DateTransform<TFieldValues, TName, TValue>;
|
|
430
|
+
/**
|
|
431
|
+
* Validation configuration specific to date selection
|
|
432
|
+
*/
|
|
433
|
+
validation?: DatePickerValidationConfig<TValue>;
|
|
434
|
+
/**
|
|
435
|
+
* The input label with support for React nodes
|
|
436
|
+
* @example "Select Date" | <span>Birth Date <em>(required)</em></span>
|
|
437
|
+
*/
|
|
438
|
+
label?: ReactNode;
|
|
439
|
+
/**
|
|
440
|
+
* Placeholder text for the input field
|
|
441
|
+
* @example "MM/DD/YYYY" | "Select a date..."
|
|
442
|
+
*/
|
|
443
|
+
placeholder?: string;
|
|
444
|
+
/**
|
|
445
|
+
* Whether the text input should be read-only (picker interaction only)
|
|
446
|
+
* @defaultValue false
|
|
447
|
+
*/
|
|
448
|
+
textReadOnly?: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Helper text to display below the input field
|
|
451
|
+
*/
|
|
452
|
+
helperText?: TextFieldProps["helperText"];
|
|
453
|
+
/**
|
|
454
|
+
* Props for the underlying TextField component
|
|
455
|
+
*/
|
|
456
|
+
inputProps?: Omit<TextFieldProps, "name" | "value" | "onChange" | "error" | "helperText">;
|
|
457
|
+
/**
|
|
458
|
+
* Props for customizing date picker slots and subcomponents
|
|
459
|
+
*/
|
|
460
|
+
slotProps?: TypedDatePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
|
461
|
+
/**
|
|
462
|
+
* Props for the underlying DatePicker component
|
|
463
|
+
*/
|
|
464
|
+
datePickerProps?: Omit<DatePickerProps<TEnableAccessibleFieldDOMStructure>, "value" | "onChange" | "slotProps" | "name">;
|
|
465
|
+
/**
|
|
466
|
+
* The TextField variant to use
|
|
467
|
+
* @defaultValue "outlined"
|
|
468
|
+
*/
|
|
469
|
+
variant?: TextFieldVariants;
|
|
470
|
+
/**
|
|
471
|
+
* Custom styles for the date picker with theme-aware typing
|
|
472
|
+
*/
|
|
473
|
+
sx?: SxProps<Theme>;
|
|
474
|
+
/**
|
|
475
|
+
* Whether the component is in a loading state
|
|
476
|
+
* @defaultValue false
|
|
477
|
+
*/
|
|
478
|
+
loading?: boolean;
|
|
479
|
+
/**
|
|
480
|
+
* Custom loading indicator component
|
|
481
|
+
*/
|
|
482
|
+
LoadingComponent?: React.ComponentType;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Props for the grid wrapper functionality
|
|
486
|
+
*/
|
|
487
|
+
interface DatePickerElementGridProps {
|
|
488
|
+
/**
|
|
489
|
+
* Grid layout configuration for the wrapper Grid component
|
|
490
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
491
|
+
*/
|
|
492
|
+
gridProps?: GridProps | false;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Complete props interface for DatePickerElement combining core and grid props
|
|
496
|
+
* @template TFieldValues - The form values type
|
|
497
|
+
* @template TName - The field name type
|
|
498
|
+
* @template TValue - The transformed value type
|
|
499
|
+
* @template TEnableAccessibleFieldDOMStructure - Whether accessible field DOM structure is enabled
|
|
500
|
+
*/
|
|
501
|
+
interface DatePickerElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false> extends DatePickerElementCoreProps<TFieldValues, TName, TValue, TEnableAccessibleFieldDOMStructure>, DatePickerElementGridProps {
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Return type for date picker hooks with strict typing
|
|
505
|
+
* @template TFieldValues - The form values type
|
|
506
|
+
* @template TName - The field name type
|
|
507
|
+
* @template TValue - The transformed value type
|
|
508
|
+
*/
|
|
509
|
+
interface DatePickerHookReturn<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate> {
|
|
510
|
+
/** The current transformed value for the picker */
|
|
511
|
+
value: TValue | null;
|
|
512
|
+
/** Change handler with proper typing */
|
|
513
|
+
onChange: (value: TValue | null, context: PickerChangeHandlerContext<DateValidationError>) => void;
|
|
514
|
+
/** Current validation error if any */
|
|
515
|
+
error: FieldError | DateValidationError | undefined;
|
|
516
|
+
/** Whether the field has an error */
|
|
517
|
+
hasError: boolean;
|
|
518
|
+
/** Formatted error message for display */
|
|
519
|
+
errorMessage: ReactNode;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* A fully-featured, type-safe DatePickerElement component for react-hook-form integration.
|
|
524
|
+
*
|
|
525
|
+
* This component combines the core date picker functionality with optional Grid layout wrapping,
|
|
526
|
+
* providing a complete solution for form-based date selection with comprehensive TypeScript support.
|
|
527
|
+
*
|
|
528
|
+
* Key Features:
|
|
529
|
+
* - 🎯 **Type Safety**: Full TypeScript inference for form field types and date values
|
|
530
|
+
* - 🔧 **React Hook Form Integration**: Seamless integration with react-hook-form validation
|
|
531
|
+
* - 🎨 **Theming**: Automatic adaptation to MUI theme with customizable styles
|
|
532
|
+
* - ♿ **Accessibility**: WCAG-compliant with proper ARIA attributes and keyboard navigation
|
|
533
|
+
* - 🚀 **Performance**: Optimized with memoization and efficient re-rendering
|
|
534
|
+
* - 📱 **Responsive**: Built-in Grid layout with configurable breakpoints
|
|
535
|
+
* - 🛡️ **Validation**: Comprehensive validation with custom error messages
|
|
536
|
+
* - 🔄 **Transformation**: Flexible value transformation between form and picker formats
|
|
537
|
+
* - 📚 **Developer Experience**: Rich TypeScript IntelliSense and comprehensive documentation
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* Basic usage with automatic Grid wrapper:
|
|
541
|
+
* ```tsx
|
|
542
|
+
* import { useForm } from 'react-hook-form';
|
|
543
|
+
* import { DatePickerElement } from '@gnwebsoft/ui/wrappers';
|
|
544
|
+
*
|
|
545
|
+
* function MyForm() {
|
|
546
|
+
* const { control } = useForm<{ birthDate: string }>();
|
|
547
|
+
*
|
|
548
|
+
* return (
|
|
549
|
+
* <DatePickerElement
|
|
550
|
+
* name="birthDate"
|
|
551
|
+
* control={control}
|
|
552
|
+
* label="Date of Birth"
|
|
553
|
+
* required
|
|
554
|
+
* />
|
|
555
|
+
* );
|
|
556
|
+
* }
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* Advanced usage with custom transformation and validation:
|
|
561
|
+
* ```tsx
|
|
562
|
+
* function AdvancedForm() {
|
|
563
|
+
* const { control } = useForm<{ startDate: Date }>();
|
|
564
|
+
*
|
|
565
|
+
* return (
|
|
566
|
+
* <DatePickerElement
|
|
567
|
+
* name="startDate"
|
|
568
|
+
* control={control}
|
|
569
|
+
* label="Project Start Date"
|
|
570
|
+
* transform={{
|
|
571
|
+
* input: (dateString) => dateString ? new Date(dateString) : null,
|
|
572
|
+
* output: (date) => date ? date.toISOString() : null
|
|
573
|
+
* }}
|
|
574
|
+
* validation={{
|
|
575
|
+
* minDate: new Date(),
|
|
576
|
+
* maxDate: addYears(new Date(), 2),
|
|
577
|
+
* errorMessages: {
|
|
578
|
+
* minDate: 'Start date must be today or later',
|
|
579
|
+
* maxDate: 'Start date cannot be more than 2 years in the future'
|
|
580
|
+
* }
|
|
581
|
+
* }}
|
|
582
|
+
* gridProps={{ size: { xs: 12, md: 6 } }}
|
|
583
|
+
* sx={{
|
|
584
|
+
* '& .MuiInputLabel-root': {
|
|
585
|
+
* fontWeight: 'bold'
|
|
586
|
+
* }
|
|
587
|
+
* }}
|
|
588
|
+
* />
|
|
589
|
+
* );
|
|
590
|
+
* }
|
|
591
|
+
* ```
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* Without Grid wrapper for custom layouts:
|
|
595
|
+
* ```tsx
|
|
596
|
+
* function CustomLayout() {
|
|
597
|
+
* const { control } = useForm<{ eventDate: string }>();
|
|
598
|
+
*
|
|
599
|
+
* return (
|
|
600
|
+
* <Box display="flex" gap={2}>
|
|
601
|
+
* <DatePickerElement
|
|
602
|
+
* name="eventDate"
|
|
603
|
+
* control={control}
|
|
604
|
+
* label="Event Date"
|
|
605
|
+
* gridProps={false} // Disables Grid wrapper
|
|
606
|
+
* />
|
|
607
|
+
* <Button type="submit">Submit</Button>
|
|
608
|
+
* </Box>
|
|
609
|
+
* );
|
|
610
|
+
* }
|
|
611
|
+
* ```
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* With loading state and custom error handling:
|
|
615
|
+
* ```tsx
|
|
616
|
+
* function LoadingForm() {
|
|
617
|
+
* const { control } = useForm();
|
|
618
|
+
* const [isValidating, setIsValidating] = useState(false);
|
|
619
|
+
*
|
|
620
|
+
* return (
|
|
621
|
+
* <DatePickerElement
|
|
622
|
+
* name="appointmentDate"
|
|
623
|
+
* control={control}
|
|
624
|
+
* label="Appointment Date"
|
|
625
|
+
* loading={isValidating}
|
|
626
|
+
* LoadingComponent={() => <CircularProgress size={20} />}
|
|
627
|
+
* parseError={(error) => {
|
|
628
|
+
* if (typeof error === 'object' && error?.type === 'custom') {
|
|
629
|
+
* return 'This date conflicts with another appointment';
|
|
630
|
+
* }
|
|
631
|
+
* return error.message || 'Please select a valid date';
|
|
632
|
+
* }}
|
|
633
|
+
* />
|
|
634
|
+
* );
|
|
635
|
+
* }
|
|
636
|
+
* ```
|
|
637
|
+
*
|
|
638
|
+
* @template TFieldValues - The form values type (inferred from control)
|
|
639
|
+
* @template TName - The field name type (inferred from name prop)
|
|
640
|
+
* @template TValue - The transformed value type (inferred from transform functions)
|
|
641
|
+
* @template TEnableAccessibleFieldDOMStructure - Whether accessible field DOM structure is enabled
|
|
642
|
+
*
|
|
643
|
+
* @param props - Component props with full TypeScript inference
|
|
644
|
+
* @param ref - Forward ref for the root element (Grid or DatePicker container)
|
|
645
|
+
* @returns Rendered DatePickerElement component with optional Grid wrapper
|
|
646
|
+
*/
|
|
647
|
+
declare const DatePickerElement: React$1.ForwardRefExoticComponent<DatePickerElementProps<any, any, any, any> & React$1.RefAttributes<HTMLDivElement>>;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* The core DatePickerElement component without Grid wrapper.
|
|
651
|
+
*
|
|
652
|
+
* This is a lightweight, performant date picker component that integrates seamlessly
|
|
653
|
+
* with react-hook-form while providing comprehensive TypeScript support and
|
|
654
|
+
* accessibility features.
|
|
655
|
+
*
|
|
656
|
+
* Features:
|
|
657
|
+
* - Full TypeScript inference for form field types
|
|
658
|
+
* - Automatic value transformation between form and picker formats
|
|
659
|
+
* - Comprehensive validation with custom error messages
|
|
660
|
+
* - Theme-aware styling with accessibility support
|
|
661
|
+
* - Performance optimized with proper memoization
|
|
662
|
+
* - Forward ref support for advanced use cases
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* Basic usage:
|
|
666
|
+
* ```tsx
|
|
667
|
+
* <DatePickerElementCore
|
|
668
|
+
* name="birthDate"
|
|
669
|
+
* control={control}
|
|
670
|
+
* label="Date of Birth"
|
|
671
|
+
* required
|
|
672
|
+
* />
|
|
673
|
+
* ```
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* With custom transformation:
|
|
677
|
+
* ```tsx
|
|
678
|
+
* <DatePickerElementCore
|
|
679
|
+
* name="startDate"
|
|
680
|
+
* control={control}
|
|
681
|
+
* label="Start Date"
|
|
682
|
+
* transform={{
|
|
683
|
+
* input: (dateString) => dateString ? new Date(dateString) : null,
|
|
684
|
+
* output: (date) => date ? date.toISOString() : null
|
|
685
|
+
* }}
|
|
686
|
+
* validation={{
|
|
687
|
+
* minDate: new Date(),
|
|
688
|
+
* errorMessages: {
|
|
689
|
+
* minDate: 'Start date must be today or later'
|
|
690
|
+
* }
|
|
691
|
+
* }}
|
|
692
|
+
* />
|
|
693
|
+
* ```
|
|
694
|
+
*
|
|
695
|
+
* @template TFieldValues - The form values type
|
|
696
|
+
* @template TName - The field name type
|
|
697
|
+
* @template TValue - The transformed value type
|
|
698
|
+
* @template TEnableAccessibleFieldDOMStructure - Whether accessible field DOM structure is enabled
|
|
699
|
+
*/
|
|
700
|
+
declare const DatePickerElementCore: React$1.ForwardRefExoticComponent<DatePickerElementCoreProps<any, any, any, any> & React$1.RefAttributes<HTMLDivElement>>;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Type-safe date value reader that handles string to date conversion
|
|
704
|
+
* @template TDate - The date type from the date adapter
|
|
705
|
+
* @param adapter - The localization context from MUI date pickers
|
|
706
|
+
* @param value - The value to convert (string, date, or null)
|
|
707
|
+
* @returns Properly typed date value or null
|
|
708
|
+
*/
|
|
709
|
+
declare function readDatePickerValueAsDate<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: string | null | TDate | undefined): TDate | null;
|
|
710
|
+
/**
|
|
711
|
+
* Options for the useDatePickerValue hook
|
|
712
|
+
* @template TFieldValues - The form values type
|
|
713
|
+
* @template TName - The field name type
|
|
714
|
+
* @template TValue - The transformed value type
|
|
715
|
+
*/
|
|
716
|
+
interface UseDatePickerValueOptions<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate> {
|
|
717
|
+
/** The field controller from react-hook-form */
|
|
718
|
+
field: UseControllerReturn<TFieldValues, TName>["field"];
|
|
719
|
+
/** Optional transformation functions */
|
|
720
|
+
transform?: DateTransform<TFieldValues, TName, TValue>;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Return type for the useDatePickerValue hook
|
|
724
|
+
* @template TValue - The transformed value type
|
|
725
|
+
*/
|
|
726
|
+
interface UseDatePickerValueReturn<TValue extends PickerValidDate = PickerValidDate> {
|
|
727
|
+
/** The transformed value for display in the picker */
|
|
728
|
+
value: TValue | null;
|
|
729
|
+
/** Change handler for picker value updates */
|
|
730
|
+
onChange: (value: TValue | null, context: PickerChangeHandlerContext<DateValidationError>) => void;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Hook for managing date picker value transformations with type safety
|
|
734
|
+
*
|
|
735
|
+
* This hook handles the conversion between form field values and date picker values,
|
|
736
|
+
* applying custom transformations while maintaining strict TypeScript typing.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* Basic usage with string to date conversion:
|
|
740
|
+
* ```tsx
|
|
741
|
+
* const { value, onChange } = useDatePickerValue({
|
|
742
|
+
* field,
|
|
743
|
+
* transform: {
|
|
744
|
+
* input: (dateString) => dateString ? new Date(dateString) : null,
|
|
745
|
+
* output: (date) => date ? date.toISOString() : null
|
|
746
|
+
* }
|
|
747
|
+
* });
|
|
748
|
+
* ```
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* Usage with Day.js dates:
|
|
752
|
+
* ```tsx
|
|
753
|
+
* const { value, onChange } = useDatePickerValue({
|
|
754
|
+
* field,
|
|
755
|
+
* transform: {
|
|
756
|
+
* input: (dateString) => dateString ? dayjs(dateString) : null,
|
|
757
|
+
* output: (date) => date ? date.format('YYYY-MM-DD') : null
|
|
758
|
+
* }
|
|
759
|
+
* });
|
|
760
|
+
* ```
|
|
761
|
+
*
|
|
762
|
+
* @template TFieldValues - The form values type
|
|
763
|
+
* @template TName - The field name type
|
|
764
|
+
* @template TValue - The transformed value type
|
|
765
|
+
* @param options - Configuration options for value transformation
|
|
766
|
+
* @returns Object with transformed value and change handler
|
|
767
|
+
*/
|
|
768
|
+
declare function useDatePickerValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate>(options: UseDatePickerValueOptions<TFieldValues, TName, TValue>): UseDatePickerValueReturn<TValue>;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Options for the useDatePickerValidation hook
|
|
772
|
+
* @template TFieldValues - The form values type
|
|
773
|
+
* @template TName - The field name type
|
|
774
|
+
* @template TValue - The transformed value type
|
|
775
|
+
*/
|
|
776
|
+
interface UseDatePickerValidationOptions<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate> {
|
|
777
|
+
/** The field state from react-hook-form controller */
|
|
778
|
+
fieldState: UseControllerReturn<TFieldValues, TName>["fieldState"];
|
|
779
|
+
/** Validation configuration for the date picker */
|
|
780
|
+
validation?: DatePickerValidationConfig<TValue>;
|
|
781
|
+
/** Custom error message parser */
|
|
782
|
+
parseError?: (error: FieldError | DateValidationError) => ReactNode;
|
|
783
|
+
/** The current date value for validation */
|
|
784
|
+
value?: TValue | null;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Return type for the useDatePickerValidation hook
|
|
788
|
+
*/
|
|
789
|
+
interface UseDatePickerValidationReturn {
|
|
790
|
+
/** Whether the field has any validation errors */
|
|
791
|
+
hasError: boolean;
|
|
792
|
+
/** The current validation error (form or date-specific) */
|
|
793
|
+
error: FieldError | DateValidationError | undefined;
|
|
794
|
+
/** Formatted error message for display */
|
|
795
|
+
errorMessage: ReactNode;
|
|
796
|
+
/** Whether the field is in an invalid state */
|
|
797
|
+
invalid: boolean;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Hook for managing date picker validation with comprehensive error handling
|
|
801
|
+
*
|
|
802
|
+
* This hook centralizes validation logic for date pickers, handling both
|
|
803
|
+
* react-hook-form validation errors and date-specific validation errors
|
|
804
|
+
* from MUI date pickers.
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* Basic usage with form validation:
|
|
808
|
+
* ```tsx
|
|
809
|
+
* const { hasError, errorMessage, invalid } = useDatePickerValidation({
|
|
810
|
+
* fieldState,
|
|
811
|
+
* validation: {
|
|
812
|
+
* minDate: dayjs().subtract(1, 'year'),
|
|
813
|
+
* maxDate: dayjs().add(1, 'year'),
|
|
814
|
+
* errorMessages: {
|
|
815
|
+
* minDate: 'Date must be within the last year',
|
|
816
|
+
* maxDate: 'Date cannot be more than 1 year in the future'
|
|
817
|
+
* }
|
|
818
|
+
* }
|
|
819
|
+
* });
|
|
820
|
+
* ```
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* Usage with custom error parser:
|
|
824
|
+
* ```tsx
|
|
825
|
+
* const { hasError, errorMessage } = useDatePickerValidation({
|
|
826
|
+
* fieldState,
|
|
827
|
+
* parseError: (error) => {
|
|
828
|
+
* if (typeof error === 'string') {
|
|
829
|
+
* return `Date Error: ${error}`;
|
|
830
|
+
* }
|
|
831
|
+
* return error.message || 'Invalid date';
|
|
832
|
+
* }
|
|
833
|
+
* });
|
|
834
|
+
* ```
|
|
835
|
+
*
|
|
836
|
+
* @template TFieldValues - The form values type
|
|
837
|
+
* @template TName - The field name type
|
|
838
|
+
* @template TValue - The transformed value type
|
|
839
|
+
* @param options - Validation configuration options
|
|
840
|
+
* @returns Validation state and error information
|
|
841
|
+
*/
|
|
842
|
+
declare function useDatePickerValidation<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate>(options: UseDatePickerValidationOptions<TFieldValues, TName, TValue>): UseDatePickerValidationReturn;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Options for the useDatePickerStyles hook
|
|
846
|
+
*/
|
|
847
|
+
interface UseDatePickerStylesOptions {
|
|
848
|
+
/** Whether the component is disabled */
|
|
849
|
+
disabled?: boolean;
|
|
850
|
+
/** Whether the component has a validation error */
|
|
851
|
+
hasError?: boolean;
|
|
852
|
+
/** Whether the component is in loading state */
|
|
853
|
+
loading?: boolean;
|
|
854
|
+
/** Whether the text input is read-only */
|
|
855
|
+
textReadOnly?: boolean;
|
|
856
|
+
/** Custom styles to merge with defaults */
|
|
857
|
+
sx?: SxProps<Theme>;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Return type for the useDatePickerStyles hook
|
|
861
|
+
*/
|
|
862
|
+
interface UseDatePickerStylesReturn {
|
|
863
|
+
/** Computed styles for the date picker component */
|
|
864
|
+
sx: SxProps<Theme>;
|
|
865
|
+
/** Additional class names for styling */
|
|
866
|
+
className?: string;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Hook for managing theme-aware date picker styles with consistent design system integration
|
|
870
|
+
*
|
|
871
|
+
* This hook provides optimized, memoized styles for date picker components that automatically
|
|
872
|
+
* adapt to the current MUI theme and component state (disabled, error, loading, etc.).
|
|
873
|
+
* It ensures consistent styling across all date picker instances while allowing customization.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* Basic usage:
|
|
877
|
+
* ```tsx
|
|
878
|
+
* const { sx } = useDatePickerStyles({
|
|
879
|
+
* disabled: isDisabled,
|
|
880
|
+
* hasError: !!error,
|
|
881
|
+
* loading: isLoading
|
|
882
|
+
* });
|
|
883
|
+
*
|
|
884
|
+
* return <DatePicker sx={sx} ... />;
|
|
885
|
+
* ```
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* With custom styles:
|
|
889
|
+
* ```tsx
|
|
890
|
+
* const { sx } = useDatePickerStyles({
|
|
891
|
+
* hasError: !!error,
|
|
892
|
+
* sx: {
|
|
893
|
+
* '& .MuiInputLabel-root': {
|
|
894
|
+
* color: 'primary.main'
|
|
895
|
+
* }
|
|
896
|
+
* }
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
899
|
+
*
|
|
900
|
+
* @param options - Style configuration options
|
|
901
|
+
* @returns Computed styles and class names
|
|
902
|
+
*/
|
|
903
|
+
declare function useDatePickerStyles(options?: UseDatePickerStylesOptions): UseDatePickerStylesReturn;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Utility type for creating branded date types to prevent mixing different date formats
|
|
907
|
+
* @template TDate - The base date type
|
|
908
|
+
* @template TBrand - The brand string for type safety
|
|
909
|
+
*/
|
|
910
|
+
type BrandedDate<TDate extends PickerValidDate, TBrand extends string> = TDate & {
|
|
911
|
+
readonly __brand: TBrand;
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
* Type guard to check if a value is a valid date
|
|
915
|
+
* @param value - The value to check
|
|
916
|
+
* @returns True if the value is a valid date-like object
|
|
917
|
+
*/
|
|
918
|
+
declare function isValidDate(value: unknown): value is PickerValidDate;
|
|
919
|
+
/**
|
|
920
|
+
* Type guard to check if a value is a string that can be parsed as a date
|
|
921
|
+
* @param value - The value to check
|
|
922
|
+
* @returns True if the value is a parseable date string
|
|
923
|
+
*/
|
|
924
|
+
declare function isParsableDateString(value: unknown): value is string;
|
|
925
|
+
/**
|
|
926
|
+
* Creates a type-safe date transformation function that converts form values to date picker values
|
|
927
|
+
* @template TFieldValues - The form values type
|
|
928
|
+
* @template TName - The field name type
|
|
929
|
+
* @template TDate - The date type used by the picker
|
|
930
|
+
* @param adapter - The date adapter from MUI localization context
|
|
931
|
+
* @returns A transformation function that safely converts form values to dates
|
|
932
|
+
*/
|
|
933
|
+
declare function createDateInputTransform<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>, TDate extends PickerValidDate = PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>): (value: PathValue<TFieldValues, TName>) => TDate | null;
|
|
934
|
+
/**
|
|
935
|
+
* Creates a type-safe date transformation function that converts date picker values back to form values
|
|
936
|
+
* @template TFieldValues - The form values type
|
|
937
|
+
* @template TName - The field name type
|
|
938
|
+
* @template TDate - The date type used by the picker
|
|
939
|
+
* @param format - The format to use for string conversion (optional)
|
|
940
|
+
* @returns A transformation function that safely converts dates to form values
|
|
941
|
+
*/
|
|
942
|
+
declare function createDateOutputTransform<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>, TDate extends PickerValidDate = PickerValidDate>(format?: string): (value: TDate | null) => PathValue<TFieldValues, TName>;
|
|
943
|
+
/**
|
|
944
|
+
* Utility function to create default date picker configuration
|
|
945
|
+
* @template TDate - The date type
|
|
946
|
+
* @returns Default configuration object
|
|
947
|
+
*/
|
|
948
|
+
declare function createDefaultDatePickerConfig<TDate extends PickerValidDate = PickerValidDate>(): {
|
|
949
|
+
readonly slotProps: {
|
|
950
|
+
readonly actionBar: {
|
|
951
|
+
readonly actions: readonly ["clear", "today", "cancel", "accept"];
|
|
952
|
+
};
|
|
953
|
+
readonly textField: {
|
|
954
|
+
readonly fullWidth: true;
|
|
955
|
+
readonly variant: "outlined";
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
readonly gridProps: {
|
|
959
|
+
readonly size: {
|
|
960
|
+
readonly xs: 12;
|
|
961
|
+
readonly sm: 12;
|
|
962
|
+
readonly md: 12;
|
|
963
|
+
readonly lg: 12;
|
|
964
|
+
readonly xl: 12;
|
|
965
|
+
};
|
|
966
|
+
};
|
|
967
|
+
readonly validation: {
|
|
968
|
+
readonly errorMessages: {
|
|
969
|
+
readonly invalidDate: "Please enter a valid date";
|
|
970
|
+
readonly minDate: "Date must be after the minimum allowed date";
|
|
971
|
+
readonly maxDate: "Date must be before the maximum allowed date";
|
|
972
|
+
readonly disabledDate: "This date is not allowed";
|
|
973
|
+
};
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* Utility to safely extract error message from various error types
|
|
978
|
+
* @param error - The error object (could be from react-hook-form or MUI date picker)
|
|
979
|
+
* @returns A user-friendly error message string
|
|
980
|
+
*/
|
|
981
|
+
declare function extractErrorMessage(error: unknown): string;
|
|
982
|
+
/**
|
|
983
|
+
* Performance utility to create stable references for complex props
|
|
984
|
+
* This helps prevent unnecessary re-renders when using complex configuration objects
|
|
985
|
+
* @template T - The type of the configuration object
|
|
986
|
+
* @param config - The configuration object
|
|
987
|
+
* @returns A JSON string that can be used as a dependency in useMemo/useCallback
|
|
988
|
+
*/
|
|
989
|
+
declare function createStableKey<T extends Record<string, unknown>>(config: T): string;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Props for the PasswordElement component.
|
|
993
|
+
*
|
|
994
|
+
* @template TFieldValues - The form values type
|
|
995
|
+
* @template TName - The field name type
|
|
996
|
+
* @template TValue - The value type
|
|
997
|
+
*
|
|
998
|
+
* @public
|
|
999
|
+
*/
|
|
1000
|
+
type PasswordElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue = unknown> = Omit<TextFieldProps, "name"> & {
|
|
1001
|
+
/**
|
|
1002
|
+
* The field name in the form
|
|
1003
|
+
* @example "password" | "user.currentPassword"
|
|
1004
|
+
*/
|
|
1005
|
+
name: TName;
|
|
1006
|
+
/**
|
|
1007
|
+
* The form control instance from react-hook-form
|
|
1008
|
+
*/
|
|
1009
|
+
control?: Control<TFieldValues>;
|
|
1010
|
+
/**
|
|
1011
|
+
* Color of the visibility toggle icon button
|
|
1012
|
+
* @defaultValue "default"
|
|
1013
|
+
*/
|
|
1014
|
+
iconColor?: IconButtonProps["color"];
|
|
1015
|
+
/**
|
|
1016
|
+
* Custom render function for the visibility toggle icon
|
|
1017
|
+
* @param password - Whether password is currently hidden
|
|
1018
|
+
* @returns ReactNode to render as the icon
|
|
1019
|
+
* @defaultValue Default visibility/visibility-off icons
|
|
1020
|
+
*/
|
|
1021
|
+
renderIcon?: (password: boolean) => ReactNode;
|
|
1022
|
+
/**
|
|
1023
|
+
* Grid layout props for the wrapper Grid component
|
|
1024
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
1025
|
+
*/
|
|
1026
|
+
gridProps?: GridProps;
|
|
1027
|
+
};
|
|
1028
|
+
/**
|
|
1029
|
+
* A react-hook-form integrated password TextField with show/hide functionality.
|
|
1030
|
+
*
|
|
1031
|
+
* This component provides a fully integrated password input that works seamlessly with react-hook-form,
|
|
1032
|
+
* including automatic validation, error handling, and a built-in visibility toggle button. The password
|
|
1033
|
+
* can be shown or hidden by clicking the eye icon in the input's end adornment.
|
|
1034
|
+
*
|
|
1035
|
+
* Features:
|
|
1036
|
+
* - Full react-hook-form integration
|
|
1037
|
+
* - Password visibility toggle
|
|
1038
|
+
* - Automatic error display
|
|
1039
|
+
* - Customizable visibility icons
|
|
1040
|
+
* - Grid layout wrapper
|
|
1041
|
+
* - TypeScript type safety
|
|
1042
|
+
* - Disabled state support
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* Basic usage:
|
|
1046
|
+
* ```tsx
|
|
1047
|
+
* <PasswordElement
|
|
1048
|
+
* control={control}
|
|
1049
|
+
* name="password"
|
|
1050
|
+
* label="Password"
|
|
1051
|
+
* rules={{
|
|
1052
|
+
* required: 'Password is required',
|
|
1053
|
+
* minLength: { value: 8, message: 'Minimum 8 characters' }
|
|
1054
|
+
* }}
|
|
1055
|
+
* />
|
|
1056
|
+
* ```
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* With custom icon color:
|
|
1060
|
+
* ```tsx
|
|
1061
|
+
* <PasswordElement
|
|
1062
|
+
* control={control}
|
|
1063
|
+
* name="confirmPassword"
|
|
1064
|
+
* label="Confirm Password"
|
|
1065
|
+
* iconColor="primary"
|
|
1066
|
+
* placeholder="Re-enter your password"
|
|
1067
|
+
* />
|
|
1068
|
+
* ```
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* Custom grid layout:
|
|
1072
|
+
* ```tsx
|
|
1073
|
+
* <PasswordElement
|
|
1074
|
+
* control={control}
|
|
1075
|
+
* name="newPassword"
|
|
1076
|
+
* label="New Password"
|
|
1077
|
+
* gridProps={{ size: { xs: 12, md: 6 } }}
|
|
1078
|
+
* renderIcon={(hidden) => hidden ? <CustomHideIcon /> : <CustomShowIcon />}
|
|
1079
|
+
* />
|
|
1080
|
+
* ```
|
|
1081
|
+
*
|
|
1082
|
+
* @template TFieldValues - The form values type
|
|
1083
|
+
* @template TName - The field name type
|
|
1084
|
+
* @template TValue - The value type
|
|
1085
|
+
*
|
|
1086
|
+
* @param props - Component props
|
|
1087
|
+
* @returns React element with optional Grid wrapper
|
|
1088
|
+
*
|
|
1089
|
+
* @public
|
|
1090
|
+
*/
|
|
1091
|
+
declare const PasswordElement: {
|
|
1092
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue = unknown>({ gridProps, ...props }: PasswordElementProps<TFieldValues, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
1093
|
+
displayName: string;
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
type PrimitiveValue = string | number | boolean;
|
|
1097
|
+
type OptionObject<TValueKey extends string = string, TLabelKey extends string = string, TDisabledKey extends string = string> = Record<TValueKey, PrimitiveValue> & Record<TLabelKey, string> & Partial<Record<TDisabledKey, boolean>> & Record<string, unknown>;
|
|
1098
|
+
interface RadioButtonGroupProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TOption extends OptionObject<TValueKey, TLabelKey, TDisabledKey> = OptionObject, TValueKey extends keyof TOption & string = "id", TLabelKey extends keyof TOption & string = "label", TDisabledKey extends keyof TOption & string = "disabled"> {
|
|
1099
|
+
options: TOption[];
|
|
1100
|
+
helperText?: ReactNode;
|
|
1101
|
+
name: TName;
|
|
1102
|
+
required?: boolean;
|
|
1103
|
+
parseError?: (error: FieldError) => ReactNode;
|
|
1104
|
+
label?: string;
|
|
1105
|
+
labelKey?: TLabelKey;
|
|
1106
|
+
valueKey?: TValueKey;
|
|
1107
|
+
disabledKey?: TDisabledKey;
|
|
1108
|
+
type?: "number" | "string" | "boolean";
|
|
1109
|
+
emptyOptionLabel?: string;
|
|
1110
|
+
onChange?: (value: TOption[TValueKey] | TOption | undefined) => void;
|
|
1111
|
+
returnObject?: boolean;
|
|
1112
|
+
row?: boolean;
|
|
1113
|
+
control?: Control<TFieldValues>;
|
|
1114
|
+
labelProps?: Omit<FormControlLabelProps, "label" | "control" | "value">;
|
|
1115
|
+
formLabelProps?: Omit<FormLabelProps, "required" | "error">;
|
|
1116
|
+
radioProps?: RadioProps;
|
|
1117
|
+
disabled?: boolean;
|
|
1118
|
+
transform?: {
|
|
1119
|
+
input?: (value: PathValue<TFieldValues, TName>) => TOption[TValueKey];
|
|
1120
|
+
output?: (value: TOption[TValueKey] | TOption | undefined) => PathValue<TFieldValues, TName>;
|
|
1121
|
+
};
|
|
1122
|
+
gridProps?: GridProps;
|
|
1123
|
+
}
|
|
1124
|
+
declare const RadioButtonGroup: {
|
|
1125
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TOption extends OptionObject<TValueKey, TLabelKey, TDisabledKey> = OptionObject<string, string, string>, TValueKey extends keyof TOption & string = "id", TLabelKey extends keyof TOption & string = "label", TDisabledKey extends keyof TOption & string = "disabled">({ gridProps, ...props }: RadioButtonGroupProps<TFieldValues, TName, TOption, TValueKey, TLabelKey, TDisabledKey>): react_jsx_runtime.JSX.Element;
|
|
1126
|
+
displayName: string;
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
type SelectCascadeElementProps<TOption, TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = Omit<AutocompleteProps<TOption, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'name' | 'renderInput' | 'isOptionEqualToValue' | 'getOptionLabel' | 'disabled'> & {
|
|
1130
|
+
rules?: UseControllerProps<TFieldValues, TName>['rules'];
|
|
1131
|
+
name: TName;
|
|
1132
|
+
dependsOn: TName;
|
|
1133
|
+
control?: Control<TFieldValues>;
|
|
1134
|
+
gridProps?: GridProps;
|
|
1135
|
+
placeholder?: string;
|
|
1136
|
+
label?: string;
|
|
1137
|
+
variant?: TextFieldVariants;
|
|
1138
|
+
disabled?: boolean;
|
|
1139
|
+
sx?: SxProps;
|
|
1140
|
+
isEdit?: boolean;
|
|
1141
|
+
labelKey?: keyof TOption;
|
|
1142
|
+
valueKey?: keyof TOption;
|
|
1143
|
+
textFieldProps?: Omit<TextFieldProps, 'name'>;
|
|
1144
|
+
};
|
|
1145
|
+
declare const SelectCascadeElement: {
|
|
1146
|
+
<TOption, TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ gridProps, ...props }: SelectCascadeElementProps<TOption, TFieldValues, TName>): React.ReactElement;
|
|
1147
|
+
displayName: string;
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Props for the SelectElement component.
|
|
1152
|
+
*
|
|
1153
|
+
* @template TOption - The option object type
|
|
1154
|
+
* @template TFieldValues - The form values type
|
|
1155
|
+
* @template TName - The field name type
|
|
1156
|
+
* @template Multiple - Whether multiple selection is enabled
|
|
1157
|
+
* @template DisableClearable - Whether the clear button is disabled
|
|
1158
|
+
* @template FreeSolo - Whether free text input is allowed
|
|
1159
|
+
* @template ChipComponent - The chip component type for multiple selection
|
|
1160
|
+
*
|
|
1161
|
+
* @public
|
|
1162
|
+
*/
|
|
1163
|
+
type SelectElementProps<TOption, TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap["defaultComponent"]> = Omit<AutocompleteProps<TOption, Multiple, DisableClearable, FreeSolo, ChipComponent>, "name" | "renderInput" | "isOptionEqualToValue" | "getOptionLabel" | "disabled"> & {
|
|
1164
|
+
/**
|
|
1165
|
+
* Validation rules for the field
|
|
1166
|
+
* @example { required: 'Please select an option' }
|
|
1167
|
+
*/
|
|
1168
|
+
rules?: UseControllerProps<TFieldValues, TName>["rules"];
|
|
1169
|
+
/**
|
|
1170
|
+
* The field name in the form
|
|
1171
|
+
* @example "category" | "user.department"
|
|
1172
|
+
*/
|
|
1173
|
+
name: TName;
|
|
1174
|
+
/**
|
|
1175
|
+
* The form control instance from react-hook-form
|
|
1176
|
+
*/
|
|
1177
|
+
control?: Control<TFieldValues>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Grid layout props for the wrapper Grid component
|
|
1180
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
1181
|
+
*/
|
|
1182
|
+
gridProps?: GridProps;
|
|
1183
|
+
/**
|
|
1184
|
+
* Placeholder text for the select input
|
|
1185
|
+
* @example "Choose an option..."
|
|
1186
|
+
*/
|
|
1187
|
+
placeholder?: string;
|
|
1188
|
+
/**
|
|
1189
|
+
* The input label text
|
|
1190
|
+
* @example "Category"
|
|
1191
|
+
*/
|
|
1192
|
+
label?: string;
|
|
1193
|
+
/**
|
|
1194
|
+
* The TextField variant
|
|
1195
|
+
* @defaultValue "outlined"
|
|
1196
|
+
*/
|
|
1197
|
+
variant?: TextFieldVariants;
|
|
1198
|
+
/**
|
|
1199
|
+
* Custom styles for the component
|
|
1200
|
+
*/
|
|
1201
|
+
sx?: SxProps;
|
|
1202
|
+
/**
|
|
1203
|
+
* Whether the component is in edit mode (affects auto-selection behavior)
|
|
1204
|
+
* When false and only one option exists, that option is auto-selected
|
|
1205
|
+
* @defaultValue false
|
|
1206
|
+
*/
|
|
1207
|
+
isEdit?: boolean;
|
|
1208
|
+
/**
|
|
1209
|
+
* Whether the select is disabled
|
|
1210
|
+
*/
|
|
1211
|
+
disabled?: boolean;
|
|
1212
|
+
/**
|
|
1213
|
+
* The property name in option objects to use as display label
|
|
1214
|
+
* @defaultValue "Label"
|
|
1215
|
+
* @example "name" | "title"
|
|
1216
|
+
*/
|
|
1217
|
+
labelKey?: string;
|
|
1218
|
+
/**
|
|
1219
|
+
* The property name in option objects to use as the value
|
|
1220
|
+
* @defaultValue "Value"
|
|
1221
|
+
* @example "id" | "code"
|
|
1222
|
+
*/
|
|
1223
|
+
valueKey?: keyof TOption;
|
|
1224
|
+
/**
|
|
1225
|
+
* Additional props for the underlying TextField component
|
|
1226
|
+
*/
|
|
1227
|
+
textFieldProps?: Omit<TextFieldProps, "name">;
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* A react-hook-form integrated Autocomplete component for selecting from predefined options.
|
|
1231
|
+
*
|
|
1232
|
+
* This component provides a fully integrated select/autocomplete input that works seamlessly
|
|
1233
|
+
* with react-hook-form, including automatic validation, error handling, and optional Grid wrapper
|
|
1234
|
+
* for responsive layouts. It supports both single and multiple selection modes.
|
|
1235
|
+
*
|
|
1236
|
+
* Features:
|
|
1237
|
+
* - Full react-hook-form integration
|
|
1238
|
+
* - Autocomplete with filtering
|
|
1239
|
+
* - Single and multiple selection support
|
|
1240
|
+
* - Automatic error display
|
|
1241
|
+
* - Customizable option display (labelKey/valueKey)
|
|
1242
|
+
* - Auto-selection when only one option exists
|
|
1243
|
+
* - Grid layout wrapper
|
|
1244
|
+
* - TypeScript type safety
|
|
1245
|
+
* - Disabled state styling
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* Basic usage:
|
|
1249
|
+
* ```tsx
|
|
1250
|
+
* <SelectElement
|
|
1251
|
+
* control={control}
|
|
1252
|
+
* name="category"
|
|
1253
|
+
* label="Category"
|
|
1254
|
+
* options={[
|
|
1255
|
+
* { Label: 'Technology', Value: 'tech' },
|
|
1256
|
+
* { Label: 'Finance', Value: 'finance' }
|
|
1257
|
+
* ]}
|
|
1258
|
+
* rules={{ required: 'Please select a category' }}
|
|
1259
|
+
* />
|
|
1260
|
+
* ```
|
|
1261
|
+
*
|
|
1262
|
+
* @example
|
|
1263
|
+
* With custom keys:
|
|
1264
|
+
* ```tsx
|
|
1265
|
+
* <SelectElement
|
|
1266
|
+
* control={control}
|
|
1267
|
+
* name="userId"
|
|
1268
|
+
* label="Assign to User"
|
|
1269
|
+
* options={users}
|
|
1270
|
+
* labelKey="fullName"
|
|
1271
|
+
* valueKey="id"
|
|
1272
|
+
* placeholder="Choose a user..."
|
|
1273
|
+
* />
|
|
1274
|
+
* ```
|
|
1275
|
+
*
|
|
1276
|
+
* @example
|
|
1277
|
+
* Multiple selection:
|
|
1278
|
+
* ```tsx
|
|
1279
|
+
* <SelectElement
|
|
1280
|
+
* control={control}
|
|
1281
|
+
* name="tags"
|
|
1282
|
+
* label="Tags"
|
|
1283
|
+
* options={availableTags}
|
|
1284
|
+
* multiple
|
|
1285
|
+
* gridProps={{ size: { xs: 12, md: 8 } }}
|
|
1286
|
+
* />
|
|
1287
|
+
* ```
|
|
1288
|
+
*
|
|
1289
|
+
* @template TOption - The option object type
|
|
1290
|
+
* @template TFieldValues - The form values type
|
|
1291
|
+
* @template TName - The field name type
|
|
1292
|
+
* @template Multiple - Whether multiple selection is enabled
|
|
1293
|
+
* @template DisableClearable - Whether the clear button is disabled
|
|
1294
|
+
* @template FreeSolo - Whether free text input is allowed
|
|
1295
|
+
* @template ChipComponent - The chip component type for multiple selection
|
|
1296
|
+
*
|
|
1297
|
+
* @param props - Component props
|
|
1298
|
+
* @returns React element with optional Grid wrapper
|
|
1299
|
+
*
|
|
1300
|
+
* @public
|
|
1301
|
+
*/
|
|
1302
|
+
declare const SelectElement: {
|
|
1303
|
+
<TOption extends Record<string, any> = Record<string, any>, TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = "div">({ gridProps, ...props }: SelectElementProps<TOption, TFieldValues, TName, Multiple, DisableClearable, FreeSolo, ChipComponent>): React.ReactElement;
|
|
1304
|
+
displayName: string;
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
type BaseAutocompleteProps<TOption, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType> = Omit<AutocompleteProps<TOption, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'name' | 'renderInput' | 'multiple' | 'onChange' | 'value'>;
|
|
1308
|
+
type SelectMultiElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TOption extends Record<string, any> = Record<string, any>, Multiple extends boolean | undefined = true, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> = BaseAutocompleteProps<TOption, Multiple, DisableClearable, FreeSolo, ChipComponent> & {
|
|
1309
|
+
rules?: UseControllerProps<TFieldValues, TName>['rules'];
|
|
1310
|
+
name: TName;
|
|
1311
|
+
control?: Control<TFieldValues>;
|
|
1312
|
+
gridProps?: GridProps;
|
|
1313
|
+
placeholder?: string;
|
|
1314
|
+
label?: string;
|
|
1315
|
+
variant?: TextFieldVariants;
|
|
1316
|
+
sx?: SxProps;
|
|
1317
|
+
labelKey?: keyof TOption;
|
|
1318
|
+
valueKey?: keyof TOption;
|
|
1319
|
+
};
|
|
1320
|
+
declare const SelectMultiElement: {
|
|
1321
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TOption extends Record<string, any> = Record<string, any>>({ gridProps, ...props }: SelectMultiElementProps<TFieldValues, TName, TOption>): React.ReactElement;
|
|
1322
|
+
displayName: string;
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Props for the TextFieldElement component.
|
|
1327
|
+
*
|
|
1328
|
+
* @template TFieldValues - The form values type
|
|
1329
|
+
* @template TName - The field name type
|
|
1330
|
+
* @template TValue - The transformed value type
|
|
1331
|
+
*
|
|
1332
|
+
* @public
|
|
1333
|
+
*/
|
|
1334
|
+
interface TextFieldElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue = unknown> {
|
|
1335
|
+
/**
|
|
1336
|
+
* Validation rules for the field
|
|
1337
|
+
* @example { required: 'This field is required', minLength: { value: 3, message: 'Minimum 3 characters' } }
|
|
1338
|
+
*/
|
|
1339
|
+
rules?: UseControllerProps<TFieldValues, TName>["rules"];
|
|
1340
|
+
/**
|
|
1341
|
+
* The field name in the form
|
|
1342
|
+
* @example "firstName" | "user.email"
|
|
1343
|
+
*/
|
|
1344
|
+
name: TName;
|
|
1345
|
+
/**
|
|
1346
|
+
* Custom error message parser
|
|
1347
|
+
* @param error - The field error object
|
|
1348
|
+
* @returns Custom error message or component
|
|
1349
|
+
*/
|
|
1350
|
+
parseError?: (error: FieldError) => ReactNode;
|
|
1351
|
+
/**
|
|
1352
|
+
* The form control instance from react-hook-form
|
|
1353
|
+
*/
|
|
1354
|
+
control?: Control<TFieldValues>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Custom TextField component to use instead of default MUI TextField
|
|
1357
|
+
*/
|
|
1358
|
+
component?: typeof TextField;
|
|
1359
|
+
/**
|
|
1360
|
+
* Value transformation functions for input/output
|
|
1361
|
+
*/
|
|
1362
|
+
transform?: {
|
|
1363
|
+
/** Transform value before displaying in input */
|
|
1364
|
+
input?: (value: PathValue<TFieldValues, TName>) => TValue;
|
|
1365
|
+
/** Transform input event to form value */
|
|
1366
|
+
output?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => PathValue<TFieldValues, TName>;
|
|
1367
|
+
};
|
|
1368
|
+
/**
|
|
1369
|
+
* The input label text
|
|
1370
|
+
* @example "Email Address"
|
|
1371
|
+
*/
|
|
1372
|
+
label?: string;
|
|
1373
|
+
/**
|
|
1374
|
+
* Placeholder text for the input
|
|
1375
|
+
* @example "Enter your email"
|
|
1376
|
+
*/
|
|
1377
|
+
placeholder?: string;
|
|
1378
|
+
/**
|
|
1379
|
+
* Additional props for the underlying TextField component
|
|
1380
|
+
*/
|
|
1381
|
+
textFieldProps?: Omit<TextFieldProps, "name">;
|
|
1382
|
+
/**
|
|
1383
|
+
* Grid layout props for the wrapper Grid component
|
|
1384
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
1385
|
+
*/
|
|
1386
|
+
gridProps?: GridProps;
|
|
1387
|
+
/**
|
|
1388
|
+
* The TextField variant
|
|
1389
|
+
* @defaultValue "outlined"
|
|
1390
|
+
*/
|
|
1391
|
+
variant?: TextFieldVariants;
|
|
1392
|
+
/**
|
|
1393
|
+
* Custom styles for the TextField
|
|
1394
|
+
*/
|
|
1395
|
+
sx?: SxProps;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* A react-hook-form integrated TextField component with automatic validation and grid layout.
|
|
1399
|
+
*
|
|
1400
|
+
* This component provides a fully integrated TextField that works seamlessly with react-hook-form,
|
|
1401
|
+
* including automatic validation, error handling, and optional Grid wrapper for responsive layouts.
|
|
1402
|
+
*
|
|
1403
|
+
* Features:
|
|
1404
|
+
* - Full react-hook-form integration
|
|
1405
|
+
* - Automatic error display
|
|
1406
|
+
* - Value transformation support
|
|
1407
|
+
* - Grid layout wrapper
|
|
1408
|
+
* - TypeScript type safety
|
|
1409
|
+
* - Number input handling
|
|
1410
|
+
* - Disabled state styling
|
|
1411
|
+
*
|
|
1412
|
+
* @example
|
|
1413
|
+
* Basic usage:
|
|
1414
|
+
* ```tsx
|
|
1415
|
+
* <TextFieldElement
|
|
1416
|
+
* control={control}
|
|
1417
|
+
* name="firstName"
|
|
1418
|
+
* label="First Name"
|
|
1419
|
+
* rules={{ required: 'First name is required' }}
|
|
1420
|
+
* />
|
|
1421
|
+
* ```
|
|
1422
|
+
*
|
|
1423
|
+
* @example
|
|
1424
|
+
* With custom grid layout:
|
|
1425
|
+
* ```tsx
|
|
1426
|
+
* <TextFieldElement
|
|
1427
|
+
* control={control}
|
|
1428
|
+
* name="email"
|
|
1429
|
+
* label="Email"
|
|
1430
|
+
* type="email"
|
|
1431
|
+
* gridProps={{ size: { xs: 12, md: 6 } }}
|
|
1432
|
+
* rules={{
|
|
1433
|
+
* required: 'Email is required',
|
|
1434
|
+
* pattern: { value: /\S+@\S+\.\S+/, message: 'Invalid email' }
|
|
1435
|
+
* }}
|
|
1436
|
+
* />
|
|
1437
|
+
* ```
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* Number input with transformation:
|
|
1441
|
+
* ```tsx
|
|
1442
|
+
* <TextFieldElement
|
|
1443
|
+
* control={control}
|
|
1444
|
+
* name="age"
|
|
1445
|
+
* label="Age"
|
|
1446
|
+
* textFieldProps={{ type: 'number' }}
|
|
1447
|
+
* transform={{
|
|
1448
|
+
* input: (value) => value?.toString() || '',
|
|
1449
|
+
* output: (event) => parseInt(event.target.value) || null
|
|
1450
|
+
* }}
|
|
1451
|
+
* />
|
|
1452
|
+
* ```
|
|
1453
|
+
*
|
|
1454
|
+
* @template TFieldValues - The form values type
|
|
1455
|
+
* @template TName - The field name type
|
|
1456
|
+
* @template TValue - The transformed value type
|
|
1457
|
+
*
|
|
1458
|
+
* @param props - Component props
|
|
1459
|
+
* @returns React element with optional Grid wrapper
|
|
1460
|
+
*
|
|
1461
|
+
* @public
|
|
1462
|
+
*/
|
|
1463
|
+
declare const TextFieldElement: {
|
|
1464
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue = unknown>({ gridProps, ...props }: TextFieldElementProps<TFieldValues, TName, TValue>): React$1.ReactElement;
|
|
1465
|
+
displayName: string;
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1468
|
+
/**
|
|
1469
|
+
* Props for the EnhancedTextFieldElement component.
|
|
1470
|
+
*
|
|
1471
|
+
* @template TFieldValues - The form values type
|
|
1472
|
+
* @template TName - The field name type
|
|
1473
|
+
* @template TValue - The transformed value type
|
|
1474
|
+
*
|
|
1475
|
+
* @public
|
|
1476
|
+
*/
|
|
1477
|
+
interface EnhancedTextFieldElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue = PathValue<TFieldValues, TName>> {
|
|
1478
|
+
/**
|
|
1479
|
+
* Validation rules for the field
|
|
1480
|
+
* @example { required: 'This field is required', minLength: { value: 3, message: 'Minimum 3 characters' } }
|
|
1481
|
+
*/
|
|
1482
|
+
rules?: UseControllerProps<TFieldValues, TName>["rules"];
|
|
1483
|
+
/**
|
|
1484
|
+
* The field name in the form
|
|
1485
|
+
* @example "firstName" | "user.email"
|
|
1486
|
+
*/
|
|
1487
|
+
name: TName;
|
|
1488
|
+
/**
|
|
1489
|
+
* Custom error message parser
|
|
1490
|
+
* @param error - The field error object
|
|
1491
|
+
* @returns Custom error message or component
|
|
1492
|
+
*/
|
|
1493
|
+
parseError?: (error: FieldError) => ReactNode;
|
|
1494
|
+
/**
|
|
1495
|
+
* The form control instance from react-hook-form
|
|
1496
|
+
*/
|
|
1497
|
+
control?: Control<TFieldValues>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Custom TextField component to use instead of default MUI TextField
|
|
1500
|
+
*/
|
|
1501
|
+
component?: typeof TextField;
|
|
1502
|
+
/**
|
|
1503
|
+
* Value transformation functions for input/output
|
|
1504
|
+
* @deprecated Use fieldType for common patterns or custom transforms for complex cases
|
|
1505
|
+
*/
|
|
1506
|
+
transform?: {
|
|
1507
|
+
/** Transform value before displaying in input */
|
|
1508
|
+
input?: (value: PathValue<TFieldValues, TName>) => TValue;
|
|
1509
|
+
/** Transform input event to form value */
|
|
1510
|
+
output?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => PathValue<TFieldValues, TName>;
|
|
1511
|
+
};
|
|
1512
|
+
/**
|
|
1513
|
+
* Built-in field type for automatic transformation
|
|
1514
|
+
* @example 'text' | 'number' | 'date' | 'time' | 'select'
|
|
1515
|
+
*/
|
|
1516
|
+
fieldType?: FieldType;
|
|
1517
|
+
/**
|
|
1518
|
+
* Default value to display when field value is null/undefined
|
|
1519
|
+
* @example ""
|
|
1520
|
+
*/
|
|
1521
|
+
defaultValue?: TValue;
|
|
1522
|
+
/**
|
|
1523
|
+
* The input label text
|
|
1524
|
+
* @example "Email Address"
|
|
1525
|
+
*/
|
|
1526
|
+
label?: string;
|
|
1527
|
+
/**
|
|
1528
|
+
* Placeholder text for the input
|
|
1529
|
+
* @example "Enter your email"
|
|
1530
|
+
*/
|
|
1531
|
+
placeholder?: string;
|
|
1532
|
+
/**
|
|
1533
|
+
* Additional props for the underlying TextField component
|
|
1534
|
+
*/
|
|
1535
|
+
textFieldProps?: Omit<TextFieldProps, "name">;
|
|
1536
|
+
/**
|
|
1537
|
+
* Grid layout props for the wrapper Grid component
|
|
1538
|
+
* @defaultValue { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } }
|
|
1539
|
+
*/
|
|
1540
|
+
gridProps?: GridProps;
|
|
1541
|
+
/**
|
|
1542
|
+
* The TextField variant
|
|
1543
|
+
* @defaultValue "outlined"
|
|
1544
|
+
*/
|
|
1545
|
+
variant?: TextFieldVariants;
|
|
1546
|
+
/**
|
|
1547
|
+
* Custom styles for the TextField
|
|
1548
|
+
*/
|
|
1549
|
+
sx?: SxProps;
|
|
1550
|
+
/**
|
|
1551
|
+
* Custom onChange handler called after transformation
|
|
1552
|
+
*/
|
|
1553
|
+
onChange?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
1554
|
+
/**
|
|
1555
|
+
* Enable development warnings for debugging transformation issues
|
|
1556
|
+
* @defaultValue process.env.NODE_ENV === 'development'
|
|
1557
|
+
*/
|
|
1558
|
+
enableWarnings?: boolean;
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* An enhanced react-hook-form integrated TextField component with automatic validation,
|
|
1562
|
+
* performance optimizations, and built-in field type handling.
|
|
1563
|
+
*
|
|
1564
|
+
* This enhanced version provides all the functionality of the original TextFieldElement
|
|
1565
|
+
* plus additional features:
|
|
1566
|
+
* - Performance optimizations with memoized transformations
|
|
1567
|
+
* - Built-in field type handling (number, text, etc.)
|
|
1568
|
+
* - Better TypeScript inference and type safety
|
|
1569
|
+
* - Development warnings for debugging
|
|
1570
|
+
* - Stable references to prevent unnecessary re-renders
|
|
1571
|
+
* - Enhanced error handling with custom parseError support
|
|
1572
|
+
*
|
|
1573
|
+
* Features:
|
|
1574
|
+
* - Full react-hook-form integration
|
|
1575
|
+
* - Automatic error display with custom parsing
|
|
1576
|
+
* - Value transformation support (backward compatible)
|
|
1577
|
+
* - Built-in field types for common patterns
|
|
1578
|
+
* - Grid layout wrapper
|
|
1579
|
+
* - Enhanced TypeScript type safety
|
|
1580
|
+
* - Optimized number input handling
|
|
1581
|
+
* - Disabled state styling
|
|
1582
|
+
* - Performance optimizations
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
* Basic usage with built-in number handling:
|
|
1586
|
+
* ```tsx
|
|
1587
|
+
* <EnhancedTextFieldElement
|
|
1588
|
+
* control={control}
|
|
1589
|
+
* name="age"
|
|
1590
|
+
* label="Age"
|
|
1591
|
+
* fieldType="number"
|
|
1592
|
+
* rules={{ required: 'Age is required', min: { value: 0, message: 'Age must be positive' } }}
|
|
1593
|
+
* />
|
|
1594
|
+
* ```
|
|
1595
|
+
*
|
|
1596
|
+
* @example
|
|
1597
|
+
* Advanced usage with custom grid layout:
|
|
1598
|
+
* ```tsx
|
|
1599
|
+
* <EnhancedTextFieldElement
|
|
1600
|
+
* control={control}
|
|
1601
|
+
* name="email"
|
|
1602
|
+
* label="Email"
|
|
1603
|
+
* fieldType="text"
|
|
1604
|
+
* placeholder="Enter your email address"
|
|
1605
|
+
* gridProps={{ size: { xs: 12, md: 6 } }}
|
|
1606
|
+
* rules={{
|
|
1607
|
+
* required: 'Email is required',
|
|
1608
|
+
* pattern: { value: /\S+@\S+\.\S+/, message: 'Invalid email' }
|
|
1609
|
+
* }}
|
|
1610
|
+
* />
|
|
1611
|
+
* ```
|
|
1612
|
+
*
|
|
1613
|
+
* @example
|
|
1614
|
+
* Custom transformation (backward compatible):
|
|
1615
|
+
* ```tsx
|
|
1616
|
+
* <EnhancedTextFieldElement
|
|
1617
|
+
* control={control}
|
|
1618
|
+
* name="price"
|
|
1619
|
+
* label="Price"
|
|
1620
|
+
* transform={{
|
|
1621
|
+
* input: (value) => value ? `$${value}` : '',
|
|
1622
|
+
* output: (event) => parseFloat(event.target.value.replace('$', '')) || null
|
|
1623
|
+
* }}
|
|
1624
|
+
* />
|
|
1625
|
+
* ```
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* With custom error parsing:
|
|
1629
|
+
* ```tsx
|
|
1630
|
+
* <EnhancedTextFieldElement
|
|
1631
|
+
* control={control}
|
|
1632
|
+
* name="username"
|
|
1633
|
+
* label="Username"
|
|
1634
|
+
* fieldType="text"
|
|
1635
|
+
* parseError={(error) => (
|
|
1636
|
+
* <span style={{ color: 'red' }}>
|
|
1637
|
+
* ⚠️ {error.message}
|
|
1638
|
+
* </span>
|
|
1639
|
+
* )}
|
|
1640
|
+
* />
|
|
1641
|
+
* ```
|
|
1642
|
+
*
|
|
1643
|
+
* @template TFieldValues - The form values type
|
|
1644
|
+
* @template TName - The field name type
|
|
1645
|
+
* @template TValue - The transformed value type
|
|
1646
|
+
*
|
|
1647
|
+
* @param props - Component props
|
|
1648
|
+
* @returns React element with optional Grid wrapper
|
|
1649
|
+
*
|
|
1650
|
+
* @public
|
|
1651
|
+
*/
|
|
1652
|
+
declare const EnhancedTextFieldElement: {
|
|
1653
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue = PathValue<TFieldValues, TName>>({ gridProps, ...props }: EnhancedTextFieldElementProps<TFieldValues, TName, TValue>): React$1.ReactElement;
|
|
1654
|
+
displayName: string;
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
interface TimePickerElementProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends PickerValidDate = PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false> {
|
|
1658
|
+
name: TName;
|
|
1659
|
+
required?: boolean;
|
|
1660
|
+
isDate?: boolean;
|
|
1661
|
+
parseError?: (error: FieldError | TimeValidationError) => ReactNode;
|
|
1662
|
+
rules?: UseControllerProps<TFieldValues, TName>["rules"];
|
|
1663
|
+
control?: Control<TFieldValues>;
|
|
1664
|
+
inputProps?: TextFieldProps;
|
|
1665
|
+
helperText?: TextFieldProps["helperText"];
|
|
1666
|
+
label?: ReactNode;
|
|
1667
|
+
placeholder?: string;
|
|
1668
|
+
textReadOnly?: boolean;
|
|
1669
|
+
slotProps?: Omit<TimePickerSlotProps<TEnableAccessibleFieldDOMStructure>, "textField">;
|
|
1670
|
+
transform?: {
|
|
1671
|
+
input?: (value: PathValue<TFieldValues, TName>) => TValue | null;
|
|
1672
|
+
output?: (value: TValue | null, context: PickerChangeHandlerContext<TimeValidationError>) => PathValue<TFieldValues, TName>;
|
|
1673
|
+
};
|
|
1674
|
+
gridProps?: GridProps;
|
|
1675
|
+
timePickerProps?: Omit<TimePickerProps<TEnableAccessibleFieldDOMStructure>, "value" | "slotProps">;
|
|
1676
|
+
variant?: TextFieldVariants;
|
|
1677
|
+
sx?: SxProps;
|
|
1678
|
+
}
|
|
1679
|
+
declare const TimePickerElement: {
|
|
1680
|
+
<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TValue extends unknown = any>({ gridProps, ...props }: TimePickerElementProps<TFieldValues, TName, TValue>): React$1.ReactElement;
|
|
1681
|
+
displayName: string;
|
|
1682
|
+
};
|
|
1683
|
+
|
|
1684
|
+
export { AsyncMultiSelect2, type AsyncMultiSelect2Props, type AsyncSelect2Payload, type BrandedDate, CheckboxElement, type CheckboxElementProps, CheckboxGroup, type CheckboxGroupProps, DatePickerElement, DatePickerElementCore, type DatePickerElementCoreProps, type DatePickerElementGridProps, type DatePickerElementProps, type DatePickerHookReturn, type DatePickerValidationConfig, type DateTransform, EnhancedTextFieldElement, type EnhancedTextFieldElementProps, type Option2Item, type OptionObject$1 as OptionObject, PasswordElement, RadioButtonGroup, SelectCascadeElement, SelectElement, SelectMultiElement, TextFieldElement, TimePickerElement, type TypedDatePickerSlotProps, type UseDatePickerStylesOptions, type UseDatePickerStylesReturn, type UseDatePickerValidationOptions, type UseDatePickerValidationReturn, type UseDatePickerValueOptions, type UseDatePickerValueReturn, type ValidatedDate, createDateInputTransform, createDateOutputTransform, createDefaultDatePickerConfig, createStableKey, extractErrorMessage, isParsableDateString, isValidDate, readDatePickerValueAsDate, useDatePickerStyles, useDatePickerValidation, useDatePickerValue };
|