@ultraviolet/form 3.16.0 → 3.17.1

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.
@@ -8,7 +8,7 @@ const maxDate = require("../../validators/maxDate.cjs");
8
8
  const minDate = require("../../validators/minDate.cjs");
9
9
  const index = require("../../providers/ErrorContext/index.cjs");
10
10
  const parseDate = (value) => typeof value === "string" ? new Date(value) : value;
11
- const isEmpty = (value) => typeof value === "string" ? value === "" : value === void 0;
11
+ const isEmpty = (value) => !value;
12
12
  const DateField = ({
13
13
  required,
14
14
  name,
@@ -28,6 +28,8 @@ const DateField = ({
28
28
  selectsRange,
29
29
  size,
30
30
  placeholder,
31
+ tooltip,
32
+ clearable,
31
33
  "data-testid": dataTestId,
32
34
  shouldUnregister = false,
33
35
  showMonthYearPicker,
@@ -73,6 +75,10 @@ const DateField = ({
73
75
  newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
74
76
  field.onChange(newDate);
75
77
  } else if (Array.isArray(val)) {
78
+ onChange?.(val);
79
+ field.onChange(val);
80
+ } else if (val === null) {
81
+ onChange?.(val);
76
82
  field.onChange(val);
77
83
  }
78
84
  }, onBlur: (e) => {
@@ -82,6 +88,6 @@ const DateField = ({
82
88
  minDate: minDate$1,
83
89
  maxDate: maxDate$1,
84
90
  label
85
- }, error), disabled, autoFocus, excludeDates, selectsRange, showMonthYearPicker, "data-testid": dataTestId, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, input });
91
+ }, error), disabled, autoFocus, excludeDates, selectsRange, showMonthYearPicker, "data-testid": dataTestId, clearable, tooltip, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, input });
86
92
  };
87
93
  exports.DateField = DateField;
@@ -13,5 +13,5 @@ type DateFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPa
13
13
  autoFocus?: boolean;
14
14
  placeholder?: string;
15
15
  };
16
- export declare const DateField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, locale, maxDate, minDate, disabled, onChange, onBlur, onFocus, validate, autoFocus, excludeDates, selectsRange, size, placeholder, "data-testid": dataTestId, shouldUnregister, showMonthYearPicker, input, }: DateFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
16
+ export declare const DateField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, locale, maxDate, minDate, disabled, onChange, onBlur, onFocus, validate, autoFocus, excludeDates, selectsRange, size, placeholder, tooltip, clearable, "data-testid": dataTestId, shouldUnregister, showMonthYearPicker, input, }: DateFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
17
17
  export {};
@@ -6,7 +6,7 @@ import { maxDateValidator } from "../../validators/maxDate.js";
6
6
  import { minDateValidator } from "../../validators/minDate.js";
7
7
  import { useErrors } from "../../providers/ErrorContext/index.js";
8
8
  const parseDate = (value) => typeof value === "string" ? new Date(value) : value;
9
- const isEmpty = (value) => typeof value === "string" ? value === "" : value === void 0;
9
+ const isEmpty = (value) => !value;
10
10
  const DateField = ({
11
11
  required,
12
12
  name,
@@ -26,6 +26,8 @@ const DateField = ({
26
26
  selectsRange,
27
27
  size,
28
28
  placeholder,
29
+ tooltip,
30
+ clearable,
29
31
  "data-testid": dataTestId,
30
32
  shouldUnregister = false,
31
33
  showMonthYearPicker,
@@ -71,6 +73,10 @@ const DateField = ({
71
73
  newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
72
74
  field.onChange(newDate);
73
75
  } else if (Array.isArray(val)) {
76
+ onChange?.(val);
77
+ field.onChange(val);
78
+ } else if (val === null) {
79
+ onChange?.(val);
74
80
  field.onChange(val);
75
81
  }
76
82
  }, onBlur: (e) => {
@@ -80,7 +86,7 @@ const DateField = ({
80
86
  minDate,
81
87
  maxDate,
82
88
  label
83
- }, error), disabled, autoFocus, excludeDates, selectsRange, showMonthYearPicker, "data-testid": dataTestId, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, input });
89
+ }, error), disabled, autoFocus, excludeDates, selectsRange, showMonthYearPicker, "data-testid": dataTestId, clearable, tooltip, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, input });
84
90
  };
