@ttoss/forms 0.27.0 → 0.28.1
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/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-C7MZJ6SO.js";
|
|
3
3
|
|
|
4
4
|
// src/Brazil/FormFieldPhone.tsx
|
|
5
5
|
import { Input } from "@ttoss/ui";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import { Form, useForm, yupResolver } from "../chunk-
|
|
2
|
+
import { Form, useForm, yupResolver } from "../chunk-C7MZJ6SO.js";
|
|
3
3
|
|
|
4
4
|
// src/MultistepForm/MultistepForm.tsx
|
|
5
|
-
import * as React3 from "react";
|
|
6
5
|
import { Flex as Flex6 } from "@ttoss/ui";
|
|
6
|
+
import * as React3 from "react";
|
|
7
7
|
|
|
8
8
|
// src/MultistepForm/MultistepFooter.tsx
|
|
9
9
|
import { Flex, Text } from "@ttoss/ui";
|
|
@@ -19,9 +19,9 @@ var MultistepFooter = ({
|
|
|
19
19
|
children: /* @__PURE__ */jsx(Text, {
|
|
20
20
|
sx: {
|
|
21
21
|
textAlign: "center",
|
|
22
|
-
marginTop: "
|
|
23
|
-
marginBottom: "
|
|
24
|
-
marginX: "
|
|
22
|
+
marginTop: "8",
|
|
23
|
+
marginBottom: "4",
|
|
24
|
+
marginX: "6"
|
|
25
25
|
},
|
|
26
26
|
children: footer
|
|
27
27
|
})
|
|
@@ -41,9 +41,9 @@ var MultistepFlowMessageImageText = ({
|
|
|
41
41
|
return /* @__PURE__ */jsxs(Flex2, {
|
|
42
42
|
sx: {
|
|
43
43
|
flexDirection: "column",
|
|
44
|
-
paddingY: "
|
|
45
|
-
paddingX: "
|
|
46
|
-
gap: "
|
|
44
|
+
paddingY: "5",
|
|
45
|
+
paddingX: "6",
|
|
46
|
+
gap: "5"
|
|
47
47
|
},
|
|
48
48
|
children: [/* @__PURE__ */jsx2(Image, {
|
|
49
49
|
src,
|
|
@@ -83,20 +83,20 @@ var MultistepQuestion = ({
|
|
|
83
83
|
return /* @__PURE__ */jsxs2(Flex3, {
|
|
84
84
|
sx: {
|
|
85
85
|
flexDirection: "column",
|
|
86
|
-
paddingTop: "
|
|
87
|
-
paddingX: "
|
|
86
|
+
paddingTop: "5",
|
|
87
|
+
paddingX: "6"
|
|
88
88
|
},
|
|
89
89
|
children: [/* @__PURE__ */jsx4(Text3, {
|
|
90
90
|
sx: {
|
|
91
91
|
textAlign: "center",
|
|
92
92
|
fontSize: "lg",
|
|
93
|
-
marginBottom: "
|
|
93
|
+
marginBottom: "5"
|
|
94
94
|
},
|
|
95
95
|
children: question
|
|
96
96
|
}), /* @__PURE__ */jsx4(Flex3, {
|
|
97
97
|
sx: {
|
|
98
98
|
flexDirection: "column",
|
|
99
|
-
gap: "
|
|
99
|
+
gap: "4"
|
|
100
100
|
},
|
|
101
101
|
children: fields
|
|
102
102
|
})]
|
|
@@ -136,9 +136,9 @@ var MultistepFormStepper = ({
|
|
|
136
136
|
}), /* @__PURE__ */jsx5(Button, {
|
|
137
137
|
sx: {
|
|
138
138
|
justifyContent: "center",
|
|
139
|
-
marginTop: "
|
|
140
|
-
marginBottom: "
|
|
141
|
-
marginX: "
|
|
139
|
+
marginTop: "6",
|
|
140
|
+
marginBottom: "4",
|
|
141
|
+
marginX: "6"
|
|
142
142
|
},
|
|
143
143
|
rightIcon: isLastStep ? void 0 : "nav-right",
|
|
144
144
|
"aria-label": `btn-step-${stepNumber}`,
|
|
@@ -148,9 +148,6 @@ var MultistepFormStepper = ({
|
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
// src/MultistepForm/MultistepHeader.tsx
|
|
152
|
-
import { CloseButton, Flex as Flex4, Image as Image2, Text as Text4 } from "@ttoss/ui";
|
|
153
|
-
|
|
154
151
|
// ../react-icons/src/Icon.tsx
|
|
155
152
|
import * as React2 from "react";
|
|
156
153
|
|
|
@@ -2410,6 +2407,7 @@ var Icon2 = React2.forwardRef((props, ref) => {
|
|
|
2410
2407
|
Icon2.displayName = "Icon";
|
|
2411
2408
|
|
|
2412
2409
|
// src/MultistepForm/MultistepHeader.tsx
|
|
2410
|
+
import { CloseButton, Flex as Flex4, Image as Image2, Text as Text4 } from "@ttoss/ui";
|
|
2413
2411
|
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2414
2412
|
var MultistepHeaderTitled = ({
|
|
2415
2413
|
title,
|
|
@@ -2422,8 +2420,8 @@ var MultistepHeaderTitled = ({
|
|
|
2422
2420
|
sx: {
|
|
2423
2421
|
display: "flex",
|
|
2424
2422
|
justifyContent: "space-between",
|
|
2425
|
-
paddingX: "
|
|
2426
|
-
paddingY: "
|
|
2423
|
+
paddingX: "5",
|
|
2424
|
+
paddingY: "4",
|
|
2427
2425
|
alignItems: "center"
|
|
2428
2426
|
},
|
|
2429
2427
|
children: [/* @__PURE__ */jsx7(Icon2, {
|
|
@@ -2449,8 +2447,8 @@ var MultistepHeaderLogo = ({
|
|
|
2449
2447
|
sx: {
|
|
2450
2448
|
justifyContent: "space-between",
|
|
2451
2449
|
alignItems: "center",
|
|
2452
|
-
paddingX: "
|
|
2453
|
-
paddingY: "
|
|
2450
|
+
paddingX: "5",
|
|
2451
|
+
paddingY: "4"
|
|
2454
2452
|
},
|
|
2455
2453
|
children: [/* @__PURE__ */jsx7(Image2, {
|
|
2456
2454
|
width: 115,
|
|
@@ -2492,7 +2490,7 @@ var MultistepNavigation = ({
|
|
|
2492
2490
|
return /* @__PURE__ */jsxs5(Flex5, {
|
|
2493
2491
|
sx: {
|
|
2494
2492
|
justifyContent: "space-between",
|
|
2495
|
-
marginX: "
|
|
2493
|
+
marginX: "5"
|
|
2496
2494
|
},
|
|
2497
2495
|
children: [/* @__PURE__ */jsxs5(Flex5, {
|
|
2498
2496
|
onClick: onBack,
|
|
@@ -68,12 +68,13 @@ var FormErrorMessage = ({
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// src/FormField.tsx
|
|
71
|
+
import { Box as Box2, Flex, Label } from "@ttoss/ui";
|
|
71
72
|
import * as React from "react";
|
|
72
73
|
import { useController } from "react-hook-form";
|
|
73
|
-
import {
|
|
74
|
-
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
74
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
75
75
|
var FormField = ({
|
|
76
76
|
label,
|
|
77
|
+
labelPosition = "top",
|
|
77
78
|
id: idProp,
|
|
78
79
|
name,
|
|
79
80
|
defaultValue,
|
|
@@ -88,32 +89,51 @@ var FormField = ({
|
|
|
88
89
|
name,
|
|
89
90
|
defaultValue
|
|
90
91
|
});
|
|
91
|
-
const
|
|
92
|
+
const uniqueId = React.useId();
|
|
93
|
+
const id = idProp || `form-field-${name}-${uniqueId}`;
|
|
92
94
|
const memoizedRender = React.useMemo(() => {
|
|
93
95
|
return React.Children.map(render(controllerReturn), child => {
|
|
94
96
|
if (!React.isValidElement(child)) {
|
|
95
97
|
return null;
|
|
96
98
|
}
|
|
97
99
|
const childProps = child.props;
|
|
98
|
-
|
|
100
|
+
const isLabelHorizontal = ["left", "right"].includes(labelPosition);
|
|
101
|
+
const labelFontSize = isLabelHorizontal ? "md" : "sm";
|
|
102
|
+
const flexDirectionMap = {
|
|
103
|
+
top: "column",
|
|
104
|
+
bottom: "column-reverse",
|
|
105
|
+
left: "row",
|
|
106
|
+
right: "row-reverse"
|
|
107
|
+
};
|
|
108
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
109
|
+
sx: {
|
|
110
|
+
width: "100%",
|
|
111
|
+
flexDirection: flexDirectionMap[labelPosition],
|
|
112
|
+
gap: "sm"
|
|
113
|
+
},
|
|
99
114
|
children: [label && /* @__PURE__ */jsx3(Label, {
|
|
100
115
|
"aria-disabled": disabled,
|
|
101
116
|
htmlFor: id,
|
|
102
117
|
tooltip,
|
|
103
118
|
onTooltipClick,
|
|
119
|
+
sx: {
|
|
120
|
+
fontSize: labelFontSize
|
|
121
|
+
},
|
|
104
122
|
children: label
|
|
105
|
-
}),
|
|
106
|
-
|
|
107
|
-
|
|
123
|
+
}), /* @__PURE__ */jsx3(Box2, {
|
|
124
|
+
children: React.createElement(child.type, {
|
|
125
|
+
id,
|
|
126
|
+
...childProps
|
|
127
|
+
})
|
|
108
128
|
})]
|
|
109
129
|
});
|
|
110
130
|
});
|
|
111
|
-
}, [controllerReturn,
|
|
131
|
+
}, [render, controllerReturn, labelPosition, label, disabled, id, tooltip, onTooltipClick]);
|
|
112
132
|
return /* @__PURE__ */jsxs(Flex, {
|
|
113
133
|
sx: {
|
|
114
134
|
flexDirection: "column",
|
|
115
135
|
width: "100%",
|
|
116
|
-
gap: "
|
|
136
|
+
gap: "1",
|
|
117
137
|
...sx
|
|
118
138
|
},
|
|
119
139
|
css,
|
|
@@ -124,61 +144,29 @@ var FormField = ({
|
|
|
124
144
|
};
|
|
125
145
|
|
|
126
146
|
// src/FormFieldCheckbox.tsx
|
|
127
|
-
import { Checkbox
|
|
128
|
-
import
|
|
129
|
-
import { useController as useController2 } from "react-hook-form";
|
|
130
|
-
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
147
|
+
import { Checkbox } from "@ttoss/ui";
|
|
148
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
131
149
|
var FormFieldCheckbox = ({
|
|
132
150
|
label,
|
|
133
151
|
name,
|
|
134
152
|
sx,
|
|
135
153
|
...checkboxProps
|
|
136
154
|
}) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
onBlur,
|
|
141
|
-
value,
|
|
142
|
-
ref
|
|
143
|
-
},
|
|
144
|
-
formState: {
|
|
145
|
-
errors
|
|
146
|
-
}
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
|
-
} = useController2({
|
|
155
|
+
return /* @__PURE__ */jsx4(FormField, {
|
|
156
|
+
label,
|
|
157
|
+
labelPosition: "right",
|
|
149
158
|
name,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
children: [/* @__PURE__ */jsx4(Flex2, {
|
|
162
|
-
sx: {
|
|
163
|
-
alignItems: "center"
|
|
164
|
-
},
|
|
165
|
-
children: /* @__PURE__ */jsxs2(Label2, {
|
|
166
|
-
"aria-disabled": checkboxProps.disabled,
|
|
167
|
-
htmlFor: id,
|
|
168
|
-
children: [/* @__PURE__ */jsx4(Checkbox, {
|
|
169
|
-
id,
|
|
170
|
-
ref,
|
|
171
|
-
checked: value,
|
|
172
|
-
onChange,
|
|
173
|
-
onBlur,
|
|
174
|
-
name,
|
|
175
|
-
"aria-invalid": error ? "true" : "false",
|
|
176
|
-
...checkboxProps
|
|
177
|
-
}), label]
|
|
178
|
-
})
|
|
179
|
-
}), /* @__PURE__ */jsx4(FormErrorMessage, {
|
|
180
|
-
name
|
|
181
|
-
})]
|
|
159
|
+
render: ({
|
|
160
|
+
field,
|
|
161
|
+
fieldState
|
|
162
|
+
}) => {
|
|
163
|
+
return /* @__PURE__ */jsx4(Checkbox, {
|
|
164
|
+
...field,
|
|
165
|
+
...checkboxProps,
|
|
166
|
+
"aria-invalid": !!fieldState.error,
|
|
167
|
+
sx
|
|
168
|
+
});
|
|
169
|
+
}
|
|
182
170
|
});
|
|
183
171
|
};
|
|
184
172
|
|
|
@@ -349,9 +337,9 @@ var FormFieldPassword = ({
|
|
|
349
337
|
};
|
|
350
338
|
|
|
351
339
|
// src/FormFieldRadio.tsx
|
|
352
|
-
import { Box as
|
|
353
|
-
import { useController as
|
|
354
|
-
import { jsx as jsx11, jsxs as
|
|
340
|
+
import { Box as Box3, Flex as Flex2, Label as Label2, Radio } from "@ttoss/ui";
|
|
341
|
+
import { useController as useController2 } from "react-hook-form";
|
|
342
|
+
import { jsx as jsx11, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
355
343
|
var FormFieldRadio = ({
|
|
356
344
|
label,
|
|
357
345
|
name,
|
|
@@ -367,25 +355,25 @@ var FormFieldRadio = ({
|
|
|
367
355
|
ref
|
|
368
356
|
}
|
|
369
357
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
370
|
-
} =
|
|
358
|
+
} = useController2({
|
|
371
359
|
name,
|
|
372
360
|
defaultValue: ""
|
|
373
361
|
});
|
|
374
|
-
return /* @__PURE__ */
|
|
362
|
+
return /* @__PURE__ */jsxs2(Flex2, {
|
|
375
363
|
sx: {
|
|
376
364
|
flexDirection: "column",
|
|
377
365
|
width: "100%",
|
|
378
366
|
...sx
|
|
379
367
|
},
|
|
380
|
-
children: [label && /* @__PURE__ */jsx11(
|
|
368
|
+
children: [label && /* @__PURE__ */jsx11(Label2, {
|
|
381
369
|
sx: {
|
|
382
|
-
marginBottom: "
|
|
370
|
+
marginBottom: "1"
|
|
383
371
|
},
|
|
384
372
|
children: label
|
|
385
|
-
}), /* @__PURE__ */jsx11(
|
|
373
|
+
}), /* @__PURE__ */jsx11(Box3, {
|
|
386
374
|
children: options.map(option => {
|
|
387
375
|
const id = `form-field-radio-${name}-${option.value}`;
|
|
388
|
-
return /* @__PURE__ */
|
|
376
|
+
return /* @__PURE__ */jsxs2(Label2, {
|
|
389
377
|
htmlFor: id,
|
|
390
378
|
children: [/* @__PURE__ */jsx11(Radio, {
|
|
391
379
|
ref,
|
|
@@ -444,9 +432,36 @@ var FormFieldSelect = ({
|
|
|
444
432
|
});
|
|
445
433
|
};
|
|
446
434
|
|
|
435
|
+
// src/FormFieldSwitch.tsx
|
|
436
|
+
import { Switch } from "@ttoss/ui";
|
|
437
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
438
|
+
var FormFieldSwitch = ({
|
|
439
|
+
label,
|
|
440
|
+
name,
|
|
441
|
+
sx,
|
|
442
|
+
...switchProps
|
|
443
|
+
}) => {
|
|
444
|
+
return /* @__PURE__ */jsx13(FormField, {
|
|
445
|
+
label,
|
|
446
|
+
labelPosition: "right",
|
|
447
|
+
name,
|
|
448
|
+
render: ({
|
|
449
|
+
field,
|
|
450
|
+
fieldState
|
|
451
|
+
}) => {
|
|
452
|
+
return /* @__PURE__ */jsx13(Switch, {
|
|
453
|
+
...field,
|
|
454
|
+
...switchProps,
|
|
455
|
+
"aria-invalid": !!fieldState.error,
|
|
456
|
+
sx
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
|
|
447
462
|
// src/FormFieldTextarea.tsx
|
|
448
463
|
import { Textarea } from "@ttoss/ui";
|
|
449
|
-
import { jsx as
|
|
464
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
450
465
|
var FormFieldTextarea = ({
|
|
451
466
|
label,
|
|
452
467
|
name,
|
|
@@ -454,7 +469,7 @@ var FormFieldTextarea = ({
|
|
|
454
469
|
...textareaProps
|
|
455
470
|
}) => {
|
|
456
471
|
const id = `form-field-textarea-${name}`;
|
|
457
|
-
return /* @__PURE__ */
|
|
472
|
+
return /* @__PURE__ */jsx14(FormField, {
|
|
458
473
|
label,
|
|
459
474
|
name,
|
|
460
475
|
id,
|
|
@@ -463,7 +478,7 @@ var FormFieldTextarea = ({
|
|
|
463
478
|
field,
|
|
464
479
|
fieldState
|
|
465
480
|
}) => {
|
|
466
|
-
return /* @__PURE__ */
|
|
481
|
+
return /* @__PURE__ */jsx14(Textarea, {
|
|
467
482
|
...field,
|
|
468
483
|
...textareaProps,
|
|
469
484
|
"aria-invalid": fieldState.error ? "true" : void 0
|
|
@@ -473,10 +488,10 @@ var FormFieldTextarea = ({
|
|
|
473
488
|
};
|
|
474
489
|
|
|
475
490
|
// src/FormGroup.tsx
|
|
476
|
-
import
|
|
477
|
-
import
|
|
478
|
-
import { jsx as
|
|
479
|
-
var FormGroupLevelsManagerContext =
|
|
491
|
+
import { Box as Box4, Flex as Flex3, Text } from "@ttoss/ui";
|
|
492
|
+
import * as React2 from "react";
|
|
493
|
+
import { jsx as jsx15, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
494
|
+
var FormGroupLevelsManagerContext = React2.createContext({
|
|
480
495
|
levelsLength: 1,
|
|
481
496
|
registerChild: () => {
|
|
482
497
|
return null;
|
|
@@ -485,13 +500,13 @@ var FormGroupLevelsManagerContext = React3.createContext({
|
|
|
485
500
|
var FormGroupLevelsManager = ({
|
|
486
501
|
children
|
|
487
502
|
}) => {
|
|
488
|
-
const [levelsLength, setLevelsLength] =
|
|
489
|
-
const registerChild =
|
|
503
|
+
const [levelsLength, setLevelsLength] = React2.useState(0);
|
|
504
|
+
const registerChild = React2.useCallback(level => {
|
|
490
505
|
if (level + 1 > levelsLength) {
|
|
491
506
|
setLevelsLength(level + 1);
|
|
492
507
|
}
|
|
493
508
|
}, [levelsLength]);
|
|
494
|
-
return /* @__PURE__ */
|
|
509
|
+
return /* @__PURE__ */jsx15(FormGroupLevelsManagerContext.Provider, {
|
|
495
510
|
value: {
|
|
496
511
|
levelsLength,
|
|
497
512
|
registerChild
|
|
@@ -499,14 +514,14 @@ var FormGroupLevelsManager = ({
|
|
|
499
514
|
children
|
|
500
515
|
});
|
|
501
516
|
};
|
|
502
|
-
var FormGroupContext =
|
|
517
|
+
var FormGroupContext = React2.createContext({});
|
|
503
518
|
var useFormGroup = () => {
|
|
504
519
|
const {
|
|
505
520
|
parentLevel
|
|
506
|
-
} =
|
|
521
|
+
} = React2.useContext(FormGroupContext);
|
|
507
522
|
const {
|
|
508
523
|
levelsLength
|
|
509
|
-
} =
|
|
524
|
+
} = React2.useContext(FormGroupLevelsManagerContext);
|
|
510
525
|
return {
|
|
511
526
|
level: parentLevel,
|
|
512
527
|
levelsLength
|
|
@@ -524,40 +539,40 @@ var FormGroupWrapper = ({
|
|
|
524
539
|
} = useFormGroup();
|
|
525
540
|
const {
|
|
526
541
|
registerChild
|
|
527
|
-
} =
|
|
528
|
-
|
|
542
|
+
} = React2.useContext(FormGroupLevelsManagerContext);
|
|
543
|
+
React2.useEffect(() => {
|
|
529
544
|
if (typeof level === "number") {
|
|
530
545
|
registerChild(level);
|
|
531
546
|
}
|
|
532
547
|
}, [level, registerChild]);
|
|
533
548
|
const childrenContainerSx = {
|
|
534
549
|
flexDirection: direction || "column",
|
|
535
|
-
gap: "
|
|
550
|
+
gap: "1",
|
|
536
551
|
width: "100%"
|
|
537
552
|
};
|
|
538
|
-
return /* @__PURE__ */
|
|
553
|
+
return /* @__PURE__ */jsxs3(Box4, {
|
|
539
554
|
"aria-level": level,
|
|
540
555
|
...boxProps,
|
|
541
556
|
sx: {
|
|
542
|
-
marginTop: level === 0 ? "none" : "
|
|
543
|
-
marginBottom: "
|
|
557
|
+
marginTop: level === 0 ? "none" : "4",
|
|
558
|
+
marginBottom: "4",
|
|
544
559
|
...boxProps.sx
|
|
545
560
|
},
|
|
546
|
-
children: [title && /* @__PURE__ */
|
|
561
|
+
children: [title && /* @__PURE__ */jsx15(Box4, {
|
|
547
562
|
sx: {
|
|
548
|
-
marginBottom: "
|
|
563
|
+
marginBottom: "2"
|
|
549
564
|
},
|
|
550
|
-
children: /* @__PURE__ */
|
|
565
|
+
children: /* @__PURE__ */jsx15(Text, {
|
|
551
566
|
sx: {
|
|
552
567
|
fontSize: "2xl",
|
|
553
568
|
fontWeight: "bold"
|
|
554
569
|
},
|
|
555
570
|
children: title
|
|
556
571
|
})
|
|
557
|
-
}), /* @__PURE__ */
|
|
572
|
+
}), /* @__PURE__ */jsx15(Flex3, {
|
|
558
573
|
sx: childrenContainerSx,
|
|
559
574
|
children
|
|
560
|
-
}), name && /* @__PURE__ */
|
|
575
|
+
}), name && /* @__PURE__ */jsx15(FormErrorMessage, {
|
|
561
576
|
name
|
|
562
577
|
})]
|
|
563
578
|
});
|
|
@@ -567,15 +582,15 @@ var FormGroup = props => {
|
|
|
567
582
|
level
|
|
568
583
|
} = useFormGroup();
|
|
569
584
|
const currentLevel = level === void 0 ? 0 : level + 1;
|
|
570
|
-
return /* @__PURE__ */
|
|
585
|
+
return /* @__PURE__ */jsx15(FormGroupContext.Provider, {
|
|
571
586
|
value: {
|
|
572
587
|
parentLevel: currentLevel
|
|
573
588
|
},
|
|
574
|
-
children: currentLevel === 0 ? /* @__PURE__ */
|
|
575
|
-
children: /* @__PURE__ */
|
|
589
|
+
children: currentLevel === 0 ? /* @__PURE__ */jsx15(FormGroupLevelsManager, {
|
|
590
|
+
children: /* @__PURE__ */jsx15(FormGroupWrapper, {
|
|
576
591
|
...props
|
|
577
592
|
})
|
|
578
|
-
}) : /* @__PURE__ */
|
|
593
|
+
}) : /* @__PURE__ */jsx15(FormGroupWrapper, {
|
|
579
594
|
...props
|
|
580
595
|
})
|
|
581
596
|
});
|
|
@@ -645,7 +660,7 @@ import * as yup from "yup";
|
|
|
645
660
|
// src/Brazil/FormFieldCNPJ.tsx
|
|
646
661
|
import { Input as Input4 } from "@ttoss/ui";
|
|
647
662
|
import { PatternFormat as PatternFormat2 } from "react-number-format";
|
|
648
|
-
import { jsx as
|
|
663
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
649
664
|
var isCnpjValid = cnpj => {
|
|
650
665
|
if (cnpj?.length != 14) {
|
|
651
666
|
return false;
|
|
@@ -689,13 +704,13 @@ var FormFieldCNPJ = ({
|
|
|
689
704
|
name,
|
|
690
705
|
...patternFormatProps
|
|
691
706
|
}) => {
|
|
692
|
-
return /* @__PURE__ */
|
|
707
|
+
return /* @__PURE__ */jsx16(FormField, {
|
|
693
708
|
name,
|
|
694
709
|
label,
|
|
695
710
|
render: ({
|
|
696
711
|
field
|
|
697
712
|
}) => {
|
|
698
|
-
return /* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */jsx16(PatternFormat2, {
|
|
699
714
|
name: field.name,
|
|
700
715
|
value: field.value,
|
|
701
716
|
onBlur: field.onBlur,
|
|
@@ -732,6 +747,6 @@ import * as yup2 from "yup";
|
|
|
732
747
|
|
|
733
748
|
// src/index.ts
|
|
734
749
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
735
|
-
import { Controller, FormProvider as FormProvider2, useController as
|
|
750
|
+
import { Controller, FormProvider as FormProvider2, useController as useController3, useFieldArray, useForm, useFormContext as useFormContext2, useFormState, useWatch } from "react-hook-form";
|
|
736
751
|
export * from "react-hook-form";
|
|
737
|
-
export { Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldPatternFormat, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, useFormGroup, FormGroup, isCnpjValid, FormFieldCNPJ, yup2 as yup, yupResolver, Controller, FormProvider2 as FormProvider,
|
|
752
|
+
export { Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldPatternFormat, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, useFormGroup, FormGroup, isCnpjValid, FormFieldCNPJ, yup2 as yup, yupResolver, Controller, FormProvider2 as FormProvider, useController3 as useController, useFieldArray, useForm, useFormContext2 as useFormContext, useFormState, useWatch };
|
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, FormErrorMessage, 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, FormErrorMessage, 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, Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver } from "./chunk-C7MZJ6SO.js";
|
|
3
|
+
export { Controller, Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldPatternFormat, FormFieldRadio, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormGroup, useFormState, useWatch, yup, yupResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
|
|
3
|
+
import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, SwitchProps, TextareaProps } from '@ttoss/ui';
|
|
4
4
|
import { FieldValues, FormProviderProps, FieldName, FieldPath, UseControllerReturn, FieldPathValue } from 'react-hook-form';
|
|
5
5
|
export * from 'react-hook-form';
|
|
6
6
|
export { Controller, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
|
|
@@ -24,7 +24,8 @@ declare const FormErrorMessage: <TFieldValues extends FieldValues = FieldValues>
|
|
|
24
24
|
}) => react_jsx_runtime.JSX.Element;
|
|
25
25
|
|
|
26
26
|
type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
27
|
-
label?:
|
|
27
|
+
label?: React.ReactNode;
|
|
28
|
+
labelPosition?: 'top' | 'bottom' | 'left' | 'right';
|
|
28
29
|
id?: string;
|
|
29
30
|
name: TName;
|
|
30
31
|
defaultValue?: FieldPathValue<TFieldValues, TName>;
|
|
@@ -35,7 +36,7 @@ type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extend
|
|
|
35
36
|
type FormFieldCompleteProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
|
|
36
37
|
render: (props: UseControllerReturn<TFieldValues, TName>) => React.ReactElement;
|
|
37
38
|
} & FormFieldProps<TFieldValues, TName>;
|
|
38
|
-
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, id: idProp, name, defaultValue, disabled, tooltip, onTooltipClick, sx, css, render, }: FormFieldCompleteProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, labelPosition, id: idProp, name, defaultValue, disabled, tooltip, onTooltipClick, sx, css, render, }: FormFieldCompleteProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
|
|
39
40
|
|
|
40
41
|
declare const FormFieldCheckbox: <TFieldValues extends FieldValues = FieldValues>({ label, name, sx, ...checkboxProps }: {
|
|
41
42
|
label?: React.ReactNode;
|
|
@@ -88,6 +89,11 @@ declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
88
89
|
type FormFieldSelectProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<SelectProps, 'defaultValue'> & FormFieldProps<TFieldValues, TName>;
|
|
89
90
|
declare const FormFieldSelect: <TFieldValues extends FieldValues = FieldValues>({ label, name, id, defaultValue, sx, css, disabled, tooltip, onTooltipClick, ...selectProps }: FormFieldSelectProps<TFieldValues>) => react_jsx_runtime.JSX.Element;
|
|
90
91
|
|
|
92
|
+
declare const FormFieldSwitch: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, sx, ...switchProps }: {
|
|
93
|
+
label?: React.ReactNode;
|
|
94
|
+
name: TName;
|
|
95
|
+
} & SwitchProps) => react_jsx_runtime.JSX.Element;
|
|
96
|
+
|
|
91
97
|
declare const FormFieldTextarea: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, sx, ...textareaProps }: {
|
|
92
98
|
label?: string;
|
|
93
99
|
name: TName;
|
|
@@ -104,4 +110,4 @@ type FormGroupProps = {
|
|
|
104
110
|
} & BoxProps;
|
|
105
111
|
declare const FormGroup: (props: FormGroupProps) => react_jsx_runtime.JSX.Element;
|
|
106
112
|
|
|
107
|
-
export { Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, useFormGroup };
|
|
113
|
+
export { Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, FormGroup, useFormGroup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8.0",
|
|
42
42
|
"@ttoss/react-i18n": "^2.0.9",
|
|
43
|
-
"@ttoss/ui": "^5.
|
|
43
|
+
"@ttoss/ui": "^5.1.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/jest": "^29.5.14",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"tsup": "^8.3.5",
|
|
52
52
|
"yup": "^1.6.1",
|
|
53
53
|
"@ttoss/config": "^1.35.2",
|
|
54
|
+
"@ttoss/react-i18n": "^2.0.9",
|
|
54
55
|
"@ttoss/react-icons": "^0.4.9",
|
|
56
|
+
"@ttoss/test-utils": "^2.1.22",
|
|
55
57
|
"@ttoss/i18n-cli": "^0.7.26",
|
|
56
|
-
"@ttoss/
|
|
57
|
-
"@ttoss/ui": "^5.0.15",
|
|
58
|
-
"@ttoss/test-utils": "^2.1.22"
|
|
58
|
+
"@ttoss/ui": "^5.1.1"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public",
|