@ttoss/forms 0.11.3 → 0.11.5

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 CHANGED
@@ -1,8 +1,5 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
 
3
- // tsup.inject.js
4
- import * as React from "react";
5
-
6
3
  // src/index.ts
7
4
  import { yupResolver } from "@hookform/resolvers/yup";
8
5
  export * from "react-hook-form";
@@ -18,9 +15,9 @@ var Form = ({
18
15
  sx,
19
16
  ...formMethods
20
17
  }) => {
21
- return /* @__PURE__ */ jsx(FormProvider, {
22
- ...formMethods,
23
- children: /* @__PURE__ */ jsx(Box, {
18
+ return /* @__PURE__ */ jsx(FormProvider, { ...formMethods, children: /* @__PURE__ */ jsx(
19
+ Box,
20
+ {
24
21
  as: "form",
25
22
  variant: "forms.form",
26
23
  onSubmit: formMethods.handleSubmit((data) => {
@@ -28,8 +25,8 @@ var Form = ({
28
25
  }),
29
26
  sx,
30
27
  children
31
- })
32
- });
28
+ }
29
+ ) });
33
30
  };
34
31
 
35
32
  // src/FormFieldCheckbox.tsx
@@ -46,14 +43,14 @@ var ErrorMessage = ({
46
43
  const {
47
44
  formState: { errors }
48
45
  } = useFormContext();
49
- return /* @__PURE__ */ jsx2(HookFormErrorMessage, {
50
- errors,
51
- name,
52
- as: /* @__PURE__ */ jsx2(Text, {
53
- variant: "text.error",
54
- role: "alert"
55
- })
56
- });
46
+ return /* @__PURE__ */ jsx2(
47
+ HookFormErrorMessage,
48
+ {
49
+ errors,
50
+ name,
51
+ as: /* @__PURE__ */ jsx2(Text, { variant: "text.error", role: "alert" })
52
+ }
53
+ );
57
54
  };
58
55
 
59
56
  // src/FormFieldCheckbox.tsx
@@ -71,31 +68,23 @@ var FormFieldCheckbox = ({
71
68
  defaultValue: false
72
69
  });
73
70
  const id = `form-field-checkbox-${name}`;
74
- return /* @__PURE__ */ jsxs(Box2, {
75
- children: [
76
- /* @__PURE__ */ jsxs(Flex, {
77
- sx: { alignItems: "center" },
78
- children: [
79
- /* @__PURE__ */ jsx3(Checkbox, {
80
- id,
81
- ref,
82
- disabled,
83
- checked: value,
84
- onChange,
85
- onBlur
86
- }),
87
- label && /* @__PURE__ */ jsx3(Label, {
88
- "aria-disabled": disabled,
89
- htmlFor: id,
90
- children: label
91
- })
92
- ]
93
- }),
94
- /* @__PURE__ */ jsx3(ErrorMessage, {
95
- name
96
- })
97
- ]
98
- });
71
+ return /* @__PURE__ */ jsxs(Box2, { children: [
72
+ /* @__PURE__ */ jsxs(Flex, { sx: { alignItems: "center" }, children: [
73
+ /* @__PURE__ */ jsx3(
74
+ Checkbox,
75
+ {
76
+ id,
77
+ ref,
78
+ disabled,
79
+ checked: value,
80
+ onChange,
81
+ onBlur
82
+ }
83
+ ),
84
+ label && /* @__PURE__ */ jsx3(Label, { "aria-disabled": disabled, htmlFor: id, children: label })
85
+ ] }),
86
+ /* @__PURE__ */ jsx3(ErrorMessage, { name })
87
+ ] });
99
88
  };
100
89
 
101
90
  // src/FormFieldInput.tsx
@@ -115,14 +104,11 @@ var FormFieldInput = ({
115
104
  defaultValue: ""
116
105
  });
117
106
  const id = `form-field-input-${name}`;
118
- return /* @__PURE__ */ jsxs2(Box3, {
119
- children: [
120
- label && /* @__PURE__ */ jsx4(Label2, {
121
- "aria-disabled": disabled,
122
- htmlFor: id,
123
- children: label
124
- }),
125
- /* @__PURE__ */ jsx4(Input, {
107
+ return /* @__PURE__ */ jsxs2(Box3, { children: [
108
+ label && /* @__PURE__ */ jsx4(Label2, { "aria-disabled": disabled, htmlFor: id, children: label }),
109
+ /* @__PURE__ */ jsx4(
110
+ Input,
111
+ {
126
112
  ref,
127
113
  onChange,
128
114
  onBlur,
@@ -131,12 +117,10 @@ var FormFieldInput = ({
131
117
  disabled,
132
118
  placeholder,
133
119
  id
134
- }),
135
- /* @__PURE__ */ jsx4(ErrorMessage, {
136
- name
137
- })
138
- ]
139
- });
120
+ }
121
+ ),
122
+ /* @__PURE__ */ jsx4(ErrorMessage, { name })
123
+ ] });
140
124
  };
141
125
 
142
126
  // src/FormFieldRadio.tsx
@@ -154,36 +138,28 @@ var FormFieldRadio = ({
154
138
  name,
155
139
  defaultValue: ""
156
140
  });
157
- return /* @__PURE__ */ jsxs3(Box4, {
158
- children: [
159
- label && /* @__PURE__ */ jsx5(Label3, {
160
- children: label
161
- }),
162
- /* @__PURE__ */ jsx5(Box4, {
163
- children: options.map((option) => {
164
- const id = `form-field-radio-${name}-${option.value}`;
165
- return /* @__PURE__ */ jsxs3(Label3, {
166
- htmlFor: id,
167
- children: [
168
- /* @__PURE__ */ jsx5(Radio, {
169
- ref,
170
- onChange,
171
- onBlur,
172
- value: option.value,
173
- defaultChecked: value === option.value,
174
- name,
175
- id
176
- }),
177
- option.label
178
- ]
179
- }, id);
180
- })
181
- }),
182
- /* @__PURE__ */ jsx5(ErrorMessage, {
183
- name
184
- })
185
- ]
186
- });
141
+ return /* @__PURE__ */ jsxs3(Box4, { children: [
142
+ label && /* @__PURE__ */ jsx5(Label3, { children: label }),
143
+ /* @__PURE__ */ jsx5(Box4, { children: options.map((option) => {
144
+ const id = `form-field-radio-${name}-${option.value}`;
145
+ return /* @__PURE__ */ jsxs3(Label3, { htmlFor: id, children: [
146
+ /* @__PURE__ */ jsx5(
147
+ Radio,
148
+ {
149
+ ref,
150
+ onChange,
151
+ onBlur,
152
+ value: option.value,
153
+ defaultChecked: value === option.value,
154
+ name,
155
+ id
156
+ }
157
+ ),
158
+ option.label
159
+ ] }, id);
160
+ }) }),
161
+ /* @__PURE__ */ jsx5(ErrorMessage, { name })
162
+ ] });
187
163
  };
188
164
 
189
165
  // src/FormFieldSelect.tsx
@@ -203,13 +179,11 @@ var FormFieldSelect = ({
203
179
  defaultValue: ""
204
180
  });
205
181
  const id = `form-field-select-${name}`;
206
- return /* @__PURE__ */ jsxs4(Box5, {
207
- children: [
208
- label && /* @__PURE__ */ jsx6(Label4, {
209
- htmlFor: id,
210
- children: label
211
- }),
212
- /* @__PURE__ */ jsx6(Select, {
182
+ return /* @__PURE__ */ jsxs4(Box5, { children: [
183
+ label && /* @__PURE__ */ jsx6(Label4, { htmlFor: id, children: label }),
184
+ /* @__PURE__ */ jsx6(
185
+ Select,
186
+ {
213
187
  ref,
214
188
  name,
215
189
  onChange,
@@ -218,17 +192,12 @@ var FormFieldSelect = ({
218
192
  arrow,
219
193
  id,
220
194
  children: options.map((option) => {
221
- return /* @__PURE__ */ jsx6("option", {
222
- value: option.value,
223
- children: option.label
224
- }, option.label);
195
+ return /* @__PURE__ */ jsx6("option", { value: option.value, children: option.label }, option.label);
225
196
  })
226
- }),
227
- /* @__PURE__ */ jsx6(ErrorMessage, {
228
- name
229
- })
230
- ]
231
- });
197
+ }
198
+ ),
199
+ /* @__PURE__ */ jsx6(ErrorMessage, { name })
200
+ ] });
232
201
  };
233
202
 
234
203
  // src/FormField.tsx
package/dist/index.d.ts CHANGED
@@ -65,7 +65,7 @@ declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues>({
65
65
  placeholder?: string | undefined;
66
66
  }) => JSX.Element;
67
67
 
68
- declare type FormRadioOption$1 = {
68
+ type FormRadioOption$1 = {
69
69
  value: string | number;
70
70
  label: string;
71
71
  };
@@ -75,7 +75,7 @@ declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({
75
75
  options: FormRadioOption$1[];
76
76
  }) => JSX.Element;
77
77
 
78
- declare type FormRadioOption = {
78
+ type FormRadioOption = {
79
79
  value: string | number;
80
80
  label: string;
81
81
  };
package/dist/index.js CHANGED
@@ -38,11 +38,6 @@ __export(src_exports, {
38
38
  yupResolver: () => import_yup.yupResolver
39
39
  });
40
40
  module.exports = __toCommonJS(src_exports);
41
-
42
- // tsup.inject.js
43
- var React = __toESM(require("react"));
44
-
45
- // src/index.ts
46
41
  var import_yup = require("@hookform/resolvers/yup");
47
42
  __reExport(src_exports, require("react-hook-form"), module.exports);
48
43
  var yup = __toESM(require("yup"));
@@ -57,9 +52,9 @@ var Form = ({
57
52
  sx,
58
53
  ...formMethods
59
54
  }) => {
60
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_hook_form.FormProvider, {
61
- ...formMethods,
62
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Box, {
55
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_hook_form.FormProvider, { ...formMethods, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ import_ui.Box,
57
+ {
63
58
  as: "form",
64
59
  variant: "forms.form",
65
60
  onSubmit: formMethods.handleSubmit((data) => {
@@ -67,8 +62,8 @@ var Form = ({
67
62
  }),
68
63
  sx,
69
64
  children
70
- })
71
- });
65
+ }
66
+ ) });
72
67
  };
73
68
 
74
69
  // src/FormFieldCheckbox.tsx
@@ -85,14 +80,14 @@ var ErrorMessage = ({
85
80
  const {
86
81
  formState: { errors }
87
82
  } = (0, import_react_hook_form2.useFormContext)();
88
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_error_message.ErrorMessage, {
89
- errors,
90
- name,
91
- as: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Text, {
92
- variant: "text.error",
93
- role: "alert"
94
- })
95
- });
83
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
84
+ import_error_message.ErrorMessage,
85
+ {
86
+ errors,
87
+ name,
88
+ as: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Text, { variant: "text.error", role: "alert" })
89
+ }
90
+ );
96
91
  };