85
91
  export {
86
92
  DateField
@@ -7,42 +7,17 @@ const react = require("react");
7
7
  const reactHookForm = require("react-hook-form");
8
8
  const index = require("../../providers/ErrorContext/index.cjs");
9
9
  const SelectInputFieldV2 = ({
10
- autofocus,
11
- className,
12
- id,
13
10
  label = "",
14
- onFocus,
15
11
  onBlur,
16
- placeholder,
17
- readOnly,
18
12
  required,
19
- size,
20
- "data-testid": dataTestId,
21
- disabled,
22
- placeholderSearch,
23
- helper,
24
- options,
25
- emptyState,
26
- onChange,
27
- searchable,
28
- clearable,
29
- multiselect,
30
- descriptionDirection,
31
- footer,
32
- labelDescription,
33
- success,
34
- loadMore,
35
- isLoading,
36
- selectAll,
37
- selectAllGroup,
38
13
  name,
39
14
  "aria-label": ariaLabel,
40
- optionalInfoPlacement,
41
15
  shouldUnregister = false,
42
16
  control,
43
17
  validate,
44
- tooltip,
45
- dropdownAlign
18
+ onChange,
19
+ multiselect,
20
+ ...props
46
21
  }) => {
47
22
  const {
48
23
  field,
@@ -65,11 +40,11 @@ const SelectInputFieldV2 = ({
65
40
  onChange?.(value);
66
41
  field.onChange(value);
67
42
  }, [onChange, field]);
68
- return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInputV2, { name: field.name, options, required, size, "data-testid": dataTestId, className, disabled, id, label, onFocus, onBlur: (event) => {
43
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInputV2, { name: field.name, multiselect, required, onBlur: (event) => {
69
44
  field.onBlur();
70
45
  onBlur?.(event);
71
- }, placeholder, readOnly, multiselect, value: field.value, placeholderSearch, helper, emptyState, searchable, clearable, descriptionDirection, footer, labelDescription, error: getError({
46
+ }, value: field.value, error: getError({
72
47
  label: label ?? ariaLabel ?? name
73
- }, error), success, loadMore, isLoading, selectAll, selectAllGroup, autofocus, optionalInfoPlacement, "aria-label": ariaLabel, onChange: handleChange, tooltip, dropdownAlign });
48
+ }, error), onChange: handleChange, ...props });
74
49
  };
75
50
  exports.SelectInputFieldV2 = SelectInputFieldV2;
@@ -2,6 +2,6 @@ import { SelectInputV2 } from '@ultraviolet/ui';
2
2
  import { type ComponentProps } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
4
  import type { BaseFieldProps } from '../../types';
5
- type SelectInputFieldV2Props<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & 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' | 'id' | 'onBlur' | 'aria-label' | 'className' | 'onFocus' | 'optionalInfoPlacement' | 'disabled' | 'tooltip' | 'dropdownAlign'>;
6
- export declare const SelectInputFieldV2: <TFieldValues extends FieldValues, TFieldName 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, shouldUnregister, control, validate, tooltip, dropdownAlign, }: SelectInputFieldV2Props<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ type SelectInputFieldV2Props<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof SelectInputV2>, 'value' | 'onChange'>;
6
+ export declare const SelectInputFieldV2: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, onBlur, required, name, "aria-label": ariaLabel, shouldUnregister, control, validate, onChange, multiselect, ...props }: SelectInputFieldV2Props<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -5,42 +5,17 @@ import { useCallback } from "react";
5
5
  import { useController } from "react-hook-form";
6
6
  import { useErrors } from "../../providers/ErrorContext/index.js";
7
7
  const SelectInputFieldV2 = ({
8
- autofocus,
9
- className,
10
- id,
11
8
  label = "",
12
- onFocus,
13
9
  onBlur,
14
- placeholder,
15
- readOnly,
16
10
  required,
17
- size,
18
- "data-testid": dataTestId,
19
- disabled,
20
- placeholderSearch,
21
- helper,
22
- options,
23
- emptyState,
24
- onChange,
25
- searchable,
26
- clearable,
27
- multiselect,
28
- descriptionDirection,
29
- footer,
30
- labelDescription,
31
- success,
32
- loadMore,
33
- isLoading,
34
- selectAll,
35
- selectAllGroup,
36
11
  name,
37
12
  "aria-label": ariaLabel,
38
- optionalInfoPlacement,
39
13
  shouldUnregister = false,
40
14
  control,
41
15
  validate,
42
- tooltip,
43
- dropdownAlign
16
+ onChange,
17
+ multiselect,
18
+ ...props
44
19
  }) => {
45
20
  const {
46
21
  field,
@@ -63,12 +38,12 @@ const SelectInputFieldV2 = ({
63
38
  onChange?.(value);
64
39
  field.onChange(value);
65
40
  }, [onChange, field]);
66
- return /* @__PURE__ */ jsx(SelectInputV2, { name: field.name, options, required, size, "data-testid": dataTestId, className, disabled, id, label, onFocus, onBlur: (event) => {
41
+ return /* @__PURE__ */ jsx(SelectInputV2, { name: field.name, multiselect, required, onBlur: (event) => {
67
42
  field.onBlur();
68
43
  onBlur?.(event);
69
- }, placeholder, readOnly, multiselect, value: field.value, placeholderSearch, helper, emptyState, searchable, clearable, descriptionDirection, footer, labelDescription, error: getError({
44
+ }, value: field.value, error: getError({
70
45
  label: label ?? ariaLabel ?? name
71
- }, error), success, loadMore, isLoading, selectAll, selectAllGroup, autofocus, optionalInfoPlacement, "aria-label": ariaLabel, onChange: handleChange, tooltip, dropdownAlign });
46
+ }, error), onChange: handleChange, ...props });
72
47
  };
73
48
  export {
74
49
  SelectInputFieldV2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/form",
3
- "version": "3.16.0",
3
+ "version": "3.17.1",
4
4
  "description": "Ultraviolet Form",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -71,7 +71,7 @@
71
71
  "@babel/runtime": "7.27.0",
72
72
  "react-hook-form": "7.55.0",
73
73
  "react-select": "5.10.0",
74
- "@ultraviolet/ui": "1.93.0",
74
+ "@ultraviolet/ui": "1.94.1",
75
75
  "@ultraviolet/themes": "1.17.0"
76
76
  },
77
77
  "scripts": {