@ultraviolet/form 2.0.0-next.6 → 2.0.0-next.8
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 +3 -1
- package/dist/components/CheckboxGroupField/index.js +4 -2
- package/dist/components/DateField/index.js +3 -1
- package/dist/components/NumberInputField/index.js +3 -1
- package/dist/components/RadioField/index.js +3 -1
- package/dist/components/RadioGroupField/index.js +7 -2
- package/dist/components/SelectInputField/index.js +3 -1
- package/dist/components/SelectableCardField/index.js +3 -1
- package/dist/components/TagInputField/index.js +3 -1
- package/dist/components/TextInputField/index.js +3 -1
- package/dist/components/TimeField/index.js +3 -1
- package/dist/components/ToggleField/index.js +3 -1
- package/dist/hooks/useField.js +2 -2
- package/dist/hooks/useFormState.js +1 -0
- package/dist/hooks/useOnFieldChange.js +0 -3
- package/dist/index.d.ts +36 -26
- package/package.json +6 -6
|
@@ -20,7 +20,8 @@ const CheckboxField = _ref => {
|
|
|
20
20
|
helper,
|
|
21
21
|
tooltip,
|
|
22
22
|
'data-testid': dataTestId,
|
|
23
|
-
value
|
|
23
|
+
value,
|
|
24
|
+
shouldUnregister = false
|
|
24
25
|
} = _ref;
|
|
25
26
|
const {
|
|
26
27
|
getError
|
|
@@ -33,6 +34,7 @@ const CheckboxField = _ref => {
|
|
|
33
34
|
} = useController({
|
|
34
35
|
name,
|
|
35
36
|
disabled,
|
|
37
|
+
shouldUnregister,
|
|
36
38
|
rules: {
|
|
37
39
|
required,
|
|
38
40
|
...rules
|
|
@@ -14,7 +14,8 @@ const CheckboxGroupField = _ref => {
|
|
|
14
14
|
label = '',
|
|
15
15
|
error: customError,
|
|
16
16
|
name,
|
|
17
|
-
required = false
|
|
17
|
+
required = false,
|
|
18
|
+
shouldUnregister = false
|
|
18
19
|
} = _ref;
|
|
19
20
|
const {
|
|
20
21
|
getError
|
|
@@ -25,7 +26,8 @@ const CheckboxGroupField = _ref => {
|
|
|
25
26
|
error
|
|
26
27
|
}
|
|
27
28
|
} = useController({
|
|
28
|
-
name
|
|
29
|
+
name,
|
|
30
|
+
shouldUnregister
|
|
29
31
|
});
|
|
30
32
|
return jsx(CheckboxGroup, {
|
|
31
33
|
legend: legend,
|
|
@@ -24,7 +24,8 @@ const DateField = _ref => {
|
|
|
24
24
|
autoFocus = false,
|
|
25
25
|
excludeDates,
|
|
26
26
|
selectsRange,
|
|
27
|
-
'data-testid': dataTestId
|
|
27
|
+
'data-testid': dataTestId,
|
|
28
|
+
shouldUnregister = false
|
|
28
29
|
} = _ref;
|
|
29
30
|
const {
|
|
30
31
|
getError
|
|
@@ -36,6 +37,7 @@ const DateField = _ref => {
|
|
|
36
37
|
}
|
|
37
38
|
} = useController({
|
|
38
39
|
name,
|
|
40
|
+
shouldUnregister,
|
|
39
41
|
rules: {
|
|
40
42
|
...rules,
|
|
41
43
|
validate: {
|
|
@@ -20,7 +20,8 @@ const NumberInputField = _ref => {
|
|
|
20
20
|
text,
|
|
21
21
|
rules,
|
|
22
22
|
className,
|
|
23
|
-
label
|
|
23
|
+
label,
|
|
24
|
+
shouldUnregister = false
|
|
24
25
|
} = _ref;
|
|
25
26
|
const {
|
|
26
27
|
getError
|
|
@@ -32,6 +33,7 @@ const NumberInputField = _ref => {
|
|
|
32
33
|
}
|
|
33
34
|
} = useController({
|
|
34
35
|
name,
|
|
36
|
+
shouldUnregister,
|
|
35
37
|
rules: {
|
|
36
38
|
max: maxValue,
|
|
37
39
|
min: minValue,
|
|
@@ -17,7 +17,8 @@ const RadioField = _ref => {
|
|
|
17
17
|
required,
|
|
18
18
|
value,
|
|
19
19
|
rules,
|
|
20
|
-
tooltip
|
|
20
|
+
tooltip,
|
|
21
|
+
shouldUnregister = false
|
|
21
22
|
} = _ref;
|
|
22
23
|
const {
|
|
23
24
|
getError
|
|
@@ -29,6 +30,7 @@ const RadioField = _ref => {
|
|
|
29
30
|
}
|
|
30
31
|
} = useController({
|
|
31
32
|
name,
|
|
33
|
+
shouldUnregister,
|
|
32
34
|
rules: {
|
|
33
35
|
required,
|
|
34
36
|
...rules
|
|
@@ -15,7 +15,8 @@ const RadioGroupField = _ref => {
|
|
|
15
15
|
label = '',
|
|
16
16
|
error: customError,
|
|
17
17
|
helper,
|
|
18
|
-
direction
|
|
18
|
+
direction,
|
|
19
|
+
shouldUnregister = false
|
|
19
20
|
} = _ref;
|
|
20
21
|
const {
|
|
21
22
|
getError
|
|
@@ -27,7 +28,11 @@ const RadioGroupField = _ref => {
|
|
|
27
28
|
}
|
|
28
29
|
} = useController({
|
|
29
30
|
name,
|
|
30
|
-
|
|
31
|
+
shouldUnregister,
|
|
32
|
+
rules: {
|
|
33
|
+
required,
|
|
34
|
+
...rules
|
|
35
|
+
}
|
|
31
36
|
});
|
|
32
37
|
return jsx(RadioGroup, {
|
|
33
38
|
className: className,
|
|
@@ -40,7 +40,8 @@ const SelectInputField = _ref => {
|
|
|
40
40
|
rules,
|
|
41
41
|
noTopLabel,
|
|
42
42
|
noOptionsMessage,
|
|
43
|
-
customStyle
|
|
43
|
+
customStyle,
|
|
44
|
+
shouldUnregister = false
|
|
44
45
|
} = _ref;
|
|
45
46
|
const options = useMemo(() => optionsProp || Children.toArray(children).flat().filter(Boolean).map(_ref2 => {
|
|
46
47
|
let {
|
|
@@ -81,6 +82,7 @@ const SelectInputField = _ref => {
|
|
|
81
82
|
}
|
|
82
83
|
} = useController({
|
|
83
84
|
name,
|
|
85
|
+
shouldUnregister,
|
|
84
86
|
rules: {
|
|
85
87
|
required,
|
|
86
88
|
minLength: minLength || required ? 1 : undefined,
|
|
@@ -18,7 +18,8 @@ const SelectableCardField = _ref => {
|
|
|
18
18
|
tooltip,
|
|
19
19
|
id,
|
|
20
20
|
label,
|
|
21
|
-
rules
|
|
21
|
+
rules,
|
|
22
|
+
shouldUnregister = false
|
|
22
23
|
} = _ref;
|
|
23
24
|
const {
|
|
24
25
|
field,
|
|
@@ -27,6 +28,7 @@ const SelectableCardField = _ref => {
|
|
|
27
28
|
}
|
|
28
29
|
} = useController({
|
|
29
30
|
name,
|
|
31
|
+
shouldUnregister,
|
|
30
32
|
rules: {
|
|
31
33
|
required,
|
|
32
34
|
...rules
|
|
@@ -12,7 +12,8 @@ const TagInputField = _ref => {
|
|
|
12
12
|
placeholder,
|
|
13
13
|
required,
|
|
14
14
|
rules,
|
|
15
|
-
variant
|
|
15
|
+
variant,
|
|
16
|
+
shouldUnregister = false
|
|
16
17
|
} = _ref;
|
|
17
18
|
const {
|
|
18
19
|
field
|
|
@@ -20,6 +21,7 @@ const TagInputField = _ref => {
|
|
|
20
21
|
name,
|
|
21
22
|
rules: {
|
|
22
23
|
required,
|
|
24
|
+
shouldUnregister,
|
|
23
25
|
...rules
|
|
24
26
|
}
|
|
25
27
|
});
|
|
@@ -48,7 +48,8 @@ const TextInputField = _ref => {
|
|
|
48
48
|
validate,
|
|
49
49
|
defaultValue,
|
|
50
50
|
customError,
|
|
51
|
-
innerRef
|
|
51
|
+
innerRef,
|
|
52
|
+
shouldUnregister = false
|
|
52
53
|
} = _ref;
|
|
53
54
|
const {
|
|
54
55
|
getError
|
|
@@ -61,6 +62,7 @@ const TextInputField = _ref => {
|
|
|
61
62
|
} = useController({
|
|
62
63
|
name,
|
|
63
64
|
defaultValue,
|
|
65
|
+
shouldUnregister,
|
|
64
66
|
rules: {
|
|
65
67
|
required,
|
|
66
68
|
validate: {
|
|
@@ -31,7 +31,8 @@ const TimeField = _ref => {
|
|
|
31
31
|
isSearchable,
|
|
32
32
|
rules,
|
|
33
33
|
options,
|
|
34
|
-
'data-testid': dataTestId
|
|
34
|
+
'data-testid': dataTestId,
|
|
35
|
+
shouldUnregister = false
|
|
35
36
|
} = _ref;
|
|
36
37
|
const {
|
|
37
38
|
field,
|
|
@@ -40,6 +41,7 @@ const TimeField = _ref => {
|
|
|
40
41
|
}
|
|
41
42
|
} = useController({
|
|
42
43
|
name,
|
|
44
|
+
shouldUnregister,
|
|
43
45
|
rules: {
|
|
44
46
|
required,
|
|
45
47
|
...rules
|
|
@@ -16,12 +16,14 @@ const ToggleField = _ref => {
|
|
|
16
16
|
labelPosition,
|
|
17
17
|
parse,
|
|
18
18
|
format,
|
|
19
|
-
'data-testid': dataTestId
|
|
19
|
+
'data-testid': dataTestId,
|
|
20
|
+
shouldUnregister = false
|
|
20
21
|
} = _ref;
|
|
21
22
|
const {
|
|
22
23
|
field
|
|
23
24
|
} = useController({
|
|
24
25
|
name,
|
|
26
|
+
shouldUnregister,
|
|
25
27
|
rules: {
|
|
26
28
|
required,
|
|
27
29
|
...rules
|
package/dist/hooks/useField.js
CHANGED
|
@@ -2,9 +2,10 @@ import { useFormContext, useController } from 'react-hook-form';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @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.
|
|
5
|
+
*
|
|
5
6
|
* @example
|
|
6
7
|
* ```tsx
|
|
7
|
-
*
|
|
8
|
+
* const Input = () {
|
|
8
9
|
* const username = useWatch({
|
|
9
10
|
* name: 'username'
|
|
10
11
|
* })
|
|
@@ -14,7 +15,6 @@ import { useFormContext, useController } from 'react-hook-form';
|
|
|
14
15
|
* console.log(errors.username)
|
|
15
16
|
* }
|
|
16
17
|
* ```
|
|
17
|
-
|
|
18
18
|
*/
|
|
19
19
|
const useFieldDeprecated = (name, options) => {
|
|
20
20
|
const {
|
|
@@ -2,6 +2,7 @@ import { useFormContext, useWatch } from 'react-hook-form';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @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.
|
|
5
|
+
*
|
|
5
6
|
* @example
|
|
6
7
|
* ```tsx
|
|
7
8
|
* const Input = () {
|
package/dist/index.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ type RequiredErrors = {
|
|
|
27
27
|
type FormErrors = {
|
|
28
28
|
[key in 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'minDate' | 'maxDate']: RequiredErrors[key];
|
|
29
29
|
};
|
|
30
|
-
type BaseFieldProps<TFieldValues extends FieldValues
|
|
31
|
-
name:
|
|
30
|
+
type BaseFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
31
|
+
name: TName;
|
|
32
32
|
required?: boolean;
|
|
33
33
|
/**
|
|
34
34
|
* @deprecated use rules props instead
|
|
@@ -38,18 +38,19 @@ type BaseFieldProps<TFieldValues extends FieldValues = FieldValues> = {
|
|
|
38
38
|
defaultValue?: PathValue<TFieldValues, Path<TFieldValues>>;
|
|
39
39
|
label?: string;
|
|
40
40
|
value?: PathValue<TFieldValues, Path<TFieldValues>>;
|
|
41
|
-
onChange?: (value?: PathValue<TFieldValues,
|
|
41
|
+
onChange?: (value?: PathValue<TFieldValues, TName>) => void;
|
|
42
|
+
shouldUnregister?: UseControllerProps<TFieldValues, TName>['shouldUnregister'];
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
type CheckboxFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldValues> & Partial<Pick<ComponentProps<typeof Checkbox>, 'disabled' | 'onBlur' | 'onFocus' | 'progress' | 'size' | 'data-testid' | 'helper' | 'tooltip'>> & {
|
|
45
46
|
className?: string;
|
|
46
47
|
children?: ReactNode;
|
|
47
48
|
};
|
|
48
|
-
declare const CheckboxField: <TFieldValues extends FieldValues>({ name, label, size, progress, disabled, required, className, children, onChange, onBlur, onFocus, rules, helper, tooltip, "data-testid": dataTestId, value, }: CheckboxFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
49
|
+
declare const CheckboxField: <TFieldValues extends FieldValues>({ name, label, size, progress, disabled, required, className, children, onChange, onBlur, onFocus, rules, helper, tooltip, "data-testid": dataTestId, value, shouldUnregister, }: CheckboxFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
49
50
|
|
|
50
51
|
type CheckboxGroupFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldValues> & Partial<Pick<ComponentProps<typeof CheckboxGroup>, 'className' | 'helper' | 'required' | 'direction' | 'children' | 'error' | 'legend'>> & Required<Pick<ComponentProps<typeof CheckboxGroup>, 'legend'>>;
|
|
51
52
|
declare const CheckboxGroupField: {
|
|
52
|
-
<TFieldValues extends FieldValues>({ legend, className, helper, direction, children, onChange, label, error: customError, name, required, }: CheckboxGroupFieldProps<TFieldValues>): _emotion_react_jsx_runtime.JSX.Element;
|
|
53
|
+
<TFieldValues extends FieldValues>({ legend, className, helper, direction, children, onChange, label, error: customError, name, required, shouldUnregister, }: CheckboxGroupFieldProps<TFieldValues>): _emotion_react_jsx_runtime.JSX.Element;
|
|
53
54
|
Checkbox: ({ onFocus, onBlur, disabled, error, name, value, children, helper, className, autoFocus, "data-testid": dataTestId, }: Omit<({
|
|
54
55
|
error?: react.ReactNode;
|
|
55
56
|
size?: number | undefined;
|
|
@@ -85,7 +86,7 @@ type DateFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldVal
|
|
|
85
86
|
onFocus?: (value: FocusEvent<HTMLElement>) => void;
|
|
86
87
|
autoFocus?: boolean;
|
|
87
88
|
};
|
|
88
|
-
declare const DateField: <TFieldValues extends FieldValues>({ required, name, label, format, locale, maxDate, minDate, disabled, onChange, onBlur, onFocus, rules, autoFocus, excludeDates, selectsRange, "data-testid": dataTestId, }: DateFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
89
|
+
declare const DateField: <TFieldValues extends FieldValues>({ required, name, label, format, locale, maxDate, minDate, disabled, onChange, onBlur, onFocus, rules, autoFocus, excludeDates, selectsRange, "data-testid": dataTestId, shouldUnregister, }: DateFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
89
90
|
|
|
90
91
|
type Without<T, U> = {
|
|
91
92
|
[P in Exclude<keyof T, keyof U>]?: never;
|
|
@@ -123,7 +124,21 @@ type FormProps<TFormValues extends FieldValues = FieldValues> = {
|
|
|
123
124
|
} & XOR<[
|
|
124
125
|
{
|
|
125
126
|
/**
|
|
126
|
-
* @deprecated
|
|
127
|
+
* @deprecated Use the `methods` prop with [useForm](https://www.react-hook-form.com/api/useform/) instead.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```tsx
|
|
131
|
+
* const methods = useForm({
|
|
132
|
+
* defaultValues,
|
|
133
|
+
* mode: 'onChange'
|
|
134
|
+
* })
|
|
135
|
+
*
|
|
136
|
+
* return (
|
|
137
|
+
* <Form methods={methods} onRawSubmit={handleSubmit} errors={formErrors}>
|
|
138
|
+
* // ...
|
|
139
|
+
* </Form>
|
|
140
|
+
* )
|
|
141
|
+
* ```
|
|
127
142
|
*/
|
|
128
143
|
initialValues?: DefaultValues<TFormValues>;
|
|
129
144
|
},
|
|
@@ -136,7 +151,7 @@ declare const Form: <TFormValues extends FieldValues>({ children, methods: metho
|
|
|
136
151
|
type RadioFieldProps<TFieldValues extends FieldValues> = Omit<BaseFieldProps<TFieldValues>, 'label'> & Partial<Pick<ComponentProps<typeof Radio>, 'disabled' | 'id' | 'onBlur' | 'onFocus' | 'data-testid' | 'tooltip' | 'label'>> & {
|
|
137
152
|
className?: string;
|
|
138
153
|
};
|
|
139
|
-
declare const RadioField: <TFieldValues extends FieldValues>({ className, "data-testid": dataTestId, disabled, id, name, onBlur, label, onChange, onFocus, required, value, rules, tooltip, }: RadioFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
154
|
+
declare const RadioField: <TFieldValues extends FieldValues>({ className, "data-testid": dataTestId, disabled, id, name, onBlur, label, onChange, onFocus, required, value, rules, tooltip, shouldUnregister, }: RadioFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
140
155
|
|
|
141
156
|
type SelectOption = {
|
|
142
157
|
value: string;
|
|
@@ -205,7 +220,7 @@ type SelectInputFieldProps<TFieldValues extends FieldValues = FieldValues> = Omi
|
|
|
205
220
|
minLength?: number;
|
|
206
221
|
};
|
|
207
222
|
declare const SelectInputField: {
|
|
208
|
-
<TFieldValues extends FieldValues>({ animation, animationDuration, animationOnChange, children, className, disabled, format: formatProp, id, inputId, isClearable, isLoading, isSearchable, label, maxLength, menuPortalTarget, minLength, multiple, name, onBlur, onChange, onFocus, options: optionsProp, parse: parseProp, placeholder, readOnly, required, rules, noTopLabel, noOptionsMessage, customStyle, }: SelectInputFieldProps<TFieldValues>): _emotion_react_jsx_runtime.JSX.Element;
|
|
223
|
+
<TFieldValues extends FieldValues>({ animation, animationDuration, animationOnChange, children, className, disabled, format: formatProp, id, inputId, isClearable, isLoading, isSearchable, label, maxLength, menuPortalTarget, minLength, multiple, name, onBlur, onChange, onFocus, options: optionsProp, parse: parseProp, placeholder, readOnly, required, rules, noTopLabel, noOptionsMessage, customStyle, shouldUnregister, }: SelectInputFieldProps<TFieldValues>): _emotion_react_jsx_runtime.JSX.Element;
|
|
209
224
|
Option: (props: Partial<OptionProps<{
|
|
210
225
|
value: string;
|
|
211
226
|
label: ReactNode;
|
|
@@ -230,26 +245,23 @@ declare const SelectInputField: {
|
|
|
230
245
|
type SelectableCardFieldProps<TFieldValues extends FieldValues> = Omit<BaseFieldProps<TFieldValues>, 'label' | 'onChange'> & Partial<Pick<ComponentProps<typeof SelectableCard>, 'disabled' | 'onBlur' | 'onChange' | 'onFocus' | 'showTick' | 'type' | 'id' | 'children' | 'tooltip' | 'label'>> & {
|
|
231
246
|
className?: string;
|
|
232
247
|
};
|
|
233
|
-
declare const SelectableCardField: <TFieldValues extends FieldValues>({ name, value, onChange, showTick, type, disabled, children, className, onFocus, onBlur, required, tooltip, id, label, rules, }: SelectableCardFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
248
|
+
declare const SelectableCardField: <TFieldValues extends FieldValues>({ name, value, onChange, showTick, type, disabled, children, className, onFocus, onBlur, required, tooltip, id, label, rules, shouldUnregister, }: SelectableCardFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
234
249
|
|
|
235
250
|
type NumberInputValueFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldValues> & Partial<Pick<ComponentProps<typeof NumberInput>, 'disabled' | 'maxValue' | 'minValue' | 'onMaxCrossed' | 'onMinCrossed' | 'size' | 'step' | 'text' | 'className'>> & {
|
|
236
251
|
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
237
252
|
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
238
253
|
};
|
|
239
|
-
declare const NumberInputField: <TFieldValues extends FieldValues>({ disabled, maxValue, minValue, name, onChange, onBlur, onFocus, onMaxCrossed, onMinCrossed, required, size, step, text, rules, className, label, }: NumberInputValueFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
254
|
+
declare const NumberInputField: <TFieldValues extends FieldValues>({ disabled, maxValue, minValue, name, onChange, onBlur, onFocus, onMaxCrossed, onMinCrossed, required, size, step, text, rules, className, label, shouldUnregister, }: NumberInputValueFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
240
255
|
|
|
241
256
|
declare const SubmitErrorAlert: ({ className }: {
|
|
242
257
|
className?: string | undefined;
|
|
243
258
|
}) => _emotion_react_jsx_runtime.JSX.Element | null;
|
|
244
259
|
|
|
245
260
|
type TagInputFieldProps<TFieldValues extends FieldValues = FieldValues> = BaseFieldProps<TFieldValues> & Partial<Pick<ComponentProps<typeof TagInput>, 'tags' | 'variant' | 'placeholder' | 'disabled' | 'className' | 'id'>>;
|
|
246
|
-
declare const TagInputField: <TFieldValues extends FieldValues>({ className, disabled, id, name, onChange, placeholder, required, rules, variant, }: TagInputFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
261
|
+
declare const TagInputField: <TFieldValues extends FieldValues>({ className, disabled, id, name, onChange, placeholder, required, rules, variant, shouldUnregister, }: TagInputFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
247
262
|
|
|
248
|
-
type TextInputFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldValues> & Partial<Pick<ComponentProps<typeof TextInput>, 'autoCapitalize' | 'autoComplete' | 'autoCorrect' | 'autoFocus' | 'autoSave' | 'cols' | 'disabled' | 'fillAvailable' | 'generated' | 'id' | 'multiline' | 'notice' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'placeholder' | 'random' | 'readOnly' | 'resizable' | 'rows' | 'type' | 'noTopLabel' | 'unit' | 'valid' | 'size' | 'maxLength' | 'minLength' | 'min' | 'max'>> & {
|
|
263
|
+
type TextInputFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Partial<Pick<ComponentProps<typeof TextInput>, 'autoCapitalize' | 'autoComplete' | 'autoCorrect' | 'autoFocus' | 'autoSave' | 'cols' | 'disabled' | 'fillAvailable' | 'generated' | 'id' | 'multiline' | 'notice' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'placeholder' | 'random' | 'readOnly' | 'resizable' | 'rows' | 'type' | 'noTopLabel' | 'unit' | 'valid' | 'size' | 'maxLength' | 'minLength' | 'min' | 'max'>> & {
|
|
249
264
|
className?: string;
|
|
250
|
-
/**
|
|
251
|
-
* @deprecated Use rules instead
|
|
252
|
-
*/
|
|
253
265
|
regex?: (RegExp | RegExp[])[];
|
|
254
266
|
format?: (value: unknown) => PathValue<TFieldValues, Path<TFieldValues>>;
|
|
255
267
|
parse?: (value: string) => PathValue<TFieldValues, Path<TFieldValues>>;
|
|
@@ -257,18 +269,18 @@ type TextInputFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFie
|
|
|
257
269
|
formatOnBlur?: boolean;
|
|
258
270
|
innerRef?: Ref<HTMLInputElement>;
|
|
259
271
|
};
|
|
260
|
-
declare const TextInputField: <TFieldValues extends FieldValues>({ autoCapitalize, autoComplete, autoCorrect, autoFocus, autoSave, className, cols, disabled, fillAvailable, generated, id, label, multiline, name, noTopLabel, notice, onChange, onFocus, onKeyDown, onKeyUp, onBlur, placeholder, random, readOnly, required, resizable, rows, type, unit, size, rules, valid, parse, format, formatOnBlur, regex: regexes, min, max, minLength, maxLength, validate, defaultValue, customError, innerRef, }: TextInputFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
272
|
+
declare const TextInputField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autoCapitalize, autoComplete, autoCorrect, autoFocus, autoSave, className, cols, disabled, fillAvailable, generated, id, label, multiline, name, noTopLabel, notice, onChange, onFocus, onKeyDown, onKeyUp, onBlur, placeholder, random, readOnly, required, resizable, rows, type, unit, size, rules, valid, parse, format, formatOnBlur, regex: regexes, min, max, minLength, maxLength, validate, defaultValue, customError, innerRef, shouldUnregister, }: TextInputFieldProps<TFieldValues, TName>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
261
273
|
|
|
262
274
|
type TimeFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFieldValues> & Omit<ComponentProps<typeof TimeInput>, 'onChange'> & {
|
|
263
275
|
name: string;
|
|
264
276
|
};
|
|
265
|
-
declare const TimeField: <TFieldValues extends FieldValues>({ required, name, schedule, placeholder, disabled, readOnly, onBlur, onFocus, onChange, isLoading, isClearable, inputId, id, animation, animationDuration, animationOnChange, className, isSearchable, rules, options, "data-testid": dataTestId, }: TimeFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
277
|
+
declare const TimeField: <TFieldValues extends FieldValues>({ required, name, schedule, placeholder, disabled, readOnly, onBlur, onFocus, onChange, isLoading, isClearable, inputId, id, animation, animationDuration, animationOnChange, className, isSearchable, rules, options, "data-testid": dataTestId, shouldUnregister, }: TimeFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
266
278
|
|
|
267
279
|
type ToggleFieldProps<TFieldValues extends FieldValues> = Omit<BaseFieldProps<TFieldValues>, 'label'> & Pick<ComponentProps<typeof Toggle>, 'disabled' | 'label' | 'onChange' | 'size' | 'tooltip' | 'labelPosition' | 'className' | 'data-testid'> & {
|
|
268
280
|
parse?: (value: boolean) => any;
|
|
269
281
|
format?: (value: any) => boolean;
|
|
270
282
|
};
|
|
271
|
-
declare const ToggleField: <TFieldValues extends FieldValues>({ className, disabled, label, name, onChange, required, size, tooltip, rules, labelPosition, parse, format, "data-testid": dataTestId, }: ToggleFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
283
|
+
declare const ToggleField: <TFieldValues extends FieldValues>({ className, disabled, label, name, onChange, required, size, tooltip, rules, labelPosition, parse, format, "data-testid": dataTestId, shouldUnregister, }: ToggleFieldProps<TFieldValues>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
272
284
|
|
|
273
285
|
type SubmitProps = {
|
|
274
286
|
children?: ReactNode;
|
|
@@ -289,19 +301,19 @@ type RadioGroupFieldProps<TFieldValues extends FieldValues> = BaseFieldProps<TFi
|
|
|
289
301
|
className?: string;
|
|
290
302
|
};
|
|
291
303
|
declare const RadioGroupField: {
|
|
292
|
-
<TFieldValues extends FieldValues>({ className, legend, name, onChange, required, rules, children, label, error: customError, helper, direction, }: RadioGroupFieldProps<TFieldValues>): JSX.Element;
|
|
304
|
+
<TFieldValues extends FieldValues>({ className, legend, name, onChange, required, rules, children, label, error: customError, helper, direction, shouldUnregister, }: RadioGroupFieldProps<TFieldValues>): JSX.Element;
|
|
293
305
|
Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, "data-testid": dataTestId, }: {
|
|
294
306
|
value: string | number;
|
|
295
307
|
onBlur?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
296
308
|
disabled?: boolean | undefined;
|
|
297
309
|
className?: string | undefined;
|
|
298
310
|
ref?: react.Ref<HTMLInputElement> | undefined;
|
|
299
|
-
label?: react.ReactNode;
|
|
300
311
|
onFocus?: react.FocusEventHandler<HTMLInputElement> | undefined;
|
|
301
312
|
name?: string | undefined;
|
|
302
313
|
autoFocus?: boolean | undefined;
|
|
303
314
|
id?: string | undefined;
|
|
304
315
|
'aria-label'?: string | undefined;
|
|
316
|
+
label?: react.ReactNode;
|
|
305
317
|
'data-testid'?: string | undefined;
|
|
306
318
|
helper?: react.ReactNode;
|
|
307
319
|
tooltip?: string | undefined;
|
|
@@ -323,9 +335,6 @@ declare const ErrorProvider: ({ children, errors }: ErrorProviderProps) => _emot
|
|
|
323
335
|
declare const useErrors: () => ErrorContextValue;
|
|
324
336
|
|
|
325
337
|
type CallbackFn<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = (value: FieldPathValue<TFieldValues, TFieldName>, values: DeepPartial<TFieldValues>) => void | Promise<void>;
|
|
326
|
-
/**
|
|
327
|
-
* @deprecated
|
|
328
|
-
*/
|
|
329
338
|
declare const useOnFieldChange: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>>(fieldName: TFieldName, callback: CallbackFn<TFieldValues, TFieldName>, enabled?: boolean) => void;
|
|
330
339
|
|
|
331
340
|
type UseFormStateParams = {
|
|
@@ -333,6 +342,7 @@ type UseFormStateParams = {
|
|
|
333
342
|
};
|
|
334
343
|
/**
|
|
335
344
|
* @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.
|
|
345
|
+
*
|
|
336
346
|
* @example
|
|
337
347
|
* ```tsx
|
|
338
348
|
* const Input = () {
|
|
@@ -371,9 +381,10 @@ type Options$1<TFieldValues extends FieldValues> = {
|
|
|
371
381
|
};
|
|
372
382
|
/**
|
|
373
383
|
* @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.
|
|
384
|
+
*
|
|
374
385
|
* @example
|
|
375
386
|
* ```tsx
|
|
376
|
-
*
|
|
387
|
+
* const Input = () {
|
|
377
388
|
* const username = useWatch({
|
|
378
389
|
* name: 'username'
|
|
379
390
|
* })
|
|
@@ -383,7 +394,6 @@ type Options$1<TFieldValues extends FieldValues> = {
|
|
|
383
394
|
* console.log(errors.username)
|
|
384
395
|
* }
|
|
385
396
|
* ```
|
|
386
|
-
|
|
387
397
|
*/
|
|
388
398
|
declare const useFieldDeprecated: <T, TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: Options$1<TFieldValues> | undefined) => {
|
|
389
399
|
input: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.8",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"react-hook-form": "7.47.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@babel/core": "7.23.
|
|
42
|
+
"@babel/core": "7.23.5",
|
|
43
43
|
"@types/final-form-focus": "1.1.7",
|
|
44
|
-
"@types/react": "18.2.
|
|
45
|
-
"@types/react-dom": "18.2.
|
|
44
|
+
"@types/react": "18.2.43",
|
|
45
|
+
"@types/react-dom": "18.2.17",
|
|
46
46
|
"react": "18.2.0",
|
|
47
47
|
"react-dom": "18.2.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@babel/runtime": "7.23.
|
|
50
|
+
"@babel/runtime": "7.23.5",
|
|
51
51
|
"@emotion/babel-plugin": "11.11.0",
|
|
52
52
|
"@emotion/react": "11.11.1",
|
|
53
53
|
"@emotion/styled": "11.11.0",
|
|
54
54
|
"react-select": "5.8.0",
|
|
55
55
|
"react-hook-form": "^7.47.0",
|
|
56
|
-
"@ultraviolet/ui": "1.
|
|
56
|
+
"@ultraviolet/ui": "1.28.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "rollup -c ../../rollup.config.mjs"
|