@ultraviolet/form 6.0.6 → 6.0.7

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.
@@ -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,2 @@
1
+ export { OptionSelectorField } from './OptionSelectorField';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -0,0 +1,4 @@
1
+ import { OptionSelectorField } from "./OptionSelectorField/index.js";
2
+ export {
3
+ OptionSelectorField
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/form",
3
- "version": "6.0.6",
3
+ "version": "6.0.7",
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": [
@@ -61,15 +66,15 @@
61
66
  "@types/react-dom": "19.2.3",
62
67
  "react": "19.2.3",
63
68
  "react-dom": "19.2.3",
64
- "@repo/config": "0.0.1",
65
- "@utils/test": "0.0.1"
69
+ "@utils/test": "0.0.1",
70
+ "@repo/config": "0.0.1"
66
71
  },
67
72
  "dependencies": {
68
73
  "@babel/runtime": "7.28.4",
69
74
  "react-hook-form": "7.55.0",
70
75
  "@ultraviolet/icons": "5.0.3",
71
76
  "@ultraviolet/themes": "3.0.2",
72
- "@ultraviolet/ui": "3.3.1"
77
+ "@ultraviolet/ui": "3.4.0"
73
78
  },
74
79
  "scripts": {
75
80
  "build:profile": "npx vite-bundle-visualizer -c vite.config.ts",