@ultraviolet/form 2.0.0-next.5 → 2.0.0-next.6
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 +36 -39
- package/dist/components/CheckboxGroupField/index.js +29 -32
- package/dist/components/DateField/index.js +50 -50
- package/dist/components/NumberInputField/index.js +38 -41
- package/dist/components/RadioField/index.js +32 -35
- package/dist/components/RadioGroupField/index.js +25 -28
- package/dist/components/SelectInputField/index.js +46 -49
- package/dist/components/SelectableCardField/index.js +33 -36
- package/dist/components/TagInputField/index.js +18 -21
- package/dist/components/TextInputField/index.js +86 -83
- package/dist/components/TimeField/index.js +44 -47
- package/dist/components/ToggleField/index.js +31 -36
- package/dist/index.d.ts +25 -366
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checkbox } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
5
|
|
|
@@ -25,49 +25,46 @@ const CheckboxField = _ref => {
|
|
|
25
25
|
const {
|
|
26
26
|
getError
|
|
27
27
|
} = useErrors();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const {
|
|
29
|
+
field,
|
|
30
|
+
fieldState: {
|
|
31
|
+
error
|
|
32
|
+
}
|
|
33
|
+
} = useController({
|
|
34
|
+
name,
|
|
35
|
+
disabled,
|
|
31
36
|
rules: {
|
|
32
37
|
required,
|
|
33
38
|
...rules
|
|
34
|
-
},
|
|
35
|
-
render: _ref2 => {
|
|
36
|
-
let {
|
|
37
|
-
field,
|
|
38
|
-
fieldState: {
|
|
39
|
-
error
|
|
40
|
-
}
|
|
41
|
-
} = _ref2;
|
|
42
|
-
return jsx(Checkbox, {
|
|
43
|
-
name: field.name,
|
|
44
|
-
onChange: event => {
|
|
45
|
-
field.onChange(value ? [...(field.value ?? []), value] : event.target.checked);
|
|
46
|
-
onChange?.(event);
|
|
47
|
-
},
|
|
48
|
-
onBlur: event => {
|
|
49
|
-
field.onBlur();
|
|
50
|
-
onBlur?.(event);
|
|
51
|
-
},
|
|
52
|
-
onFocus: onFocus,
|
|
53
|
-
size: size,
|
|
54
|
-
progress: progress,
|
|
55
|
-
disabled: field.disabled,
|
|
56
|
-
checked: Array.isArray(field.value) ? field.value.includes(value) : !!field.value,
|
|
57
|
-
error: getError({
|
|
58
|
-
label: label ?? ''
|
|
59
|
-
}, error),
|
|
60
|
-
ref: field.ref,
|
|
61
|
-
className: className,
|
|
62
|
-
required: required,
|
|
63
|
-
"data-testid": dataTestId,
|
|
64
|
-
helper: helper,
|
|
65
|
-
tooltip: tooltip,
|
|
66
|
-
value: value,
|
|
67
|
-
children: children
|
|
68
|
-
});
|
|
69
39
|
}
|
|
70
40
|
});
|
|
41
|
+
return jsx(Checkbox, {
|
|
42
|
+
name: field.name,
|
|
43
|
+
onChange: event => {
|
|
44
|
+
field.onChange(value ? [...(field.value ?? []), value] : event.target.checked);
|
|
45
|
+
onChange?.(event.target.checked);
|
|
46
|
+
},
|
|
47
|
+
onBlur: event => {
|
|
48
|
+
field.onBlur();
|
|
49
|
+
onBlur?.(event);
|
|
50
|
+
},
|
|
51
|
+
onFocus: onFocus,
|
|
52
|
+
size: size,
|
|
53
|
+
progress: progress,
|
|
54
|
+
disabled: field.disabled,
|
|
55
|
+
checked: Array.isArray(field.value) ? field.value.includes(value) : !!field.value,
|
|
56
|
+
error: getError({
|
|
57
|
+
label: label ?? ''
|
|
58
|
+
}, error),
|
|
59
|
+
ref: field.ref,
|
|
60
|
+
className: className,
|
|
61
|
+
required: required,
|
|
62
|
+
"data-testid": dataTestId,
|
|
63
|
+
helper: helper,
|
|
64
|
+
tooltip: tooltip,
|
|
65
|
+
value: value,
|
|
66
|
+
children: children
|
|
67
|
+
});
|
|
71
68
|
};
|
|
72
69
|
|
|
73
70
|
export { CheckboxField };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckboxGroup } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
5
|
|
|
@@ -19,38 +19,35 @@ const CheckboxGroupField = _ref => {
|
|
|
19
19
|
const {
|
|
20
20
|
getError
|
|
21
21
|
} = useErrors();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
field,
|
|
27
|
-
fieldState: {
|
|
28
|
-
error
|
|
29
|
-
}
|
|
30
|
-
} = _ref2;
|
|
31
|
-
return jsx(CheckboxGroup, {
|
|
32
|
-
legend: legend,
|
|
33
|
-
name: name,
|
|
34
|
-
value: field.value,
|
|
35
|
-
onChange: event => {
|
|
36
|
-
const fieldValue = field.value;
|
|
37
|
-
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
38
|
-
field.onChange(fieldValue?.filter(currentValue => currentValue !== event.currentTarget.value));
|
|
39
|
-
} else {
|
|
40
|
-
field.onChange([...field.value, event.currentTarget.value]);
|
|
41
|
-
}
|
|
42
|
-
onChange?.(event);
|
|
43
|
-
},
|
|
44
|
-
error: getError({
|
|
45
|
-
label
|
|
46
|
-
}, error) ?? customError,
|
|
47
|
-
className: className,
|
|
48
|
-
direction: direction,
|
|
49
|
-
helper: helper,
|
|
50
|
-
required: required,
|
|
51
|
-
children: children
|
|
52
|
-
});
|
|
22
|
+
const {
|
|
23
|
+
field,
|
|
24
|
+
fieldState: {
|
|
25
|
+
error
|
|
53
26
|
}
|
|
27
|
+
} = useController({
|
|
28
|
+
name
|
|
29
|
+
});
|
|
30
|
+
return jsx(CheckboxGroup, {
|
|
31
|
+
legend: legend,
|
|
32
|
+
name: name,
|
|
33
|
+
value: field.value,
|
|
34
|
+
onChange: event => {
|
|
35
|
+
const fieldValue = field.value;
|
|
36
|
+
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
37
|
+
field.onChange(fieldValue?.filter(currentValue => currentValue !== event.currentTarget.value));
|
|
38
|
+
} else {
|
|
39
|
+
field.onChange([...field.value, event.currentTarget.value]);
|
|
40
|
+
}
|
|
41
|
+
onChange?.(event.currentTarget.value);
|
|
42
|
+
},
|
|
43
|
+
error: getError({
|
|
44
|
+
label
|
|
45
|
+
}, error) ?? customError,
|
|
46
|
+
className: className,
|
|
47
|
+
direction: direction,
|
|
48
|
+
helper: helper,
|
|
49
|
+
required: required,
|
|
50
|
+
children: children
|
|
54
51
|
});
|
|
55
52
|
};
|
|
56
53
|
CheckboxGroupField.Checkbox = CheckboxGroup.Checkbox;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DateInput } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
3
|
import { maxDateValidator } from '../../validators/maxDate.js';
|
|
4
4
|
import { minDateValidator } from '../../validators/minDate.js';
|
|
5
5
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
@@ -29,8 +29,13 @@ const DateField = _ref => {
|
|
|
29
29
|
const {
|
|
30
30
|
getError
|
|
31
31
|
} = useErrors();
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const {
|
|
33
|
+
field,
|
|
34
|
+
fieldState: {
|
|
35
|
+
error
|
|
36
|
+
}
|
|
37
|
+
} = useController({
|
|
38
|
+
name,
|
|
34
39
|
rules: {
|
|
35
40
|
...rules,
|
|
36
41
|
validate: {
|
|
@@ -39,55 +44,50 @@ const DateField = _ref => {
|
|
|
39
44
|
maxDate: maxDateValidator(maxDate)
|
|
40
45
|
},
|
|
41
46
|
required
|
|
42
|
-
},
|
|
43
|
-
render: _ref2 => {
|
|
44
|
-
let {
|
|
45
|
-
field,
|
|
46
|
-
fieldState: {
|
|
47
|
-
error
|
|
48
|
-
}
|
|
49
|
-
} = _ref2;
|
|
50
|
-
return jsx(DateInput, {
|
|
51
|
-
name: field.name,
|
|
52
|
-
label: label,
|
|
53
|
-
value: field.value,
|
|
54
|
-
format: format || (value => value ? parseDate(value).toLocaleDateString() : ''),
|
|
55
|
-
locale: locale,
|
|
56
|
-
required: required,
|
|
57
|
-
onChange: val => {
|
|
58
|
-
if (val && val instanceof Date) {
|
|
59
|
-
onChange?.(val);
|
|
60
|
-
const newDate = parseDate(val);
|
|
61
|
-
if (isEmpty(field.value)) {
|
|
62
|
-
field.onChange(newDate);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const currentDate = parseDate(field.value);
|
|
66
|
-
newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
|
|
67
|
-
field.onChange(newDate);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
onBlur: e => {
|
|
71
|
-
field.onBlur();
|
|
72
|
-
onBlur?.(e);
|
|
73
|
-
},
|
|
74
|
-
onFocus: onFocus,
|
|
75
|
-
maxDate: maxDate,
|
|
76
|
-
minDate: minDate,
|
|
77
|
-
error: getError({
|
|
78
|
-
minDate,
|
|
79
|
-
maxDate,
|
|
80
|
-
label
|
|
81
|
-
}, error),
|
|
82
|
-
disabled: disabled,
|
|
83
|
-
autoFocus: autoFocus,
|
|
84
|
-
excludeDates: excludeDates,
|
|
85
|
-
"data-testid": dataTestId,
|
|
86
|
-
startDate: selectsRange ? field.value[0] : undefined,
|
|
87
|
-
endDate: selectsRange ? field.value[1] : undefined
|
|
88
|
-
});
|
|
89
47
|
}
|
|
90
48
|
});
|
|
49
|
+
return jsx(DateInput, {
|
|
50
|
+
name: field.name,
|
|
51
|
+
label: label,
|
|
52
|
+
value: field.value,
|
|
53
|
+
format: format || (value => value ? parseDate(value).toLocaleDateString() : ''),
|
|
54
|
+
locale: locale,
|
|
55
|
+
required: required,
|
|
56
|
+
onChange: val => {
|
|
57
|
+
if (val && val instanceof Date) {
|
|
58
|
+
onChange?.(val);
|
|
59
|
+
const newDate = parseDate(val);
|
|
60
|
+
if (isEmpty(field.value)) {
|
|
61
|
+
field.onChange(newDate);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const currentDate = parseDate(field.value);
|
|
65
|
+
newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
|
|
66
|
+
field.onChange(newDate);
|
|
67
|
+
} else if (Array.isArray(val)) {
|
|
68
|
+
field.onChange(val);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
onBlur: e => {
|
|
72
|
+
field.onBlur();
|
|
73
|
+
onBlur?.(e);
|
|
74
|
+
},
|
|
75
|
+
onFocus: onFocus,
|
|
76
|
+
maxDate: maxDate,
|
|
77
|
+
minDate: minDate,
|
|
78
|
+
error: getError({
|
|
79
|
+
minDate,
|
|
80
|
+
maxDate,
|
|
81
|
+
label
|
|
82
|
+
}, error),
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
autoFocus: autoFocus,
|
|
85
|
+
excludeDates: excludeDates,
|
|
86
|
+
selectsRange: selectsRange,
|
|
87
|
+
"data-testid": dataTestId,
|
|
88
|
+
startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : undefined,
|
|
89
|
+
endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : undefined
|
|
90
|
+
});
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
export { DateField };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NumberInput } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
5
|
|
|
@@ -25,52 +25,49 @@ const NumberInputField = _ref => {
|
|
|
25
25
|
const {
|
|
26
26
|
getError
|
|
27
27
|
} = useErrors();
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const {
|
|
29
|
+
field,
|
|
30
|
+
fieldState: {
|
|
31
|
+
error
|
|
32
|
+
}
|
|
33
|
+
} = useController({
|
|
34
|
+
name,
|
|
30
35
|
rules: {
|
|
31
|
-
required,
|
|
32
36
|
max: maxValue,
|
|
33
37
|
min: minValue,
|
|
38
|
+
required,
|
|
34
39
|
...rules
|
|
35
|
-
},
|
|
36
|
-
render: _ref2 => {
|
|
37
|
-
let {
|
|
38
|
-
field,
|
|
39
|
-
fieldState: {
|
|
40
|
-
error
|
|
41
|
-
}
|
|
42
|
-
} = _ref2;
|
|
43
|
-
return jsx(NumberInput, {
|
|
44
|
-
name: field.name,
|
|
45
|
-
value: field.value,
|
|
46
|
-
disabled: disabled,
|
|
47
|
-
onBlur: event => {
|
|
48
|
-
field.onBlur();
|
|
49
|
-
onBlur?.(event);
|
|
50
|
-
},
|
|
51
|
-
onChange: event => {
|
|
52
|
-
// React hook form doesnt allow undefined values after definition https://react-hook-form.com/docs/usecontroller/controller (that make sense)
|
|
53
|
-
field.onChange(event ?? null);
|
|
54
|
-
onChange?.(event);
|
|
55
|
-
},
|
|
56
|
-
onFocus: onFocus,
|
|
57
|
-
maxValue: maxValue,
|
|
58
|
-
minValue: minValue,
|
|
59
|
-
onMinCrossed: onMinCrossed,
|
|
60
|
-
onMaxCrossed: onMaxCrossed,
|
|
61
|
-
size: size,
|
|
62
|
-
step: step,
|
|
63
|
-
text: text,
|
|
64
|
-
className: className,
|
|
65
|
-
label: label,
|
|
66
|
-
error: getError({
|
|
67
|
-
label: label ?? '',
|
|
68
|
-
max: maxValue,
|
|
69
|
-
min: minValue
|
|
70
|
-
}, error)
|
|
71
|
-
});
|
|
72
40
|
}
|
|
73
41
|
});
|
|
42
|
+
return jsx(NumberInput, {
|
|
43
|
+
name: field.name,
|
|
44
|
+
value: field.value,
|
|
45
|
+
disabled: disabled,
|
|
46
|
+
onBlur: event => {
|
|
47
|
+
field.onBlur();
|
|
48
|
+
onBlur?.(event);
|
|
49
|
+
},
|
|
50
|
+
onChange: event => {
|
|
51
|
+
// React hook form doesnt allow undefined values after definition https://react-hook-form.com/docs/usecontroller/controller (that make sense)
|
|
52
|
+
field.onChange(event ?? null);
|
|
53
|
+
onChange?.(event);
|
|
54
|
+
},
|
|
55
|
+
onFocus: onFocus,
|
|
56
|
+
maxValue: maxValue,
|
|
57
|
+
minValue: minValue,
|
|
58
|
+
onMinCrossed: onMinCrossed,
|
|
59
|
+
onMaxCrossed: onMaxCrossed,
|
|
60
|
+
size: size,
|
|
61
|
+
step: step,
|
|
62
|
+
text: text,
|
|
63
|
+
className: className,
|
|
64
|
+
label: label,
|
|
65
|
+
error: getError({
|
|
66
|
+
label: label ?? '',
|
|
67
|
+
max: maxValue,
|
|
68
|
+
min: minValue
|
|
69
|
+
}, error)
|
|
70
|
+
});
|
|
74
71
|
};
|
|
75
72
|
|
|
76
73
|
export { NumberInputField };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Radio } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
5
|
|
|
@@ -22,45 +22,42 @@ const RadioField = _ref => {
|
|
|
22
22
|
const {
|
|
23
23
|
getError
|
|
24
24
|
} = useErrors();
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const {
|
|
26
|
+
field,
|
|
27
|
+
fieldState: {
|
|
28
|
+
error
|
|
29
|
+
}
|
|
30
|
+
} = useController({
|
|
31
|
+
name,
|
|
27
32
|
rules: {
|
|
28
33
|
required,
|
|
29
34
|
...rules
|
|
30
|
-
},
|
|
31
|
-
render: _ref2 => {
|
|
32
|
-
let {
|
|
33
|
-
field,
|
|
34
|
-
fieldState: {
|
|
35
|
-
error
|
|
36
|
-
}
|
|
37
|
-
} = _ref2;
|
|
38
|
-
return jsx(Radio, {
|
|
39
|
-
name: field.name,
|
|
40
|
-
checked: field.value === value,
|
|
41
|
-
className: className,
|
|
42
|
-
"data-testid": dataTestId,
|
|
43
|
-
disabled: disabled,
|
|
44
|
-
error: getError({
|
|
45
|
-
label: typeof label === 'string' ? label : ''
|
|
46
|
-
}, error),
|
|
47
|
-
id: id,
|
|
48
|
-
onChange: event => {
|
|
49
|
-
field.onChange(value);
|
|
50
|
-
onChange?.(event);
|
|
51
|
-
},
|
|
52
|
-
onBlur: event => {
|
|
53
|
-
field.onBlur();
|
|
54
|
-
onBlur?.(event);
|
|
55
|
-
},
|
|
56
|
-
onFocus: onFocus,
|
|
57
|
-
required: required,
|
|
58
|
-
value: value ?? '',
|
|
59
|
-
label: label,
|
|
60
|
-
tooltip: tooltip
|
|
61
|
-
});
|
|
62
35
|
}
|
|
63
36
|
});
|
|
37
|
+
return jsx(Radio, {
|
|
38
|
+
name: field.name,
|
|
39
|
+
checked: field.value === value,
|
|
40
|
+
className: className,
|
|
41
|
+
"data-testid": dataTestId,
|
|
42
|
+
disabled: disabled,
|
|
43
|
+
error: getError({
|
|
44
|
+
label: typeof label === 'string' ? label : ''
|
|
45
|
+
}, error),
|
|
46
|
+
id: id,
|
|
47
|
+
onChange: () => {
|
|
48
|
+
field.onChange(value);
|
|
49
|
+
onChange?.(value);
|
|
50
|
+
},
|
|
51
|
+
onBlur: event => {
|
|
52
|
+
field.onBlur();
|
|
53
|
+
onBlur?.(event);
|
|
54
|
+
},
|
|
55
|
+
onFocus: onFocus,
|
|
56
|
+
required: required,
|
|
57
|
+
value: value ?? '',
|
|
58
|
+
label: label,
|
|
59
|
+
tooltip: tooltip
|
|
60
|
+
});
|
|
64
61
|
};
|
|
65
62
|
|
|
66
63
|
export { RadioField };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RadioGroup } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
5
|
|
|
@@ -20,34 +20,31 @@ const RadioGroupField = _ref => {
|
|
|
20
20
|
const {
|
|
21
21
|
getError
|
|
22
22
|
} = useErrors();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let {
|
|
28
|
-
field,
|
|
29
|
-
fieldState: {
|
|
30
|
-
error
|
|
31
|
-
}
|
|
32
|
-
} = _ref2;
|
|
33
|
-
return jsx(RadioGroup, {
|
|
34
|
-
className: className,
|
|
35
|
-
name: field.name,
|
|
36
|
-
onChange: event => {
|
|
37
|
-
field.onChange(event);
|
|
38
|
-
onChange?.(event);
|
|
39
|
-
},
|
|
40
|
-
required: required,
|
|
41
|
-
value: field.value,
|
|
42
|
-
legend: legend,
|
|
43
|
-
error: getError({
|
|
44
|
-
label
|
|
45
|
-
}, error) ?? customError,
|
|
46
|
-
helper: helper,
|
|
47
|
-
direction: direction,
|
|
48
|
-
children: children
|
|
49
|
-
});
|
|
23
|
+
const {
|
|
24
|
+
field,
|
|
25
|
+
fieldState: {
|
|
26
|
+
error
|
|
50
27
|
}
|
|
28
|
+
} = useController({
|
|
29
|
+
name,
|
|
30
|
+
rules
|
|
31
|
+
});
|
|
32
|
+
return jsx(RadioGroup, {
|
|
33
|
+
className: className,
|
|
34
|
+
name: field.name,
|
|
35
|
+
onChange: event => {
|
|
36
|
+
field.onChange(event);
|
|
37
|
+
onChange?.(event.target.value);
|
|
38
|
+
},
|
|
39
|
+
required: required,
|
|
40
|
+
value: field.value,
|
|
41
|
+
legend: legend,
|
|
42
|
+
error: getError({
|
|
43
|
+
label
|
|
44
|
+
}, error) ?? customError,
|
|
45
|
+
helper: helper,
|
|
46
|
+
direction: direction,
|
|
47
|
+
children: children
|
|
51
48
|
});
|
|
52
49
|
};
|
|
53
50
|
RadioGroupField.Radio = RadioGroup.Radio;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SelectInput } from '@ultraviolet/ui';
|
|
2
2
|
import { useMemo, Children, useCallback } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
4
4
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
5
5
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
6
6
|
|
|
@@ -74,61 +74,58 @@ const SelectInputField = _ref => {
|
|
|
74
74
|
const {
|
|
75
75
|
getError
|
|
76
76
|
} = useErrors();
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const {
|
|
78
|
+
field,
|
|
79
|
+
fieldState: {
|
|
80
|
+
error
|
|
81
|
+
}
|
|
82
|
+
} = useController({
|
|
83
|
+
name,
|
|
79
84
|
rules: {
|
|
80
85
|
required,
|
|
81
86
|
minLength: minLength || required ? 1 : undefined,
|
|
82
87
|
maxLength,
|
|
83
88
|
...rules
|
|
84
|
-
},
|
|
85
|
-
render: _ref3 => {
|
|
86
|
-
let {
|
|
87
|
-
field,
|
|
88
|
-
fieldState: {
|
|
89
|
-
error
|
|
90
|
-
}
|
|
91
|
-
} = _ref3;
|
|
92
|
-
return jsx(SelectInput, {
|
|
93
|
-
name: field.name,
|
|
94
|
-
animation: animation,
|
|
95
|
-
animationDuration: animationDuration,
|
|
96
|
-
animationOnChange: animationOnChange,
|
|
97
|
-
className: className,
|
|
98
|
-
disabled: disabled,
|
|
99
|
-
error: getError({
|
|
100
|
-
label,
|
|
101
|
-
minLength,
|
|
102
|
-
maxLength
|
|
103
|
-
}, error),
|
|
104
|
-
id: id,
|
|
105
|
-
inputId: inputId,
|
|
106
|
-
isClearable: isClearable,
|
|
107
|
-
isLoading: isLoading,
|
|
108
|
-
isMulti: multiple,
|
|
109
|
-
customStyle: customStyle,
|
|
110
|
-
isSearchable: isSearchable,
|
|
111
|
-
menuPortalTarget: menuPortalTarget,
|
|
112
|
-
onBlur: event => {
|
|
113
|
-
field.onBlur();
|
|
114
|
-
onBlur?.(event);
|
|
115
|
-
},
|
|
116
|
-
onChange: (event, action) => {
|
|
117
|
-
field.onChange(parse(event));
|
|
118
|
-
onChange?.(event, action);
|
|
119
|
-
},
|
|
120
|
-
onFocus: onFocus,
|
|
121
|
-
options: options,
|
|
122
|
-
placeholder: placeholder,
|
|
123
|
-
readOnly: readOnly,
|
|
124
|
-
noTopLabel: noTopLabel,
|
|
125
|
-
required: required,
|
|
126
|
-
value: format(field.value),
|
|
127
|
-
noOptionsMessage: noOptionsMessage,
|
|
128
|
-
children: children
|
|
129
|
-
});
|
|
130
89
|
}
|
|
131
90
|
});
|
|
91
|
+
return jsx(SelectInput, {
|
|
92
|
+
name: field.name,
|
|
93
|
+
animation: animation,
|
|
94
|
+
animationDuration: animationDuration,
|
|
95
|
+
animationOnChange: animationOnChange,
|
|
96
|
+
className: className,
|
|
97
|
+
disabled: disabled,
|
|
98
|
+
error: getError({
|
|
99
|
+
label,
|
|
100
|
+
minLength,
|
|
101
|
+
maxLength
|
|
102
|
+
}, error),
|
|
103
|
+
id: id,
|
|
104
|
+
inputId: inputId,
|
|
105
|
+
isClearable: isClearable,
|
|
106
|
+
isLoading: isLoading,
|
|
107
|
+
isMulti: multiple,
|
|
108
|
+
customStyle: customStyle,
|
|
109
|
+
isSearchable: isSearchable,
|
|
110
|
+
menuPortalTarget: menuPortalTarget,
|
|
111
|
+
onBlur: event => {
|
|
112
|
+
field.onBlur();
|
|
113
|
+
onBlur?.(event);
|
|
114
|
+
},
|
|
115
|
+
onChange: (event, action) => {
|
|
116
|
+
field.onChange(parse(event));
|
|
117
|
+
onChange?.(event, action);
|
|
118
|
+
},
|
|
119
|
+
onFocus: onFocus,
|
|
120
|
+
options: options,
|
|
121
|
+
placeholder: placeholder,
|
|
122
|
+
readOnly: readOnly,
|
|
123
|
+
noTopLabel: noTopLabel,
|
|
124
|
+
required: required,
|
|
125
|
+
value: format(field.value),
|
|
126
|
+
noOptionsMessage: noOptionsMessage,
|
|
127
|
+
children: children
|
|
128
|
+
});
|
|
132
129
|
};
|
|
133
130
|
SelectInputField.Option = SelectInput.Option;
|
|
134
131
|
|