@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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { CloseButton, Flex, Image, Text } from '@ttoss/ui';
|
|
2
|
-
import { Icon, type IconType } from '@ttoss/react-icons';
|
|
3
|
-
|
|
4
|
-
type MultistepHeaderTitledProps = {
|
|
5
|
-
variant: 'titled';
|
|
6
|
-
title: string;
|
|
7
|
-
leftIcon: IconType;
|
|
8
|
-
rightIcon: IconType;
|
|
9
|
-
onLeftIconClick: () => void;
|
|
10
|
-
onRightIconClick: () => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const MultistepHeaderTitled = ({
|
|
14
|
-
title,
|
|
15
|
-
leftIcon,
|
|
16
|
-
onLeftIconClick,
|
|
17
|
-
rightIcon,
|
|
18
|
-
onRightIconClick,
|
|
19
|
-
}: MultistepHeaderTitledProps) => {
|
|
20
|
-
return (
|
|
21
|
-
<Flex
|
|
22
|
-
sx={{
|
|
23
|
-
display: 'flex',
|
|
24
|
-
justifyContent: 'space-between',
|
|
25
|
-
paddingX: 'xl',
|
|
26
|
-
paddingY: 'lg',
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
<Icon icon={leftIcon} onClick={onLeftIconClick} />
|
|
31
|
-
<Text sx={{ fontWeight: 'bold', fontSize: 'lg' }}>{title}</Text>
|
|
32
|
-
<Icon icon={rightIcon} onClick={onRightIconClick} />
|
|
33
|
-
</Flex>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
type MultistepHeaderLogoProps = {
|
|
38
|
-
variant: 'logo';
|
|
39
|
-
src: string;
|
|
40
|
-
onClose?: () => void;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const MultistepHeaderLogo = ({ onClose, src }: MultistepHeaderLogoProps) => {
|
|
44
|
-
return (
|
|
45
|
-
<Flex
|
|
46
|
-
sx={{
|
|
47
|
-
justifyContent: 'space-between',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
paddingX: 'xl',
|
|
50
|
-
paddingY: 'lg',
|
|
51
|
-
}}
|
|
52
|
-
>
|
|
53
|
-
<Image
|
|
54
|
-
width={115}
|
|
55
|
-
height={32}
|
|
56
|
-
sx={{ objectFit: 'cover', width: 115, height: 32 }}
|
|
57
|
-
src={src}
|
|
58
|
-
/>
|
|
59
|
-
{onClose && <CloseButton onClick={onClose} />}
|
|
60
|
-
</Flex>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type MultistepHeaderProps =
|
|
65
|
-
| MultistepHeaderLogoProps
|
|
66
|
-
| MultistepHeaderTitledProps;
|
|
67
|
-
|
|
68
|
-
export const MultistepHeader = (props: MultistepHeaderProps) => {
|
|
69
|
-
if (props.variant === 'logo') {
|
|
70
|
-
return <MultistepHeaderLogo {...props} />;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (props.variant === 'titled') {
|
|
74
|
-
return <MultistepHeaderTitled {...props} />;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return null;
|
|
78
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Flex, Text } from '@ttoss/ui';
|
|
2
|
-
import { Icon } from '@ttoss/react-icons';
|
|
3
|
-
|
|
4
|
-
export type MultistepNavigationProps = {
|
|
5
|
-
amountOfSteps: number;
|
|
6
|
-
currentStepNumber: number;
|
|
7
|
-
onBack: () => void;
|
|
8
|
-
stepsLabel: string[];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const MultistepNavigation = ({
|
|
12
|
-
amountOfSteps,
|
|
13
|
-
currentStepNumber,
|
|
14
|
-
onBack,
|
|
15
|
-
stepsLabel,
|
|
16
|
-
}: MultistepNavigationProps) => {
|
|
17
|
-
return (
|
|
18
|
-
<Flex
|
|
19
|
-
sx={{
|
|
20
|
-
justifyContent: 'space-between',
|
|
21
|
-
marginX: '2xl',
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
<Flex onClick={onBack} sx={{ alignItems: 'center', cursor: 'pointer' }}>
|
|
25
|
-
<Text sx={{ color: '#ACADB7', display: 'flex' }}>
|
|
26
|
-
<Icon icon="nav-left" />
|
|
27
|
-
</Text>
|
|
28
|
-
<Text sx={{ color: '#ACADB7' }}>
|
|
29
|
-
{stepsLabel[currentStepNumber - 2]}
|
|
30
|
-
</Text>
|
|
31
|
-
</Flex>
|
|
32
|
-
|
|
33
|
-
<Text sx={{ alignItems: 'center', color: '#ACADB7' }}>
|
|
34
|
-
{currentStepNumber}/{amountOfSteps}
|
|
35
|
-
</Text>
|
|
36
|
-
</Flex>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Flex, Text } from '@ttoss/ui';
|
|
3
|
-
|
|
4
|
-
type MultistepQuestionProps = {
|
|
5
|
-
question: string;
|
|
6
|
-
fields: React.ReactNode | React.ReactNode[];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const MultistepQuestion = ({
|
|
10
|
-
fields,
|
|
11
|
-
question,
|
|
12
|
-
}: MultistepQuestionProps) => {
|
|
13
|
-
return (
|
|
14
|
-
<Flex
|
|
15
|
-
sx={{
|
|
16
|
-
flexDirection: 'column',
|
|
17
|
-
paddingTop: 'xl',
|
|
18
|
-
paddingX: '2xl',
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<Text sx={{ textAlign: 'center', fontSize: 'lg', marginBottom: 'xl' }}>
|
|
22
|
-
{question}
|
|
23
|
-
</Text>
|
|
24
|
-
|
|
25
|
-
<Flex sx={{ flexDirection: 'column', gap: 'xl' }}>{fields}</Flex>
|
|
26
|
-
</Flex>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MultistepForm, type MultistepFormProps } from './MultistepForm';
|
package/src/index.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export { yupResolver } from '@hookform/resolvers/yup';
|
|
2
|
-
export { yup } from './yup/yup';
|
|
3
|
-
|
|
4
|
-
export { Form } from './Form';
|
|
5
|
-
export { FormErrorMessage } from './FormErrorMessage';
|
|
6
|
-
export { FormField } from './FormField';
|
|
7
|
-
export { FormFieldCheckbox } from './FormFieldCheckbox';
|
|
8
|
-
export { FormFieldCreditCardNumber } from './FormFieldCreditCardNumber';
|
|
9
|
-
export { FormFieldNumericFormat } from './FormFieldNumericFormat';
|
|
10
|
-
export { FormFieldPatternFormat } from './FormFieldPatternFormat';
|
|
11
|
-
export { FormFieldCurrencyInput } from './FormFieldCurrencyInput';
|
|
12
|
-
export { FormFieldInput } from './FormFieldInput';
|
|
13
|
-
export { FormFieldPassword } from './FormFieldPassword';
|
|
14
|
-
export { FormFieldRadio } from './FormFieldRadio';
|
|
15
|
-
export { FormFieldSelect } from './FormFieldSelect';
|
|
16
|
-
export { FormFieldTextarea } from './FormFieldTextarea';
|
|
17
|
-
export { FormGroup, useFormGroup } from './FormGroup';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Export everything from react-hook-form without using export *
|
|
21
|
-
* https://github.com/evanw/esbuild/issues/1737
|
|
22
|
-
*/
|
|
23
|
-
export {
|
|
24
|
-
useForm,
|
|
25
|
-
useFormContext,
|
|
26
|
-
useWatch,
|
|
27
|
-
useFieldArray,
|
|
28
|
-
useController,
|
|
29
|
-
useFormState,
|
|
30
|
-
Controller,
|
|
31
|
-
FormProvider,
|
|
32
|
-
} from 'react-hook-form';
|
|
33
|
-
|
|
34
|
-
// Export types
|
|
35
|
-
export * from 'react-hook-form';
|
package/src/yup/i18n.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defineMessage } from '@ttoss/react-i18n';
|
|
2
|
-
import { setLocale } from 'yup';
|
|
3
|
-
|
|
4
|
-
setLocale({
|
|
5
|
-
mixed: {
|
|
6
|
-
required: defineMessage({
|
|
7
|
-
defaultMessage: 'Field is required',
|
|
8
|
-
description: 'Field is required',
|
|
9
|
-
}),
|
|
10
|
-
notType: ({ type }) => {
|
|
11
|
-
return {
|
|
12
|
-
...defineMessage({
|
|
13
|
-
defaultMessage: 'Invalid Value for Field of type {type}',
|
|
14
|
-
description: 'Invalid Value',
|
|
15
|
-
}),
|
|
16
|
-
values: { type },
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
string: {
|
|
21
|
-
min: ({ min }) => {
|
|
22
|
-
return {
|
|
23
|
-
...defineMessage({
|
|
24
|
-
defaultMessage: 'Field must be at least {min} characters',
|
|
25
|
-
description: 'Min length field',
|
|
26
|
-
}),
|
|
27
|
-
values: { min },
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
});
|
package/src/yup/schema.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as yup from 'yup';
|
|
2
|
-
import { isCnpjValid } from '../Brazil/FormFieldCNPJ';
|
|
3
|
-
/**
|
|
4
|
-
* Need this import to extend yup types on build time.
|
|
5
|
-
*/
|
|
6
|
-
import './typings.d';
|
|
7
|
-
|
|
8
|
-
yup.addMethod(yup.string, 'cnpj', function () {
|
|
9
|
-
return this.test('valid-cnpj', 'Invalid CNPJ', (value) => {
|
|
10
|
-
return isCnpjValid(value);
|
|
11
|
-
});
|
|
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/src/yup/yup.ts
DELETED