@ultraviolet/form 3.9.8 → 3.10.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/CheckboxField/index.cjs +2 -2
- package/dist/components/CheckboxField/index.js +2 -2
- package/dist/components/VerificationCodeField/index.cjs +60 -0
- package/dist/components/VerificationCodeField/index.d.ts +12 -0
- package/dist/components/VerificationCodeField/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
|
@@ -44,8 +44,8 @@ const CheckboxField = ({
|
|
|
44
44
|
onBlur?.(event);
|
|
45
45
|
}, disabled: field.disabled, checked: !!field.value, error: getError({
|
|
46
46
|
label: label ?? ariaLabel ?? name
|
|
47
|
-
}, error), ref: field.ref, ...
|
|
48
|
-
children
|
|
47
|
+
}, error), ref: field.ref, ...children ? {
|
|
48
|
+
children,
|
|
49
49
|
"aria-label": void 0
|
|
50
50
|
} : {
|
|
51
51
|
"aria-label": ariaLabel
|
|
@@ -42,8 +42,8 @@ const CheckboxField = ({
|
|
|
42
42
|
onBlur?.(event);
|
|
43
43
|
}, disabled: field.disabled, checked: !!field.value, error: getError({
|
|
44
44
|
label: label ?? ariaLabel ?? name
|
|
45
|
-
}, error), ref: field.ref, ...
|
|
46
|
-
children
|
|
45
|
+
}, error), ref: field.ref, ...children ? {
|
|
46
|
+
children,
|
|
47
47
|
"aria-label": void 0
|
|
48
48
|
} : {
|
|
49
49
|
"aria-label": ariaLabel
|
|
@@ -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 VerificationCodeField = ({
|
|
8
|
+
className,
|
|
9
|
+
fields,
|
|
10
|
+
id = "verification-code-input",
|
|
11
|
+
label,
|
|
12
|
+
name,
|
|
13
|
+
onChange,
|
|
14
|
+
onComplete,
|
|
15
|
+
placeholder,
|
|
16
|
+
required,
|
|
17
|
+
type = "number",
|
|
18
|
+
disabled,
|
|
19
|
+
validate
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
getError
|
|
23
|
+
} = index.useErrors();
|
|
24
|
+
const {
|
|
25
|
+
field,
|
|
26
|
+
fieldState: {
|
|
27
|
+
error
|
|
28
|
+
}
|
|
29
|
+
} = reactHookForm.useController({
|
|
30
|
+
name,
|
|
31
|
+
rules: {
|
|
32
|
+
required,
|
|
33
|
+
validate: {
|
|
34
|
+
required: (localValue) => {
|
|
35
|
+
if (required && localValue.length !== (fields ?? 4)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
...validate
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { className, gap: 1, justifyContent: "center", alignItems: "center", direction: "column", "aria-label": "verification-code-field", children: [
|
|
45
|
+
label ? /* @__PURE__ */ jsxRuntime.jsx("label", { id: `${id}-label`, htmlFor: `${id}-0`, style: {
|
|
46
|
+
cursor: "pointer",
|
|
47
|
+
flexShrink: 0
|
|
48
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "p", variant: "body", prominence: "strong", children: label }) }) : null,
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.VerificationCode, { inputId: id, error: !!error, placeholder, fields, onChange: (event) => {
|
|
50
|
+
onChange?.(event);
|
|
51
|
+
field.onChange(event);
|
|
52
|
+
}, onComplete: (event) => {
|
|
53
|
+
onComplete?.(event);
|
|
54
|
+
}, type, disabled, required }),
|
|
55
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "small", variant: "caption", sentiment: "danger", children: getError({
|
|
56
|
+
label: label || "verification-code-field"
|
|
57
|
+
}, error) }) : null
|
|
58
|
+
] });
|
|
59
|
+
};
|
|
60
|
+
exports.VerificationCodeField = VerificationCodeField;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VerificationCode } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type VerificationCodeFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Partial<Pick<ComponentProps<typeof VerificationCode>, 'disabled' | 'error' | 'fields' | 'initialValue' | 'onChange' | 'onComplete' | 'placeholder' | 'required' | 'type'>> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const VerificationCodeField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, fields, id, label, name, onChange, onComplete, placeholder, required, type, disabled, validate, }: VerificationCodeFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Stack, Text, VerificationCode } from "@ultraviolet/ui";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
5
|
+
const VerificationCodeField = ({
|
|
6
|
+
className,
|
|
7
|
+
fields,
|
|
8
|
+
id = "verification-code-input",
|
|
9
|
+
label,
|
|
10
|
+
name,
|
|
11
|
+
onChange,
|
|
12
|
+
onComplete,
|
|
13
|
+
placeholder,
|
|
14
|
+
required,
|
|
15
|
+
type = "number",
|
|
16
|
+
disabled,
|
|
17
|
+
validate
|
|
18
|
+
}) => {
|
|
19
|
+
const {
|
|
20
|
+
getError
|
|
21
|
+
} = useErrors();
|
|
22
|
+
const {
|
|
23
|
+
field,
|
|
24
|
+
fieldState: {
|
|
25
|
+
error
|
|
26
|
+
}
|
|
27
|
+
} = useController({
|
|
28
|
+
name,
|
|
29
|
+
rules: {
|
|
30
|
+
required,
|
|
31
|
+
validate: {
|
|
32
|
+
required: (localValue) => {
|
|
33
|
+
if (required && localValue.length !== (fields ?? 4)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
},
|
|
38
|
+
...validate
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return /* @__PURE__ */ jsxs(Stack, { className, gap: 1, justifyContent: "center", alignItems: "center", direction: "column", "aria-label": "verification-code-field", children: [
|
|
43
|
+
label ? /* @__PURE__ */ jsx("label", { id: `${id}-label`, htmlFor: `${id}-0`, style: {
|
|
44
|
+
cursor: "pointer",
|
|
45
|
+
flexShrink: 0
|
|
46
|
+
}, children: /* @__PURE__ */ jsx(Text, { as: "p", variant: "body", prominence: "strong", children: label }) }) : null,
|
|
47
|
+
/* @__PURE__ */ jsx(VerificationCode, { inputId: id, error: !!error, placeholder, fields, onChange: (event) => {
|
|
48
|
+
onChange?.(event);
|
|
49
|
+
field.onChange(event);
|
|
50
|
+
}, onComplete: (event) => {
|
|
51
|
+
onComplete?.(event);
|
|
52
|
+
}, type, disabled, required }),
|
|
53
|
+
error ? /* @__PURE__ */ jsx(Text, { as: "small", variant: "caption", sentiment: "danger", children: getError({
|
|
54
|
+
label: label || "verification-code-field"
|
|
55
|
+
}, error) }) : null
|
|
56
|
+
] });
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
VerificationCodeField
|
|
60
|
+
};
|
|
@@ -21,3 +21,4 @@ export { SelectableCardGroupField } from './SelectableCardGroupField';
|
|
|
21
21
|
export { SelectInputFieldV2 } from './SelectInputFieldV2';
|
|
22
22
|
export { UnitInputField } from './UnitInputField';
|
|
23
23
|
export { SliderField } from './SliderField';
|
|
24
|
+
export { VerificationCodeField } from './VerificationCodeField';
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ const index$k = require("./components/SelectableCardGroupField/index.cjs");
|
|
|
26
26
|
const index$l = require("./components/SelectInputFieldV2/index.cjs");
|
|
27
27
|
const index$m = require("./components/UnitInputField/index.cjs");
|
|
28
28
|
const index$n = require("./components/SliderField/index.cjs");
|
|
29
|
+
const index$o = require("./components/VerificationCodeField/index.cjs");
|
|
29
30
|
exports.ErrorProvider = index.ErrorProvider;
|
|
30
31
|
exports.useErrors = index.useErrors;
|
|
31
32
|
Object.defineProperty(exports, "useController", {
|
|
@@ -76,3 +77,4 @@ exports.SelectableCardGroupField = index$k.SelectableCardGroupField;
|
|
|
76
77
|
exports.SelectInputFieldV2 = index$l.SelectInputFieldV2;
|
|
77
78
|
exports.UnitInputField = index$m.UnitInputField;
|
|
78
79
|
exports.SliderField = index$n.SliderField;
|
|
80
|
+
exports.VerificationCodeField = index$o.VerificationCodeField;
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { SelectableCardGroupField } from "./components/SelectableCardGroupField/
|
|
|
24
24
|
import { SelectInputFieldV2 } from "./components/SelectInputFieldV2/index.js";
|
|
25
25
|
import { UnitInputField } from "./components/UnitInputField/index.js";
|
|
26
26
|
import { SliderField } from "./components/SliderField/index.js";
|
|
27
|
+
import { VerificationCodeField } from "./components/VerificationCodeField/index.js";
|
|
27
28
|
export {
|
|
28
29
|
CheckboxField,
|
|
29
30
|
CheckboxGroupField,
|
|
@@ -49,6 +50,7 @@ export {
|
|
|
49
50
|
TimeField,
|
|
50
51
|
ToggleField,
|
|
51
52
|
UnitInputField,
|
|
53
|
+
VerificationCodeField,
|
|
52
54
|
useController,
|
|
53
55
|
useErrors,
|
|
54
56
|
useFieldArray,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@babel/runtime": "7.25.7",
|
|
72
|
-
"react-hook-form": "7.53.
|
|
72
|
+
"react-hook-form": "7.53.1",
|
|
73
73
|
"react-select": "5.8.1",
|
|
74
74
|
"@ultraviolet/themes": "1.14.2",
|
|
75
|
-
"@ultraviolet/ui": "1.
|
|
75
|
+
"@ultraviolet/ui": "1.75.0"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|