@ttoss/forms 0.24.9 → 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 +4 -4
- package/dist/esm/{chunk-ECFRAK7U.js → chunk-6U527R3X.js} +12 -3
- package/dist/esm/index.js +1 -1
- package/package.json +11 -13
- 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";
|
|
@@ -2269,7 +2269,7 @@ var {
|
|
|
2269
2269
|
} = IconifyIconComponent;
|
|
2270
2270
|
|
|
2271
2271
|
// ../../node_modules/.pnpm/@iconify-icon+react@2.1.0_react@18.3.1/node_modules/@iconify-icon/react/dist/iconify.mjs
|
|
2272
|
-
var Icon =
|
|
2272
|
+
var Icon = React.forwardRef((props, ref) => {
|
|
2273
2273
|
const newProps = {
|
|
2274
2274
|
...props,
|
|
2275
2275
|
ref
|
|
@@ -2283,12 +2283,12 @@ var Icon = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
2283
2283
|
if (props.className) {
|
|
2284
2284
|
newProps["class"] = props.className;
|
|
2285
2285
|
}
|
|
2286
|
-
return
|
|
2286
|
+
return React.createElement("iconify-icon", newProps);
|
|
2287
2287
|
});
|
|
2288
2288
|
|
|
2289
2289
|
// ../react-icons/src/Icon.tsx
|
|
2290
2290
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2291
|
-
var Icon2 =
|
|
2291
|
+
var Icon2 = React2.forwardRef((props, ref) => {
|
|
2292
2292
|
return /* @__PURE__ */jsx6(Icon, {
|
|
2293
2293
|
ref,
|
|
2294
2294
|
"data-testid": "iconify-icon",
|
|
@@ -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";
|
|
@@ -249,7 +258,7 @@ var FormField = ({
|
|
|
249
258
|
tooltip,
|
|
250
259
|
onTooltipClick,
|
|
251
260
|
children: label
|
|
252
|
-
}),
|
|
261
|
+
}), React.createElement(child.type, {
|
|
253
262
|
id,
|
|
254
263
|
...child.props
|
|
255
264
|
})]
|
|
@@ -621,7 +630,7 @@ var FormFieldTextarea = ({
|
|
|
621
630
|
import * as React2 from "react";
|
|
622
631
|
import { Box as Box3, Flex as Flex4, Text } from "@ttoss/ui";
|
|
623
632
|
import { jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
624
|
-
var FormGroupLevelsManagerContext =
|
|
633
|
+
var FormGroupLevelsManagerContext = React2.createContext({
|
|
625
634
|
levelsLength: 1,
|
|
626
635
|
registerChild: () => {
|
|
627
636
|
return null;
|
|
@@ -644,7 +653,7 @@ var FormGroupLevelsManager = ({
|
|
|
644
653
|
children
|
|
645
654
|
});
|
|
646
655
|
};
|
|
647
|
-
var FormGroupContext =
|
|
656
|
+
var FormGroupContext = React2.createContext({});
|
|
648
657
|
var useFormGroup = () => {
|
|
649
658
|
const {
|
|
650
659
|
parentLevel
|
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/react-i18n": "^
|
|
45
|
-
"@ttoss/ui": "^
|
|
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/config": "^1.32.
|
|
56
|
-
"@ttoss/i18n
|
|
57
|
-
"@ttoss/test-utils": "^2.1.
|
|
58
|
-
"@ttoss/
|
|
59
|
-
"@ttoss/
|
|
60
|
-
"@ttoss/
|
|
53
|
+
"@ttoss/config": "^1.32.9",
|
|
54
|
+
"@ttoss/react-i18n": "^2.0.0",
|
|
55
|
+
"@ttoss/test-utils": "^2.1.13",
|
|
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",
|
|
@@ -66,6 +64,6 @@
|
|
|
66
64
|
"gitHead": "e2b509ee8717f07f7365191b651dcbb5f080e05a",
|
|
67
65
|
"scripts": {
|
|
68
66
|
"build": "tsup",
|
|
69
|
-
"test": "jest"
|
|
67
|
+
"test": "jest --projects tests/unit"
|
|
70
68
|
}
|
|
71
69
|
}
|
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 };
|