@reverso/forms 0.1.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 +58 -0
- package/dist/components/Form.d.ts +13 -0
- package/dist/components/Form.d.ts.map +1 -0
- package/dist/components/FormField.d.ts +9 -0
- package/dist/components/FormField.d.ts.map +1 -0
- package/dist/components/FormProgress.d.ts +11 -0
- package/dist/components/FormProgress.d.ts.map +1 -0
- package/dist/components/FormStep.d.ts +11 -0
- package/dist/components/FormStep.d.ts.map +1 -0
- package/dist/components/fields/CheckboxField.d.ts +6 -0
- package/dist/components/fields/CheckboxField.d.ts.map +1 -0
- package/dist/components/fields/DateField.d.ts +6 -0
- package/dist/components/fields/DateField.d.ts.map +1 -0
- package/dist/components/fields/EmailField.d.ts +6 -0
- package/dist/components/fields/EmailField.d.ts.map +1 -0
- package/dist/components/fields/FileField.d.ts +6 -0
- package/dist/components/fields/FileField.d.ts.map +1 -0
- package/dist/components/fields/HiddenField.d.ts +6 -0
- package/dist/components/fields/HiddenField.d.ts.map +1 -0
- package/dist/components/fields/NumberField.d.ts +6 -0
- package/dist/components/fields/NumberField.d.ts.map +1 -0
- package/dist/components/fields/RadioField.d.ts +6 -0
- package/dist/components/fields/RadioField.d.ts.map +1 -0
- package/dist/components/fields/SelectField.d.ts +6 -0
- package/dist/components/fields/SelectField.d.ts.map +1 -0
- package/dist/components/fields/TextField.d.ts +6 -0
- package/dist/components/fields/TextField.d.ts.map +1 -0
- package/dist/components/fields/TextareaField.d.ts +6 -0
- package/dist/components/fields/TextareaField.d.ts.map +1 -0
- package/dist/components/fields/index.d.ts +14 -0
- package/dist/components/fields/index.d.ts.map +1 -0
- package/dist/hooks/useConditionalFields.d.ts +12 -0
- package/dist/hooks/useConditionalFields.d.ts.map +1 -0
- package/dist/hooks/useReversoForm.d.ts +32 -0
- package/dist/hooks/useReversoForm.d.ts.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4959 -0
- package/dist/types.d.ts +115 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validation/buildSchema.d.ts +17 -0
- package/dist/validation/buildSchema.d.ts.map +1 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @reverso/forms
|
|
2
|
+
|
|
3
|
+
Form builder system for Reverso CMS.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @reverso/forms
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Form, useReversoForm } from '@reverso/forms';
|
|
15
|
+
|
|
16
|
+
function ContactForm() {
|
|
17
|
+
const { form, handleSubmit } = useReversoForm({
|
|
18
|
+
fields: [
|
|
19
|
+
{ name: 'name', type: 'text', label: 'Name', required: true },
|
|
20
|
+
{ name: 'email', type: 'email', label: 'Email', required: true },
|
|
21
|
+
{ name: 'message', type: 'textarea', label: 'Message' },
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Form
|
|
27
|
+
form={form}
|
|
28
|
+
onSubmit={handleSubmit(async (data) => {
|
|
29
|
+
await fetch('/api/contact', {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: JSON.stringify(data),
|
|
32
|
+
});
|
|
33
|
+
})}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **10 Field Types**: Text, email, textarea, number, select, checkbox, radio, date, file, hidden
|
|
42
|
+
- **Multi-Step Forms**: Built-in step navigation
|
|
43
|
+
- **Conditional Fields**: Show/hide based on other field values
|
|
44
|
+
- **Validation**: Zod-based with custom rules
|
|
45
|
+
- **Honeypot**: Built-in spam protection
|
|
46
|
+
|
|
47
|
+
## Peer Dependencies
|
|
48
|
+
|
|
49
|
+
- React 18+
|
|
50
|
+
- React DOM 18+
|
|
51
|
+
|
|
52
|
+
## Documentation
|
|
53
|
+
|
|
54
|
+
See [https://reverso.dev/docs/packages/forms](https://reverso.dev/docs/packages/forms)
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form component - main form rendering component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormConfig, FormSubmissionData, FormSubmitResult } from '../types';
|
|
5
|
+
export interface FormProps {
|
|
6
|
+
config: FormConfig;
|
|
7
|
+
onSubmit?: (data: FormSubmissionData) => Promise<FormSubmitResult>;
|
|
8
|
+
defaultValues?: FormSubmissionData;
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function Form({ config, onSubmit, defaultValues, className, children }: FormProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAmB,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAKlG,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnE,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,2CA0JvF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormField component - dispatches to appropriate field type.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Render a form field based on its type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function FormField(props: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=FormField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../src/components/FormField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAC;AAchE;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CAsC9C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormProgress component - shows progress through multi-step forms.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormStepConfig } from '../types';
|
|
5
|
+
export interface FormProgressProps {
|
|
6
|
+
steps: FormStepConfig[];
|
|
7
|
+
currentStep: number;
|
|
8
|
+
onStepClick?: (step: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function FormProgress({ steps, currentStep, onStepClick }: FormProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=FormProgress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormProgress.d.ts","sourceRoot":"","sources":["../../src/components/FormProgress.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,iBAAiB,2CAwClF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormStep component - wrapper for multi-step form content.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormStepConfig } from '../types';
|
|
5
|
+
export interface FormStepProps {
|
|
6
|
+
step: FormStepConfig;
|
|
7
|
+
isActive: boolean;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function FormStep({ step, isActive, children }: FormStepProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
//# sourceMappingURL=FormStep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormStep.d.ts","sourceRoot":"","sources":["../../src/components/FormStep.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,aAAa,kDAYnE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function CheckboxField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=CheckboxField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/CheckboxField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAwBxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/DateField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAsBpF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function EmailField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=EmailField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/EmailField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAuBrF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File upload field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function FileField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=FileField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FileField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAoCpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HiddenField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/HiddenField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,cAAc,2CAE3D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function NumberField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=NumberField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAyBtF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radio field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function RadioField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=RadioField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/RadioField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAkCrF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function SelectField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=SelectField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SelectField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CA+BtF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/TextField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CA0BpF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Textarea field component.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldProps } from '../../types';
|
|
5
|
+
export declare function TextareaField({ field, value, onChange, error, disabled }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=TextareaField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextareaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/TextareaField.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,2CAyBxF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field components barrel export.
|
|
3
|
+
*/
|
|
4
|
+
export { TextField } from './TextField';
|
|
5
|
+
export { EmailField } from './EmailField';
|
|
6
|
+
export { TextareaField } from './TextareaField';
|
|
7
|
+
export { NumberField } from './NumberField';
|
|
8
|
+
export { SelectField } from './SelectField';
|
|
9
|
+
export { CheckboxField } from './CheckboxField';
|
|
10
|
+
export { RadioField } from './RadioField';
|
|
11
|
+
export { DateField } from './DateField';
|
|
12
|
+
export { FileField } from './FileField';
|
|
13
|
+
export { HiddenField } from './HiddenField';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for handling conditional field visibility.
|
|
3
|
+
*/
|
|
4
|
+
import type { FormFieldConfig, FormSubmissionData } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Hook to determine which fields should be visible based on conditional logic.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useConditionalFields(fields: FormFieldConfig[], data: FormSubmissionData): {
|
|
9
|
+
visibleFields: FormFieldConfig[];
|
|
10
|
+
isFieldVisible: (fieldName: string) => boolean;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useConditionalFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConditionalFields.d.ts","sourceRoot":"","sources":["../../src/hooks/useConditionalFields.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAkB,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsDpF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,eAAe,EAAE,EACzB,IAAI,EAAE,kBAAkB,GACvB;IACD,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CAChD,CAsBA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main form hook for @reverso/forms.
|
|
3
|
+
*/
|
|
4
|
+
import { useForm } from 'react-hook-form';
|
|
5
|
+
import type { FormConfig, FormFieldConfig, FormState, FormSubmissionData, FormSubmitResult } from '../types';
|
|
6
|
+
export interface UseReversoFormOptions {
|
|
7
|
+
config: FormConfig;
|
|
8
|
+
onSubmit?: (data: FormSubmissionData) => Promise<FormSubmitResult>;
|
|
9
|
+
defaultValues?: FormSubmissionData;
|
|
10
|
+
}
|
|
11
|
+
export interface UseReversoFormReturn {
|
|
12
|
+
form: ReturnType<typeof useForm>;
|
|
13
|
+
state: FormState;
|
|
14
|
+
currentStep: number;
|
|
15
|
+
totalSteps: number;
|
|
16
|
+
canGoNext: boolean;
|
|
17
|
+
canGoPrev: boolean;
|
|
18
|
+
nextStep: () => void;
|
|
19
|
+
prevStep: () => void;
|
|
20
|
+
goToStep: (step: number) => void;
|
|
21
|
+
visibleFields: FormFieldConfig[];
|
|
22
|
+
currentStepFields: FormFieldConfig[];
|
|
23
|
+
isFieldVisible: (fieldName: string) => boolean;
|
|
24
|
+
handleSubmit: () => void;
|
|
25
|
+
reset: () => void;
|
|
26
|
+
config: FormConfig;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Main hook for using Reverso forms.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useReversoForm({ config, onSubmit, defaultValues, }: UseReversoFormOptions): UseReversoFormReturn;
|
|
32
|
+
//# sourceMappingURL=useReversoForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReversoForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useReversoForm.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAIlB,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnE,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IAEnC,IAAI,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE,SAAS,CAAC;IAGjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAGjC,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,iBAAiB,EAAE,eAAe,EAAE,CAAC;IACrC,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAG/C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,IAAI,CAAC;IAGlB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,aAAkB,GACnB,EAAE,qBAAqB,GAAG,oBAAoB,CAqJ9C"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @reverso/forms
|
|
3
|
+
*
|
|
4
|
+
* Form builder system for Reverso CMS.
|
|
5
|
+
* Create and manage forms with validation, multi-step support, and integrations.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { Form, useReversoForm } from '@reverso/forms';
|
|
10
|
+
*
|
|
11
|
+
* function ContactForm() {
|
|
12
|
+
* return (
|
|
13
|
+
* <Form
|
|
14
|
+
* config={formConfig}
|
|
15
|
+
* onSubmit={async (data) => {
|
|
16
|
+
* const response = await fetch('/api/forms/submit', {
|
|
17
|
+
* method: 'POST',
|
|
18
|
+
* body: JSON.stringify(data),
|
|
19
|
+
* });
|
|
20
|
+
* const result = await response.json();
|
|
21
|
+
* return {
|
|
22
|
+
* success: result.success,
|
|
23
|
+
* message: result.message,
|
|
24
|
+
* };
|
|
25
|
+
* }}
|
|
26
|
+
* />
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const VERSION = "0.0.0";
|
|
32
|
+
export type { FieldCondition, FieldOption, FormConfig, FormFieldConfig, FormFieldProps, FormFieldType, FormSettings, FormState, FormStepConfig, FormSubmissionData, FormSubmitResult, } from './types';
|
|
33
|
+
export { Form } from './components/Form';
|
|
34
|
+
export type { FormProps } from './components/Form';
|
|
35
|
+
export { FormField } from './components/FormField';
|
|
36
|
+
export { FormProgress } from './components/FormProgress';
|
|
37
|
+
export type { FormProgressProps } from './components/FormProgress';
|
|
38
|
+
export { FormStep } from './components/FormStep';
|
|
39
|
+
export type { FormStepProps } from './components/FormStep';
|
|
40
|
+
export { CheckboxField, DateField, EmailField, FileField, HiddenField, NumberField, RadioField, SelectField, TextareaField, TextField, } from './components/fields';
|
|
41
|
+
export { useReversoForm } from './hooks/useReversoForm';
|
|
42
|
+
export type { UseReversoFormOptions, UseReversoFormReturn } from './hooks/useReversoForm';
|
|
43
|
+
export { useConditionalFields } from './hooks/useConditionalFields';
|
|
44
|
+
export { buildFormSchema, validateFormData } from './validation/buildSchema';
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,YAAY,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACZ,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EACL,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,GACV,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
|