@ultraviolet/form 2.10.9 → 2.12.0
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/SelectInputFieldV2/index.js +102 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { SelectInputV2 } from '@ultraviolet/ui';
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
|
+
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
|
+
|
|
6
|
+
const SelectInputFieldV2 = ({
|
|
7
|
+
autofocus,
|
|
8
|
+
className,
|
|
9
|
+
id,
|
|
10
|
+
label = '',
|
|
11
|
+
onFocus,
|
|
12
|
+
onBlur,
|
|
13
|
+
placeholder,
|
|
14
|
+
readOnly,
|
|
15
|
+
required,
|
|
16
|
+
size,
|
|
17
|
+
'data-testid': dataTestId,
|
|
18
|
+
disabled,
|
|
19
|
+
placeholderSearch,
|
|
20
|
+
helper,
|
|
21
|
+
options,
|
|
22
|
+
emptyState,
|
|
23
|
+
onChange,
|
|
24
|
+
searchable,
|
|
25
|
+
clearable,
|
|
26
|
+
multiselect,
|
|
27
|
+
descriptionDirection,
|
|
28
|
+
footer,
|
|
29
|
+
labelDescription,
|
|
30
|
+
success,
|
|
31
|
+
loadMore,
|
|
32
|
+
isLoading,
|
|
33
|
+
selectAll,
|
|
34
|
+
selectAllGroup,
|
|
35
|
+
name,
|
|
36
|
+
'aria-label': ariaLabel,
|
|
37
|
+
optionalInfoPlacement,
|
|
38
|
+
rules,
|
|
39
|
+
shouldUnregister = false
|
|
40
|
+
}) => {
|
|
41
|
+
const {
|
|
42
|
+
field,
|
|
43
|
+
fieldState: {
|
|
44
|
+
error
|
|
45
|
+
}
|
|
46
|
+
} = useController({
|
|
47
|
+
name,
|
|
48
|
+
shouldUnregister,
|
|
49
|
+
rules: {
|
|
50
|
+
required,
|
|
51
|
+
...rules
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const {
|
|
55
|
+
getError
|
|
56
|
+
} = useErrors();
|
|
57
|
+
return jsx(SelectInputV2, {
|
|
58
|
+
name: field.name,
|
|
59
|
+
options: options,
|
|
60
|
+
required: required,
|
|
61
|
+
size: size,
|
|
62
|
+
"data-testid": dataTestId,
|
|
63
|
+
className: className,
|
|
64
|
+
disabled: disabled,
|
|
65
|
+
id: id,
|
|
66
|
+
label: label,
|
|
67
|
+
onFocus: onFocus,
|
|
68
|
+
onBlur: event => {
|
|
69
|
+
field.onBlur();
|
|
70
|
+
onBlur?.(event);
|
|
71
|
+
},
|
|
72
|
+
placeholder: placeholder,
|
|
73
|
+
readOnly: readOnly,
|
|
74
|
+
value: field.value,
|
|
75
|
+
placeholderSearch: placeholderSearch,
|
|
76
|
+
helper: helper,
|
|
77
|
+
emptyState: emptyState,
|
|
78
|
+
searchable: searchable,
|
|
79
|
+
clearable: clearable,
|
|
80
|
+
multiselect: multiselect,
|
|
81
|
+
descriptionDirection: descriptionDirection,
|
|
82
|
+
footer: footer,
|
|
83
|
+
labelDescription: labelDescription,
|
|
84
|
+
error: getError({
|
|
85
|
+
label
|
|
86
|
+
}, error),
|
|
87
|
+
success: success,
|
|
88
|
+
loadMore: loadMore,
|
|
89
|
+
isLoading: isLoading,
|
|
90
|
+
selectAll: selectAll,
|
|
91
|
+
selectAllGroup: selectAllGroup,
|
|
92
|
+
autofocus: autofocus,
|
|
93
|
+
optionalInfoPlacement: optionalInfoPlacement,
|
|
94
|
+
"aria-label": ariaLabel,
|
|
95
|
+
onChange: value => {
|
|
96
|
+
field.onChange(value);
|
|
97
|
+
onChange?.(value);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export { SelectInputFieldV2 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
|
|
2
|
-
import { Checkbox, CheckboxGroup, DateInput, Radio, SelectInput, SelectableCard, NumberInput, NumberInputV2, TagInput, TextArea, TextInput, TextInputV2, TimeInput, Toggle, Button, RadioGroup, SelectableCardGroup } from '@ultraviolet/ui';
|
|
2
|
+
import { Checkbox, CheckboxGroup, DateInput, Radio, SelectInput, SelectableCard, NumberInput, NumberInputV2, TagInput, TextArea, TextInput, TextInputV2, TimeInput, Toggle, Button, RadioGroup, SelectableCardGroup, SelectInputV2 } from '@ultraviolet/ui';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ComponentProps, ReactNode, FocusEvent, ForwardedRef, FocusEventHandler, Ref, JSX } from 'react';
|
|
5
5
|
import * as react_hook_form from 'react-hook-form';
|
|
@@ -215,6 +215,9 @@ type SelectInputProps = Partial<SelectProps & SelectStyleProps & Pick<ComponentP
|
|
|
215
215
|
children: ReactNode;
|
|
216
216
|
emptyState?: ComponentProps<Select>['noOptionsMessage'];
|
|
217
217
|
}>;
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated This component is deprecated, please use `SelectInputFieldV2` instead
|
|
220
|
+
*/
|
|
218
221
|
type SelectInputFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TName>, 'onChange'> & Partial<Pick<SelectInputProps, 'animation' | 'animationDuration' | 'animationOnChange' | 'children' | 'className' | 'disabled' | 'error' | 'id' | 'inputId' | 'isClearable' | 'isLoading' | 'isSearchable' | 'menuPortalTarget' | 'onBlur' | 'onChange' | 'onFocus' | 'options' | 'placeholder' | 'readOnly' | 'required' | 'value' | 'noTopLabel' | 'emptyState' | 'customStyle' | 'data-testid'>> & {
|
|
219
222
|
multiple?: boolean;
|
|
220
223
|
parse?: (value: unknown, name?: string) => unknown;
|
|
@@ -420,6 +423,9 @@ declare const SelectableCardGroupField: {
|
|
|
420
423
|
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
421
424
|
};
|
|
422
425
|
|
|
426
|
+
type SelectInputFieldV2Props<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Pick<ComponentProps<typeof SelectInputV2>, 'placeholder' | 'placeholderSearch' | 'label' | 'helper' | 'options' | 'emptyState' | 'searchable' | 'readOnly' | 'clearable' | 'size' | 'multiselect' | 'required' | 'descriptionDirection' | 'footer' | 'labelDescription' | 'success' | 'loadMore' | 'isLoading' | 'selectAll' | 'selectAllGroup' | 'autofocus' | 'data-testid' | 'onChange' | 'id' | 'onBlur' | 'aria-label' | 'className' | 'onFocus' | 'optionalInfoPlacement' | 'disabled'>;
|
|
427
|
+
declare const SelectInputFieldV2: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autofocus, className, id, label, onFocus, onBlur, placeholder, readOnly, required, size, "data-testid": dataTestId, disabled, placeholderSearch, helper, options, emptyState, onChange, searchable, clearable, multiselect, descriptionDirection, footer, labelDescription, success, loadMore, isLoading, selectAll, selectAllGroup, name, "aria-label": ariaLabel, optionalInfoPlacement, rules, shouldUnregister, }: SelectInputFieldV2Props<TFieldValues, TName>) => _emotion_react_jsx_runtime.JSX.Element;
|
|
428
|
+
|
|
423
429
|
type ErrorContextValue = {
|
|
424
430
|
errors: RequiredErrors;
|
|
425
431
|
getError: (meta: MetaField, error?: FieldError) => string | undefined;
|
|
@@ -546,4 +552,4 @@ declare const useFieldArrayDeprecated: <T, TFieldValues extends FieldValues = Fi
|
|
|
546
552
|
};
|
|
547
553
|
};
|
|
548
554
|
|
|
549
|
-
export { type BaseFieldProps, CheckboxField, CheckboxGroupField, DateField, ErrorProvider, FORM_ERROR, Form, type FormErrors, type FormProps, KeyValueField, NumberInputField, NumberInputFieldV2, RadioField, RadioGroupField, SelectInputField, SelectableCardField, SelectableCardGroupField, Submit, SubmitErrorAlert, TagInputField, TextAreaField, TextInputField$1 as TextInputField, TextInputField as TextInputFieldV2, TimeField, ToggleField, useErrors, useFieldArrayDeprecated, useFieldDeprecated, useFormDeprecated, useFormStateDeprecated, useOnFieldChange };
|
|
555
|
+
export { type BaseFieldProps, CheckboxField, CheckboxGroupField, DateField, ErrorProvider, FORM_ERROR, Form, type FormErrors, type FormProps, KeyValueField, NumberInputField, NumberInputFieldV2, RadioField, RadioGroupField, SelectInputField, SelectInputFieldV2, SelectableCardField, SelectableCardGroupField, Submit, SubmitErrorAlert, TagInputField, TextAreaField, TextInputField$1 as TextInputField, TextInputField as TextInputFieldV2, TimeField, ToggleField, useErrors, useFieldArrayDeprecated, useFieldDeprecated, useFormDeprecated, useFormStateDeprecated, useOnFieldChange };
|
package/dist/index.js
CHANGED
|
@@ -26,3 +26,4 @@ export { Submit } from './components/Submit/index.js';
|
|
|
26
26
|
export { RadioGroupField } from './components/RadioGroupField/index.js';
|
|
27
27
|
export { KeyValueField } from './components/KeyValueField/index.js';
|
|
28
28
|
export { SelectableCardGroupField } from './components/SelectableCardGroupField/index.js';
|
|
29
|
+
export { SelectInputFieldV2 } from './components/SelectInputFieldV2/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18.x",
|
|
22
|
-
"pnpm": ">=
|
|
22
|
+
"pnpm": ">=9.x"
|
|
23
23
|
},
|
|
24
24
|
"os": [
|
|
25
25
|
"darwin",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@emotion/styled": "11.11.5",
|
|
54
54
|
"react-select": "5.8.0",
|
|
55
55
|
"react-hook-form": "7.51.3",
|
|
56
|
-
"@ultraviolet/ui": "1.
|
|
56
|
+
"@ultraviolet/ui": "1.49.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "rollup -c ../../rollup.config.mjs",
|