@ttoss/forms 0.25.6 → 0.26.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/LICENSE +21 -674
- package/dist/Brazil/index.d.ts +24 -0
- package/dist/FormFieldPatternFormat-CkcL14ho.d.ts +10 -0
- package/dist/MultistepForm/index.d.ts +65 -0
- package/dist/esm/Brazil/index.js +51 -0
- package/dist/esm/MultistepForm/index.js +2502 -0
- package/dist/esm/chunk-6U527R3X.js +741 -0
- package/dist/esm/index.js +3 -0
- package/dist/index.d.ts +107 -0
- package/{src/yup/typings.d.ts → dist/typings.d-HZBqJJjn.d.ts} +1 -3
- package/package.json +11 -11
- package/src/Brazil/FormFieldCEP.tsx +0 -25
- package/src/Brazil/FormFieldCNPJ.tsx +0 -93
- package/src/Brazil/FormFieldPhone.tsx +0 -41
- package/src/Brazil/index.ts +0 -4
- package/src/Form.tsx +0 -29
- package/src/FormErrorMessage.tsx +0 -60
- package/src/FormField.tsx +0 -86
- package/src/FormFieldCheckbox.tsx +0 -49
- package/src/FormFieldCreditCardNumber.tsx +0 -25
- package/src/FormFieldCurrencyInput.tsx +0 -36
- package/src/FormFieldInput.tsx +0 -43
- package/src/FormFieldNumericFormat.tsx +0 -35
- package/src/FormFieldPassword.tsx +0 -43
- package/src/FormFieldPatternFormat.tsx +0 -36
- package/src/FormFieldRadio.tsx +0 -57
- package/src/FormFieldSelect.tsx +0 -47
- package/src/FormFieldTextarea.tsx +0 -36
- package/src/FormGroup.tsx +0 -136
- package/src/MultistepForm/MultistepFlowMessage.tsx +0 -14
- package/src/MultistepForm/MultistepFlowMessageImageText.tsx +0 -37
- package/src/MultistepForm/MultistepFooter.tsx +0 -18
- package/src/MultistepForm/MultistepForm.tsx +0 -117
- package/src/MultistepForm/MultistepFormStepper.tsx +0 -70
- package/src/MultistepForm/MultistepHeader.tsx +0 -78
- package/src/MultistepForm/MultistepNavigation.tsx +0 -38
- package/src/MultistepForm/MultistepQuestion.tsx +0 -28
- package/src/MultistepForm/index.ts +0 -1
- package/src/MultistepForm/types.ts +0 -7
- package/src/index.ts +0 -35
- package/src/yup/i18n.ts +0 -31
- package/src/yup/schema.ts +0 -26
- package/src/yup/yup.ts +0 -4
|
@@ -0,0 +1,24 @@
|
|
|
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.js';
|
|
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 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PatternFormatProps } from 'react-number-format';
|
|
3
|
+
|
|
4
|
+
type FormFieldPatternFormatProps = {
|
|
5
|
+
label?: string;
|
|
6
|
+
name: string;
|
|
7
|
+
} & PatternFormatProps;
|
|
8
|
+
declare const FormFieldPatternFormat: ({ label, name, ...patternFormatProps }: FormFieldPatternFormatProps) => react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { type FormFieldPatternFormatProps as F, FormFieldPatternFormat as a };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import '../typings.d-HZBqJJjn.js';
|
|
4
|
+
import * as yup from 'yup';
|
|
5
|
+
import { IconType } from '@ttoss/react-icons';
|
|
6
|
+
|
|
7
|
+
type MultistepFlowMessageVariant = 'image-text' | 'heading-and-subheading';
|
|
8
|
+
type MultistepFlowMessageBase = {
|
|
9
|
+
variant: MultistepFlowMessageVariant;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type MultistepFlowMessageImageTextProps = MultistepFlowMessageBase & {
|
|
13
|
+
variant: 'image-text';
|
|
14
|
+
src: string;
|
|
15
|
+
description: string | React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type MultistepFlowMessageProps = MultistepFlowMessageImageTextProps;
|
|
19
|
+
|
|
20
|
+
type MultistepFormStepperProps = {
|
|
21
|
+
flowMessage: MultistepFlowMessageProps;
|
|
22
|
+
onSubmit: (data: unknown) => void;
|
|
23
|
+
question: string;
|
|
24
|
+
isLastStep: boolean;
|
|
25
|
+
fields: React.ReactNode | React.ReactNode[];
|
|
26
|
+
schema?: yup.ObjectSchema<any>;
|
|
27
|
+
defaultValues?: any;
|
|
28
|
+
submitLabel: string;
|
|
29
|
+
stepNumber: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type MultistepHeaderTitledProps = {
|
|
33
|
+
variant: 'titled';
|
|
34
|
+
title: string;
|
|
35
|
+
leftIcon: IconType;
|
|
36
|
+
rightIcon: IconType;
|
|
37
|
+
onLeftIconClick: () => void;
|
|
38
|
+
onRightIconClick: () => void;
|
|
39
|
+
};
|
|
40
|
+
type MultistepHeaderLogoProps = {
|
|
41
|
+
variant: 'logo';
|
|
42
|
+
src: string;
|
|
43
|
+
onClose?: () => void;
|
|
44
|
+
};
|
|
45
|
+
type MultistepHeaderProps = MultistepHeaderLogoProps | MultistepHeaderTitledProps;
|
|
46
|
+
|
|
47
|
+
type MultistepStep = {
|
|
48
|
+
question: string;
|
|
49
|
+
flowMessage: MultistepFlowMessageProps;
|
|
50
|
+
label: string;
|
|
51
|
+
fields: React.ReactNode | React.ReactNode[];
|
|
52
|
+
schema?: MultistepFormStepperProps['schema'];
|
|
53
|
+
defaultValues?: MultistepFormStepperProps['defaultValues'];
|
|
54
|
+
};
|
|
55
|
+
type MultistepFormProps<FormValues = unknown> = {
|
|
56
|
+
header: MultistepHeaderProps;
|
|
57
|
+
steps: MultistepStep[];
|
|
58
|
+
footer?: string;
|
|
59
|
+
onSubmit: (data: FormValues) => void;
|
|
60
|
+
nextStepButtonLabel?: string;
|
|
61
|
+
submitButtonLabel?: string;
|
|
62
|
+
};
|
|
63
|
+
declare const MultistepForm: ({ nextStepButtonLabel, submitButtonLabel, ...props }: MultistepFormProps) => react_jsx_runtime.JSX.Element;
|
|
64
|
+
|
|
65
|
+
export { MultistepForm, type MultistepFormProps };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { FormField, FormFieldCNPJ, FormFieldPatternFormat, isCnpjValid } from "../chunk-6U527R3X.js";
|
|
3
|
+
|
|
4
|
+
// src/Brazil/FormFieldPhone.tsx
|
|
5
|
+
import { Input } from "@ttoss/ui";
|
|
6
|
+
import { PatternFormat } from "react-number-format";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var FormFieldPhone = ({
|
|
9
|
+
label,
|
|
10
|
+
name,
|
|
11
|
+
...patternFormatProps
|
|
12
|
+
}) => {
|
|
13
|
+
return /* @__PURE__ */jsx(FormField, {
|
|
14
|
+
name,
|
|
15
|
+
label,
|
|
16
|
+
render: ({
|
|
17
|
+
field
|
|
18
|
+
}) => {
|
|
19
|
+
const format = field.value?.length > 10 ? "(##) #####-####" : "(##) ####-#####";
|
|
20
|
+
return /* @__PURE__ */jsx(PatternFormat, {
|
|
21
|
+
name: field.name,
|
|
22
|
+
value: field.value,
|
|
23
|
+
onBlur: field.onBlur,
|
|
24
|
+
onValueChange: values => {
|
|
25
|
+
field.onChange(values.value);
|
|
26
|
+
},
|
|
27
|
+
format,
|
|
28
|
+
customInput: Input,
|
|
29
|
+
placeholder: "(11) 91234-1234",
|
|
30
|
+
...patternFormatProps
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/Brazil/FormFieldCEP.tsx
|
|
37
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
38
|
+
var FormFieldCEP = ({
|
|
39
|
+
label,
|
|
40
|
+
name,
|
|
41
|
+
...formFieldPatternFormatProps
|
|
42
|
+
}) => {
|
|
43
|
+
return /* @__PURE__ */jsx2(FormFieldPatternFormat, {
|
|
44
|
+
name,
|
|
45
|
+
label,
|
|
46
|
+
format: "#####-###",
|
|
47
|
+
placeholder: "12345-678",
|
|
48
|
+
...formFieldPatternFormatProps
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export { FormFieldCEP, FormFieldCNPJ, FormFieldPhone, isCnpjValid };
|