@ttoss/forms 0.23.6 → 0.24.0
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/README.md +91 -57
- package/dist/Brazil/index.js +36 -34
- package/dist/MultistepForm/index.js +59 -47
- package/dist/esm/Brazil/index.js +1 -1
- package/dist/esm/MultistepForm/index.js +14 -14
- package/dist/esm/{chunk-J6VGD2RH.js → chunk-FGWZI374.js} +44 -32
- package/dist/esm/index.js +2 -2
- package/dist/index.d.mts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +37 -34
- package/package.json +10 -10
- package/src/FormGroup.tsx +4 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -49,9 +49,82 @@ export const FormComponent = () => {
|
|
|
49
49
|
|
|
50
50
|
It exposes all the API from react-hook-form, so you can use all the methods and properties from it. Check the [React Hook Form](https://react-hook-form.com/docs) documentation for more details.
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## Yup Validation
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
You can also use yup and all of API from react-hook-form importing `import { yup, useForm } from @ttoss/forms`
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
const FirstNameForm = () => {
|
|
58
|
+
const schema = yup.object({
|
|
59
|
+
firstName: yup.string().required(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const formMethods = useForm({
|
|
63
|
+
resolver: yupResolver(schema),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Form {...formMethods} onSubmit={onSubmit}>
|
|
68
|
+
<FormField
|
|
69
|
+
name="firstName"
|
|
70
|
+
label="First Name"
|
|
71
|
+
defaultValue={''}
|
|
72
|
+
render={({ field }) => {
|
|
73
|
+
return <Input {...field} />;
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
<Button type="submit">Submit</Button>
|
|
77
|
+
</Form>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When field is invalid according with schema requirements, it gonna return the default. In this example, for required fields, it gonna be `Field is required`.
|
|
83
|
+
|
|
84
|
+
You can translate the message or change the generic message by configuring the messages in the json i18n definition. To use this, please, refer to the docs on [React-i18n](https://ttoss.dev/docs/modules/packages/react-i18n/) and [i18n-CLI](https://ttoss.dev/docs/modules/packages/i18n-cli/).
|
|
85
|
+
|
|
86
|
+
### Custom Error messages
|
|
87
|
+
|
|
88
|
+
You can, also, pass custom error messages to the validation constraints in schema. It's really recommended that you use i18n pattern to create your custom message.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
const ComponentForm = () => {
|
|
92
|
+
const {
|
|
93
|
+
intl: { formatMessage },
|
|
94
|
+
} = useI18n();
|
|
95
|
+
|
|
96
|
+
const schema = useMemo(() => {
|
|
97
|
+
return yup.object({
|
|
98
|
+
name: yup.string().required(
|
|
99
|
+
formatMessage({
|
|
100
|
+
defaultMessage: 'Name must be not null',
|
|
101
|
+
description: 'Name required constraint',
|
|
102
|
+
})
|
|
103
|
+
),
|
|
104
|
+
age: yup.number().min(
|
|
105
|
+
18,
|
|
106
|
+
formatMessage(
|
|
107
|
+
{
|
|
108
|
+
defaultMessage: 'You should be {age} years old or more',
|
|
109
|
+
description: 'Min Age Constriant message',
|
|
110
|
+
},
|
|
111
|
+
{ age: 18 }
|
|
112
|
+
)
|
|
113
|
+
),
|
|
114
|
+
});
|
|
115
|
+
}, [formatMessage]);
|
|
116
|
+
|
|
117
|
+
// ...
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Components
|
|
122
|
+
|
|
123
|
+
### FormFieldSelect
|
|
124
|
+
|
|
125
|
+
#### FormFieldSelect support for Default Value
|
|
126
|
+
|
|
127
|
+
`FormFieldSelect` has support for default values, by assigning the first option defined or the value passed to it in the parameter `defaultValue`.
|
|
55
128
|
|
|
56
129
|
```tsx
|
|
57
130
|
const RADIO_OPTIONS = [
|
|
@@ -160,74 +233,35 @@ const RenderForm = () => {
|
|
|
160
233
|
};
|
|
161
234
|
```
|
|
162
235
|
|
|
163
|
-
###
|
|
236
|
+
### FormGroup
|
|
164
237
|
|
|
165
|
-
|
|
238
|
+
`FormGroup` is a component that groups fields together. It's useful when you need to group fields that are related to each other.
|
|
166
239
|
|
|
167
240
|
```tsx
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
firstName: yup.string().required(),
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const formMethods = useForm({
|
|
174
|
-
resolver: yupResolver(schema),
|
|
175
|
-
});
|
|
241
|
+
const RenderForm = () => {
|
|
242
|
+
const formMethods = useForm();
|
|
176
243
|
|
|
177
244
|
return (
|
|
178
245
|
<Form {...formMethods} onSubmit={onSubmit}>
|
|
179
|
-
<
|
|
180
|
-
name="firstName"
|
|
181
|
-
label="
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
246
|
+
<FormGroup label="Personal Information" direction="row">
|
|
247
|
+
<FormField.Input name="firstName" label="First Name" />
|
|
248
|
+
<FormField.Input name="lastName" label="Last Name" />
|
|
249
|
+
</FormGroup>
|
|
250
|
+
<FormGroup label="Address">
|
|
251
|
+
<FormField.Input name="street" label="Street" />
|
|
252
|
+
<FormField.Input name="city" label="City" />
|
|
253
|
+
</FormGroup>
|
|
187
254
|
<Button type="submit">Submit</Button>
|
|
188
255
|
</Form>
|
|
189
256
|
);
|
|
190
257
|
};
|
|
191
258
|
```
|
|
192
259
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
You can translate the message or change the generic message by configuring the messages in the json i18n definition. To use this, please, refer to the docs on [React-i18n](https://ttoss.dev/docs/modules/packages/react-i18n/) and [i18n-CLI](https://ttoss.dev/docs/modules/packages/i18n-cli/).
|
|
196
|
-
|
|
197
|
-
### Custom Error messages
|
|
198
|
-
|
|
199
|
-
You can, also, pass custom error messages to the validation constraints in schema. It's really recommended that you use i18n pattern to create your custom message.
|
|
200
|
-
|
|
201
|
-
```tsx
|
|
202
|
-
const ComponentForm = () => {
|
|
203
|
-
const {
|
|
204
|
-
intl: { formatMessage },
|
|
205
|
-
} = useI18n();
|
|
206
|
-
|
|
207
|
-
const schema = useMemo(() => {
|
|
208
|
-
return yup.object({
|
|
209
|
-
name: yup.string().required(
|
|
210
|
-
formatMessage({
|
|
211
|
-
defaultMessage: 'Name must be not null',
|
|
212
|
-
description: 'Name required constraint',
|
|
213
|
-
})
|
|
214
|
-
),
|
|
215
|
-
age: yup.number().min(
|
|
216
|
-
18,
|
|
217
|
-
formatMessage(
|
|
218
|
-
{
|
|
219
|
-
defaultMessage: 'You should be {age} years old or more',
|
|
220
|
-
description: 'Min Age Constriant message',
|
|
221
|
-
},
|
|
222
|
-
{ age: 18 }
|
|
223
|
-
)
|
|
224
|
-
),
|
|
225
|
-
});
|
|
226
|
-
}, [formatMessage]);
|
|
260
|
+
#### Props
|
|
227
261
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
262
|
+
- `title`: The label of the group.
|
|
263
|
+
- `direction`: The direction of the group. It can be `row` or `column`.
|
|
264
|
+
- `name`: The name of the group. It is used to render the group error message.
|
|
231
265
|
|
|
232
266
|
## @ttoss/forms/multistep-form
|
|
233
267
|
|
package/dist/Brazil/index.js
CHANGED
|
@@ -50,6 +50,7 @@ module.exports = __toCommonJS(Brazil_exports);
|
|
|
50
50
|
var src_exports = {};
|
|
51
51
|
__export(src_exports, {
|
|
52
52
|
Controller: () => import_react_hook_form6.Controller,
|
|
53
|
+
ErrorMessage: () => ErrorMessage,
|
|
53
54
|
Form: () => Form,
|
|
54
55
|
FormField: () => FormField,
|
|
55
56
|
FormFieldCheckbox: () => FormFieldCheckbox,
|
|
@@ -127,39 +128,12 @@ yup.addMethod(yup.string, "cnpj", function () {
|
|
|
127
128
|
// src/yup/yup.ts
|
|
128
129
|
var yup2 = __toESM(require("yup"));
|
|
129
130
|
|
|
130
|
-
// src/Form.tsx
|
|
131
|
-
var import_ui = require("@ttoss/ui");
|
|
132
|
-
var import_react_hook_form = require("react-hook-form");
|
|
133
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
134
|
-
var Form = ({
|
|
135
|
-
children,
|
|
136
|
-
onSubmit,
|
|
137
|
-
sx,
|
|
138
|
-
...formMethods
|
|
139
|
-
}) => {
|
|
140
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_hook_form.FormProvider, {
|
|
141
|
-
...formMethods,
|
|
142
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ui.Box, {
|
|
143
|
-
as: "form",
|
|
144
|
-
variant: "forms.form",
|
|
145
|
-
onSubmit: formMethods.handleSubmit(data => {
|
|
146
|
-
return onSubmit?.(data);
|
|
147
|
-
}),
|
|
148
|
-
sx,
|
|
149
|
-
children
|
|
150
|
-
})
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// src/FormField.tsx
|
|
155
|
-
var React = __toESM(require("react"));
|
|
156
|
-
|
|
157
131
|
// src/ErrorMessage.tsx
|
|
158
|
-
var
|
|
132
|
+
var import_react_hook_form = require("react-hook-form");
|
|
159
133
|
var import_react_i18n2 = require("@ttoss/react-i18n");
|
|
160
|
-
var
|
|
134
|
+
var import_ui = require("@ttoss/ui");
|
|
161
135
|
var import_error_message = require("@hookform/error-message");
|
|
162
|
-
var
|
|
136
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
163
137
|
var isMessageDescriptor = possibleMessageDescriptor => {
|
|
164
138
|
return possibleMessageDescriptor !== void 0 && possibleMessageDescriptor.defaultMessage !== void 0;
|
|
165
139
|
};
|
|
@@ -171,14 +145,14 @@ var ErrorMessage = ({
|
|
|
171
145
|
formState: {
|
|
172
146
|
errors
|
|
173
147
|
}
|
|
174
|
-
} = (0,
|
|
175
|
-
return /* @__PURE__ */(0,
|
|
148
|
+
} = (0, import_react_hook_form.useFormContext)();
|
|
149
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_error_message.ErrorMessage, {
|
|
176
150
|
name,
|
|
177
151
|
errors,
|
|
178
152
|
render: ({
|
|
179
153
|
message
|
|
180
154
|
}) => {
|
|
181
|
-
return /* @__PURE__ */(0,
|
|
155
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ui.HelpText, {
|
|
182
156
|
negative: true,
|
|
183
157
|
disabled,
|
|
184
158
|
children: (() => {
|
|
@@ -186,7 +160,7 @@ var ErrorMessage = ({
|
|
|
186
160
|
return message;
|
|
187
161
|
}
|
|
188
162
|
if (isMessageDescriptor(message)) {
|
|
189
|
-
return /* @__PURE__ */(0,
|
|
163
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_i18n2.FormattedMessage, {
|
|
190
164
|
...message
|
|
191
165
|
});
|
|
192
166
|
}
|
|
@@ -197,7 +171,32 @@ var ErrorMessage = ({
|
|
|
197
171
|
});
|
|
198
172
|
};
|
|
199
173
|
|
|
174
|
+
// src/Form.tsx
|
|
175
|
+
var import_ui2 = require("@ttoss/ui");
|
|
176
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
177
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
178
|
+
var Form = ({
|
|
179
|
+
children,
|
|
180
|
+
onSubmit,
|
|
181
|
+
sx,
|
|
182
|
+
...formMethods
|
|
183
|
+
}) => {
|
|
184
|
+
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_react_hook_form2.FormProvider, {
|
|
185
|
+
...formMethods,
|
|
186
|
+
children: /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui2.Box, {
|
|
187
|
+
as: "form",
|
|
188
|
+
variant: "forms.form",
|
|
189
|
+
onSubmit: formMethods.handleSubmit(data => {
|
|
190
|
+
return onSubmit?.(data);
|
|
191
|
+
}),
|
|
192
|
+
sx,
|
|
193
|
+
children
|
|
194
|
+
})
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
200
198
|
// src/FormField.tsx
|
|
199
|
+
var React = __toESM(require("react"));
|
|
201
200
|
var import_react_hook_form3 = require("react-hook-form");
|
|
202
201
|
var import_ui3 = require("@ttoss/ui");
|
|
203
202
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -637,6 +636,7 @@ var FormGroupWrapper = ({
|
|
|
637
636
|
title,
|
|
638
637
|
direction,
|
|
639
638
|
children,
|
|
639
|
+
name,
|
|
640
640
|
...boxProps
|
|
641
641
|
}) => {
|
|
642
642
|
const {
|
|
@@ -677,6 +677,8 @@ var FormGroupWrapper = ({
|
|
|
677
677
|
}), /* @__PURE__ */(0, import_jsx_runtime14.jsx)(import_ui12.Flex, {
|
|
678
678
|
sx: childrenContainerSx,
|
|
679
679
|
children
|
|
680
|
+
}), name && /* @__PURE__ */(0, import_jsx_runtime14.jsx)(ErrorMessage, {
|
|
681
|
+
name
|
|
680
682
|
})]
|
|
681
683
|
});
|
|
682
684
|
};
|
|
@@ -7,6 +7,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value
|
|
15
|
+
}) : obj[key] = value;
|
|
10
16
|
var __export = (target, all) => {
|
|
11
17
|
for (var name in all) __defProp(target, name, {
|
|
12
18
|
get: all[name],
|
|
@@ -35,6 +41,10 @@ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
|
35
41
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
36
42
|
value: true
|
|
37
43
|
}), mod);
|
|
44
|
+
var __publicField = (obj, key, value) => {
|
|
45
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
46
|
+
return value;
|
|
47
|
+
};
|
|
38
48
|
|
|
39
49
|
// src/MultistepForm/index.ts
|
|
40
50
|
var MultistepForm_exports = {};
|
|
@@ -77,6 +87,7 @@ var import_ui17 = require("@ttoss/ui");
|
|
|
77
87
|
var src_exports = {};
|
|
78
88
|
__export(src_exports, {
|
|
79
89
|
Controller: () => import_react_hook_form6.Controller,
|
|
90
|
+
ErrorMessage: () => ErrorMessage,
|
|
80
91
|
Form: () => Form,
|
|
81
92
|
FormField: () => FormField,
|
|
82
93
|
FormFieldCheckbox: () => FormFieldCheckbox,
|
|
@@ -199,39 +210,12 @@ yup.addMethod(yup.string, "cnpj", function () {
|
|
|
199
210
|
// src/yup/yup.ts
|
|
200
211
|
var yup2 = __toESM(require("yup"));
|
|
201
212
|
|
|
202
|
-
// src/Form.tsx
|
|
203
|
-
var import_ui3 = require("@ttoss/ui");
|
|
204
|
-
var import_react_hook_form = require("react-hook-form");
|
|
205
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
206
|
-
var Form = ({
|
|
207
|
-
children,
|
|
208
|
-
onSubmit,
|
|
209
|
-
sx,
|
|
210
|
-
...formMethods
|
|
211
|
-
}) => {
|
|
212
|
-
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_react_hook_form.FormProvider, {
|
|
213
|
-
...formMethods,
|
|
214
|
-
children: /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_ui3.Box, {
|
|
215
|
-
as: "form",
|
|
216
|
-
variant: "forms.form",
|
|
217
|
-
onSubmit: formMethods.handleSubmit(data => {
|
|
218
|
-
return onSubmit?.(data);
|
|
219
|
-
}),
|
|
220
|
-
sx,
|
|
221
|
-
children
|
|
222
|
-
})
|
|
223
|
-
});
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// src/FormField.tsx
|
|
227
|
-
var React = __toESM(require("react"));
|
|
228
|
-
|
|
229
213
|
// src/ErrorMessage.tsx
|
|
230
|
-
var
|
|
214
|
+
var import_react_hook_form = require("react-hook-form");
|
|
231
215
|
var import_react_i18n2 = require("@ttoss/react-i18n");
|
|
232
|
-
var
|
|
216
|
+
var import_ui3 = require("@ttoss/ui");
|
|
233
217
|
var import_error_message = require("@hookform/error-message");
|
|
234
|
-
var
|
|
218
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
235
219
|
var isMessageDescriptor = possibleMessageDescriptor => {
|
|
236
220
|
return possibleMessageDescriptor !== void 0 && possibleMessageDescriptor.defaultMessage !== void 0;
|
|
237
221
|
};
|
|
@@ -243,14 +227,14 @@ var ErrorMessage = ({
|
|
|
243
227
|
formState: {
|
|
244
228
|
errors
|
|
245
229
|
}
|
|
246
|
-
} = (0,
|
|
247
|
-
return /* @__PURE__ */(0,
|
|
230
|
+
} = (0, import_react_hook_form.useFormContext)();
|
|
231
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_error_message.ErrorMessage, {
|
|
248
232
|
name,
|
|
249
233
|
errors,
|
|
250
234
|
render: ({
|
|
251
235
|
message
|
|
252
236
|
}) => {
|
|
253
|
-
return /* @__PURE__ */(0,
|
|
237
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_ui3.HelpText, {
|
|
254
238
|
negative: true,
|
|
255
239
|
disabled,
|
|
256
240
|
children: (() => {
|
|
@@ -258,7 +242,7 @@ var ErrorMessage = ({
|
|
|
258
242
|
return message;
|
|
259
243
|
}
|
|
260
244
|
if (isMessageDescriptor(message)) {
|
|
261
|
-
return /* @__PURE__ */(0,
|
|
245
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_react_i18n2.FormattedMessage, {
|
|
262
246
|
...message
|
|
263
247
|
});
|
|
264
248
|
}
|
|
@@ -269,7 +253,32 @@ var ErrorMessage = ({
|
|
|
269
253
|
});
|
|
270
254
|
};
|
|
271
255
|
|
|
256
|
+
// src/Form.tsx
|
|
257
|
+
var import_ui4 = require("@ttoss/ui");
|
|
258
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
259
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
260
|
+
var Form = ({
|
|
261
|
+
children,
|
|
262
|
+
onSubmit,
|
|
263
|
+
sx,
|
|
264
|
+
...formMethods
|
|
265
|
+
}) => {
|
|
266
|
+
return /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_react_hook_form2.FormProvider, {
|
|
267
|
+
...formMethods,
|
|
268
|
+
children: /* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui4.Box, {
|
|
269
|
+
as: "form",
|
|
270
|
+
variant: "forms.form",
|
|
271
|
+
onSubmit: formMethods.handleSubmit(data => {
|
|
272
|
+
return onSubmit?.(data);
|
|
273
|
+
}),
|
|
274
|
+
sx,
|
|
275
|
+
children
|
|
276
|
+
})
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
|
|
272
280
|
// src/FormField.tsx
|
|
281
|
+
var React = __toESM(require("react"));
|
|
273
282
|
var import_react_hook_form3 = require("react-hook-form");
|
|
274
283
|
var import_ui5 = require("@ttoss/ui");
|
|
275
284
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -709,6 +718,7 @@ var FormGroupWrapper = ({
|
|
|
709
718
|
title,
|
|
710
719
|
direction,
|
|
711
720
|
children,
|
|
721
|
+
name,
|
|
712
722
|
...boxProps
|
|
713
723
|
}) => {
|
|
714
724
|
const {
|
|
@@ -749,6 +759,8 @@ var FormGroupWrapper = ({
|
|
|
749
759
|
}), /* @__PURE__ */(0, import_jsx_runtime16.jsx)(import_ui14.Flex, {
|
|
750
760
|
sx: childrenContainerSx,
|
|
751
761
|
children
|
|
762
|
+
}), name && /* @__PURE__ */(0, import_jsx_runtime16.jsx)(ErrorMessage, {
|
|
763
|
+
name
|
|
752
764
|
})]
|
|
753
765
|
});
|
|
754
766
|
};
|
|
@@ -2673,24 +2685,24 @@ function defineIconifyIcon(name = "iconify-icon") {
|
|
|
2673
2685
|
// Customisations
|
|
2674
2686
|
"width", "height", "rotate", "flip"];
|
|
2675
2687
|
const IconifyIcon2 = class extends ParentClass {
|
|
2676
|
-
// Root
|
|
2677
|
-
_shadowRoot;
|
|
2678
|
-
// Initialised
|
|
2679
|
-
_initialised = false;
|
|
2680
|
-
// Icon state
|
|
2681
|
-
_state;
|
|
2682
|
-
// Attributes check queued
|
|
2683
|
-
_checkQueued = false;
|
|
2684
|
-
// Connected
|
|
2685
|
-
_connected = false;
|
|
2686
|
-
// Observer
|
|
2687
|
-
_observer = null;
|
|
2688
|
-
_visible = true;
|
|
2689
2688
|
/**
|
|
2690
2689
|
* Constructor
|
|
2691
2690
|
*/
|
|
2692
2691
|
constructor() {
|
|
2693
2692
|
super();
|
|
2693
|
+
// Root
|
|
2694
|
+
__publicField(this, "_shadowRoot");
|
|
2695
|
+
// Initialised
|
|
2696
|
+
__publicField(this, "_initialised", false);
|
|
2697
|
+
// Icon state
|
|
2698
|
+
__publicField(this, "_state");
|
|
2699
|
+
// Attributes check queued
|
|
2700
|
+
__publicField(this, "_checkQueued", false);
|
|
2701
|
+
// Connected
|
|
2702
|
+
__publicField(this, "_connected", false);
|
|
2703
|
+
// Observer
|
|
2704
|
+
__publicField(this, "_observer", null);
|
|
2705
|
+
__publicField(this, "_visible", true);
|
|
2694
2706
|
const root = this._shadowRoot = this.attachShadow({
|
|
2695
2707
|
mode: "open"
|
|
2696
2708
|
});
|
package/dist/esm/Brazil/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { FormField, FormFieldCNPJ, FormFieldPatternFormat, isCnpjValid } from "../chunk-
|
|
2
|
+
import { FormField, FormFieldCNPJ, FormFieldPatternFormat, isCnpjValid } from "../chunk-FGWZI374.js";
|
|
3
3
|
|
|
4
4
|
// src/Brazil/FormFieldPhone.tsx
|
|
5
5
|
import { Input } from "@ttoss/ui";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { Form, useForm, yupResolver } from "../chunk-
|
|
2
|
+
import { Form, __publicField, useForm, yupResolver } from "../chunk-FGWZI374.js";
|
|
3
3
|
|
|
4
4
|
// src/MultistepForm/MultistepForm.tsx
|
|
5
5
|
import * as React3 from "react";
|
|
@@ -1929,24 +1929,24 @@ function defineIconifyIcon(name = "iconify-icon") {
|
|
|
1929
1929
|
// Customisations
|
|
1930
1930
|
"width", "height", "rotate", "flip"];
|
|
1931
1931
|
const IconifyIcon2 = class extends ParentClass {
|
|
1932
|
-
// Root
|
|
1933
|
-
_shadowRoot;
|
|
1934
|
-
// Initialised
|
|
1935
|
-
_initialised = false;
|
|
1936
|
-
// Icon state
|
|
1937
|
-
_state;
|
|
1938
|
-
// Attributes check queued
|
|
1939
|
-
_checkQueued = false;
|
|
1940
|
-
// Connected
|
|
1941
|
-
_connected = false;
|
|
1942
|
-
// Observer
|
|
1943
|
-
_observer = null;
|
|
1944
|
-
_visible = true;
|
|
1945
1932
|
/**
|
|
1946
1933
|
* Constructor
|
|
1947
1934
|
*/
|
|
1948
1935
|
constructor() {
|
|
1949
1936
|
super();
|
|
1937
|
+
// Root
|
|
1938
|
+
__publicField(this, "_shadowRoot");
|
|
1939
|
+
// Initialised
|
|
1940
|
+
__publicField(this, "_initialised", false);
|
|
1941
|
+
// Icon state
|
|
1942
|
+
__publicField(this, "_state");
|
|
1943
|
+
// Attributes check queued
|
|
1944
|
+
__publicField(this, "_checkQueued", false);
|
|
1945
|
+
// Connected
|
|
1946
|
+
__publicField(this, "_connected", false);
|
|
1947
|
+
// Observer
|
|
1948
|
+
__publicField(this, "_observer", null);
|
|
1949
|
+
__publicField(this, "_visible", true);
|
|
1950
1950
|
const root = this._shadowRoot = this.attachShadow({
|
|
1951
1951
|
mode: "open"
|
|
1952
1952
|
});
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value
|
|
8
|
+
}) : obj[key] = value;
|
|
9
|
+
var __publicField = (obj, key, value) => {
|
|
10
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
2
13
|
|
|
3
14
|
// src/index.ts
|
|
4
15
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
@@ -143,39 +154,12 @@ yup.addMethod(yup.string, "cnpj", function () {
|
|
|
143
154
|
// src/yup/yup.ts
|
|
144
155
|
import * as yup2 from "yup";
|
|
145
156
|
|
|
146
|
-
// src/Form.tsx
|
|
147
|
-
import { Box } from "@ttoss/ui";
|
|
148
|
-
import { FormProvider } from "react-hook-form";
|
|
149
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
150
|
-
var Form = ({
|
|
151
|
-
children,
|
|
152
|
-
onSubmit,
|
|
153
|
-
sx,
|
|
154
|
-
...formMethods
|
|
155
|
-
}) => {
|
|
156
|
-
return /* @__PURE__ */jsx2(FormProvider, {
|
|
157
|
-
...formMethods,
|
|
158
|
-
children: /* @__PURE__ */jsx2(Box, {
|
|
159
|
-
as: "form",
|
|
160
|
-
variant: "forms.form",
|
|
161
|
-
onSubmit: formMethods.handleSubmit(data => {
|
|
162
|
-
return onSubmit?.(data);
|
|
163
|
-
}),
|
|
164
|
-
sx,
|
|
165
|
-
children
|
|
166
|
-
})
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// src/FormField.tsx
|
|
171
|
-
import * as React from "react";
|
|
172
|
-
|
|
173
157
|
// src/ErrorMessage.tsx
|
|
174
158
|
import { useFormContext } from "react-hook-form";
|
|
175
159
|
import { FormattedMessage } from "@ttoss/react-i18n";
|
|
176
160
|
import { HelpText } from "@ttoss/ui";
|
|
177
161
|
import { ErrorMessage as HookformErrorMessage } from "@hookform/error-message";
|
|
178
|
-
import { jsx as
|
|
162
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
179
163
|
var isMessageDescriptor = possibleMessageDescriptor => {
|
|
180
164
|
return possibleMessageDescriptor !== void 0 && possibleMessageDescriptor.defaultMessage !== void 0;
|
|
181
165
|
};
|
|
@@ -188,13 +172,13 @@ var ErrorMessage = ({
|
|
|
188
172
|
errors
|
|
189
173
|
}
|
|
190
174
|
} = useFormContext();
|
|
191
|
-
return /* @__PURE__ */
|
|
175
|
+
return /* @__PURE__ */jsx2(HookformErrorMessage, {
|
|
192
176
|
name,
|
|
193
177
|
errors,
|
|
194
178
|
render: ({
|
|
195
179
|
message
|
|
196
180
|
}) => {
|
|
197
|
-
return /* @__PURE__ */
|
|
181
|
+
return /* @__PURE__ */jsx2(HelpText, {
|
|
198
182
|
negative: true,
|
|
199
183
|
disabled,
|
|
200
184
|
children: (() => {
|
|
@@ -202,7 +186,7 @@ var ErrorMessage = ({
|
|
|
202
186
|
return message;
|
|
203
187
|
}
|
|
204
188
|
if (isMessageDescriptor(message)) {
|
|
205
|
-
return /* @__PURE__ */
|
|
189
|
+
return /* @__PURE__ */jsx2(FormattedMessage, {
|
|
206
190
|
...message
|
|
207
191
|
});
|
|
208
192
|
}
|
|
@@ -213,7 +197,32 @@ var ErrorMessage = ({
|
|
|
213
197
|
});
|
|
214
198
|
};
|
|
215
199
|
|
|
200
|
+
// src/Form.tsx
|
|
201
|
+
import { Box } from "@ttoss/ui";
|
|
202
|
+
import { FormProvider } from "react-hook-form";
|
|
203
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
204
|
+
var Form = ({
|
|
205
|
+
children,
|
|
206
|
+
onSubmit,
|
|
207
|
+
sx,
|
|
208
|
+
...formMethods
|
|
209
|
+
}) => {
|
|
210
|
+
return /* @__PURE__ */jsx3(FormProvider, {
|
|
211
|
+
...formMethods,
|
|
212
|
+
children: /* @__PURE__ */jsx3(Box, {
|
|
213
|
+
as: "form",
|
|
214
|
+
variant: "forms.form",
|
|
215
|
+
onSubmit: formMethods.handleSubmit(data => {
|
|
216
|
+
return onSubmit?.(data);
|
|
217
|
+
}),
|
|
218
|
+
sx,
|
|
219
|
+
children
|
|
220
|
+
})
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
|
|
216
224
|
// src/FormField.tsx
|
|
225
|
+
import * as React from "react";
|
|
217
226
|
import { useController } from "react-hook-form";
|
|
218
227
|
import { Flex, Label } from "@ttoss/ui";
|
|
219
228
|
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
@@ -653,6 +662,7 @@ var FormGroupWrapper = ({
|
|
|
653
662
|
title,
|
|
654
663
|
direction,
|
|
655
664
|
children,
|
|
665
|
+
name,
|
|
656
666
|
...boxProps
|
|
657
667
|
}) => {
|
|
658
668
|
const {
|
|
@@ -693,6 +703,8 @@ var FormGroupWrapper = ({
|
|
|
693
703
|
}), /* @__PURE__ */jsx15(Flex4, {
|
|
694
704
|
sx: childrenContainerSx,
|
|
695
705
|
children
|
|
706
|
+
}), name && /* @__PURE__ */jsx15(ErrorMessage, {
|
|
707
|
+
name
|
|
696
708
|
})]
|
|
697
709
|
});
|
|
698
710
|
};
|
|
@@ -718,4 +730,4 @@ var FormGroup = props => {
|
|
|
718
730
|
// src/index.ts
|
|
719
731
|
import { useForm, useFormContext as useFormContext2, useWatch, useFieldArray, useController as useController4, useFormState, Controller, FormProvider as FormProvider2 } from "react-hook-form";
|
|
720
732
|
export * from "react-hook-form";
|
|
721
|
-
export { isCnpjValid, FormFieldCNPJ, yup2 as yup, Form, FormField, FormFieldCheckbox, FormFieldPatternFormat, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, useFormGroup, FormGroup, yupResolver, useForm, useFormContext2 as useFormContext, useWatch, useFieldArray, useController4 as useController, useFormState, Controller, FormProvider2 as FormProvider };
|
|
733
|
+
export { __publicField, isCnpjValid, FormFieldCNPJ, yup2 as yup, ErrorMessage, Form, FormField, FormFieldCheckbox, FormFieldPatternFormat, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, useFormGroup, FormGroup, yupResolver, useForm, useFormContext2 as useFormContext, useWatch, useFieldArray, useController4 as useController, useFormState, Controller, FormProvider2 as FormProvider };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { Controller, Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver } from "./chunk-
|
|
3
|
-
export { Controller, Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver };
|
|
2
|
+
import { Controller, ErrorMessage, Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver } from "./chunk-FGWZI374.js";
|
|
3
|
+
export { Controller, ErrorMessage, Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,15 +3,20 @@ import './typings.d-HZBqJJjn.mjs';
|
|
|
3
3
|
import * as yup from 'yup';
|
|
4
4
|
export { yup };
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
import
|
|
7
|
-
import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
8
|
-
import { FieldValues, FormProviderProps, FieldPath, UseControllerReturn, FieldPathValue } from 'react-hook-form';
|
|
6
|
+
import { FieldValues, FieldName, FormProviderProps, FieldPath, UseControllerReturn, FieldPathValue } from 'react-hook-form';
|
|
9
7
|
export * from 'react-hook-form';
|
|
10
8
|
export { Controller, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
11
11
|
import { F as FormFieldPatternFormatProps } from './FormFieldPatternFormat-CkcL14ho.mjs';
|
|
12
12
|
export { a as FormFieldPatternFormat } from './FormFieldPatternFormat-CkcL14ho.mjs';
|
|
13
13
|
import { NumericFormatProps } from 'react-number-format';
|
|
14
14
|
|
|
15
|
+
declare const ErrorMessage: <TFieldValues extends FieldValues = FieldValues>({ name, disabled, }: {
|
|
16
|
+
name: FieldName<TFieldValues>;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
15
20
|
declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
|
|
16
21
|
children?: React.ReactNode;
|
|
17
22
|
onSubmit?: (data: TFieldValues) => Promise<void> | void;
|
|
@@ -93,9 +98,10 @@ declare const useFormGroup: () => {
|
|
|
93
98
|
levelsLength: number;
|
|
94
99
|
};
|
|
95
100
|
type FormGroupProps = {
|
|
101
|
+
name?: string;
|
|
96
102
|
title?: string;
|
|
97
103
|
direction?: 'column' | 'row';
|
|
98
104
|
} & BoxProps;
|
|
99
105
|
declare const FormGroup: (props: FormGroupProps) => react_jsx_runtime.JSX.Element;
|
|
100
106
|
|
|
101
|
-
export { Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, useFormGroup };
|
|
107
|
+
export { ErrorMessage, Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, useFormGroup };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,20 @@ import './typings.d-HZBqJJjn.js';
|
|
|
3
3
|
import * as yup from 'yup';
|
|
4
4
|
export { yup };
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
import
|
|
7
|
-
import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
8
|
-
import { FieldValues, FormProviderProps, FieldPath, UseControllerReturn, FieldPathValue } from 'react-hook-form';
|
|
6
|
+
import { FieldValues, FieldName, FormProviderProps, FieldPath, UseControllerReturn, FieldPathValue } from 'react-hook-form';
|
|
9
7
|
export * from 'react-hook-form';
|
|
10
8
|
export { Controller, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
11
11
|
import { F as FormFieldPatternFormatProps } from './FormFieldPatternFormat-CkcL14ho.js';
|
|
12
12
|
export { a as FormFieldPatternFormat } from './FormFieldPatternFormat-CkcL14ho.js';
|
|
13
13
|
import { NumericFormatProps } from 'react-number-format';
|
|
14
14
|
|
|
15
|
+
declare const ErrorMessage: <TFieldValues extends FieldValues = FieldValues>({ name, disabled, }: {
|
|
16
|
+
name: FieldName<TFieldValues>;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
15
20
|
declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
|
|
16
21
|
children?: React.ReactNode;
|
|
17
22
|
onSubmit?: (data: TFieldValues) => Promise<void> | void;
|
|
@@ -93,9 +98,10 @@ declare const useFormGroup: () => {
|
|
|
93
98
|
levelsLength: number;
|
|
94
99
|
};
|
|
95
100
|
type FormGroupProps = {
|
|
101
|
+
name?: string;
|
|
96
102
|
title?: string;
|
|
97
103
|
direction?: 'column' | 'row';
|
|
98
104
|
} & BoxProps;
|
|
99
105
|
declare const FormGroup: (props: FormGroupProps) => react_jsx_runtime.JSX.Element;
|
|
100
106
|
|
|
101
|
-
export { Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, useFormGroup };
|
|
107
|
+
export { ErrorMessage, Form, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, useFormGroup };
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
40
40
|
var src_exports = {};
|
|
41
41
|
__export(src_exports, {
|
|
42
42
|
Controller: () => import_react_hook_form6.Controller,
|
|
43
|
+
ErrorMessage: () => ErrorMessage,
|
|
43
44
|
Form: () => Form,
|
|
44
45
|
FormField: () => FormField,
|
|
45
46
|
FormFieldCheckbox: () => FormFieldCheckbox,
|
|
@@ -163,39 +164,12 @@ yup.addMethod(yup.string, "cnpj", function () {
|
|
|
163
164
|
// src/yup/yup.ts
|
|
164
165
|
var yup2 = __toESM(require("yup"));
|
|
165
166
|
|
|
166
|
-
// src/Form.tsx
|
|
167
|
-
var import_ui2 = require("@ttoss/ui");
|
|
168
|
-
var import_react_hook_form = require("react-hook-form");
|
|
169
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
170
|
-
var Form = ({
|
|
171
|
-
children,
|
|
172
|
-
onSubmit,
|
|
173
|
-
sx,
|
|
174
|
-
...formMethods
|
|
175
|
-
}) => {
|
|
176
|
-
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_react_hook_form.FormProvider, {
|
|
177
|
-
...formMethods,
|
|
178
|
-
children: /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui2.Box, {
|
|
179
|
-
as: "form",
|
|
180
|
-
variant: "forms.form",
|
|
181
|
-
onSubmit: formMethods.handleSubmit(data => {
|
|
182
|
-
return onSubmit?.(data);
|
|
183
|
-
}),
|
|
184
|
-
sx,
|
|
185
|
-
children
|
|
186
|
-
})
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// src/FormField.tsx
|
|
191
|
-
var React = __toESM(require("react"));
|
|
192
|
-
|
|
193
167
|
// src/ErrorMessage.tsx
|
|
194
|
-
var
|
|
168
|
+
var import_react_hook_form = require("react-hook-form");
|
|
195
169
|
var import_react_i18n2 = require("@ttoss/react-i18n");
|
|
196
|
-
var
|
|
170
|
+
var import_ui2 = require("@ttoss/ui");
|
|
197
171
|
var import_error_message = require("@hookform/error-message");
|
|
198
|
-
var
|
|
172
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
199
173
|
var isMessageDescriptor = possibleMessageDescriptor => {
|
|
200
174
|
return possibleMessageDescriptor !== void 0 && possibleMessageDescriptor.defaultMessage !== void 0;
|
|
201
175
|
};
|
|
@@ -207,14 +181,14 @@ var ErrorMessage = ({
|
|
|
207
181
|
formState: {
|
|
208
182
|
errors
|
|
209
183
|
}
|
|
210
|
-
} = (0,
|
|
211
|
-
return /* @__PURE__ */(0,
|
|
184
|
+
} = (0, import_react_hook_form.useFormContext)();
|
|
185
|
+
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_error_message.ErrorMessage, {
|
|
212
186
|
name,
|
|
213
187
|
errors,
|
|
214
188
|
render: ({
|
|
215
189
|
message
|
|
216
190
|
}) => {
|
|
217
|
-
return /* @__PURE__ */(0,
|
|
191
|
+
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui2.HelpText, {
|
|
218
192
|
negative: true,
|
|
219
193
|
disabled,
|
|
220
194
|
children: (() => {
|
|
@@ -222,7 +196,7 @@ var ErrorMessage = ({
|
|
|
222
196
|
return message;
|
|
223
197
|
}
|
|
224
198
|
if (isMessageDescriptor(message)) {
|
|
225
|
-
return /* @__PURE__ */(0,
|
|
199
|
+
return /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_react_i18n2.FormattedMessage, {
|
|
226
200
|
...message
|
|
227
201
|
});
|
|
228
202
|
}
|
|
@@ -233,7 +207,32 @@ var ErrorMessage = ({
|
|
|
233
207
|
});
|
|
234
208
|
};
|
|
235
209
|
|
|
210
|
+
// src/Form.tsx
|
|
211
|
+
var import_ui3 = require("@ttoss/ui");
|
|
212
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
213
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
214
|
+
var Form = ({
|
|
215
|
+
children,
|
|
216
|
+
onSubmit,
|
|
217
|
+
sx,
|
|
218
|
+
...formMethods
|
|
219
|
+
}) => {
|
|
220
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_react_hook_form2.FormProvider, {
|
|
221
|
+
...formMethods,
|
|
222
|
+
children: /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_ui3.Box, {
|
|
223
|
+
as: "form",
|
|
224
|
+
variant: "forms.form",
|
|
225
|
+
onSubmit: formMethods.handleSubmit(data => {
|
|
226
|
+
return onSubmit?.(data);
|
|
227
|
+
}),
|
|
228
|
+
sx,
|
|
229
|
+
children
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
236
234
|
// src/FormField.tsx
|
|
235
|
+
var React = __toESM(require("react"));
|
|
237
236
|
var import_react_hook_form3 = require("react-hook-form");
|
|
238
237
|
var import_ui4 = require("@ttoss/ui");
|
|
239
238
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -673,6 +672,7 @@ var FormGroupWrapper = ({
|
|
|
673
672
|
title,
|
|
674
673
|
direction,
|
|
675
674
|
children,
|
|
675
|
+
name,
|
|
676
676
|
...boxProps
|
|
677
677
|
}) => {
|
|
678
678
|
const {
|
|
@@ -713,6 +713,8 @@ var FormGroupWrapper = ({
|
|
|
713
713
|
}), /* @__PURE__ */(0, import_jsx_runtime15.jsx)(import_ui13.Flex, {
|
|
714
714
|
sx: childrenContainerSx,
|
|
715
715
|
children
|
|
716
|
+
}), name && /* @__PURE__ */(0, import_jsx_runtime15.jsx)(ErrorMessage, {
|
|
717
|
+
name
|
|
716
718
|
})]
|
|
717
719
|
});
|
|
718
720
|
};
|
|
@@ -741,6 +743,7 @@ __reExport(src_exports, require("react-hook-form"), module.exports);
|
|
|
741
743
|
// Annotate the CommonJS export names for ESM import in node:
|
|
742
744
|
0 && (module.exports = {
|
|
743
745
|
Controller,
|
|
746
|
+
ErrorMessage,
|
|
744
747
|
Form,
|
|
745
748
|
FormField,
|
|
746
749
|
FormFieldCheckbox,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"author": "ttoss",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Pedro Arantes <pedro@arantespp.com> (https://arantespp.com/contact)"
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hookform/error-message": "^2.0.1",
|
|
37
37
|
"@hookform/resolvers": "^3.3.4",
|
|
38
|
-
"react-hook-form": "^7.51.
|
|
38
|
+
"react-hook-form": "^7.51.4",
|
|
39
39
|
"react-number-format": "^5.3.4",
|
|
40
40
|
"yup": "^1.4.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">=16.8.0",
|
|
44
|
-
"@ttoss/react-i18n": "^1.26.
|
|
45
|
-
"@ttoss/ui": "^4.1.
|
|
44
|
+
"@ttoss/react-i18n": "^1.26.7",
|
|
45
|
+
"@ttoss/ui": "^4.1.9"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/jest": "^29.5.12",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"theme-ui": "^0.16.2",
|
|
54
54
|
"tsup": "^8.0.2",
|
|
55
55
|
"yup": "^1.4.0",
|
|
56
|
-
"@ttoss/config": "^1.32.
|
|
57
|
-
"@ttoss/i18n-cli": "^0.7.
|
|
58
|
-
"@ttoss/react-
|
|
59
|
-
"@ttoss/test-utils": "^2.1.
|
|
60
|
-
"@ttoss/
|
|
61
|
-
"@ttoss/
|
|
56
|
+
"@ttoss/config": "^1.32.3",
|
|
57
|
+
"@ttoss/i18n-cli": "^0.7.11",
|
|
58
|
+
"@ttoss/react-icons": "^0.3.6",
|
|
59
|
+
"@ttoss/test-utils": "^2.1.6",
|
|
60
|
+
"@ttoss/ui": "^4.1.9",
|
|
61
|
+
"@ttoss/react-i18n": "^1.26.7"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public",
|
package/src/FormGroup.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Box, BoxProps, Flex, FlexProps, Text } from '@ttoss/ui';
|
|
3
|
+
import { ErrorMessage } from './ErrorMessage';
|
|
3
4
|
|
|
4
5
|
type FormGroupLevelsManagerContextType = {
|
|
5
6
|
levelsLength: number;
|
|
@@ -56,6 +57,7 @@ export const useFormGroup = () => {
|
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
type FormGroupProps = {
|
|
60
|
+
name?: string;
|
|
59
61
|
title?: string;
|
|
60
62
|
direction?: 'column' | 'row';
|
|
61
63
|
} & BoxProps;
|
|
@@ -64,6 +66,7 @@ const FormGroupWrapper = ({
|
|
|
64
66
|
title,
|
|
65
67
|
direction,
|
|
66
68
|
children,
|
|
69
|
+
name,
|
|
67
70
|
...boxProps
|
|
68
71
|
}: FormGroupProps) => {
|
|
69
72
|
const { level } = useFormGroup();
|
|
@@ -109,6 +112,7 @@ const FormGroupWrapper = ({
|
|
|
109
112
|
</Box>
|
|
110
113
|
)}
|
|
111
114
|
<Flex sx={childrenContainerSx}>{children}</Flex>
|
|
115
|
+
{name && <ErrorMessage name={name} />}
|
|
112
116
|
</Box>
|
|
113
117
|
);
|
|
114
118
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { yupResolver } from '@hookform/resolvers/yup';
|
|
2
2
|
export { yup } from './yup/yup';
|
|
3
3
|
|
|
4
|
+
export { ErrorMessage } from './ErrorMessage';
|
|
4
5
|
export { Form } from './Form';
|
|
5
6
|
export { FormField } from './FormField';
|
|
6
7
|
export { FormFieldCheckbox } from './FormFieldCheckbox';
|