@ttoss/forms 0.15.8 → 0.15.9
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 +46 -14
- package/dist/index.d.ts +8 -7
- package/dist/index.js +40 -8
- package/package.json +2 -2
- package/src/FormField.tsx +5 -3
- package/src/FormFieldCheckbox.tsx +4 -3
- package/src/FormFieldInput.tsx +10 -3
- package/src/FormFieldRadio.tsx +4 -3
- package/src/FormFieldSelect.tsx +4 -3
- package/src/FormFieldTextarea.tsx +2 -0
package/dist/esm/index.js
CHANGED
|
@@ -31,7 +31,6 @@ var Form = ({
|
|
|
31
31
|
|
|
32
32
|
// src/FormField.tsx
|
|
33
33
|
import * as React2 from "react";
|
|
34
|
-
import { Box as Box2, Label } from "@ttoss/ui";
|
|
35
34
|
|
|
36
35
|
// src/ErrorMessage.tsx
|
|
37
36
|
import { useFormContext } from "react-hook-form";
|
|
@@ -59,12 +58,14 @@ var ErrorMessage = ({
|
|
|
59
58
|
|
|
60
59
|
// src/FormField.tsx
|
|
61
60
|
import { useController } from "react-hook-form";
|
|
61
|
+
import { Flex, Label } from "@ttoss/ui";
|
|
62
62
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
63
63
|
var FormField = ({
|
|
64
64
|
label,
|
|
65
65
|
id: idProp,
|
|
66
66
|
name,
|
|
67
67
|
defaultValue,
|
|
68
|
+
sx,
|
|
68
69
|
render
|
|
69
70
|
}) => {
|
|
70
71
|
const controllerReturn = useController({
|
|
@@ -80,7 +81,12 @@ var FormField = ({
|
|
|
80
81
|
});
|
|
81
82
|
});
|
|
82
83
|
}, [controllerReturn, id, render]);
|
|
83
|
-
return /* @__PURE__ */jsxs(
|
|
84
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
85
|
+
sx: {
|
|
86
|
+
flexDirection: "column",
|
|
87
|
+
width: "100%",
|
|
88
|
+
...sx
|
|
89
|
+
},
|
|
84
90
|
children: [label && /* @__PURE__ */jsx3(Label, {
|
|
85
91
|
htmlFor: id,
|
|
86
92
|
children: label
|
|
@@ -91,12 +97,13 @@ var FormField = ({
|
|
|
91
97
|
};
|
|
92
98
|
|
|
93
99
|
// src/FormFieldCheckbox.tsx
|
|
94
|
-
import {
|
|
100
|
+
import { Checkbox, Flex as Flex2, Label as Label2 } from "@ttoss/ui";
|
|
95
101
|
import { useController as useController2 } from "react-hook-form";
|
|
96
102
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
97
103
|
var FormFieldCheckbox = ({
|
|
98
104
|
label,
|
|
99
105
|
name,
|
|
106
|
+
sx,
|
|
100
107
|
...checkboxProps
|
|
101
108
|
}) => {
|
|
102
109
|
const {
|
|
@@ -115,8 +122,13 @@ var FormFieldCheckbox = ({
|
|
|
115
122
|
});
|
|
116
123
|
const id = `form-field-checkbox-${name}`;
|
|
117
124
|
const error = !!errors[name]?.message;
|
|
118
|
-
return /* @__PURE__ */jsxs2(
|
|
119
|
-
|
|
125
|
+
return /* @__PURE__ */jsxs2(Flex2, {
|
|
126
|
+
sx: {
|
|
127
|
+
flexDirection: "column",
|
|
128
|
+
width: "100%",
|
|
129
|
+
...sx
|
|
130
|
+
},
|
|
131
|
+
children: [/* @__PURE__ */jsx4(Flex2, {
|
|
120
132
|
sx: {
|
|
121
133
|
alignItems: "center"
|
|
122
134
|
},
|
|
@@ -141,14 +153,15 @@ var FormFieldCheckbox = ({
|
|
|
141
153
|
};
|
|
142
154
|
|
|
143
155
|
// src/FormFieldInput.tsx
|
|
144
|
-
import { Box as Box4, Input, Label as Label3 } from "@ttoss/ui";
|
|
145
156
|
import { useController as useController3 } from "react-hook-form";
|
|
157
|
+
import { Flex as Flex3, Input, Label as Label3 } from "@ttoss/ui";
|
|
146
158
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
147
159
|
var FormFieldInput = ({
|
|
148
160
|
label,
|
|
149
161
|
name,
|
|
150
162
|
tooltip,
|
|
151
163
|
onTooltipClick,
|
|
164
|
+
sx,
|
|
152
165
|
...inputProps
|
|
153
166
|
}) => {
|
|
154
167
|
const {
|
|
@@ -167,7 +180,12 @@ var FormFieldInput = ({
|
|
|
167
180
|
});
|
|
168
181
|
const id = `form-field-input-${name}`;
|
|
169
182
|
const hasError = !!errors[name]?.message;
|
|
170
|
-
return /* @__PURE__ */jsxs3(
|
|
183
|
+
return /* @__PURE__ */jsxs3(Flex3, {
|
|
184
|
+
sx: {
|
|
185
|
+
flexDirection: "column",
|
|
186
|
+
width: "100%",
|
|
187
|
+
...sx
|
|
188
|
+
},
|
|
171
189
|
children: [label && /* @__PURE__ */jsx5(Label3, {
|
|
172
190
|
"aria-disabled": inputProps.disabled,
|
|
173
191
|
htmlFor: id,
|
|
@@ -190,13 +208,14 @@ var FormFieldInput = ({
|
|
|
190
208
|
};
|
|
191
209
|
|
|
192
210
|
// src/FormFieldRadio.tsx
|
|
193
|
-
import { Box as
|
|
211
|
+
import { Box as Box2, Flex as Flex4, Label as Label4, Radio } from "@ttoss/ui";
|
|
194
212
|
import { useController as useController4 } from "react-hook-form";
|
|
195
213
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
196
214
|
var FormFieldRadio = ({
|
|
197
215
|
label,
|
|
198
216
|
name,
|
|
199
217
|
options,
|
|
218
|
+
sx,
|
|
200
219
|
...radioProps
|
|
201
220
|
}) => {
|
|
202
221
|
const {
|
|
@@ -210,10 +229,15 @@ var FormFieldRadio = ({
|
|
|
210
229
|
name,
|
|
211
230
|
defaultValue: ""
|
|
212
231
|
});
|
|
213
|
-
return /* @__PURE__ */jsxs4(
|
|
232
|
+
return /* @__PURE__ */jsxs4(Flex4, {
|
|
233
|
+
sx: {
|
|
234
|
+
flexDirection: "column",
|
|
235
|
+
width: "100%",
|
|
236
|
+
...sx
|
|
237
|
+
},
|
|
214
238
|
children: [label && /* @__PURE__ */jsx6(Label4, {
|
|
215
239
|
children: label
|
|
216
|
-
}), /* @__PURE__ */jsx6(
|
|
240
|
+
}), /* @__PURE__ */jsx6(Box2, {
|
|
217
241
|
children: options.map(option => {
|
|
218
242
|
const id = `form-field-radio-${name}-${option.value}`;
|
|
219
243
|
return /* @__PURE__ */jsxs4(Label4, {
|
|
@@ -237,13 +261,14 @@ var FormFieldRadio = ({
|
|
|
237
261
|
};
|
|
238
262
|
|
|
239
263
|
// src/FormFieldSelect.tsx
|
|
240
|
-
import { Box as Box6, Label as Label5, Select } from "@ttoss/ui";
|
|
241
264
|
import { useController as useController5 } from "react-hook-form";
|
|
265
|
+
import { Flex as Flex5, Label as Label5, Select } from "@ttoss/ui";
|
|
242
266
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
243
267
|
var FormFieldSelect = ({
|
|
244
268
|
label,
|
|
245
269
|
name,
|
|
246
270
|
options,
|
|
271
|
+
sx,
|
|
247
272
|
...selectProps
|
|
248
273
|
}) => {
|
|
249
274
|
const {
|
|
@@ -258,7 +283,12 @@ var FormFieldSelect = ({
|
|
|
258
283
|
defaultValue: ""
|
|
259
284
|
});
|
|
260
285
|
const id = `form-field-select-${name}`;
|
|
261
|
-
return /* @__PURE__ */jsxs5(
|
|
286
|
+
return /* @__PURE__ */jsxs5(Flex5, {
|
|
287
|
+
sx: {
|
|
288
|
+
flexDirection: "column",
|
|
289
|
+
width: "100%",
|
|
290
|
+
...sx
|
|
291
|
+
},
|
|
262
292
|
children: [label && /* @__PURE__ */jsx7(Label5, {
|
|
263
293
|
htmlFor: id,
|
|
264
294
|
children: label
|
|
@@ -288,6 +318,7 @@ import { jsx as jsx8 } from "react/jsx-runtime";
|
|
|
288
318
|
var FormFieldTextarea = ({
|
|
289
319
|
label,
|
|
290
320
|
name,
|
|
321
|
+
sx,
|
|
291
322
|
...textareaProps
|
|
292
323
|
}) => {
|
|
293
324
|
const id = `form-field-textarea-${name}`;
|
|
@@ -295,6 +326,7 @@ var FormFieldTextarea = ({
|
|
|
295
326
|
label,
|
|
296
327
|
name,
|
|
297
328
|
id,
|
|
329
|
+
sx,
|
|
298
330
|
render: ({
|
|
299
331
|
field
|
|
300
332
|
}) => {
|
|
@@ -307,7 +339,7 @@ var FormFieldTextarea = ({
|
|
|
307
339
|
};
|
|
308
340
|
|
|
309
341
|
// src/FormGroup.tsx
|
|
310
|
-
import { Flex as
|
|
342
|
+
import { Flex as Flex6 } from "@ttoss/ui";
|
|
311
343
|
import React3 from "react";
|
|
312
344
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
313
345
|
var FormGroupLevelsManagerContext = /*#__PURE__*/React3.createContext({
|
|
@@ -366,7 +398,7 @@ var FormGroupWrapper = props => {
|
|
|
366
398
|
paddingX: level ? "md" : "none",
|
|
367
399
|
...props.sx
|
|
368
400
|
};
|
|
369
|
-
return /* @__PURE__ */jsx9(
|
|
401
|
+
return /* @__PURE__ */jsx9(Flex6, {
|
|
370
402
|
"aria-level": level,
|
|
371
403
|
...props,
|
|
372
404
|
sx,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from 'react-hook-form';
|
|
|
5
5
|
import * as yup from 'yup';
|
|
6
6
|
export { yup };
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import { BoxProps, CheckboxProps, InputProps, LabelProps, RadioProps, SelectProps, TextareaProps
|
|
8
|
+
import { BoxProps, FlexProps, CheckboxProps, InputProps, LabelProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
9
9
|
|
|
10
10
|
declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
|
|
11
11
|
children?: React.ReactNode;
|
|
@@ -15,20 +15,21 @@ declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children,
|
|
|
15
15
|
children: React.ReactNode | React.ReactNode[];
|
|
16
16
|
} & react_hook_form.UseFormReturn<TFieldValues, any>) => JSX.Element;
|
|
17
17
|
|
|
18
|
-
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, id: idProp, name, defaultValue, render, }: {
|
|
18
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, id: idProp, name, defaultValue, sx, render, }: {
|
|
19
19
|
label?: string | undefined;
|
|
20
20
|
id?: string | undefined;
|
|
21
21
|
name: TName;
|
|
22
22
|
defaultValue?: FieldPathValue<TFieldValues, TName> | undefined;
|
|
23
|
+
sx?: FlexProps['sx'];
|
|
23
24
|
render: (props: UseControllerReturn<TFieldValues, TName>) => React.ReactElement;
|
|
24
25
|
}) => JSX.Element;
|
|
25
26
|
|
|
26
|
-
declare const FormFieldCheckbox: <TFieldValues extends FieldValues = FieldValues>({ label, name, ...checkboxProps }: {
|
|
27
|
+
declare const FormFieldCheckbox: <TFieldValues extends FieldValues = FieldValues>({ label, name, sx, ...checkboxProps }: {
|
|
27
28
|
label?: string | undefined;
|
|
28
29
|
name: FieldPath<TFieldValues>;
|
|
29
30
|
} & CheckboxProps) => JSX.Element;
|
|
30
31
|
|
|
31
|
-
declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, tooltip, onTooltipClick, ...inputProps }: {
|
|
32
|
+
declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, tooltip, onTooltipClick, sx, ...inputProps }: {
|
|
32
33
|
label?: string | undefined;
|
|
33
34
|
name: TName;
|
|
34
35
|
} & InputProps & Pick<LabelProps, "tooltip" | "onTooltipClick">) => JSX.Element;
|
|
@@ -37,7 +38,7 @@ type FormRadioOption$1 = {
|
|
|
37
38
|
value: string | number;
|
|
38
39
|
label: string;
|
|
39
40
|
};
|
|
40
|
-
declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, ...radioProps }: {
|
|
41
|
+
declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, sx, ...radioProps }: {
|
|
41
42
|
label?: string | undefined;
|
|
42
43
|
name: FieldPath<TFieldValues>;
|
|
43
44
|
options: FormRadioOption$1[];
|
|
@@ -47,13 +48,13 @@ type FormRadioOption = {
|
|
|
47
48
|
value: string | number;
|
|
48
49
|
label: string;
|
|
49
50
|
};
|
|
50
|
-
declare const FormFieldSelect: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, ...selectProps }: {
|
|
51
|
+
declare const FormFieldSelect: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, sx, ...selectProps }: {
|
|
51
52
|
label?: string | undefined;
|
|
52
53
|
name: FieldPath<TFieldValues>;
|
|
53
54
|
options: FormRadioOption[];
|
|
54
55
|
} & SelectProps) => JSX.Element;
|
|
55
56
|
|
|
56
|
-
declare const FormFieldTextarea: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, ...textareaProps }: {
|
|
57
|
+
declare const FormFieldTextarea: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, sx, ...textareaProps }: {
|
|
57
58
|
label?: string | undefined;
|
|
58
59
|
name: TName;
|
|
59
60
|
} & TextareaProps) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,6 @@ var Form = ({
|
|
|
82
82
|
|
|
83
83
|
// src/FormField.tsx
|
|
84
84
|
var React2 = __toESM(require("react"));
|
|
85
|
-
var import_ui3 = require("@ttoss/ui");
|
|
86
85
|
|
|
87
86
|
// src/ErrorMessage.tsx
|
|
88
87
|
var import_react_hook_form2 = require("react-hook-form");
|
|
@@ -110,12 +109,14 @@ var ErrorMessage = ({
|
|
|
110
109
|
|
|
111
110
|
// src/FormField.tsx
|
|
112
111
|
var import_react_hook_form3 = require("react-hook-form");
|
|
112
|
+
var import_ui3 = require("@ttoss/ui");
|
|
113
113
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
114
114
|
var FormField = ({
|
|
115
115
|
label,
|
|
116
116
|
id: idProp,
|
|
117
117
|
name,
|
|
118
118
|
defaultValue,
|
|
119
|
+
sx,
|
|
119
120
|
render
|
|
120
121
|
}) => {
|
|
121
122
|
const controllerReturn = (0, import_react_hook_form3.useController)({
|
|
@@ -131,7 +132,12 @@ var FormField = ({
|
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
134
|
}, [controllerReturn, id, render]);
|
|
134
|
-
return /* @__PURE__ */(0, import_jsx_runtime3.jsxs)(import_ui3.
|
|
135
|
+
return /* @__PURE__ */(0, import_jsx_runtime3.jsxs)(import_ui3.Flex, {
|
|
136
|
+
sx: {
|
|
137
|
+
flexDirection: "column",
|
|
138
|
+
width: "100%",
|
|
139
|
+
...sx
|
|
140
|
+
},
|
|
135
141
|
children: [label && /* @__PURE__ */(0, import_jsx_runtime3.jsx)(import_ui3.Label, {
|
|
136
142
|
htmlFor: id,
|
|
137
143
|
children: label
|
|
@@ -148,6 +154,7 @@ var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
|
148
154
|
var FormFieldCheckbox = ({
|
|
149
155
|
label,
|
|
150
156
|
name,
|
|
157
|
+
sx,
|
|
151
158
|
...checkboxProps
|
|
152
159
|
}) => {
|
|
153
160
|
const {
|
|
@@ -166,7 +173,12 @@ var FormFieldCheckbox = ({
|
|
|
166
173
|
});
|
|
167
174
|
const id = `form-field-checkbox-${name}`;
|
|
168
175
|
const error = !!errors[name]?.message;
|
|
169
|
-
return /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(import_ui4.
|
|
176
|
+
return /* @__PURE__ */(0, import_jsx_runtime4.jsxs)(import_ui4.Flex, {
|
|
177
|
+
sx: {
|
|
178
|
+
flexDirection: "column",
|
|
179
|
+
width: "100%",
|
|
180
|
+
...sx
|
|
181
|
+
},
|
|
170
182
|
children: [/* @__PURE__ */(0, import_jsx_runtime4.jsx)(import_ui4.Flex, {
|
|
171
183
|
sx: {
|
|
172
184
|
alignItems: "center"
|
|
@@ -192,14 +204,15 @@ var FormFieldCheckbox = ({
|
|
|
192
204
|
};
|
|
193
205
|
|
|
194
206
|
// src/FormFieldInput.tsx
|
|
195
|
-
var import_ui5 = require("@ttoss/ui");
|
|
196
207
|
var import_react_hook_form5 = require("react-hook-form");
|
|
208
|
+
var import_ui5 = require("@ttoss/ui");
|
|
197
209
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
198
210
|
var FormFieldInput = ({
|
|
199
211
|
label,
|
|
200
212
|
name,
|
|
201
213
|
tooltip,
|
|
202
214
|
onTooltipClick,
|
|
215
|
+
sx,
|
|
203
216
|
...inputProps
|
|
204
217
|
}) => {
|
|
205
218
|
const {
|
|
@@ -218,7 +231,12 @@ var FormFieldInput = ({
|
|
|
218
231
|
});
|
|
219
232
|
const id = `form-field-input-${name}`;
|
|
220
233
|
const hasError = !!errors[name]?.message;
|
|
221
|
-
return /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(import_ui5.
|
|
234
|
+
return /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(import_ui5.Flex, {
|
|
235
|
+
sx: {
|
|
236
|
+
flexDirection: "column",
|
|
237
|
+
width: "100%",
|
|
238
|
+
...sx
|
|
239
|
+
},
|
|
222
240
|
children: [label && /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui5.Label, {
|
|
223
241
|
"aria-disabled": inputProps.disabled,
|
|
224
242
|
htmlFor: id,
|
|
@@ -248,6 +266,7 @@ var FormFieldRadio = ({
|
|
|
248
266
|
label,
|
|
249
267
|
name,
|
|
250
268
|
options,
|
|
269
|
+
sx,
|
|
251
270
|
...radioProps
|
|
252
271
|
}) => {
|
|
253
272
|
const {
|
|
@@ -261,7 +280,12 @@ var FormFieldRadio = ({
|
|
|
261
280
|
name,
|
|
262
281
|
defaultValue: ""
|
|
263
282
|
});
|
|
264
|
-
return /* @__PURE__ */(0, import_jsx_runtime6.jsxs)(import_ui6.
|
|
283
|
+
return /* @__PURE__ */(0, import_jsx_runtime6.jsxs)(import_ui6.Flex, {
|
|
284
|
+
sx: {
|
|
285
|
+
flexDirection: "column",
|
|
286
|
+
width: "100%",
|
|
287
|
+
...sx
|
|
288
|
+
},
|
|
265
289
|
children: [label && /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui6.Label, {
|
|
266
290
|
children: label
|
|
267
291
|
}), /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui6.Box, {
|
|
@@ -288,13 +312,14 @@ var FormFieldRadio = ({
|
|
|
288
312
|
};
|
|
289
313
|
|
|
290
314
|
// src/FormFieldSelect.tsx
|
|
291
|
-
var import_ui7 = require("@ttoss/ui");
|
|
292
315
|
var import_react_hook_form7 = require("react-hook-form");
|
|
316
|
+
var import_ui7 = require("@ttoss/ui");
|
|
293
317
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
294
318
|
var FormFieldSelect = ({
|
|
295
319
|
label,
|
|
296
320
|
name,
|
|
297
321
|
options,
|
|
322
|
+
sx,
|
|
298
323
|
...selectProps
|
|
299
324
|
}) => {
|
|
300
325
|
const {
|
|
@@ -309,7 +334,12 @@ var FormFieldSelect = ({
|
|
|
309
334
|
defaultValue: ""
|
|
310
335
|
});
|
|
311
336
|
const id = `form-field-select-${name}`;
|
|
312
|
-
return /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_ui7.
|
|
337
|
+
return /* @__PURE__ */(0, import_jsx_runtime7.jsxs)(import_ui7.Flex, {
|
|
338
|
+
sx: {
|
|
339
|
+
flexDirection: "column",
|
|
340
|
+
width: "100%",
|
|
341
|
+
...sx
|
|
342
|
+
},
|
|
313
343
|
children: [label && /* @__PURE__ */(0, import_jsx_runtime7.jsx)(import_ui7.Label, {
|
|
314
344
|
htmlFor: id,
|
|
315
345
|
children: label
|
|
@@ -339,6 +369,7 @@ var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
|
339
369
|
var FormFieldTextarea = ({
|
|
340
370
|
label,
|
|
341
371
|
name,
|
|
372
|
+
sx,
|
|
342
373
|
...textareaProps
|
|
343
374
|
}) => {
|
|
344
375
|
const id = `form-field-textarea-${name}`;
|
|
@@ -346,6 +377,7 @@ var FormFieldTextarea = ({
|
|
|
346
377
|
label,
|
|
347
378
|
name,
|
|
348
379
|
id,
|
|
380
|
+
sx,
|
|
349
381
|
render: ({
|
|
350
382
|
field
|
|
351
383
|
}) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.9",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "7eb5868534a149425c37f2b977a35cd01860eeff"
|
|
48
48
|
}
|
package/src/FormField.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Box, Label } from '@ttoss/ui';
|
|
3
2
|
import { ErrorMessage } from './ErrorMessage';
|
|
4
3
|
import {
|
|
5
4
|
FieldPath,
|
|
@@ -8,6 +7,7 @@ import {
|
|
|
8
7
|
UseControllerReturn,
|
|
9
8
|
useController,
|
|
10
9
|
} from 'react-hook-form';
|
|
10
|
+
import { Flex, type FlexProps, Label } from '@ttoss/ui';
|
|
11
11
|
|
|
12
12
|
export const FormField = <
|
|
13
13
|
TFieldValues extends FieldValues = FieldValues,
|
|
@@ -17,12 +17,14 @@ export const FormField = <
|
|
|
17
17
|
id: idProp,
|
|
18
18
|
name,
|
|
19
19
|
defaultValue,
|
|
20
|
+
sx,
|
|
20
21
|
render,
|
|
21
22
|
}: {
|
|
22
23
|
label?: string;
|
|
23
24
|
id?: string;
|
|
24
25
|
name: TName;
|
|
25
26
|
defaultValue?: FieldPathValue<TFieldValues, TName>;
|
|
27
|
+
sx?: FlexProps['sx'];
|
|
26
28
|
render: (
|
|
27
29
|
props: UseControllerReturn<TFieldValues, TName>
|
|
28
30
|
) => React.ReactElement;
|
|
@@ -41,10 +43,10 @@ export const FormField = <
|
|
|
41
43
|
}, [controllerReturn, id, render]);
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
|
-
<
|
|
46
|
+
<Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
|
|
45
47
|
{label && <Label htmlFor={id}>{label}</Label>}
|
|
46
48
|
{memoizedRender}
|
|
47
49
|
<ErrorMessage name={name} />
|
|
48
|
-
</
|
|
50
|
+
</Flex>
|
|
49
51
|
);
|
|
50
52
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Checkbox, type CheckboxProps, Flex, Label } from '@ttoss/ui';
|
|
2
2
|
import { ErrorMessage } from './ErrorMessage';
|
|
3
3
|
import { FieldPath, FieldValues, useController } from 'react-hook-form';
|
|
4
4
|
|
|
@@ -7,6 +7,7 @@ export const FormFieldCheckbox = <
|
|
|
7
7
|
>({
|
|
8
8
|
label,
|
|
9
9
|
name,
|
|
10
|
+
sx,
|
|
10
11
|
...checkboxProps
|
|
11
12
|
}: {
|
|
12
13
|
label?: string;
|
|
@@ -25,7 +26,7 @@ export const FormFieldCheckbox = <
|
|
|
25
26
|
const error = !!errors[name]?.message;
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
+
<Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
|
|
29
30
|
<Flex sx={{ alignItems: 'center' }}>
|
|
30
31
|
<Label aria-disabled={checkboxProps.disabled} htmlFor={id}>
|
|
31
32
|
<Checkbox
|
|
@@ -42,6 +43,6 @@ export const FormFieldCheckbox = <
|
|
|
42
43
|
</Label>
|
|
43
44
|
</Flex>
|
|
44
45
|
<ErrorMessage name={name} />
|
|
45
|
-
</
|
|
46
|
+
</Flex>
|
|
46
47
|
);
|
|
47
48
|
};
|
package/src/FormFieldInput.tsx
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { Box, Input, type InputProps, Label, type LabelProps } from '@ttoss/ui';
|
|
2
1
|
import { ErrorMessage } from './ErrorMessage';
|
|
3
2
|
import { FieldPath, FieldValues, useController } from 'react-hook-form';
|
|
3
|
+
import {
|
|
4
|
+
Flex,
|
|
5
|
+
Input,
|
|
6
|
+
type InputProps,
|
|
7
|
+
Label,
|
|
8
|
+
type LabelProps,
|
|
9
|
+
} from '@ttoss/ui';
|
|
4
10
|
|
|
5
11
|
export const FormFieldInput = <
|
|
6
12
|
TFieldValues extends FieldValues = FieldValues,
|
|
@@ -10,6 +16,7 @@ export const FormFieldInput = <
|
|
|
10
16
|
name,
|
|
11
17
|
tooltip,
|
|
12
18
|
onTooltipClick,
|
|
19
|
+
sx,
|
|
13
20
|
...inputProps
|
|
14
21
|
}: {
|
|
15
22
|
label?: string;
|
|
@@ -29,7 +36,7 @@ export const FormFieldInput = <
|
|
|
29
36
|
const hasError = !!errors[name]?.message;
|
|
30
37
|
|
|
31
38
|
return (
|
|
32
|
-
<
|
|
39
|
+
<Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
|
|
33
40
|
{label && (
|
|
34
41
|
<Label
|
|
35
42
|
aria-disabled={inputProps.disabled}
|
|
@@ -53,6 +60,6 @@ export const FormFieldInput = <
|
|
|
53
60
|
/>
|
|
54
61
|
|
|
55
62
|
<ErrorMessage name={name} />
|
|
56
|
-
</
|
|
63
|
+
</Flex>
|
|
57
64
|
);
|
|
58
65
|
};
|
package/src/FormFieldRadio.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Label, Radio, type RadioProps } from '@ttoss/ui';
|
|
1
|
+
import { Box, Flex, Label, Radio, type RadioProps } from '@ttoss/ui';
|
|
2
2
|
import { ErrorMessage } from './ErrorMessage';
|
|
3
3
|
import { FieldPath, FieldValues, useController } from 'react-hook-form';
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@ export const FormFieldRadio = <TFieldValues extends FieldValues = FieldValues>({
|
|
|
11
11
|
label,
|
|
12
12
|
name,
|
|
13
13
|
options,
|
|
14
|
+
sx,
|
|
14
15
|
...radioProps
|
|
15
16
|
}: {
|
|
16
17
|
label?: string;
|
|
@@ -25,7 +26,7 @@ export const FormFieldRadio = <TFieldValues extends FieldValues = FieldValues>({
|
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
+
<Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
|
|
29
30
|
{label && <Label>{label}</Label>}
|
|
30
31
|
<Box>
|
|
31
32
|
{options.map((option) => {
|
|
@@ -50,6 +51,6 @@ export const FormFieldRadio = <TFieldValues extends FieldValues = FieldValues>({
|
|
|
50
51
|
</Box>
|
|
51
52
|
|
|
52
53
|
<ErrorMessage name={name} />
|
|
53
|
-
</
|
|
54
|
+
</Flex>
|
|
54
55
|
);
|
|
55
56
|
};
|
package/src/FormFieldSelect.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Box, Label, Select, type SelectProps } from '@ttoss/ui';
|
|
2
1
|
import { ErrorMessage } from './ErrorMessage';
|
|
3
2
|
import { FieldPath, FieldValues, useController } from 'react-hook-form';
|
|
3
|
+
import { Flex, Label, Select, type SelectProps } from '@ttoss/ui';
|
|
4
4
|
|
|
5
5
|
type FormRadioOption = {
|
|
6
6
|
value: string | number;
|
|
@@ -13,6 +13,7 @@ export const FormFieldSelect = <
|
|
|
13
13
|
label,
|
|
14
14
|
name,
|
|
15
15
|
options,
|
|
16
|
+
sx,
|
|
16
17
|
...selectProps
|
|
17
18
|
}: {
|
|
18
19
|
label?: string;
|
|
@@ -29,7 +30,7 @@ export const FormFieldSelect = <
|
|
|
29
30
|
const id = `form-field-select-${name}`;
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
|
-
<
|
|
33
|
+
<Flex sx={{ flexDirection: 'column', width: '100%', ...sx }}>
|
|
33
34
|
{label && <Label htmlFor={id}>{label}</Label>}
|
|
34
35
|
<Select
|
|
35
36
|
ref={ref}
|
|
@@ -49,6 +50,6 @@ export const FormFieldSelect = <
|
|
|
49
50
|
})}
|
|
50
51
|
</Select>
|
|
51
52
|
<ErrorMessage name={name} />
|
|
52
|
-
</
|
|
53
|
+
</Flex>
|
|
53
54
|
);
|
|
54
55
|
};
|
|
@@ -8,6 +8,7 @@ export const FormFieldTextarea = <
|
|
|
8
8
|
>({
|
|
9
9
|
label,
|
|
10
10
|
name,
|
|
11
|
+
sx,
|
|
11
12
|
...textareaProps
|
|
12
13
|
}: {
|
|
13
14
|
label?: string;
|
|
@@ -20,6 +21,7 @@ export const FormFieldTextarea = <
|
|
|
20
21
|
label={label}
|
|
21
22
|
name={name}
|
|
22
23
|
id={id}
|
|
24
|
+
sx={sx}
|
|
23
25
|
render={({ field }) => {
|
|
24
26
|
return <Textarea {...field} {...textareaProps} />;
|
|
25
27
|
}}
|