@ultraviolet/form 3.15.1 → 3.15.3

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.
@@ -60,8 +60,8 @@ const SelectInputFieldV2 = ({
60
60
  getError
61
61
  } = index.useErrors();
62
62
  const handleChange = react.useCallback((value) => {
63
- field.onChange(value);
64
63
  onChange?.(value);
64
+ field.onChange(value);
65
65
  }, [onChange, field]);
66
66
  return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInputV2, { name: field.name, options, required, size, "data-testid": dataTestId, className, disabled, id, label, onFocus, onBlur: (event) => {
67
67
  field.onBlur();
@@ -58,8 +58,8 @@ const SelectInputFieldV2 = ({
58
58
  getError
59
59
  } = useErrors();
60
60
  const handleChange = useCallback((value) => {
61
- field.onChange(value);
62
61
  onChange?.(value);
62
+ field.onChange(value);
63
63
  }, [onChange, field]);
64
64
  return /* @__PURE__ */ jsx(SelectInputV2, { name: field.name, options, required, size, "data-testid": dataTestId, className, disabled, id, label, onFocus, onBlur: (event) => {
65
65
  field.onBlur();
@@ -8,6 +8,7 @@ const SelectableCardOptionGroupField = ({
8
8
  legend,
9
9
  control,
10
10
  name,
11
+ optionName,
11
12
  onChange,
12
13
  onChangeOption,
13
14
  required = false,
@@ -38,7 +39,7 @@ const SelectableCardOptionGroupField = ({
38
39
  const {
39
40
  field: optionField
40
41
  } = reactHookForm.useController({
41
- name: `${name}Option`,
42
+ name: optionName ?? `${name}Option`,
42
43
  shouldUnregister,
43
44
  rules: {
44
45
  required
@@ -2,9 +2,11 @@ import { SelectableCardOptionGroup } from '@ultraviolet/ui';
2
2
  import type { ComponentProps, JSX } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
4
  import type { BaseFieldProps } from '../../types';
5
- type SelectableCardOptionGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<ComponentProps<typeof SelectableCardOptionGroup>, 'onChange' | 'onChangeOption'> & Partial<Pick<ComponentProps<typeof SelectableCardOptionGroup>, 'onChangeOption' | 'onChange'>> & BaseFieldProps<TFieldValues, TFieldName> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'>;
5
+ type SelectableCardOptionGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<ComponentProps<typeof SelectableCardOptionGroup>, 'onChange' | 'onChangeOption'> & Partial<Pick<ComponentProps<typeof SelectableCardOptionGroup>, 'onChangeOption' | 'onChange'>> & BaseFieldProps<TFieldValues, TFieldName> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & {
6
+ optionName?: string;
7
+ };
6
8
  export declare const SelectableCardOptionGroupField: {
7
- <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ legend, control, name, onChange, onChangeOption, required, children, label, error: customError, shouldUnregister, validate, ...props }: SelectableCardOptionGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
9
+ <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ legend, control, name, optionName, onChange, onChangeOption, required, children, label, error: customError, shouldUnregister, validate, ...props }: SelectableCardOptionGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
8
10
  Option: ({ value, label, labelDescription, "aria-label": ariaLabel, children, className, options, optionPlaceholder, image, disabled, id, "data-testid": dataTestId, tooltip, }: Omit<import("node_modules/@ultraviolet/ui/dist/components/SelectableCard").SelectableCardProps & import("react").RefAttributes<HTMLDivElement>, "onChange"> & {
9
11
  value: string;
10
12
  className?: string;
@@ -6,6 +6,7 @@ const SelectableCardOptionGroupField = ({
6
6
  legend,
7
7
  control,
8
8
  name,
9
+ optionName,
9
10
  onChange,
10
11
  onChangeOption,
11
12
  required = false,
@@ -36,7 +37,7 @@ const SelectableCardOptionGroupField = ({
36
37
  const {
37
38
  field: optionField
38
39
  } = useController({
39
- name: `${name}Option`,
40
+ name: optionName ?? `${name}Option`,
40
41
  shouldUnregister,
41
42
  rules: {
42
43
  required
@@ -24,7 +24,8 @@ const UnitInputField = ({
24
24
  helper,
25
25
  shouldUnregister = false,
26
26
  validate,
27
- control
27
+ control,
28
+ optionName
28
29
  }) => {
29
30
  const {
30
31
  getError
@@ -32,7 +33,7 @@ const UnitInputField = ({
32
33
  const {
33
34
  field: unitField
34
35
  } = reactHookForm.useController({
35
- name: `${name}-unit`,
36
+ name: optionName ?? `${name}-unit`,
36
37
  shouldUnregister,
37
38
  rules: {
38
39
  required
@@ -5,6 +5,7 @@ import type { BaseFieldProps } from '../../types';
5
5
  type UnitInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Pick<ComponentProps<typeof UnitInput>, 'id' | 'name' | 'className' | 'data-testid' | 'disabled' | 'value' | 'max' | 'min' | 'options' | 'placeholder' | 'placeholderUnit' | 'size' | 'unitValue' | 'required' | 'width' | 'helper' | 'selectInputWidth'> & {
6
6
  onChangeUnitValue?: ComponentProps<typeof UnitInput>['onChangeUnitValue'];
7
7
  label: string;
8
+ optionName?: string;
8
9
  };
9
- export declare const UnitInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ id, name, max, min, size, placeholder, placeholderUnit, onChange, onChangeUnitValue, disabled, options, className, label, required, width, selectInputWidth, helper, shouldUnregister, validate, control, }: UnitInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare const UnitInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ id, name, max, min, size, placeholder, placeholderUnit, onChange, onChangeUnitValue, disabled, options, className, label, required, width, selectInputWidth, helper, shouldUnregister, validate, control, optionName, }: UnitInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -22,7 +22,8 @@ const UnitInputField = ({
22
22
  helper,
23
23
  shouldUnregister = false,
24
24
  validate,
25
- control
25
+ control,
26
+ optionName
26
27
  }) => {
27
28
  const {
28
29
  getError
@@ -30,7 +31,7 @@ const UnitInputField = ({
30
31
  const {
31
32
  field: unitField
32
33
  } = useController({
33
- name: `${name}-unit`,
34
+ name: optionName ?? `${name}-unit`,
34
35
  shouldUnregister,
35
36
  rules: {
36
37
  required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/form",
3
- "version": "3.15.1",
3
+ "version": "3.15.3",
4
4
  "description": "Ultraviolet Form",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -68,11 +68,11 @@
68
68
  "@utils/test": "0.0.1"
69
69
  },
70
70
  "dependencies": {
71
- "@babel/runtime": "7.26.10",
71
+ "@babel/runtime": "7.27.0",
72
72
  "react-hook-form": "7.54.2",
73
73
  "react-select": "5.10.0",
74
74
  "@ultraviolet/themes": "1.16.0",
75
- "@ultraviolet/ui": "1.92.0"
75
+ "@ultraviolet/ui": "1.92.1"
76
76
  },
77
77
  "scripts": {
78
78
  "build:profile": "npx vite-bundle-visualizer -c vite.config.ts",