@ttoss/forms 0.14.19 → 0.14.21
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/esm/index.js +5 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +5 -0
- package/package.json +4 -4
- package/src/FormFieldCheckbox.tsx +4 -0
package/dist/esm/index.js
CHANGED
|
@@ -103,12 +103,16 @@ var FormFieldCheckbox = ({
|
|
|
103
103
|
onBlur,
|
|
104
104
|
value,
|
|
105
105
|
ref
|
|
106
|
+
},
|
|
107
|
+
formState: {
|
|
108
|
+
errors
|
|
106
109
|
}
|
|
107
110
|
} = useController2({
|
|
108
111
|
name,
|
|
109
112
|
defaultValue: false
|
|
110
113
|
});
|
|
111
114
|
const id = `form-field-checkbox-${name}`;
|
|
115
|
+
const error = !!errors[name]?.message;
|
|
112
116
|
return /* @__PURE__ */jsxs2(Box3, {
|
|
113
117
|
children: [/* @__PURE__ */jsx4(Flex, {
|
|
114
118
|
sx: {
|
|
@@ -124,6 +128,7 @@ var FormFieldCheckbox = ({
|
|
|
124
128
|
onChange,
|
|
125
129
|
onBlur,
|
|
126
130
|
name,
|
|
131
|
+
"aria-invalid": error ? "true" : "false",
|
|
127
132
|
...checkboxProps
|
|
128
133
|
}), label]
|
|
129
134
|
})
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { yupResolver } from '@hookform/resolvers/yup';
|
|
2
2
|
import * as react_hook_form from 'react-hook-form';
|
|
3
|
-
import { FieldValues, UseControllerReturn } from 'react-hook-form';
|
|
3
|
+
import { FieldValues, FieldPath, FieldPathValue, UseControllerReturn } from 'react-hook-form';
|
|
4
4
|
export * from 'react-hook-form';
|
|
5
5
|
import * as yup from 'yup';
|
|
6
6
|
export { yup };
|
|
@@ -16,20 +16,20 @@ declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children,
|
|
|
16
16
|
children: React.ReactNode | React.ReactNode[];
|
|
17
17
|
} & react_hook_form.UseFormReturn<TFieldValues, any>) => JSX.Element;
|
|
18
18
|
|
|
19
|
-
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends
|
|
19
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, id: idProp, name, defaultValue, render, }: {
|
|
20
20
|
label?: string | undefined;
|
|
21
21
|
id?: string | undefined;
|
|
22
22
|
name: TName;
|
|
23
|
-
defaultValue?:
|
|
23
|
+
defaultValue?: FieldPathValue<TFieldValues, TName> | undefined;
|
|
24
24
|
render: (props: UseControllerReturn<TFieldValues, TName>) => React.ReactElement;
|
|
25
25
|
}) => JSX.Element;
|
|
26
26
|
|
|
27
27
|
declare const FormFieldCheckbox: <TFieldValues extends FieldValues = FieldValues>({ label, name, ...checkboxProps }: {
|
|
28
28
|
label?: string | undefined;
|
|
29
|
-
name:
|
|
29
|
+
name: FieldPath<TFieldValues>;
|
|
30
30
|
} & CheckboxProps) => JSX.Element;
|
|
31
31
|
|
|
32
|
-
declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues, TName extends
|
|
32
|
+
declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, tooltipIcon, showCharacterCounter, ...inputProps }: {
|
|
33
33
|
label?: string | undefined;
|
|
34
34
|
name: TName;
|
|
35
35
|
tooltipIcon?: IconType | undefined;
|
|
@@ -45,7 +45,7 @@ type FormRadioOption$1 = {
|
|
|
45
45
|
};
|
|
46
46
|
declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, ...radioProps }: {
|
|
47
47
|
label?: string | undefined;
|
|
48
|
-
name:
|
|
48
|
+
name: FieldPath<TFieldValues>;
|
|
49
49
|
options: FormRadioOption$1[];
|
|
50
50
|
} & RadioProps) => JSX.Element;
|
|
51
51
|
|
|
@@ -55,11 +55,11 @@ type FormRadioOption = {
|
|
|
55
55
|
};
|
|
56
56
|
declare const FormFieldSelect: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, ...selectProps }: {
|
|
57
57
|
label?: string | undefined;
|
|
58
|
-
name:
|
|
58
|
+
name: FieldPath<TFieldValues>;
|
|
59
59
|
options: FormRadioOption[];
|
|
60
60
|
} & SelectProps) => JSX.Element;
|
|
61
61
|
|
|
62
|
-
declare const FormFieldTextarea: <TFieldValues extends FieldValues = FieldValues, TName extends
|
|
62
|
+
declare const FormFieldTextarea: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, ...textareaProps }: {
|
|
63
63
|
label?: string | undefined;
|
|
64
64
|
name: TName;
|
|
65
65
|
} & TextareaProps) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -152,12 +152,16 @@ var FormFieldCheckbox = ({
|
|
|
152
152
|
onBlur,
|
|
153
153
|
value,
|
|
154
154
|
ref
|
|
155
|
+
},
|
|
156
|
+
formState: {
|
|
157
|
+
errors
|
|
155
158
|
}
|
|
156
159
|
} = (0, import_react_hook_form4.useController)({
|
|
157
160
|
name,
|
|
158
161
|
defaultValue: false
|
|
159
162
|
});
|
|
160
163
|
const id = `form-field-checkbox-${name}`;
|
|
164
|
+
const error = !!errors[name]?.message;
|
|
161
165
|
return /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(import_ui4.Box, {
|
|
162
166
|
children: [/* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui4.Flex, {
|
|
163
167
|
sx: {
|
|
@@ -173,6 +177,7 @@ var FormFieldCheckbox = ({
|
|
|
173
177
|
onChange,
|
|
174
178
|
onBlur,
|
|
175
179
|
name,
|
|
180
|
+
"aria-invalid": error ? "true" : "false",
|
|
176
181
|
...checkboxProps
|
|
177
182
|
}), label]
|
|
178
183
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.21",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@ttoss/config": "^1.29.2",
|
|
33
|
-
"@ttoss/test-utils": "^1.
|
|
34
|
-
"@ttoss/ui": "^1.31.
|
|
33
|
+
"@ttoss/test-utils": "^1.21.0",
|
|
34
|
+
"@ttoss/ui": "^1.31.8",
|
|
35
35
|
"@types/jest": "^29.5.0",
|
|
36
36
|
"jest": "^29.5.0",
|
|
37
37
|
"react": "^18.2.0",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "01701f2c03d9872297d85af0a33d1ca4c2a6eb6b"
|
|
45
45
|
}
|
|
@@ -14,6 +14,7 @@ export const FormFieldCheckbox = <
|
|
|
14
14
|
} & CheckboxProps) => {
|
|
15
15
|
const {
|
|
16
16
|
field: { onChange, onBlur, value, ref },
|
|
17
|
+
formState: { errors },
|
|
17
18
|
} = useController<any>({
|
|
18
19
|
name,
|
|
19
20
|
defaultValue: false,
|
|
@@ -21,6 +22,8 @@ export const FormFieldCheckbox = <
|
|
|
21
22
|
|
|
22
23
|
const id = `form-field-checkbox-${name}`;
|
|
23
24
|
|
|
25
|
+
const error = !!errors[name]?.message;
|
|
26
|
+
|
|
24
27
|
return (
|
|
25
28
|
<Box>
|
|
26
29
|
<Flex sx={{ alignItems: 'center' }}>
|
|
@@ -32,6 +35,7 @@ export const FormFieldCheckbox = <
|
|
|
32
35
|
onChange={onChange}
|
|
33
36
|
onBlur={onBlur}
|
|
34
37
|
name={name}
|
|
38
|
+
aria-invalid={error ? 'true' : 'false'}
|
|
35
39
|
{...checkboxProps}
|
|
36
40
|
/>
|
|
37
41
|
{label}
|