@ttoss/forms 0.27.0 → 0.28.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/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-3L7PNPZA.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, useForm, yupResolver } from "../chunk-3L7PNPZA.js";
|
|
3
3
|
|
|
4
4
|
// src/MultistepForm/MultistepForm.tsx
|
|
5
5
|
import * as React3 from "react";
|
|
@@ -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,27 +89,46 @@ 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",
|
|
@@ -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
370
|
marginBottom: "md"
|
|
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 * as
|
|
477
|
-
import { Box as
|
|
478
|
-
import { jsx as
|
|
479
|
-
var FormGroupLevelsManagerContext =
|
|
491
|
+
import * as React2 from "react";
|
|
492
|
+
import { Box as Box4, Flex as Flex3, Text } from "@ttoss/ui";
|
|
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,8 +539,8 @@ 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
|
}
|
|
@@ -535,7 +550,7 @@ var FormGroupWrapper = ({
|
|
|
535
550
|
gap: "md",
|
|
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: {
|
|
@@ -543,21 +558,21 @@ var FormGroupWrapper = ({
|
|
|
543
558
|
marginBottom: "lg",
|
|
544
559
|
...boxProps.sx
|
|
545
560
|
},
|
|
546
|
-
children: [title && /* @__PURE__ */
|
|
561
|
+
children: [title && /* @__PURE__ */jsx15(Box4, {
|
|
547
562
|
sx: {
|
|
548
563
|
marginBottom: "md"
|
|
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-3L7PNPZA.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.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8.0",
|
|
42
|
-
"@ttoss/
|
|
43
|
-
"@ttoss/
|
|
42
|
+
"@ttoss/ui": "^5.1.0",
|
|
43
|
+
"@ttoss/react-i18n": "^2.0.9"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/jest": "^29.5.14",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"tsup": "^8.3.5",
|
|
52
52
|
"yup": "^1.6.1",
|
|
53
53
|
"@ttoss/config": "^1.35.2",
|
|
54
|
-
"@ttoss/react-icons": "^0.4.9",
|
|
55
54
|
"@ttoss/i18n-cli": "^0.7.26",
|
|
55
|
+
"@ttoss/react-icons": "^0.4.9",
|
|
56
56
|
"@ttoss/react-i18n": "^2.0.9",
|
|
57
|
-
"@ttoss/ui": "^5.0
|
|
57
|
+
"@ttoss/ui": "^5.1.0",
|
|
58
58
|
"@ttoss/test-utils": "^2.1.22"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|