97
92
 
98
93
  // src/FormFieldCheckbox.tsx
@@ -110,31 +105,23 @@ var FormFieldCheckbox = ({
110
105
  defaultValue: false
111
106
  });
112
107
  const id = `form-field-checkbox-${name}`;
113
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Box, {
114
- children: [
115
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Flex, {
116
- sx: { alignItems: "center" },
117
- children: [
118
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Checkbox, {
119
- id,
120
- ref,
121
- disabled,
122
- checked: value,
123
- onChange,
124
- onBlur
125
- }),
126
- label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, {
127
- "aria-disabled": disabled,
128
- htmlFor: id,
129
- children: label
130
- })
131
- ]
132
- }),
133
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorMessage, {
134
- name
135
- })
136
- ]
137
- });
108
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Box, { children: [
109
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Flex, { sx: { alignItems: "center" }, children: [
110
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
111
+ import_ui3.Checkbox,
112
+ {
113
+ id,
114
+ ref,
115
+ disabled,
116
+ checked: value,
117
+ onChange,
118
+ onBlur
119
+ }
120
+ ),
121
+ label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, { "aria-disabled": disabled, htmlFor: id, children: label })
122
+ ] }),
123
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorMessage, { name })
124
+ ] });
138
125
  };
139
126
 
140
127
  // src/FormFieldInput.tsx
