@visiion/forms-library 1.0.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.
@@ -0,0 +1,118 @@
1
+ import React from 'react';
2
+ export interface IFormField {
3
+ id: string;
4
+ name: string;
5
+ type: 'radio' | 'text' | 'select' | 'textarea' | 'checkbox' | 'rut' | 'address' | 'subtitle' | 'alert' | 'date' | 'declaration' | 'status';
6
+ label: string;
7
+ value?: string | number | null;
8
+ options?: Array<{
9
+ value: string;
10
+ label: string;
11
+ }>;
12
+ required?: boolean;
13
+ disabled?: boolean;
14
+ placeholder?: string;
15
+ addon?: string;
16
+ minLength?: number;
17
+ maxLength?: number;
18
+ className?: string;
19
+ onSearch?: (value: string | any) => void;
20
+ onAddressChange?: (address: any) => void;
21
+ showMap?: boolean;
22
+ mapHeight?: string;
23
+ validation?: {
24
+ pattern?: string;
25
+ message?: string;
26
+ };
27
+ validations?: Array<{
28
+ type: 'required' | 'min' | 'max' | 'email' | 'pattern' | 'custom';
29
+ params: string[];
30
+ }>;
31
+ tooltip?: string;
32
+ props?: any;
33
+ }
34
+ export interface IFormConfig {
35
+ id: string;
36
+ title: string;
37
+ subtitle?: string;
38
+ description?: string;
39
+ backStep?: string | null;
40
+ showInfoAlert?: boolean;
41
+ steps?: any;
42
+ infoMessage?: {
43
+ type: string | 'info' | 'warning' | 'error';
44
+ message: string | null;
45
+ };
46
+ fields: IFormField[];
47
+ navigation?: {
48
+ containerClass?: string;
49
+ buttons?: {
50
+ key: string;
51
+ direction: string | 'next' | 'back' | 'success' | 'guardar' | 'out';
52
+ label: string;
53
+ onClick: string;
54
+ show: boolean;
55
+ disabled?: boolean;
56
+ className?: string;
57
+ }[];
58
+ };
59
+ validation?: (formData: any) => {
60
+ success: boolean;
61
+ message: string;
62
+ nextStep: string;
63
+ step?: number | undefined;
64
+ } | undefined;
65
+ onNext?: (formData: any) => void;
66
+ onBack?: () => void;
67
+ onOut?: () => void;
68
+ onEnd?: () => void;
69
+ onSearch?: (field: IFormField, value: string, formData: any) => void;
70
+ initialData?: any;
71
+ }
72
+ export interface IStepProps {
73
+ activeStep: number;
74
+ changeActiveStep: (stepValue: number) => void;
75
+ markStepCompleted: (stepValue: number) => void;
76
+ }
77
+ export interface ResponseOnSearch {
78
+ data?: any;
79
+ success?: boolean;
80
+ nextStep?: string | null;
81
+ }
82
+ export interface NavigationButtonProps {
83
+ direction: 'default' | 'next' | 'back' | 'success' | 'guardar' | 'out' | 'out-light';
84
+ onClick: (e: React.FormEvent) => void;
85
+ disabled?: boolean;
86
+ label?: string;
87
+ }
88
+ export interface DynamicInputProps {
89
+ field: IFormField;
90
+ value: any;
91
+ onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
92
+ error?: string;
93
+ }
94
+ export interface InputWrapperProps {
95
+ label?: string;
96
+ error?: string;
97
+ tooltip?: string;
98
+ required?: boolean;
99
+ children: React.ReactNode;
100
+ className?: string;
101
+ }
102
+ export interface StepperContextType {
103
+ stepperData: any | null;
104
+ setStepperData: React.Dispatch<React.SetStateAction<any | null>>;
105
+ resetStepperData: () => void;
106
+ currentDate: Date | null;
107
+ }
108
+ export interface ValidationRule {
109
+ type: 'required' | 'min' | 'max' | 'email' | 'pattern' | 'custom';
110
+ params: string[];
111
+ }
112
+ export interface CommonValidations {
113
+ required: (message?: string) => ValidationRule;
114
+ min: (length: number, message?: string) => ValidationRule;
115
+ max: (length: number, message?: string) => ValidationRule;
116
+ email: (message?: string) => ValidationRule;
117
+ pattern: (regex: string, message?: string) => ValidationRule;
118
+ }
@@ -0,0 +1,13 @@
1
+ export declare function clean(rut: string | unknown): string;
2
+ export declare function formatRut(rut: string): string;
3
+ export declare const serialRegex: RegExp;
4
+ export declare const validateOnlyNumbersAndLetters: (value: string) => boolean;
5
+ export declare function servicioRut(rut: string): string;
6
+ export declare function dgv(T: number): string | number;
7
+ export declare function validate(rut: string): boolean;
8
+ /**
9
+ * Enmascara un RUT ocultando los dígitos del medio
10
+ * @param rut - RUT formateado (ej: "19.178.946-6")
11
+ * @returns RUT enmascarado (ej: "19.178.XXX-6")
12
+ */
13
+ export declare function maskRut(rut: string): string;
@@ -0,0 +1,8 @@
1
+ import * as Yup from 'yup';
2
+ import { IFormField, CommonValidations } from '../types';
3
+ export declare const createValidationSchema: (fields: IFormField[]) => Yup.ObjectSchema<{
4
+ [x: string]: any;
5
+ }, Yup.AnyObject, {
6
+ [x: string]: any;
7
+ }, "">;
8
+ export declare const commonValidations: CommonValidations;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@visiion/forms-library",
3
+ "version": "1.0.0",
4
+ "description": "Librería de componentes de formularios reutilizables",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/Kuantaz/forms-library.git"
15
+ },
16
+ "scripts": {
17
+ "build": "rollup -c",
18
+ "dev": "rollup -c -w",
19
+ "test": "jest",
20
+ "lint": "eslint src --ext .ts,.tsx",
21
+ "format": "prettier --write src/**/*.{ts,tsx}",
22
+ "prepare": "pnpm run build"
23
+ },
24
+ "keywords": [
25
+ "react",
26
+ "forms",
27
+ "components",
28
+ "typescript",
29
+ "ui"
30
+ ],
31
+ "author": "Visiion Team",
32
+ "license": "MIT",
33
+ "peerDependencies": {
34
+ "react": ">=18.0.0",
35
+ "react-dom": ">=18.0.0"
36
+ },
37
+ "dependencies": {
38
+ "@googlemaps/js-api-loader": "^1.16.6",
39
+ "@react-google-maps/api": "^2.19.3",
40
+ "flowbite-react": "^0.10.1",
41
+ "react-icons": "^4.12.0",
42
+ "yup": "^1.6.1"
43
+ },
44
+ "devDependencies": {
45
+ "@rollup/plugin-commonjs": "^25.0.7",
46
+ "@rollup/plugin-node-resolve": "^15.2.3",
47
+ "@rollup/plugin-typescript": "^11.1.5",
48
+ "@types/react": "^18.3.23",
49
+ "@types/react-dom": "^18.3.7",
50
+ "@typescript-eslint/eslint-plugin": "^8.31.0",
51
+ "@typescript-eslint/parser": "^8.31.0",
52
+ "eslint": "^9.25.1",
53
+ "eslint-plugin-react": "^7.33.2",
54
+ "eslint-plugin-react-hooks": "^4.6.0",
55
+ "prettier": "^3.3.2",
56
+ "rollup": "^4.9.4",
57
+ "rollup-plugin-peer-deps-external": "^2.2.4",
58
+ "rollup-plugin-postcss": "^4.0.2",
59
+ "tslib": "^2.8.1",
60
+ "typescript": "^5.2.2"
61
+ },
62
+ "directories": {
63
+ "example": "example"
64
+ },
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "git+https://github.com/Kuantaz/forms-library.git"
68
+ },
69
+ "bugs": {
70
+ "url": "https://github.com/Kuantaz/forms-library/issues"
71
+ },
72
+ "homepage": "https://github.com/Kuantaz/forms-library#readme"
73
+ }