@ultraviolet/form 6.0.6 → 6.0.8
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/KeyValueField/index.js +2 -2
- package/dist/components/SliderField/index.js +2 -2
- package/dist/components/compositions/OptionSelectorField/index.d.ts +8 -0
- package/dist/components/compositions/OptionSelectorField/index.d.ts.map +1 -0
- package/dist/components/compositions/OptionSelectorField/index.js +56 -0
- package/dist/components/compositions/index.d.ts +2 -0
- package/dist/components/compositions/index.d.ts.map +1 -0
- package/dist/components/compositions/index.js +4 -0
- package/dist/validators/isInteger.js +1 -1
- package/package.json +12 -7
|
@@ -32,7 +32,7 @@ const KeyValueField = ({
|
|
|
32
32
|
fields.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: 3, children: fields.map((field, index) => /* @__PURE__ */ jsxs(
|
|
33
33
|
Row,
|
|
34
34
|
{
|
|
35
|
-
alignItems: "end",
|
|
35
|
+
alignItems: "flex-end",
|
|
36
36
|
gap: 2,
|
|
37
37
|
templateColumns: "1fr 1fr auto",
|
|
38
38
|
children: [
|
|
@@ -93,7 +93,7 @@ const KeyValueField = ({
|
|
|
93
93
|
handleFieldChange();
|
|
94
94
|
},
|
|
95
95
|
sentiment: "primary",
|
|
96
|
-
tooltip:
|
|
96
|
+
tooltip: canAdd ? addButton.tooltip : maxSizeReachedTooltip,
|
|
97
97
|
variant: "outlined",
|
|
98
98
|
children: [
|
|
99
99
|
/* @__PURE__ */ jsx(PlusIcon, {}),
|
|
@@ -66,9 +66,9 @@ const SliderField = ({
|
|
|
66
66
|
},
|
|
67
67
|
onChange: (newValue) => {
|
|
68
68
|
if (options) {
|
|
69
|
-
const processedValue =
|
|
69
|
+
const processedValue = Array.isArray(newValue) ? newValue.map(
|
|
70
70
|
(val) => val ? options[val]?.value : options[0]?.value
|
|
71
|
-
);
|
|
71
|
+
) : options[newValue]?.value;
|
|
72
72
|
field.onChange(processedValue);
|
|
73
73
|
onChange?.(
|
|
74
74
|
processedValue
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OptionSelector } from '@ultraviolet/ui/compositions/OptionSelector';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../../types';
|
|
5
|
+
type OptionSelectorFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof OptionSelector>, 'value'>;
|
|
6
|
+
export declare const OptionSelectorField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, required, name, "aria-label": ariaLabel, shouldUnregister, control, validate, onChange, ...props }: OptionSelectorFieldProps<TFieldValues, TFieldName>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/compositions/OptionSelectorField/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,KAAK,wBAAwB,CAC3B,YAAY,SAAS,WAAW,EAChC,UAAU,SAAS,SAAS,CAAC,YAAY,CAAC,IACxC,cAAc,CAAC,YAAY,EAAE,UAAU,CAAC,GAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,EAAE,OAAO,CAAC,CAAA;AAEtD,eAAO,MAAM,mBAAmB,GAC9B,YAAY,SAAS,WAAW,EAChC,UAAU,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EACpE,6GAUC,wBAAwB,CAAC,YAAY,EAAE,UAAU,CAAC,4CAuCpD,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { OptionSelector } from "@ultraviolet/ui/compositions/OptionSelector";
|
|
4
|
+
import { useController } from "react-hook-form";
|
|
5
|
+
import { useErrors } from "../../../providers/ErrorContext/index.js";
|
|
6
|
+
const OptionSelectorField = ({
|
|
7
|
+
label = "",
|
|
8
|
+
required,
|
|
9
|
+
name,
|
|
10
|
+
"aria-label": ariaLabel,
|
|
11
|
+
shouldUnregister = false,
|
|
12
|
+
control,
|
|
13
|
+
validate,
|
|
14
|
+
onChange,
|
|
15
|
+
...props
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
field,
|
|
19
|
+
fieldState: { error }
|
|
20
|
+
} = useController({
|
|
21
|
+
control,
|
|
22
|
+
name,
|
|
23
|
+
rules: {
|
|
24
|
+
required,
|
|
25
|
+
validate: {
|
|
26
|
+
completeSelection: (value) => {
|
|
27
|
+
if (value?.first && value.second) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
},
|
|
32
|
+
...validate
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
shouldUnregister
|
|
36
|
+
});
|
|
37
|
+
const { getError } = useErrors();
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
OptionSelector,
|
|
40
|
+
{
|
|
41
|
+
"aria-label": ariaLabel,
|
|
42
|
+
error: getError({ label: label ?? ariaLabel ?? name }, error),
|
|
43
|
+
name: field.name,
|
|
44
|
+
onChange: (val) => {
|
|
45
|
+
field.onChange(val);
|
|
46
|
+
onChange?.(val);
|
|
47
|
+
},
|
|
48
|
+
required,
|
|
49
|
+
value: field.value,
|
|
50
|
+
...props
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
OptionSelectorField
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/compositions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -5,7 +5,7 @@ const isInteger = (step) => (value) => {
|
|
|
5
5
|
if (Number.isInteger(step)) {
|
|
6
6
|
return Number.isInteger(value) && Number.isInteger(value);
|
|
7
7
|
}
|
|
8
|
-
return !Number.isInteger(value)
|
|
8
|
+
return !(Number.isInteger(value) || Number.isInteger(value));
|
|
9
9
|
};
|
|
10
10
|
export {
|
|
11
11
|
isInteger
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.8",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"require": "./dist/index.cjs",
|
|
37
37
|
"default": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./compositions/*": {
|
|
40
|
+
"types": "./dist/components/compositions/*/index.d.ts",
|
|
41
|
+
"require": "./dist/components/compositions/*/index.cjs",
|
|
42
|
+
"default": "./dist/components/compositions/*/index.js"
|
|
38
43
|
}
|
|
39
44
|
},
|
|
40
45
|
"size-limit": [
|
|
@@ -55,21 +60,21 @@
|
|
|
55
60
|
"react-dom": "18.x || 19.x"
|
|
56
61
|
},
|
|
57
62
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "7.28.
|
|
63
|
+
"@babel/core": "7.28.6",
|
|
59
64
|
"@types/final-form-focus": "1.1.7",
|
|
60
65
|
"@types/react": "19.2.7",
|
|
61
66
|
"@types/react-dom": "19.2.3",
|
|
62
67
|
"react": "19.2.3",
|
|
63
68
|
"react-dom": "19.2.3",
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
69
|
+
"@utils/test": "0.0.1",
|
|
70
|
+
"@repo/config": "0.0.1"
|
|
66
71
|
},
|
|
67
72
|
"dependencies": {
|
|
68
|
-
"@babel/runtime": "7.28.
|
|
73
|
+
"@babel/runtime": "7.28.6",
|
|
69
74
|
"react-hook-form": "7.55.0",
|
|
70
|
-
"@ultraviolet/
|
|
75
|
+
"@ultraviolet/ui": "3.5.0",
|
|
71
76
|
"@ultraviolet/themes": "3.0.2",
|
|
72
|
-
"@ultraviolet/
|
|
77
|
+
"@ultraviolet/icons": "5.0.3"
|
|
73
78
|
},
|
|
74
79
|
"scripts": {
|
|
75
80
|
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|