@@ -154,14 +141,11 @@ var FormFieldInput = ({
154
141
  defaultValue: ""
155
142
  });
156
143
  const id = `form-field-input-${name}`;
157
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ui4.Box, {
158
- children: [
159
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ui4.Label, {
160
- "aria-disabled": disabled,
161
- htmlFor: id,
162
- children: label
163
- }),
164
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ui4.Input, {
144
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_ui4.Box, { children: [
145
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ui4.Label, { "aria-disabled": disabled, htmlFor: id, children: label }),
146
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
147
+ import_ui4.Input,
148
+ {
165
149
  ref,
166
150
  onChange,
167
151
  onBlur,
@@ -170,12 +154,10 @@ var FormFieldInput = ({
170
154
  disabled,
171
155
  placeholder,
172
156
  id
173
- }),
174
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorMessage, {
175
- name
176
- })
177
- ]
178
- });
157
+ }
158
+ ),
159
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorMessage, { name })
160
+ ] });
179
161
  };
180
162
 
181
163
  // src/FormFieldRadio.tsx
@@ -193,36 +175,28 @@ var FormFieldRadio = ({
193
175
  name,
194
176
  defaultValue: ""
195
177
  });
196
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.Box, {
197
- children: [
198
- label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Label, {
199
- children: label
200
- }),
201
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Box, {
202
- children: options.map((option) => {
203
- const id = `form-field-radio-${name}-${option.value}`;
204
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.Label, {
205
- htmlFor: id,
206
- children: [
207
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Radio, {
208
- ref,
209
- onChange,
210
- onBlur,
211
- value: option.value,
212
- defaultChecked: value === option.value,
213
- name,
214
- id
215
- }),
216
- option.label
217
- ]
218
- }, id);
219
- })
220
- }),
221
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorMessage, {
222
- name
223
- })
224
- ]
225
- });
178
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.Box, { children: [
179
+ label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Label, { children: label }),
180
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Box, { children: options.map((option) => {
181
+ const id = `form-field-radio-${name}-${option.value}`;
182
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.Label, { htmlFor: id, children: [
183
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
184
+ import_ui5.Radio,
185
+ {
186
+ ref,
187
+ onChange,
188
+ onBlur,
189
+ value: option.value,
190
+ defaultChecked: value === option.value,
191
+ name,
192
+ id
193
+ }
194
+ ),
195
+ option.label
196
+ ] }, id);
197
+ }) }),
198
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorMessage, { name })
199
+ ] });
226
200
  };
