@ultraviolet/form 3.8.3 → 3.9.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.
- package/dist/components/CheckboxGroupField/index.cjs +4 -1
- package/dist/components/CheckboxGroupField/index.js +4 -1
- package/dist/components/TextAreaField/index.cjs +21 -3
- package/dist/components/TextAreaField/index.d.ts +2 -1
- package/dist/components/TextAreaField/index.js +21 -3
- package/package.json +5 -5
|
@@ -36,6 +36,9 @@ const CheckboxGroupField = ({
|
|
|
36
36
|
}
|
|
37
37
|
return null;
|
|
38
38
|
})?.filter(Boolean) ?? [];
|
|
39
|
+
if (requiredChildren.length === 0 && !required) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
39
42
|
if (!required && arraysContainSameValues(value, requiredChildren)) {
|
|
40
43
|
return true;
|
|
41
44
|
}
|
|
@@ -70,7 +73,7 @@ const CheckboxGroupField = ({
|
|
|
70
73
|
onChange?.(event.currentTarget.value);
|
|
71
74
|
}, error: getError({
|
|
72
75
|
label
|
|
73
|
-
}, error) ?? customError, name, children });
|
|
76
|
+
}, error) ?? customError, name, required, children });
|
|
74
77
|
};
|
|
75
78
|
CheckboxGroupField.Checkbox = ui.CheckboxGroup.Checkbox;
|
|
76
79
|
exports.CheckboxGroupField = CheckboxGroupField;
|
|
@@ -34,6 +34,9 @@ const CheckboxGroupField = ({
|
|
|
34
34
|
}
|
|
35
35
|
return null;
|
|
36
36
|
})?.filter(Boolean) ?? [];
|
|
37
|
+
if (requiredChildren.length === 0 && !required) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
37
40
|
if (!required && arraysContainSameValues(value, requiredChildren)) {
|
|
38
41
|
return true;
|
|
39
42
|
}
|
|
@@ -68,7 +71,7 @@ const CheckboxGroupField = ({
|
|
|
68
71
|
onChange?.(event.currentTarget.value);
|
|
69
72
|
}, error: getError({
|
|
70
73
|
label
|
|
71
|
-
}, error) ?? customError, name, children });
|
|
74
|
+
}, error) ?? customError, name, required, children });
|
|
72
75
|
};
|
|
73
76
|
CheckboxGroupField.Checkbox = CheckboxGroup.Checkbox;
|
|
74
77
|
export {
|
|
@@ -22,6 +22,7 @@ const TextAreaField = ({
|
|
|
22
22
|
name,
|
|
23
23
|
onFocus,
|
|
24
24
|
onBlur,
|
|
25
|
+
onKeyDown,
|
|
25
26
|
placeholder,
|
|
26
27
|
readOnly,
|
|
27
28
|
required,
|
|
@@ -29,6 +30,7 @@ const TextAreaField = ({
|
|
|
29
30
|
success,
|
|
30
31
|
tooltip,
|
|
31
32
|
regex: regexes,
|
|
33
|
+
submitOnEnter,
|
|
32
34
|
validate
|
|
33
35
|
}) => {
|
|
34
36
|
const {
|
|
@@ -54,6 +56,24 @@ const TextAreaField = ({
|
|
|
54
56
|
maxLength
|
|
55
57
|
}
|
|
56
58
|
});
|
|
59
|
+
const onKeyDownHandler = (event) => {
|
|
60
|
+
if (submitOnEnter && event.key === "Enter" && !event.shiftKey) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
const {
|
|
64
|
+
form
|
|
65
|
+
} = event.currentTarget;
|
|
66
|
+
if (form) {
|
|
67
|
+
const submitEvent = new Event("submit", {
|
|
68
|
+
bubbles: true,
|
|
69
|
+
cancelable: true
|
|
70
|
+
});
|
|
71
|
+
form.dispatchEvent(submitEvent);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
onKeyDown?.(event);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
57
77
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.TextArea, { autoFocus, className, clearable, "data-testid": dataTestId, disabled, error: getError({
|
|
58
78
|
regex: regexes,
|
|
59
79
|
minLength,
|
|
@@ -66,8 +86,6 @@ const TextAreaField = ({
|
|
|
66
86
|
}, onChange: (event) => {
|
|
67
87
|
field.onChange(event);
|
|
68
88
|
onChange?.(event);
|
|
69
|
-
}, onFocus:
|
|
70
|
-
onFocus?.(event);
|
|
71
|
-
}, placeholder, readOnly, required, rows, success, tabIndex, tooltip, value: field.value });
|
|
89
|
+
}, onFocus, onKeyDown: onKeyDownHandler, placeholder, readOnly, required, rows, success, tabIndex, tooltip, value: field.value });
|
|
72
90
|
};
|
|
73
91
|
exports.TextAreaField = TextAreaField;
|
|
@@ -4,8 +4,9 @@ import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
5
|
export type TextAreaFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof TextArea>, 'value' | 'error' | 'name' | 'onChange'> & {
|
|
6
6
|
regex?: (RegExp | RegExp[])[];
|
|
7
|
+
submitOnEnter?: boolean;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* This component offers a form field based on Ultraviolet UI TextArea component
|
|
10
11
|
*/
|
|
11
|
-
export declare const TextAreaField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autoFocus, clearable, className, tabIndex, control, "data-testid": dataTestId, disabled, helper, label, labelDescription, onChange, minLength, maxLength, name, onFocus, onBlur, placeholder, readOnly, required, rows, success, tooltip, regex: regexes, validate, }: TextAreaFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const TextAreaField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autoFocus, clearable, className, tabIndex, control, "data-testid": dataTestId, disabled, helper, label, labelDescription, onChange, minLength, maxLength, name, onFocus, onBlur, onKeyDown, placeholder, readOnly, required, rows, success, tooltip, regex: regexes, submitOnEnter, validate, }: TextAreaFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -20,6 +20,7 @@ const TextAreaField = ({
|
|
|
20
20
|
name,
|
|
21
21
|
onFocus,
|
|
22
22
|
onBlur,
|
|
23
|
+
onKeyDown,
|
|
23
24
|
placeholder,
|
|
24
25
|
readOnly,
|
|
25
26
|
required,
|
|
@@ -27,6 +28,7 @@ const TextAreaField = ({
|
|
|
27
28
|
success,
|
|
28
29
|
tooltip,
|
|
29
30
|
regex: regexes,
|
|
31
|
+
submitOnEnter,
|
|
30
32
|
validate
|
|
31
33
|
}) => {
|
|
32
34
|
const {
|
|
@@ -52,6 +54,24 @@ const TextAreaField = ({
|
|
|
52
54
|
maxLength
|
|
53
55
|
}
|
|
54
56
|
});
|
|
57
|
+
const onKeyDownHandler = (event) => {
|
|
58
|
+
if (submitOnEnter && event.key === "Enter" && !event.shiftKey) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
const {
|
|
62
|
+
form
|
|
63
|
+
} = event.currentTarget;
|
|
64
|
+
if (form) {
|
|
65
|
+
const submitEvent = new Event("submit", {
|
|
66
|
+
bubbles: true,
|
|
67
|
+
cancelable: true
|
|
68
|
+
});
|
|
69
|
+
form.dispatchEvent(submitEvent);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
onKeyDown?.(event);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
55
75
|
return /* @__PURE__ */ jsx(TextArea, { autoFocus, className, clearable, "data-testid": dataTestId, disabled, error: getError({
|
|
56
76
|
regex: regexes,
|
|
57
77
|
minLength,
|
|
@@ -64,9 +84,7 @@ const TextAreaField = ({
|
|
|
64
84
|
}, onChange: (event) => {
|
|
65
85
|
field.onChange(event);
|
|
66
86
|
onChange?.(event);
|
|
67
|
-
}, onFocus:
|
|
68
|
-
onFocus?.(event);
|
|
69
|
-
}, placeholder, readOnly, required, rows, success, tabIndex, tooltip, value: field.value });
|
|
87
|
+
}, onFocus, onKeyDown: onKeyDownHandler, placeholder, readOnly, required, rows, success, tabIndex, tooltip, value: field.value });
|
|
70
88
|
};
|
|
71
89
|
export {
|
|
72
90
|
TextAreaField
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/react": "11.13.3",
|
|
62
62
|
"@emotion/styled": "11.13.0",
|
|
63
63
|
"@types/final-form-focus": "1.1.7",
|
|
64
|
-
"@types/react": "18.3.
|
|
64
|
+
"@types/react": "18.3.9",
|
|
65
65
|
"@types/react-dom": "18.3.0",
|
|
66
66
|
"react": "18.3.1",
|
|
67
67
|
"react-dom": "18.3.1",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@babel/runtime": "7.25.6",
|
|
72
72
|
"react-hook-form": "7.53.0",
|
|
73
|
-
"react-select": "5.8.
|
|
74
|
-
"@ultraviolet/themes": "1.14.
|
|
75
|
-
"@ultraviolet/ui": "1.
|
|
73
|
+
"react-select": "5.8.1",
|
|
74
|
+
"@ultraviolet/themes": "1.14.2",
|
|
75
|
+
"@ultraviolet/ui": "1.71.1"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|