@ttoss/forms 0.24.10 → 0.25.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/README.md +4 -0
- package/dist/esm/Brazil/index.js +1 -1
- package/dist/esm/MultistepForm/index.js +1 -1
- package/dist/esm/{chunk-ECFRAK7U.js → chunk-6U527R3X.js} +9 -0
- package/dist/esm/index.js +1 -1
- package/package.json +8 -10
- package/src/yup/schema.ts +14 -0
- package/dist/Brazil/index.d.mts +0 -24
- package/dist/Brazil/index.js +0 -832
- package/dist/FormFieldPatternFormat-CkcL14ho.d.mts +0 -10
- package/dist/MultistepForm/index.d.mts +0 -65
- package/dist/MultistepForm/index.js +0 -3260
- package/dist/index.d.mts +0 -107
- package/dist/index.js +0 -773
- package/dist/typings.d-HZBqJJjn.d.mts +0 -12
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
**@ttoss/forms** is a library of React form components for building form components. It is built on top of [React Hook Form](https://react-hook-form.com/) and [Yup](https://github.com/jquense/yup).
|
|
4
4
|
|
|
5
|
+
## ESM Only
|
|
6
|
+
|
|
7
|
+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```shell
|
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-6U527R3X.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, __publicField, useForm, yupResolver } from "../chunk-
|
|
2
|
+
import { Form, __publicField, useForm, yupResolver } from "../chunk-6U527R3X.js";
|
|
3
3
|
|
|
4
4
|
// src/MultistepForm/MultistepForm.tsx
|
|
5
5
|
import * as React3 from "react";
|
|
@@ -147,6 +147,15 @@ yup.addMethod(yup.string, "cnpj", function () {
|
|
|
147
147
|
return isCnpjValid(value);
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
|
+
yup.addMethod(yup.string, "password", function ({
|
|
151
|
+
required
|
|
152
|
+
} = {}) {
|
|
153
|
+
const schema = this.trim();
|
|
154
|
+
if (required) {
|
|
155
|
+
schema.required("Password is required");
|
|
156
|
+
}
|
|
157
|
+
return schema.min(8, "Password must be at least 8 characters long");
|
|
158
|
+
});
|
|
150
159
|
|
|
151
160
|
// src/yup/yup.ts
|
|
152
161
|
import * as yup2 from "yup";
|
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-
|
|
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
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"author": "ttoss",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Pedro Arantes <pedro@arantespp.com> (https://arantespp.com/contact)"
|
|
@@ -10,20 +10,18 @@
|
|
|
10
10
|
"url": "https://github.com/ttoss/ttoss.git",
|
|
11
11
|
"directory": "packages/forms"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"exports": {
|
|
14
15
|
".": {
|
|
15
16
|
"import": "./dist/esm/index.js",
|
|
16
|
-
"require": "./dist/index.js",
|
|
17
17
|
"types": "./dist/index.d.ts"
|
|
18
18
|
},
|
|
19
19
|
"./multistep-form": {
|
|
20
20
|
"import": "./dist/esm/MultistepForm/index.js",
|
|
21
|
-
"require": "./dist/MultistepForm/index.js",
|
|
22
21
|
"types": "./dist/MultistepForm/index.d.ts"
|
|
23
22
|
},
|
|
24
23
|
"./brazil": {
|
|
25
24
|
"import": "./dist/esm/Brazil/index.js",
|
|
26
|
-
"require": "./dist/Brazil/index.js",
|
|
27
25
|
"types": "./dist/Brazil/index.d.ts"
|
|
28
26
|
}
|
|
29
27
|
},
|
|
@@ -41,8 +39,8 @@
|
|
|
41
39
|
},
|
|
42
40
|
"peerDependencies": {
|
|
43
41
|
"react": ">=16.8.0",
|
|
44
|
-
"@ttoss/
|
|
45
|
-
"@ttoss/
|
|
42
|
+
"@ttoss/react-i18n": "^2.0.0",
|
|
43
|
+
"@ttoss/ui": "^5.0.0"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
46
|
"@types/jest": "^29.5.12",
|
|
@@ -52,12 +50,12 @@
|
|
|
52
50
|
"react-error-boundary": "^4.0.13",
|
|
53
51
|
"tsup": "^8.2.4",
|
|
54
52
|
"yup": "^1.4.0",
|
|
55
|
-
"@ttoss/i18n-cli": "^0.7.18",
|
|
56
53
|
"@ttoss/config": "^1.32.9",
|
|
54
|
+
"@ttoss/react-i18n": "^2.0.0",
|
|
57
55
|
"@ttoss/test-utils": "^2.1.13",
|
|
58
|
-
"@ttoss/
|
|
59
|
-
"@ttoss/
|
|
60
|
-
"@ttoss/
|
|
56
|
+
"@ttoss/i18n-cli": "^0.7.18",
|
|
57
|
+
"@ttoss/ui": "^5.0.0",
|
|
58
|
+
"@ttoss/react-icons": "^0.4.0"
|
|
61
59
|
},
|
|
62
60
|
"publishConfig": {
|
|
63
61
|
"access": "public",
|
package/src/yup/schema.ts
CHANGED
|
@@ -10,3 +10,17 @@ yup.addMethod(yup.string, 'cnpj', function () {
|
|
|
10
10
|
return isCnpjValid(value);
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
yup.addMethod(
|
|
15
|
+
yup.string,
|
|
16
|
+
'password',
|
|
17
|
+
function ({ required }: { required?: boolean } = {}) {
|
|
18
|
+
const schema = this.trim();
|
|
19
|
+
|
|
20
|
+
if (required) {
|
|
21
|
+
schema.required('Password is required');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return schema.min(8, 'Password must be at least 8 characters long');
|
|
25
|
+
}
|
|
26
|
+
);
|
package/dist/Brazil/index.d.mts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { PatternFormatProps } from 'react-number-format';
|
|
3
|
-
import { F as FormFieldPatternFormatProps } from '../FormFieldPatternFormat-CkcL14ho.mjs';
|
|
4
|
-
|
|
5
|
-
type FormFieldCNPJProps = {
|
|
6
|
-
label: string;
|
|
7
|
-
name: string;
|
|
8
|
-
} & Partial<PatternFormatProps>;
|
|
9
|
-
declare const isCnpjValid: (cnpj: any) => boolean;
|
|
10
|
-
declare const FormFieldCNPJ: ({ label, name, ...patternFormatProps }: FormFieldCNPJProps) => react_jsx_runtime.JSX.Element;
|
|
11
|
-
|
|
12
|
-
type FormFieldPhoneProps = {
|
|
13
|
-
label: string;
|
|
14
|
-
name: string;
|
|
15
|
-
} & Partial<PatternFormatProps>;
|
|
16
|
-
declare const FormFieldPhone: ({ label, name, ...patternFormatProps }: FormFieldPhoneProps) => react_jsx_runtime.JSX.Element;
|
|
17
|
-
|
|
18
|
-
type FormFieldCEPProps = {
|
|
19
|
-
label: string;
|
|
20
|
-
name: string;
|
|
21
|
-
} & Partial<FormFieldPatternFormatProps>;
|
|
22
|
-
declare const FormFieldCEP: ({ label, name, ...formFieldPatternFormatProps }: FormFieldCEPProps) => react_jsx_runtime.JSX.Element;
|
|
23
|
-
|
|
24
|
-
export { FormFieldCEP, FormFieldCNPJ, FormFieldPhone, isCnpjValid };
|