227
201
 
228
202
  // src/FormFieldSelect.tsx
@@ -242,13 +216,11 @@ var FormFieldSelect = ({
242
216
  defaultValue: ""
243
217
  });
244
218
  const id = `form-field-select-${name}`;
245
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Box, {
246
- children: [
247
- label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Label, {
248
- htmlFor: id,
249
- children: label
250
- }),
251
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Select, {
219
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Box, { children: [
220
+ label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Label, { htmlFor: id, children: label }),
221
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
222
+ import_ui6.Select,
223
+ {
252
224
  ref,
253
225
  name,
254
226
  onChange,
@@ -257,17 +229,12 @@ var FormFieldSelect = ({
257
229
  arrow,
258
230
  id,
259
231
  children: options.map((option) => {
260
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", {
261
- value: option.value,
262
- children: option.label
263
- }, option.label);
232
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: option.value, children: option.label }, option.label);
264
233
  })
265
- }),
266
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorMessage, {
267
- name
268
- })
269
- ]
270
- });
234
+ }
235
+ ),
236
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorMessage, { name })
237
+ ] });
271
238
  };
272
239
 
273
240
  // src/FormField.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "license": "UNLICENSED",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -16,6 +16,7 @@
16
16
  "build": "tsup",
17
17
  "test": "jest"
18
18
  },
19
+ "sideEffects": false,
19
20
  "typings": "dist/index.d.ts",
20
21
  "dependencies": {
21
22
  "@hookform/error-message": "^2.0.1",
@@ -30,7 +31,7 @@
30
31
  "devDependencies": {
31
32
  "@ttoss/config": "^1.25.0",
32
33
  "@ttoss/test-utils": "^1.18.3",
33
- "@ttoss/ui": "^1.26.3",
34
+ "@ttoss/ui": "^1.27.1",
34
35
  "@types/jest": "^29.2.4",
35
36
  "jest": "^29.3.1",
36
37
  "react": "^18.2.0",
@@ -40,5 +41,5 @@
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
- "gitHead": "88b98945c469cdfdece6b12ce41243403ad2c242"
44
+ "gitHead": "055a9b2d3f53f0d8f3bbaea24ac9e51f99d0ca57"
44
45
  }