@ttoss/forms 0.25.6 → 0.26.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.
@@ -0,0 +1,3 @@
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-6U527R3X.js";
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 };
@@ -0,0 +1,107 @@
1
+ export { yupResolver } from '@hookform/resolvers/yup';
2
+ import './typings.d-HZBqJJjn.js';
3
+ import * as yup from 'yup';
4
+ export { yup };
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+ import * as React from 'react';
7
+ import { BoxProps, SxProp, CheckboxProps, InputProps, InputPasswordProps, RadioProps, SelectProps, TextareaProps } from '@ttoss/ui';
8
+ import { FieldValues, FormProviderProps, FieldName, FieldPath, UseControllerReturn, FieldPathValue } from 'react-hook-form';
9
+ export * from 'react-hook-form';
10
+ export { Controller, FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
11
+ import { F as FormFieldPatternFormatProps } from './FormFieldPatternFormat-CkcL14ho.js';
12
+ export { a as FormFieldPatternFormat } from './FormFieldPatternFormat-CkcL14ho.js';
13
+ import { NumericFormatProps } from 'react-number-format';
14
+
15
+ declare const Form: <TFieldValues extends FieldValues = FieldValues>({ children, onSubmit, sx, ...formMethods }: {
16
+ children?: React.ReactNode;
17
+ onSubmit?: (data: TFieldValues) => Promise<void> | void;
18
+ sx?: BoxProps["sx"];
19
+ } & FormProviderProps<TFieldValues>) => react_jsx_runtime.JSX.Element;
20
+
21
+ declare const FormErrorMessage: <TFieldValues extends FieldValues = FieldValues>({ name, disabled, }: {
22
+ name: FieldName<TFieldValues>;
23
+ disabled?: boolean;
24
+ }) => react_jsx_runtime.JSX.Element;
25
+
26
+ type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
27
+ label?: string;
28
+ id?: string;
29
+ name: TName;
30
+ defaultValue?: FieldPathValue<TFieldValues, TName>;
31
+ disabled?: boolean;
32
+ tooltip?: boolean;
33
+ onTooltipClick?: () => void;
34
+ } & SxProp;
35
+ type FormFieldCompleteProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
36
+ render: (props: UseControllerReturn<TFieldValues, TName>) => React.ReactElement;
37
+ } & 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
+
40
+ declare const FormFieldCheckbox: <TFieldValues extends FieldValues = FieldValues>({ label, name, sx, ...checkboxProps }: {
41
+ label?: string;
42
+ name: FieldPath<TFieldValues>;
43
+ } & CheckboxProps) => react_jsx_runtime.JSX.Element;
44
+
45
+ type FormFieldCreditCardNumberProps = {
46
+ label: string;
47
+ name: string;
48
+ } & Partial<FormFieldPatternFormatProps>;
49
+ declare const FormFieldCreditCardNumber: ({ label, name, ...formFieldPatternFormatProps }: FormFieldCreditCardNumberProps) => react_jsx_runtime.JSX.Element;
50
+
51
+ type FormFieldNumericFormatProps = {
52
+ label?: string;
53
+ name: string;
54
+ } & NumericFormatProps;
55
+ declare const FormFieldNumericFormat: ({ label, name, ...numericFormatProps }: FormFieldNumericFormatProps) => react_jsx_runtime.JSX.Element;
56
+
57
+ type FormFieldCurrencyInputProps = {
58
+ label?: string;
59
+ name: string;
60
+ prefix: string;
61
+ decimalSeparator: string;
62
+ thousandSeparator: string;
63
+ } & FormFieldNumericFormatProps;
64
+ declare const FormFieldCurrencyInput: ({ label, name, prefix, decimalSeparator, thousandSeparator, ...formFieldNumericFormatProps }: FormFieldCurrencyInputProps) => react_jsx_runtime.JSX.Element;
65
+
66
+ type FormFieldInputProps<TName> = {
67
+ label?: string;
68
+ name: TName;
69
+ } & InputProps & FormFieldProps;
70
+ declare const FormFieldInput: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, tooltip, onTooltipClick, sx, defaultValue, ...inputProps }: FormFieldInputProps<TName>) => react_jsx_runtime.JSX.Element;
71
+
72
+ type FormFieldPasswordProps<TName> = {
73
+ label?: string;
74
+ name: TName;
75
+ } & InputPasswordProps & FormFieldProps;
76
+ declare const FormFieldPassword: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, tooltip, onTooltipClick, sx, defaultValue, ...inputProps }: FormFieldPasswordProps<TName>) => react_jsx_runtime.JSX.Element;
77
+
78
+ type FormRadioOption = {
79
+ value: string | number;
80
+ label: string;
81
+ };
82
+ declare const FormFieldRadio: <TFieldValues extends FieldValues = FieldValues>({ label, name, options, sx, ...radioProps }: {
83
+ label?: string;
84
+ name: FieldPath<TFieldValues>;
85
+ options: FormRadioOption[];
86
+ } & RadioProps) => react_jsx_runtime.JSX.Element;
87
+
88
+ type FormFieldSelectProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<SelectProps, 'defaultValue'> & FormFieldProps<TFieldValues, TName>;
89
+ 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
+ declare const FormFieldTextarea: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, name, sx, ...textareaProps }: {
92
+ label?: string;
93
+ name: TName;
94
+ } & TextareaProps) => react_jsx_runtime.JSX.Element;
95
+
96
+ declare const useFormGroup: () => {
97
+ level: number | undefined;
98
+ levelsLength: number;
99
+ };
100
+ type FormGroupProps = {
101
+ name?: string;
102
+ title?: string;
103
+ direction?: 'column' | 'row';
104
+ } & BoxProps;
105
+ declare const FormGroup: (props: FormGroupProps) => react_jsx_runtime.JSX.Element;
106
+
107
+ export { Form, FormErrorMessage, FormField, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldCurrencyInput, FormFieldInput, FormFieldNumericFormat, FormFieldPassword, FormFieldRadio, FormFieldSelect, FormFieldTextarea, FormGroup, useFormGroup };
@@ -0,0 +1,12 @@
1
+ import { Maybe, AnyObject, Flags, Schema } from 'yup';
2
+
3
+ declare module 'yup' {
4
+ interface StringSchema<
5
+ TType extends Maybe<string> = string | undefined,
6
+ TContext extends AnyObject = AnyObject,
7
+ TDefault = undefined,
8
+ TFlags extends Flags = '',
9
+ > extends Schema<TType, TContext, TDefault, TFlags> {
10
+ cnpj(): this;
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/forms",
3
- "version": "0.25.6",
3
+ "version": "0.26.0",
4
4
  "author": "ttoss",
5
5
  "contributors": [
6
6
  "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com/contact)"
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=16.8.0",
42
- "@ttoss/react-i18n": "^2.0.2",
43
- "@ttoss/ui": "^5.0.6"
42
+ "@ttoss/react-i18n": "^2.0.3",
43
+ "@ttoss/ui": "^5.0.7"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/jest": "^29.5.13",
@@ -50,12 +50,12 @@
50
50
  "react-error-boundary": "^4.0.13",
51
51
  "tsup": "^8.3.0",
52
52
  "yup": "^1.4.0",
53
- "@ttoss/i18n-cli": "^0.7.20",
54
- "@ttoss/config": "^1.33.0",
55
- "@ttoss/react-i18n": "^2.0.2",
56
- "@ttoss/react-icons": "^0.4.2",
57
- "@ttoss/test-utils": "^2.1.15",
58
- "@ttoss/ui": "^5.0.6"
53
+ "@ttoss/config": "^1.34.0",
54
+ "@ttoss/i18n-cli": "^0.7.21",
55
+ "@ttoss/react-i18n": "^2.0.3",
56
+ "@ttoss/react-icons": "^0.4.3",
57
+ "@ttoss/test-utils": "^2.1.16",
58
+ "@ttoss/ui": "^5.0.7"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public",