@ultraviolet/form 2.0.0-next.5 → 2.0.0-next.7
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/components/CheckboxField/index.js +50 -48
- package/dist/components/CheckboxGroupField/index.js +34 -34
- package/dist/components/DateField/index.js +65 -61
- package/dist/components/Form/index.js +31 -71
- package/dist/components/NumberInputField/index.js +38 -49
- package/dist/components/RadioField/index.js +42 -40
- package/dist/components/RadioGroupField/index.js +31 -31
- package/dist/components/SelectInputField/index.js +66 -61
- package/dist/components/SelectableCardField/index.js +48 -40
- package/dist/components/Submit/index.js +18 -6
- package/dist/components/SubmitErrorAlert/index.js +16 -9
- package/dist/components/TagInputField/index.js +25 -24
- package/dist/components/TextInputField/index.js +108 -98
- package/dist/components/TimeField/index.js +53 -52
- package/dist/components/ToggleField/index.js +52 -43
- package/dist/hooks/useOnFieldChange.js +20 -17
- package/dist/index.d.ts +207 -256
- package/dist/index.js +5 -6
- package/dist/providers/ErrorContext/index.js +46 -8
- package/dist/validators/maxDate.js +4 -1
- package/dist/validators/minDate.js +4 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
export { FieldArray, useFieldArray } from 'react-final-form-arrays';
|
|
2
|
+
import { FieldSubscription, AnyObject, FieldValidator, FieldState } from 'final-form';
|
|
3
|
+
export { FORM_ERROR, FormApi } from 'final-form';
|
|
4
|
+
import { UseFieldConfig, FieldMetaState, FormRenderProps, FormProps as FormProps$1 } from 'react-final-form';
|
|
5
|
+
export { Field, FormSpy, useField, useForm, useFormState } from 'react-final-form';
|
|
3
6
|
import * as react from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import * as
|
|
6
|
-
import {
|
|
7
|
-
export { ControllerRenderProps, DeepPartial, FieldErrors, FieldPath, FieldValues, Path, PathValue, UseFieldArrayMove, UseFieldArrayRemove, UseFormReturn, UseFormSetValue, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
|
|
7
|
+
import { ReactNode, ComponentProps, FocusEvent, ForwardedRef, FocusEventHandler } from 'react';
|
|
8
|
+
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
9
|
+
import { CheckboxGroup, DateInput, Radio, SelectInput, SelectableCard, NumberInput, TagInput, TextInput, TimeInput, Toggle, Button, RadioGroup } from '@ultraviolet/ui';
|
|
8
10
|
import { CSSObject, Theme, css } from '@emotion/react';
|
|
9
|
-
import Select, {
|
|
11
|
+
import Select, { GroupBase, OptionProps, Props, CommonProps } from 'react-select';
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
type FormErrorFunctionParams<InputValue = unknown> = {
|
|
14
|
+
label: string;
|
|
15
|
+
name: string;
|
|
16
|
+
value: InputValue;
|
|
17
|
+
allValues: AnyObject;
|
|
18
|
+
meta?: FieldMetaState<InputValue>;
|
|
19
|
+
};
|
|
20
|
+
type RequiredErrors = {
|
|
21
|
+
TOO_LOW: ((params: FormErrorFunctionParams & {
|
|
22
|
+
min: number;
|
|
23
|
+
}) => string) | string;
|
|
24
|
+
TOO_HIGH: ((params: FormErrorFunctionParams & {
|
|
25
|
+
max: number;
|
|
26
|
+
}) => string) | string;
|
|
27
|
+
MIN_LENGTH: ((params: FormErrorFunctionParams & {
|
|
28
|
+
minLength: number;
|
|
29
|
+
}) => string) | string;
|
|
30
|
+
MAX_LENGTH: ((params: FormErrorFunctionParams & {
|
|
31
|
+
maxLength: number;
|
|
32
|
+
}) => string) | string;
|
|
33
|
+
REGEX: ((params: FormErrorFunctionParams & {
|
|
34
|
+
regex: (RegExp | RegExp[])[];
|
|
35
|
+
}) => string) | string;
|
|
36
|
+
REQUIRED: ((params: FormErrorFunctionParams) => string) | string;
|
|
37
|
+
MAX_DATE: ((params: FormErrorFunctionParams & {
|
|
38
|
+
maxDate: Date;
|
|
39
|
+
}) => string) | string;
|
|
40
|
+
MIN_DATE: ((params: FormErrorFunctionParams & {
|
|
41
|
+
minDate: Date;
|
|
42
|
+
}) => string) | string;
|
|
43
|
+
};
|
|
44
|
+
type FormErrors = RequiredErrors;
|
|
45
|
+
type ValidatorProps = {
|
|
46
|
+
required?: boolean;
|
|
47
|
+
min?: number;
|
|
16
48
|
minLength?: number;
|
|
49
|
+
max?: number;
|
|
17
50
|
maxLength?: number;
|
|
18
51
|
regex?: (RegExp | RegExp[])[];
|
|
19
|
-
minDate?: Date;
|
|
20
52
|
maxDate?: Date;
|
|
21
|
-
|
|
22
|
-
value?: string | number;
|
|
23
|
-
};
|
|
24
|
-
type RequiredErrors = {
|
|
25
|
-
[key in FieldError['type']]: (params: MetaField) => string;
|
|
26
|
-
};
|
|
27
|
-
type FormErrors = {
|
|
28
|
-
[key in 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'minDate' | 'maxDate']: RequiredErrors[key];
|
|
53
|
+
minDate?: Date;
|
|
29
54
|
};
|
|
30
|
-
type
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
type ValidatorObject<InputValue = unknown> = {
|
|
56
|
+
validate: (value: InputValue, allValues?: AnyObject, meta?: FieldMetaState<InputValue>) => boolean;
|
|
57
|
+
error: keyof RequiredErrors;
|
|
58
|
+
};
|
|
59
|
+
type BaseFieldProps<FieldValue, InputValue = unknown> = {
|
|
60
|
+
parse?: UseFieldConfig<FieldValue, InputValue>['parse'];
|
|
61
|
+
format?: UseFieldConfig<FieldValue, InputValue>['format'];
|
|
62
|
+
formatOnBlur?: boolean;
|
|
63
|
+
subscription?: FieldSubscription;
|
|
64
|
+
validateFields?: string[];
|
|
65
|
+
defaultValue?: FieldValue;
|
|
66
|
+
data?: AnyObject;
|
|
67
|
+
allowNull?: boolean;
|
|
68
|
+
initialValue?: FieldValue;
|
|
69
|
+
multiple?: boolean;
|
|
70
|
+
isEqual?: (a: InputValue, b: InputValue) => boolean;
|
|
71
|
+
validate?: FieldValidator<FieldValue>;
|
|
72
|
+
afterSubmit?: () => void;
|
|
73
|
+
beforeSubmit?: () => void | boolean;
|
|
74
|
+
value?: FieldValue;
|
|
38
75
|
};
|
|
39
76
|
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
declare const CheckboxField: react.ForwardRefExoticComponent<BaseFieldProps<string, string> & Partial<Pick<({
|
|
78
|
+
error?: ReactNode;
|
|
79
|
+
size?: number | undefined;
|
|
80
|
+
progress?: boolean | undefined;
|
|
81
|
+
helper?: ReactNode;
|
|
82
|
+
disabled?: boolean | undefined;
|
|
83
|
+
checked?: boolean | "indeterminate" | undefined;
|
|
84
|
+
className?: string | undefined;
|
|
85
|
+
"data-visibility"?: string | undefined;
|
|
86
|
+
required?: boolean | undefined;
|
|
87
|
+
'data-testid'?: string | undefined;
|
|
88
|
+
tooltip?: string | undefined;
|
|
89
|
+
} & Pick<react.InputHTMLAttributes<HTMLInputElement>, "name" | "value" | "onFocus" | "onBlur" | "autoFocus" | "id" | "onChange"> & (({
|
|
90
|
+
"aria-label"?: undefined;
|
|
91
|
+
} & {
|
|
92
|
+
children: ReactNode;
|
|
93
|
+
}) | ({
|
|
94
|
+
children?: undefined;
|
|
95
|
+
} & {
|
|
96
|
+
'aria-label': string;
|
|
97
|
+
}))) & react.RefAttributes<HTMLInputElement>, "value" | "disabled" | "onFocus" | "onBlur" | "onChange" | "progress" | "size" | "data-testid" | "helper" | "tooltip">> & {
|
|
98
|
+
name: string;
|
|
99
|
+
label?: string | undefined;
|
|
100
|
+
className?: string | undefined;
|
|
42
101
|
children?: ReactNode;
|
|
43
|
-
|
|
44
|
-
|
|
102
|
+
required?: boolean | undefined;
|
|
103
|
+
} & react.RefAttributes<HTMLInputElement>>;
|
|
45
104
|
|
|
46
|
-
type
|
|
105
|
+
type CheckboxGroupValue = string[];
|
|
106
|
+
type CheckboxGroupFieldProps<T = CheckboxGroupValue, K = string> = BaseFieldProps<T, K> & Partial<Pick<ComponentProps<typeof CheckboxGroup>, 'className' | 'helper' | 'onChange' | 'required' | 'direction' | 'children' | 'value' | 'error' | 'legend'>> & Required<Pick<ComponentProps<typeof CheckboxGroup>, 'legend' | 'name'>>;
|
|
47
107
|
declare const CheckboxGroupField: {
|
|
48
|
-
|
|
108
|
+
({ legend, value, className, helper, direction, children, onChange, error: customError, name, required, }: CheckboxGroupFieldProps): _emotion_react_jsx_runtime.JSX.Element;
|
|
49
109
|
Checkbox: ({ onFocus, onBlur, disabled, error, name, value, children, helper, className, autoFocus, "data-testid": dataTestId, }: Omit<({
|
|
50
110
|
error?: react.ReactNode;
|
|
51
111
|
size?: number | undefined;
|
|
@@ -58,7 +118,7 @@ declare const CheckboxGroupField: {
|
|
|
58
118
|
required?: boolean | undefined;
|
|
59
119
|
'data-testid'?: string | undefined;
|
|
60
120
|
tooltip?: string | undefined;
|
|
61
|
-
} & Pick<react.InputHTMLAttributes<HTMLInputElement>, "
|
|
121
|
+
} & Pick<react.InputHTMLAttributes<HTMLInputElement>, "name" | "value" | "onFocus" | "onBlur" | "autoFocus" | "id" | "onChange"> & (({
|
|
62
122
|
"aria-label"?: undefined;
|
|
63
123
|
} & {
|
|
64
124
|
children: react.ReactNode;
|
|
@@ -71,7 +131,9 @@ declare const CheckboxGroupField: {
|
|
|
71
131
|
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
72
132
|
};
|
|
73
133
|
|
|
74
|
-
type
|
|
134
|
+
type DateExtends = Date | [Date | null, Date | null];
|
|
135
|
+
type DateFieldProps = BaseFieldProps<DateExtends> & Omit<ComponentProps<typeof DateInput>, 'maxDate' | 'minDate' | 'disabled' | 'required' | 'locale' | 'name' | 'onChange' | 'onFocus' | 'onBlur' | 'autoFocus' | 'startDate' | 'endDate'> & {
|
|
136
|
+
name: string;
|
|
75
137
|
maxDate?: Date;
|
|
76
138
|
minDate?: Date;
|
|
77
139
|
disabled?: boolean;
|
|
@@ -82,58 +144,36 @@ type DateFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldVal
|
|
|
82
144
|
onFocus?: (value: FocusEvent<HTMLElement>) => void;
|
|
83
145
|
autoFocus?: boolean;
|
|
84
146
|
};
|
|
85
|
-
declare const DateField:
|
|
147
|
+
declare const DateField: ({ required, name, label, validate, format, locale, maxDate, minDate, initialValue, disabled, value: inputVal, onChange, onBlur, onFocus, formatOnBlur, autoFocus, excludeDates, selectsRange, "data-testid": dataTestId, }: DateFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
86
148
|
|
|
87
|
-
type
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
type SingleXOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
91
|
-
type XOR<T extends unknown[]> = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] ? XOR<[SingleXOR<A, B>, ...Rest]> : never;
|
|
92
|
-
type FormStateReturn<TFormValues extends FieldValues> = {
|
|
93
|
-
values: TFormValues;
|
|
94
|
-
hasValidationErrors: boolean;
|
|
95
|
-
errors: FieldErrors<TFormValues>;
|
|
96
|
-
submitting: boolean;
|
|
97
|
-
pristine: boolean;
|
|
98
|
-
handleSubmit: () => Promise<void>;
|
|
99
|
-
submitError: boolean;
|
|
100
|
-
valid: boolean;
|
|
101
|
-
form: {
|
|
102
|
-
change: UseFormReturn<TFormValues>['setValue'];
|
|
103
|
-
reset: UseFormReturn<TFormValues>['reset'];
|
|
104
|
-
submit: () => Promise<void>;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
type OnRawSubmitReturn = {
|
|
108
|
-
[FORM_ERROR]?: string;
|
|
109
|
-
} | undefined | null | string | void | boolean | number;
|
|
110
|
-
type FormProps<TFormValues extends FieldValues = FieldValues> = {
|
|
111
|
-
children?: ((props: FormStateReturn<TFormValues>) => ReactNode) | ReactNode;
|
|
149
|
+
type FormProps<FormValues = unknown> = {
|
|
150
|
+
children?: ((props: FormRenderProps<FormValues, Partial<FormValues>>) => ReactNode) | ReactNode;
|
|
112
151
|
errors: FormErrors;
|
|
152
|
+
/**
|
|
153
|
+
* onRawSubmit is the base onSubmit from final-form
|
|
154
|
+
*/
|
|
155
|
+
onRawSubmit: FormProps$1<FormValues, Partial<FormValues>>['onSubmit'];
|
|
156
|
+
initialValues?: Partial<FormValues>;
|
|
157
|
+
validateOnBlur?: FormProps$1<FormValues, Partial<FormValues>>['validateOnBlur'];
|
|
158
|
+
validate?: FormProps$1<FormValues, Partial<FormValues>>['validate'];
|
|
159
|
+
/**
|
|
160
|
+
* The form name attribute
|
|
161
|
+
*/
|
|
113
162
|
name?: string;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
} & XOR<[
|
|
121
|
-
{
|
|
122
|
-
/**
|
|
123
|
-
* @deprecated
|
|
124
|
-
*/
|
|
125
|
-
initialValues?: DefaultValues<TFormValues>;
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
methods: UseFormReturn<TFormValues>;
|
|
129
|
-
}
|
|
130
|
-
]>;
|
|
131
|
-
declare const Form: <TFormValues extends FieldValues>({ children, methods: methodsProp, initialValues, errors, onRawSubmit, name, }: FormProps<TFormValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
163
|
+
render?: FormProps$1<FormValues, Partial<FormValues>>['render'];
|
|
164
|
+
mutators?: FormProps$1<FormValues, Partial<FormValues>>['mutators'];
|
|
165
|
+
keepDirtyOnReinitialize?: boolean;
|
|
166
|
+
className?: string;
|
|
167
|
+
};
|
|
168
|
+
declare const Form: <FormValues>({ children, onRawSubmit, errors, initialValues, validateOnBlur, validate, name, render, mutators, keepDirtyOnReinitialize, className, }: FormProps<FormValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
132
169
|
|
|
133
|
-
type
|
|
170
|
+
type RadioValue$1 = NonNullable<ComponentProps<typeof Radio>['value']>;
|
|
171
|
+
type RadioFieldProps<T = RadioValue$1, K = string> = BaseFieldProps<T, K> & Partial<Pick<ComponentProps<typeof Radio>, 'disabled' | 'id' | 'onBlur' | 'onChange' | 'onFocus' | 'value' | 'data-testid' | 'label' | 'tooltip'>> & {
|
|
134
172
|
className?: string;
|
|
173
|
+
name: string;
|
|
174
|
+
required?: boolean;
|
|
135
175
|
};
|
|
136
|
-
declare const RadioField:
|
|
176
|
+
declare const RadioField: ({ className, "data-testid": dataTestId, disabled, id, label, name, onBlur, onChange, onFocus, required, validate, value, tooltip, }: RadioFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
137
177
|
|
|
138
178
|
type SelectOption = {
|
|
139
179
|
value: string;
|
|
@@ -175,7 +215,7 @@ type SelectProps = StyledContainerProps & Omit<Props<SelectOption>, 'value'> & C
|
|
|
175
215
|
time?: boolean;
|
|
176
216
|
};
|
|
177
217
|
type StateManagedSelect = typeof Select;
|
|
178
|
-
type SelectInputProps = Partial<SelectProps & SelectStyleProps & {
|
|
218
|
+
type SelectInputProps = Partial<SelectProps & SelectStyleProps & Pick<ComponentProps<typeof SelectInput>, 'data-testid'> & {
|
|
179
219
|
/**
|
|
180
220
|
* Name of the animation
|
|
181
221
|
*/
|
|
@@ -194,15 +234,16 @@ type SelectInputProps = Partial<SelectProps & SelectStyleProps & {
|
|
|
194
234
|
children: ReactNode;
|
|
195
235
|
emptyState?: ComponentProps<Select>['noOptionsMessage'];
|
|
196
236
|
}>;
|
|
197
|
-
type
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
237
|
+
type SelectInputOptions = SelectProps['options'];
|
|
238
|
+
type SelectInputOptionOrGroup = NonNullable<SelectInputOptions>[number];
|
|
239
|
+
type SelectInputFieldProps<T extends SelectInputOptionOrGroup = SelectInputOptionOrGroup> = BaseFieldProps<T> & Pick<SelectInputProps, 'animation' | 'animationDuration' | 'animationOnChange' | 'children' | 'className' | 'disabled' | 'error' | 'id' | 'inputId' | 'isClearable' | 'isLoading' | 'isSearchable' | 'menuPortalTarget' | 'onBlur' | 'onChange' | 'onFocus' | 'options' | 'placeholder' | 'readOnly' | 'required' | 'value' | 'noTopLabel' | 'noOptionsMessage' | 'customStyle' | 'data-testid'> & {
|
|
240
|
+
label?: string;
|
|
201
241
|
maxLength?: number;
|
|
202
242
|
minLength?: number;
|
|
243
|
+
name: string;
|
|
203
244
|
};
|
|
204
245
|
declare const SelectInputField: {
|
|
205
|
-
<
|
|
246
|
+
<T extends (SelectOption | GroupBase<SelectOption>) & (SelectOption | GroupBase<SelectOption>) = (SelectOption | GroupBase<SelectOption>) & (SelectOption | GroupBase<SelectOption>)>({ animation, animationDuration, animationOnChange, children, className, disabled, error: errorProp, format: formatProp, formatOnBlur, id, inputId, isClearable, isLoading, isSearchable, label, maxLength, menuPortalTarget, minLength, multiple, name, onBlur, onChange, onFocus, options: optionsProp, parse: parseProp, placeholder, readOnly, required, value, noTopLabel, noOptionsMessage, customStyle, validate, "data-testid": dataTestId, }: SelectInputFieldProps<T>): _emotion_react_jsx_runtime.JSX.Element;
|
|
206
247
|
Option: (props: Partial<OptionProps<{
|
|
207
248
|
value: string;
|
|
208
249
|
label: ReactNode;
|
|
@@ -224,25 +265,36 @@ declare const SelectInputField: {
|
|
|
224
265
|
}>) => react.JSX.Element;
|
|
225
266
|
};
|
|
226
267
|
|
|
227
|
-
type
|
|
268
|
+
type SelectableCardValue = NonNullable<ComponentProps<typeof SelectableCard>['value']>;
|
|
269
|
+
type SelectableCardFieldProps<T = SelectableCardValue, K = string> = BaseFieldProps<T, K> & Partial<Pick<ComponentProps<typeof SelectableCard>, 'disabled' | 'onBlur' | 'onChange' | 'onFocus' | 'value' | 'showTick' | 'type' | 'id' | 'children' | 'name' | 'tooltip' | 'label' | 'data-testid'>> & {
|
|
270
|
+
name: string;
|
|
271
|
+
required?: boolean;
|
|
228
272
|
className?: string;
|
|
229
273
|
};
|
|
230
|
-
declare const SelectableCardField:
|
|
274
|
+
declare const SelectableCardField: ({ name, value, onChange, showTick, type, disabled, children, className, onFocus, onBlur, required, validate, tooltip, id, label, "data-testid": dataTestId, }: SelectableCardFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
231
275
|
|
|
232
|
-
type
|
|
276
|
+
type NumberInputValue = NonNullable<ComponentProps<typeof NumberInput>['value']>;
|
|
277
|
+
type NumberInputValueFieldProps<T = NumberInputValue, K = string> = BaseFieldProps<T, K> & Partial<Pick<ComponentProps<typeof NumberInput>, 'disabled' | 'maxValue' | 'minValue' | 'onMaxCrossed' | 'onMinCrossed' | 'size' | 'step' | 'text' | 'value' | 'onChange' | 'className' | 'data-testid'>> & {
|
|
278
|
+
name: string;
|
|
279
|
+
required?: boolean;
|
|
233
280
|
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
234
281
|
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
235
282
|
};
|
|
236
|
-
declare const NumberInputField:
|
|
283
|
+
declare const NumberInputField: ({ disabled, maxValue, minValue, name, onChange, onBlur, onFocus, onMaxCrossed, onMinCrossed, required, size, step, text, validate, value, className, "data-testid": dataTestId, }: NumberInputValueFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
237
284
|
|
|
238
|
-
declare const SubmitErrorAlert: ({ className }: {
|
|
285
|
+
declare const SubmitErrorAlert: <FormValues>({ className, }: {
|
|
239
286
|
className?: string | undefined;
|
|
240
|
-
}) => _emotion_react_jsx_runtime.JSX.Element
|
|
287
|
+
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
241
288
|
|
|
242
|
-
type
|
|
243
|
-
|
|
289
|
+
type TagInputProp = ComponentProps<typeof TagInput>['tags'];
|
|
290
|
+
type TagInputFieldProps<T = TagInputProp, K = string> = BaseFieldProps<T, K> & Partial<Pick<ComponentProps<typeof TagInput>, 'tags' | 'variant' | 'onChange' | 'placeholder' | 'disabled' | 'className' | 'id' | 'data-testid'>> & {
|
|
291
|
+
name: string;
|
|
292
|
+
required?: boolean;
|
|
293
|
+
};
|
|
294
|
+
declare const TagInputField: ({ className, "data-testid": dataTestId, disabled, id, name, onChange, placeholder, required, tags, validate, variant, }: TagInputFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
244
295
|
|
|
245
|
-
|
|
296
|
+
type TextInputValue = NonNullable<ComponentProps<typeof TextInput>['value']>;
|
|
297
|
+
declare const TextInputField: react.ForwardRefExoticComponent<BaseFieldProps<TextInputValue, string> & Partial<Pick<({
|
|
246
298
|
'data-testid'?: string | undefined;
|
|
247
299
|
ariaControls?: string | undefined;
|
|
248
300
|
autoComplete?: string | undefined;
|
|
@@ -281,32 +333,33 @@ declare const TextInputField: react.ForwardRefExoticComponent<BaseFieldProps<Fie
|
|
|
281
333
|
value?: string | number | undefined;
|
|
282
334
|
wrap?: string | undefined;
|
|
283
335
|
inputProps?: {
|
|
284
|
-
|
|
336
|
+
error?: boolean | undefined;
|
|
337
|
+
name?: string | undefined;
|
|
338
|
+
value?: string | number | readonly string[] | undefined;
|
|
285
339
|
required?: boolean | undefined;
|
|
286
340
|
min?: string | number | undefined;
|
|
341
|
+
minLength?: number | undefined;
|
|
287
342
|
max?: string | number | undefined;
|
|
288
343
|
maxLength?: number | undefined;
|
|
289
|
-
minLength?: number | undefined;
|
|
290
|
-
value?: string | number | readonly string[] | undefined;
|
|
291
|
-
onChange?: react.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
292
|
-
onBlur?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
293
344
|
disabled?: boolean | undefined;
|
|
294
|
-
|
|
345
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
346
|
+
multiple?: boolean | undefined;
|
|
347
|
+
type?: react.HTMLInputTypeAttribute | undefined;
|
|
295
348
|
children?: react.ReactNode;
|
|
296
349
|
className?: string | undefined;
|
|
297
|
-
form?: string | undefined;
|
|
298
|
-
slot?: string | undefined;
|
|
299
|
-
style?: react.CSSProperties | undefined;
|
|
300
|
-
title?: string | undefined;
|
|
301
350
|
onFocus?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
302
|
-
|
|
351
|
+
onBlur?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
303
352
|
autoFocus?: boolean | undefined;
|
|
304
353
|
id?: string | undefined;
|
|
354
|
+
onChange?: react.ChangeEventHandler<HTMLInputElement> | undefined;
|
|
305
355
|
"aria-label"?: string | undefined;
|
|
356
|
+
form?: string | undefined;
|
|
357
|
+
slot?: string | undefined;
|
|
358
|
+
style?: react.CSSProperties | undefined;
|
|
359
|
+
title?: string | undefined;
|
|
360
|
+
pattern?: string | undefined;
|
|
306
361
|
size?: number | undefined;
|
|
307
|
-
error?: boolean | undefined;
|
|
308
362
|
checked?: boolean | undefined;
|
|
309
|
-
defaultValue?: string | number | readonly string[] | undefined;
|
|
310
363
|
onSubmit?: react.FormEventHandler<HTMLInputElement> | undefined;
|
|
311
364
|
autoComplete?: string | undefined;
|
|
312
365
|
defaultChecked?: boolean | undefined;
|
|
@@ -320,7 +373,6 @@ declare const TextInputField: react.ForwardRefExoticComponent<BaseFieldProps<Fie
|
|
|
320
373
|
hidden?: boolean | undefined;
|
|
321
374
|
lang?: string | undefined;
|
|
322
375
|
nonce?: string | undefined;
|
|
323
|
-
placeholder?: string | undefined;
|
|
324
376
|
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
325
377
|
tabIndex?: number | undefined;
|
|
326
378
|
translate?: "yes" | "no" | undefined;
|
|
@@ -368,7 +420,7 @@ declare const TextInputField: react.ForwardRefExoticComponent<BaseFieldProps<Fie
|
|
|
368
420
|
"aria-description"?: string | undefined;
|
|
369
421
|
"aria-details"?: string | undefined;
|
|
370
422
|
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
371
|
-
"aria-dropeffect"?: "link" | "
|
|
423
|
+
"aria-dropeffect"?: "link" | "move" | "none" | "copy" | "execute" | "popup" | undefined;
|
|
372
424
|
"aria-errormessage"?: string | undefined;
|
|
373
425
|
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
374
426
|
"aria-flowto"?: string | undefined;
|
|
@@ -564,11 +616,11 @@ declare const TextInputField: react.ForwardRefExoticComponent<BaseFieldProps<Fie
|
|
|
564
616
|
onAnimationIterationCapture?: react.AnimationEventHandler<HTMLInputElement> | undefined;
|
|
565
617
|
onTransitionEnd?: react.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
566
618
|
onTransitionEndCapture?: react.TransitionEventHandler<HTMLInputElement> | undefined;
|
|
619
|
+
placeholder?: string | undefined;
|
|
567
620
|
height?: string | number | undefined;
|
|
568
621
|
width?: string | number | undefined;
|
|
569
|
-
list?: string | undefined;
|
|
570
622
|
readOnly?: boolean | undefined;
|
|
571
|
-
|
|
623
|
+
list?: string | undefined;
|
|
572
624
|
step?: string | number | undefined;
|
|
573
625
|
accept?: string | undefined;
|
|
574
626
|
alt?: string | undefined;
|
|
@@ -589,27 +641,24 @@ declare const TextInputField: react.ForwardRefExoticComponent<BaseFieldProps<Fie
|
|
|
589
641
|
} | undefined;
|
|
590
642
|
max?: string | number | undefined;
|
|
591
643
|
min?: string | number | undefined;
|
|
592
|
-
} & (Omit<react.InputHTMLAttributes<HTMLInputElement>, "onChange"> | Omit<react.TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange">)) & react.RefAttributes<HTMLInputElement | HTMLTextAreaElement | null>, "
|
|
644
|
+
} & (Omit<react.InputHTMLAttributes<HTMLInputElement>, "onChange"> | Omit<react.TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange">)) & react.RefAttributes<HTMLInputElement | HTMLTextAreaElement | null>, "valid" | "value" | "required" | "minLength" | "maxLength" | "disabled" | "type" | "label" | "onFocus" | "onBlur" | "autoFocus" | "id" | "onChange" | "size" | "data-testid" | "autoComplete" | "autoCapitalize" | "autoCorrect" | "autoSave" | "onKeyDown" | "onKeyUp" | "placeholder" | "noTopLabel" | "readOnly" | "cols" | "rows" | "fillAvailable" | "generated" | "multiline" | "notice" | "random" | "resizable" | "unit">> & {
|
|
645
|
+
name: string;
|
|
593
646
|
className?: string | undefined;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
*/
|
|
647
|
+
max?: number | undefined;
|
|
648
|
+
min?: number | undefined;
|
|
597
649
|
regex?: (RegExp | RegExp[])[] | undefined;
|
|
598
|
-
format?: ((value: unknown) => any) | undefined;
|
|
599
|
-
parse?: ((value: string) => any) | undefined;
|
|
600
|
-
customError?: string | undefined;
|
|
601
650
|
} & react.RefAttributes<HTMLInputElement>>;
|
|
602
651
|
|
|
603
|
-
type TimeFieldProps
|
|
652
|
+
type TimeFieldProps = BaseFieldProps<Date> & ComponentProps<typeof TimeInput> & {
|
|
604
653
|
name: string;
|
|
605
654
|
};
|
|
606
|
-
declare const TimeField:
|
|
655
|
+
declare const TimeField: ({ required, name, schedule, placeholder, disabled, initialValue, validate, readOnly, value, onChange, onBlur, onFocus, isLoading, isClearable, inputId, id, formatOnBlur, animation, animationDuration, animationOnChange, className, isSearchable, options, "data-testid": dataTestId, }: TimeFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
607
656
|
|
|
608
|
-
type ToggleFieldProps<
|
|
609
|
-
|
|
610
|
-
|
|
657
|
+
type ToggleFieldProps<T = unknown, K = unknown> = BaseFieldProps<T, K> & Pick<ComponentProps<typeof Toggle>, 'disabled' | 'label' | 'onChange' | 'size' | 'tooltip' | 'labelPosition' | 'className' | 'data-testid'> & {
|
|
658
|
+
name: string;
|
|
659
|
+
required?: boolean;
|
|
611
660
|
};
|
|
612
|
-
declare const ToggleField:
|
|
661
|
+
declare const ToggleField: ({ afterSubmit, allowNull, beforeSubmit, className, data, defaultValue, disabled, format, formatOnBlur, initialValue, isEqual, label, multiple, name, onChange, parse, required, size, subscription, tooltip, validate, validateFields, value, labelPosition, "data-testid": dataTestId, }: ToggleFieldProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
613
662
|
|
|
614
663
|
type SubmitProps = {
|
|
615
664
|
children?: ReactNode;
|
|
@@ -626,158 +675,60 @@ type SubmitProps = {
|
|
|
626
675
|
};
|
|
627
676
|
declare const Submit: ({ children, className, disabled, icon, iconPosition, size, variant, sentiment, tooltip, fullWidth, onClick, }: SubmitProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
628
677
|
|
|
629
|
-
type
|
|
678
|
+
type RadioValue = NonNullable<ComponentProps<typeof RadioGroup>['value']>;
|
|
679
|
+
type RadioGroupFieldProps<T = RadioValue, K = string> = BaseFieldProps<T, K> & Partial<Pick<ComponentProps<typeof RadioGroup>, 'onChange' | 'value' | 'legend' | 'children' | 'required' | 'name' | 'error' | 'helper' | 'direction'>> & {
|
|
630
680
|
className?: string;
|
|
681
|
+
name: string;
|
|
682
|
+
required?: boolean;
|
|
631
683
|
};
|
|
632
684
|
declare const RadioGroupField: {
|
|
633
|
-
|
|
685
|
+
({ className, legend, name, onChange, required, validate, value, children, error: customError, helper, direction, }: RadioGroupFieldProps): _emotion_react_jsx_runtime.JSX.Element;
|
|
634
686
|
Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, "data-testid": dataTestId, }: {
|
|
687
|
+
error?: react.ReactNode;
|
|
688
|
+
name?: string | undefined;
|
|
635
689
|
value: string | number;
|
|
636
|
-
|
|
690
|
+
key?: react.Key | null | undefined;
|
|
637
691
|
disabled?: boolean | undefined;
|
|
692
|
+
label?: react.ReactNode;
|
|
638
693
|
className?: string | undefined;
|
|
639
694
|
ref?: react.Ref<HTMLInputElement> | undefined;
|
|
640
|
-
label?: react.ReactNode;
|
|
641
695
|
onFocus?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
642
|
-
|
|
696
|
+
onBlur?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
643
697
|
autoFocus?: boolean | undefined;
|
|
644
698
|
id?: string | undefined;
|
|
645
699
|
'aria-label'?: string | undefined;
|
|
646
700
|
'data-testid'?: string | undefined;
|
|
647
701
|
helper?: react.ReactNode;
|
|
648
702
|
tooltip?: string | undefined;
|
|
649
|
-
error?: react.ReactNode;
|
|
650
|
-
key?: react.Key | null | undefined;
|
|
651
703
|
onKeyDown?: react.KeyboardEventHandler<HTMLInputElement> | undefined;
|
|
652
704
|
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
653
705
|
};
|
|
654
706
|
|
|
655
|
-
type
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
};
|
|
659
|
-
type ErrorProviderProps = {
|
|
660
|
-
children: ReactNode;
|
|
661
|
-
errors: RequiredErrors;
|
|
662
|
-
};
|
|
663
|
-
declare const ErrorProvider: ({ children, errors }: ErrorProviderProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
664
|
-
declare const useErrors: () => ErrorContextValue;
|
|
665
|
-
|
|
666
|
-
type CallbackFn<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = (value: FieldPathValue<TFieldValues, TFieldName>, values: DeepPartial<TFieldValues>) => void | Promise<void>;
|
|
667
|
-
/**
|
|
668
|
-
* @deprecated
|
|
669
|
-
*/
|
|
670
|
-
declare const useOnFieldChange: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>(fieldName: TFieldName, callback: CallbackFn<TFieldValues, TFieldName>, enabled?: boolean) => void;
|
|
671
|
-
|
|
672
|
-
type UseFormStateParams = {
|
|
673
|
-
subscription?: Record<string, boolean>;
|
|
674
|
-
};
|
|
675
|
-
/**
|
|
676
|
-
* @deprecated Use [useForm](https://www.react-hook-form.com/api/useform/), [useFormContext](https://www.react-hook-form.com/api/useformcontext/) or [useWatch](https://www.react-hook-form.com/api/usewatch/) to get values. Use [useFormState](https://www.react-hook-form.com/api/useformstate/) to get form states.
|
|
677
|
-
* @example
|
|
678
|
-
* ```tsx
|
|
679
|
-
* const Input = () {
|
|
680
|
-
* const username = useWatch({
|
|
681
|
-
* name: 'username'
|
|
682
|
-
* })
|
|
683
|
-
*
|
|
684
|
-
* const { isValid } = useFormState()
|
|
685
|
-
* }
|
|
686
|
-
* ```
|
|
687
|
-
|
|
688
|
-
*/
|
|
689
|
-
declare const useFormStateDeprecated: <TFieldValues extends FieldValues>(_params?: UseFormStateParams) => {
|
|
690
|
-
dirtySinceLastSubmit: boolean;
|
|
691
|
-
submitErrors: (Record<string, Partial<{
|
|
692
|
-
type: string | number;
|
|
693
|
-
message: string;
|
|
694
|
-
}>> & Partial<{
|
|
695
|
-
type: string | number;
|
|
696
|
-
message: string;
|
|
697
|
-
}>) | undefined;
|
|
698
|
-
values: TFieldValues;
|
|
699
|
-
hasValidationErrors: boolean;
|
|
700
|
-
pristine: boolean;
|
|
701
|
-
errors: react_hook_form.FieldErrors<TFieldValues>;
|
|
702
|
-
initialValues: Readonly<react_hook_form.DeepPartial<TFieldValues>> | undefined;
|
|
703
|
-
touched: Partial<Readonly<react_hook_form.DeepMap<react_hook_form.DeepPartial<TFieldValues>, boolean>>>;
|
|
704
|
-
submitting: boolean;
|
|
705
|
-
invalid: boolean;
|
|
706
|
-
valid: boolean;
|
|
707
|
+
type UseValidationParams<FieldValue = unknown> = {
|
|
708
|
+
validators: ValidatorObject<FieldValue>[];
|
|
709
|
+
validate?: FieldValidator<FieldValue>;
|
|
707
710
|
};
|
|
711
|
+
type UseValidationResult<FieldValue = unknown> = (value: FieldValue, allValues: AnyObject, meta?: FieldState<FieldValue>) => string[] | undefined | unknown;
|
|
712
|
+
declare const useValidation: <T = unknown>({ validators, validate, }: UseValidationParams<T>) => UseValidationResult<T>;
|
|
708
713
|
|
|
709
|
-
type
|
|
710
|
-
|
|
711
|
-
validate?: Validate<FieldPathValue<TFieldValues, Path<TFieldValues>>, TFieldValues>;
|
|
712
|
-
};
|
|
713
|
-
/**
|
|
714
|
-
* @deprecated Use [useForm](https://www.react-hook-form.com/api/useform/), [useFormContext](https://www.react-hook-form.com/api/useformcontext/) or [useWatch](https://www.react-hook-form.com/api/usewatch/) to get values. Use [useFormState](https://www.react-hook-form.com/api/useformstate/) to get fields states.
|
|
715
|
-
* @example
|
|
716
|
-
* ```tsx
|
|
717
|
-
* const Input = () {
|
|
718
|
-
* const username = useWatch({
|
|
719
|
-
* name: 'username'
|
|
720
|
-
* })
|
|
721
|
-
*
|
|
722
|
-
* const { errors } = useFormState()
|
|
723
|
-
*
|
|
724
|
-
* console.log(errors.username)
|
|
725
|
-
* }
|
|
726
|
-
* ```
|
|
714
|
+
type CallbackFn<FieldValue, AllValues> = (value: FieldValue, values: AllValues) => unknown;
|
|
715
|
+
declare const useOnFieldChange: <FieldValue = unknown, AllValues = unknown>(name: string, callback: CallbackFn<FieldValue, AllValues>, enabled?: boolean) => void;
|
|
727
716
|
|
|
728
|
-
|
|
729
|
-
declare const useFieldDeprecated: <T, TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: Options$1<TFieldValues> | undefined) => {
|
|
730
|
-
input: {
|
|
731
|
-
value: T;
|
|
732
|
-
onChange: (...event: any[]) => void;
|
|
733
|
-
};
|
|
734
|
-
meta: {
|
|
735
|
-
error: string | undefined;
|
|
736
|
-
touched: boolean;
|
|
737
|
-
invalid: boolean;
|
|
738
|
-
dirty: boolean;
|
|
739
|
-
};
|
|
740
|
-
};
|
|
717
|
+
declare const pickValidators: <InputValue = unknown>(args: ValidatorProps) => ValidatorObject<InputValue>[];
|
|
741
718
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
* @example
|
|
746
|
-
* ```tsx
|
|
747
|
-
* const Input = () {
|
|
748
|
-
* const { setValue } = useFormContext()
|
|
749
|
-
*
|
|
750
|
-
* setValue('username', 'John Wick')
|
|
751
|
-
* }
|
|
752
|
-
* ```
|
|
753
|
-
*/
|
|
754
|
-
declare const useFormDeprecated: <TFieldValues extends FieldValues>() => {
|
|
755
|
-
change: react_hook_form.UseFormSetValue<TFieldValues>;
|
|
756
|
-
resetFieldState: react_hook_form.UseFormResetField<TFieldValues>;
|
|
757
|
-
getFieldState: react_hook_form.UseFormGetFieldState<TFieldValues>;
|
|
758
|
-
batch: (callback: () => void) => void;
|
|
759
|
-
restart: react_hook_form.UseFormReset<TFieldValues>;
|
|
760
|
-
reset: react_hook_form.UseFormReset<TFieldValues>;
|
|
761
|
-
submit: (e?: react.BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
|
|
719
|
+
type GetErrorProps = Omit<FormErrorFunctionParams, 'allValues'> & AnyObject & {
|
|
720
|
+
errorProp?: string;
|
|
721
|
+
additionalErrorChecks?: boolean;
|
|
762
722
|
};
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
subscription?: Record<string, boolean>;
|
|
723
|
+
type ErrorContextValue = {
|
|
724
|
+
errors: FormErrors;
|
|
725
|
+
getError: (props: GetErrorProps) => string | undefined;
|
|
767
726
|
};
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
declare const useFieldArrayDeprecated: <T, TFieldValues extends FieldValues = FieldValues>(name: ArrayPath<TFieldValues>, options?: Options<TFieldValues> | undefined) => {
|
|
772
|
-
fields: {
|
|
773
|
-
push: react_hook_form.UseFieldArrayAppend<TFieldValues, ArrayPath<TFieldValues>>;
|
|
774
|
-
value: T[];
|
|
775
|
-
remove: react_hook_form.UseFieldArrayRemove;
|
|
776
|
-
update: react_hook_form.UseFieldArrayUpdate<TFieldValues, ArrayPath<TFieldValues>>;
|
|
777
|
-
map: (callback: (name: string, index: number) => ReactNode) => ReactNode[];
|
|
778
|
-
move: react_hook_form.UseFieldArrayMove;
|
|
779
|
-
length: number;
|
|
780
|
-
};
|
|
727
|
+
type ErrorProviderProps = {
|
|
728
|
+
children: ReactNode;
|
|
729
|
+
errors: FormErrors;
|
|
781
730
|
};
|
|
731
|
+
declare const ErrorProvider: ({ children, errors }: ErrorProviderProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
732
|
+
declare const useErrors: () => ErrorContextValue;
|
|
782
733
|
|
|
783
|
-
export { type BaseFieldProps, CheckboxField, CheckboxGroupField, DateField, ErrorProvider,
|
|
734
|
+
export { type BaseFieldProps, CheckboxField, CheckboxGroupField, DateField, ErrorProvider, Form, type FormErrors, NumberInputField, RadioField, RadioGroupField, SelectInputField, SelectableCardField, Submit, SubmitErrorAlert, TagInputField, TextInputField, TimeField, ToggleField, pickValidators, useErrors, useOnFieldChange, useValidation };
|