@ultraviolet/form 3.13.22 → 3.14.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/RadioGroupField/index.d.ts +1 -1
- package/dist/components/SelectableCardOptionGroupField/index.cjs +60 -0
- package/dist/components/SelectableCardOptionGroupField/index.d.ts +19 -0
- package/dist/components/SelectableCardOptionGroupField/index.js +60 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.js +2 -0
- package/package.json +3 -3
|
@@ -12,7 +12,7 @@ export declare const RadioGroupField: {
|
|
|
12
12
|
className?: string;
|
|
13
13
|
'data-testid'?: string;
|
|
14
14
|
tooltip?: string;
|
|
15
|
-
} & Required<Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "onChange">> & (Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "required" | "onBlur" | "disabled" | "name" | "autoFocus" | "id" | "onFocus" | "tabIndex" | "checked" | "onKeyDown"> & import("node_modules/@ultraviolet/ui/dist/types").LabelProp)) & import("react").RefAttributes<HTMLInputElement>, "required" | "onChange" | "checked"> & {
|
|
15
|
+
} & Required<Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "onChange">> & (Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "required" | "onBlur" | "disabled" | "name" | "autoFocus" | "id" | "onClick" | "onFocus" | "tabIndex" | "checked" | "onKeyDown"> & import("node_modules/@ultraviolet/ui/dist/types").LabelProp)) & import("react").RefAttributes<HTMLInputElement>, "required" | "onChange" | "checked"> & {
|
|
16
16
|
name?: string;
|
|
17
17
|
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
18
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
+
const ui = require("@ultraviolet/ui");
|
|
5
|
+
const reactHookForm = require("react-hook-form");
|
|
6
|
+
const index = require("../../providers/ErrorContext/index.cjs");
|
|
7
|
+
const SelectableCardOptionGroupField = ({
|
|
8
|
+
className,
|
|
9
|
+
legend,
|
|
10
|
+
control,
|
|
11
|
+
name,
|
|
12
|
+
onChange,
|
|
13
|
+
onChangeOption,
|
|
14
|
+
required = false,
|
|
15
|
+
children,
|
|
16
|
+
label = "",
|
|
17
|
+
error: customError,
|
|
18
|
+
helper,
|
|
19
|
+
columns,
|
|
20
|
+
shouldUnregister = false,
|
|
21
|
+
validate
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
getError
|
|
25
|
+
} = index.useErrors();
|
|
26
|
+
const {
|
|
27
|
+
field,
|
|
28
|
+
fieldState: {
|
|
29
|
+
error
|
|
30
|
+
}
|
|
31
|
+
} = reactHookForm.useController({
|
|
32
|
+
name,
|
|
33
|
+
control,
|
|
34
|
+
shouldUnregister,
|
|
35
|
+
rules: {
|
|
36
|
+
required,
|
|
37
|
+
validate
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const {
|
|
41
|
+
field: optionField
|
|
42
|
+
} = reactHookForm.useController({
|
|
43
|
+
name: `${name}-option`,
|
|
44
|
+
shouldUnregister,
|
|
45
|
+
rules: {
|
|
46
|
+
required
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardOptionGroup, { legend, name, value: field.value, optionValue: String(optionField.value), onChange: (event) => {
|
|
50
|
+
field.onChange(event);
|
|
51
|
+
onChange?.(event);
|
|
52
|
+
}, onChangeOption: (value) => {
|
|
53
|
+
optionField.onChange(value);
|
|
54
|
+
onChangeOption?.(value);
|
|
55
|
+
}, error: getError({
|
|
56
|
+
label
|
|
57
|
+
}, error) ?? customError, className, columns, helper, required, children });
|
|
58
|
+
};
|
|
59
|
+
SelectableCardOptionGroupField.Option = ui.SelectableCardOptionGroup.Option;
|
|
60
|
+
exports.SelectableCardOptionGroupField = SelectableCardOptionGroupField;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SelectableCardOptionGroup } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps, JSX } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type SelectableCardOptionGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = ComponentProps<typeof SelectableCardOptionGroup> & BaseFieldProps<TFieldValues, TFieldName> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'>;
|
|
6
|
+
export declare const SelectableCardOptionGroupField: {
|
|
7
|
+
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, legend, control, name, onChange, onChangeOption, required, children, label, error: customError, helper, columns, shouldUnregister, validate, }: SelectableCardOptionGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
|
|
8
|
+
Option: ({ value, label, labelDescription, "aria-label": ariaLabel, children, className, options, image, disabled, id, }: Omit<import("node_modules/@ultraviolet/ui/dist/components/SelectableCard").SelectableCardProps & import("react").RefAttributes<HTMLDivElement>, "onChange"> & {
|
|
9
|
+
value: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
children?: import("react").ReactNode;
|
|
12
|
+
options: ComponentProps<typeof import("@ultraviolet/ui").SelectInputV2>["options"];
|
|
13
|
+
optionValue?: ComponentProps<typeof import("@ultraviolet/ui").SelectInputV2>["value"];
|
|
14
|
+
image?: import("react").ReactNode;
|
|
15
|
+
labelDescription?: ComponentProps<typeof import("@ultraviolet/ui").Label>["labelDescription"];
|
|
16
|
+
id?: string;
|
|
17
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { SelectableCardOptionGroup } from "@ultraviolet/ui";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
5
|
+
const SelectableCardOptionGroupField = ({
|
|
6
|
+
className,
|
|
7
|
+
legend,
|
|
8
|
+
control,
|
|
9
|
+
name,
|
|
10
|
+
onChange,
|
|
11
|
+
onChangeOption,
|
|
12
|
+
required = false,
|
|
13
|
+
children,
|
|
14
|
+
label = "",
|
|
15
|
+
error: customError,
|
|
16
|
+
helper,
|
|
17
|
+
columns,
|
|
18
|
+
shouldUnregister = false,
|
|
19
|
+
validate
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
getError
|
|
23
|
+
} = useErrors();
|
|
24
|
+
const {
|
|
25
|
+
field,
|
|
26
|
+
fieldState: {
|
|
27
|
+
error
|
|
28
|
+
}
|
|
29
|
+
} = useController({
|
|
30
|
+
name,
|
|
31
|
+
control,
|
|
32
|
+
shouldUnregister,
|
|
33
|
+
rules: {
|
|
34
|
+
required,
|
|
35
|
+
validate
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const {
|
|
39
|
+
field: optionField
|
|
40
|
+
} = useController({
|
|
41
|
+
name: `${name}-option`,
|
|
42
|
+
shouldUnregister,
|
|
43
|
+
rules: {
|
|
44
|
+
required
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */ jsx(SelectableCardOptionGroup, { legend, name, value: field.value, optionValue: String(optionField.value), onChange: (event) => {
|
|
48
|
+
field.onChange(event);
|
|
49
|
+
onChange?.(event);
|
|
50
|
+
}, onChangeOption: (value) => {
|
|
51
|
+
optionField.onChange(value);
|
|
52
|
+
onChangeOption?.(value);
|
|
53
|
+
}, error: getError({
|
|
54
|
+
label
|
|
55
|
+
}, error) ?? customError, className, columns, helper, required, children });
|
|
56
|
+
};
|
|
57
|
+
SelectableCardOptionGroupField.Option = SelectableCardOptionGroup.Option;
|
|
58
|
+
export {
|
|
59
|
+
SelectableCardOptionGroupField
|
|
60
|
+
};
|
|
@@ -24,3 +24,4 @@ export { UnitInputField } from './UnitInputField';
|
|
|
24
24
|
export { SliderField } from './SliderField';
|
|
25
25
|
export { SwitchButtonField } from './SwitchButtonField';
|
|
26
26
|
export { VerificationCodeField } from './VerificationCodeField';
|
|
27
|
+
export { SelectableCardOptionGroupField } from './SelectableCardOptionGroupField';
|
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const index$n = require("./components/UnitInputField/index.cjs");
|
|
|
29
29
|
const index$o = require("./components/SliderField/index.cjs");
|
|
30
30
|
const index$p = require("./components/SwitchButtonField/index.cjs");
|
|
31
31
|
const index$q = require("./components/VerificationCodeField/index.cjs");
|
|
32
|
+
const index$r = require("./components/SelectableCardOptionGroupField/index.cjs");
|
|
32
33
|
exports.ErrorProvider = index.ErrorProvider;
|
|
33
34
|
exports.useErrors = index.useErrors;
|
|
34
35
|
Object.defineProperty(exports, "useController", {
|
|
@@ -82,3 +83,4 @@ exports.UnitInputField = index$n.UnitInputField;
|
|
|
82
83
|
exports.SliderField = index$o.SliderField;
|
|
83
84
|
exports.SwitchButtonField = index$p.SwitchButtonField;
|
|
84
85
|
exports.VerificationCodeField = index$q.VerificationCodeField;
|
|
86
|
+
exports.SelectableCardOptionGroupField = index$r.SelectableCardOptionGroupField;
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import { UnitInputField } from "./components/UnitInputField/index.js";
|
|
|
27
27
|
import { SliderField } from "./components/SliderField/index.js";
|
|
28
28
|
import { SwitchButtonField } from "./components/SwitchButtonField/index.js";
|
|
29
29
|
import { VerificationCodeField } from "./components/VerificationCodeField/index.js";
|
|
30
|
+
import { SelectableCardOptionGroupField } from "./components/SelectableCardOptionGroupField/index.js";
|
|
30
31
|
export {
|
|
31
32
|
CheckboxField,
|
|
32
33
|
CheckboxGroupField,
|
|
@@ -42,6 +43,7 @@ export {
|
|
|
42
43
|
SelectInputFieldV2,
|
|
43
44
|
SelectableCardField,
|
|
44
45
|
SelectableCardGroupField,
|
|
46
|
+
SelectableCardOptionGroupField,
|
|
45
47
|
SliderField,
|
|
46
48
|
Submit,
|
|
47
49
|
SubmitErrorAlert,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@babel/runtime": "7.26.9",
|
|
72
72
|
"react-hook-form": "7.54.2",
|
|
73
|
-
"react-select": "5.
|
|
73
|
+
"react-select": "5.10.0",
|
|
74
74
|
"@ultraviolet/themes": "1.16.0",
|
|
75
|
-
"@ultraviolet/ui": "1.
|
|
75
|
+
"@ultraviolet/ui": "1.89.0"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|