@ttoss/forms 0.14.18 → 0.14.20
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 +11 -11
- package/dist/index.js +8 -8
- package/package.json +3 -3
- package/src/ErrorMessage.tsx +2 -8
- package/src/FormFieldCheckbox.tsx +4 -0
package/dist/esm/index.js
CHANGED
|
@@ -35,8 +35,8 @@ import { Box as Box2, Label } from "@ttoss/ui";
|
|
|
35
35
|
|
|
36
36
|
// src/ErrorMessage.tsx
|
|
37
37
|
import { useFormContext } from "react-hook-form";
|
|
38
|
+
import { HelpText } from "@ttoss/ui";
|
|
38
39
|
import { ErrorMessage as HookFormErrorMessage } from "@hookform/error-message";
|
|
39
|
-
import { Text } from "@ttoss/ui";
|
|
40
40
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
41
41
|
var ErrorMessage = ({
|
|
42
42
|
name
|
|
@@ -49,13 +49,8 @@ var ErrorMessage = ({
|
|
|
49
49
|
return /* @__PURE__ */jsx2(HookFormErrorMessage, {
|
|
50
50
|
errors,
|
|
51
51
|
name,
|
|
52
|
-
as: /* @__PURE__ */jsx2(
|
|
53
|
-
|
|
54
|
-
role: "alert",
|
|
55
|
-
sx: {
|
|
56
|
-
fontFamily: "caption",
|
|
57
|
-
fontSize: "xs"
|
|
58
|
-
}
|
|
52
|
+
as: /* @__PURE__ */jsx2(HelpText, {
|
|
53
|
+
negative: true
|
|
59
54
|
})
|
|
60
55
|
});
|
|
61
56
|
};
|
|
@@ -108,12 +103,16 @@ var FormFieldCheckbox = ({
|
|
|
108
103
|
onBlur,
|
|
109
104
|
value,
|
|
110
105
|
ref
|
|
106
|
+
},
|
|
107
|
+
formState: {
|
|
108
|
+
errors
|
|
111
109
|
}
|
|
112
110
|
} = useController2({
|
|
113
111
|
name,
|
|
114
112
|
defaultValue: false
|
|
115
113
|
});
|
|
116
114
|
const id = `form-field-checkbox-${name}`;
|
|
115
|
+
const error = !!errors[name]?.message;
|
|
117
116
|
return /* @__PURE__ */jsxs2(Box3, {
|
|
118
117
|
children: [/* @__PURE__ */jsx4(Flex, {
|
|
119
118
|
sx: {
|
|
@@ -129,6 +128,7 @@ var FormFieldCheckbox = ({
|
|
|
129
128
|
onChange,
|
|
130
129
|
onBlur,
|
|
131
130
|
name,
|
|
131
|
+
"aria-invalid": error ? "true" : "false",
|
|
132
132
|
...checkboxProps
|
|
133
133
|
}), label]
|
|
134
134
|
})
|
|
@@ -139,7 +139,7 @@ var FormFieldCheckbox = ({
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
// src/FormFieldInput.tsx
|
|
142
|
-
import { Box as Box4, Icon, Input, Label as Label3, Text
|
|
142
|
+
import { Box as Box4, Icon, Input, Label as Label3, Text } from "@ttoss/ui";
|
|
143
143
|
import { useController as useController3 } from "react-hook-form";
|
|
144
144
|
import React3 from "react";
|
|
145
145
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
@@ -180,7 +180,7 @@ var FormFieldInput = ({
|
|
|
180
180
|
},
|
|
181
181
|
"aria-disabled": inputProps.disabled,
|
|
182
182
|
htmlFor: id,
|
|
183
|
-
children: [label, tooltipIcon && /* @__PURE__ */jsx5(
|
|
183
|
+
children: [label, tooltipIcon && /* @__PURE__ */jsx5(Text, {
|
|
184
184
|
sx: {
|
|
185
185
|
marginLeft: "md",
|
|
186
186
|
fontSize: "xs",
|
|
@@ -190,7 +190,7 @@ var FormFieldInput = ({
|
|
|
190
190
|
children: /* @__PURE__ */jsx5(Icon, {
|
|
191
191
|
icon: tooltipIcon
|
|
192
192
|
})
|
|
193
|
-
}), showCharacterCounter && /* @__PURE__ */jsx5(
|
|
193
|
+
}), showCharacterCounter && /* @__PURE__ */jsx5(Text, {
|
|
194
194
|
sx: {
|
|
195
195
|
marginLeft: "auto",
|
|
196
196
|
fontSize: "xs",
|
package/dist/index.js
CHANGED
|
@@ -84,8 +84,8 @@ var import_ui3 = require("@ttoss/ui");
|
|
|
84
84
|
|
|
85
85
|
// src/ErrorMessage.tsx
|
|
86
86
|
var import_react_hook_form2 = require("react-hook-form");
|
|
87
|
-
var import_error_message = require("@hookform/error-message");
|
|
88
87
|
var import_ui2 = require("@ttoss/ui");
|
|
88
|
+
var import_error_message = require("@hookform/error-message");
|
|
89
89
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
90
90
|
var ErrorMessage = ({
|
|
91
91
|
name
|
|
@@ -98,13 +98,8 @@ var ErrorMessage = ({
|
|
|
98
98
|
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_error_message.ErrorMessage, {
|
|
99
99
|
errors,
|
|
100
100
|
name,
|
|
101
|
-
as: /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui2.
|
|
102
|
-
|
|
103
|
-
role: "alert",
|
|
104
|
-
sx: {
|
|
105
|
-
fontFamily: "caption",
|
|
106
|
-
fontSize: "xs"
|
|
107
|
-
}
|
|
101
|
+
as: /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui2.HelpText, {
|
|
102
|
+
negative: true
|
|
108
103
|
})
|
|
109
104
|
});
|
|
110
105
|
};
|
|
@@ -157,12 +152,16 @@ var FormFieldCheckbox = ({
|
|
|
157
152
|
onBlur,
|
|
158
153
|
value,
|
|
159
154
|
ref
|
|
155
|
+
},
|
|
156
|
+
formState: {
|
|
157
|
+
errors
|
|
160
158
|
}
|
|
161
159
|
} = (0, import_react_hook_form4.useController)({
|
|
162
160
|
name,
|
|
163
161
|
defaultValue: false
|
|
164
162
|
});
|
|
165
163
|
const id = `form-field-checkbox-${name}`;
|
|
164
|
+
const error = !!errors[name]?.message;
|
|
166
165
|
return /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(import_ui4.Box, {
|
|
167
166
|
children: [/* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui4.Flex, {
|
|
168
167
|
sx: {
|
|
@@ -178,6 +177,7 @@ var FormFieldCheckbox = ({
|
|
|
178
177
|
onChange,
|
|
179
178
|
onBlur,
|
|
180
179
|
name,
|
|
180
|
+
"aria-invalid": error ? "true" : "false",
|
|
181
181
|
...checkboxProps
|
|
182
182
|
}), label]
|
|
183
183
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.20",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@ttoss/config": "^1.29.2",
|
|
33
33
|
"@ttoss/test-utils": "^1.20.9",
|
|
34
|
-
"@ttoss/ui": "^1.31.
|
|
34
|
+
"@ttoss/ui": "^1.31.7",
|
|
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": "3d2d6ecf2c24eb734b162bfe8d73a7a2886c49f6"
|
|
45
45
|
}
|
package/src/ErrorMessage.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldName, FieldValues, useFormContext } from 'react-hook-form';
|
|
2
|
+
import { HelpText } from '@ttoss/ui';
|
|
2
3
|
import { ErrorMessage as HookFormErrorMessage } from '@hookform/error-message';
|
|
3
|
-
import { Text } from '@ttoss/ui';
|
|
4
4
|
|
|
5
5
|
export const ErrorMessage = <TFieldValues extends FieldValues = FieldValues>({
|
|
6
6
|
name,
|
|
@@ -15,13 +15,7 @@ export const ErrorMessage = <TFieldValues extends FieldValues = FieldValues>({
|
|
|
15
15
|
<HookFormErrorMessage
|
|
16
16
|
errors={errors}
|
|
17
17
|
name={name as any}
|
|
18
|
-
as={
|
|
19
|
-
<Text
|
|
20
|
-
variant="text.error"
|
|
21
|
-
role="alert"
|
|
22
|
-
sx={{ fontFamily: 'caption', fontSize: 'xs' }}
|
|
23
|
-
/>
|
|
24
|
-
}
|
|
18
|
+
as={<HelpText negative />}
|
|
25
19
|
/>
|
|
26
20
|
);
|
|
27
21
|
};
|
|
@@ -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}
|