easy-forms-core 1.0.0 → 1.0.2
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 +6 -6
- package/dist/easy-form.d.ts +60 -0
- package/dist/easy-form.js +1037 -31
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +192 -1
- package/dist/index.js +1041 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,11 +20,11 @@ No depende de ningún framework.
|
|
|
20
20
|
## Instalación
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
bun add easy-forms
|
|
23
|
+
bun add easy-forms-core
|
|
24
24
|
# o
|
|
25
|
-
npm install easy-forms
|
|
25
|
+
npm install easy-forms-core
|
|
26
26
|
# o
|
|
27
|
-
pnpm add easy-forms
|
|
27
|
+
pnpm add easy-forms-core
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Uso Básico
|
|
@@ -36,7 +36,7 @@ pnpm add easy-forms
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
```javascript
|
|
39
|
-
import 'easy-forms'
|
|
39
|
+
import 'easy-forms-core'
|
|
40
40
|
|
|
41
41
|
const form = document.querySelector('#form')
|
|
42
42
|
|
|
@@ -62,7 +62,7 @@ form.addEventListener('submit', (event) => {
|
|
|
62
62
|
### React
|
|
63
63
|
|
|
64
64
|
```tsx
|
|
65
|
-
import 'easy-forms'
|
|
65
|
+
import 'easy-forms-core'
|
|
66
66
|
|
|
67
67
|
function MyForm() {
|
|
68
68
|
return (
|
|
@@ -81,7 +81,7 @@ function MyForm() {
|
|
|
81
81
|
|
|
82
82
|
```vue
|
|
83
83
|
<script setup>
|
|
84
|
-
import 'easy-forms'
|
|
84
|
+
import 'easy-forms-core'
|
|
85
85
|
|
|
86
86
|
const schema = {
|
|
87
87
|
fields: [
|
package/dist/easy-form.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ type FieldType = 'text' | 'email' | 'number' | 'password' | 'textarea' | 'select
|
|
|
6
6
|
* Tipos de validaciones soportadas
|
|
7
7
|
*/
|
|
8
8
|
type ValidationType = 'required' | 'email' | 'minLength' | 'maxLength' | 'min' | 'max' | 'pattern' | 'custom';
|
|
9
|
+
/**
|
|
10
|
+
* Operadores de condición
|
|
11
|
+
*/
|
|
12
|
+
type ConditionOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'in' | 'notIn' | 'isEmpty' | 'isNotEmpty' | 'regex';
|
|
9
13
|
/**
|
|
10
14
|
* Validación base
|
|
11
15
|
*/
|
|
@@ -50,6 +54,47 @@ interface CustomValidation extends BaseValidation {
|
|
|
50
54
|
* Unión de todas las validaciones
|
|
51
55
|
*/
|
|
52
56
|
type Validation = RequiredValidation | EmailValidation | MinLengthValidation | MaxLengthValidation | MinValidation | MaxValidation | PatternValidation | CustomValidation;
|
|
57
|
+
/**
|
|
58
|
+
* Condición individual para campos
|
|
59
|
+
*/
|
|
60
|
+
interface FieldCondition {
|
|
61
|
+
field: string;
|
|
62
|
+
operator: ConditionOperator;
|
|
63
|
+
value: any;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Dependencias de un campo
|
|
67
|
+
*/
|
|
68
|
+
interface FieldDependencies {
|
|
69
|
+
show?: FieldCondition | FieldCondition[];
|
|
70
|
+
hide?: FieldCondition | FieldCondition[];
|
|
71
|
+
enable?: FieldCondition | FieldCondition[];
|
|
72
|
+
disable?: FieldCondition | FieldCondition[];
|
|
73
|
+
required?: FieldCondition | FieldCondition[];
|
|
74
|
+
optional?: FieldCondition | FieldCondition[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Tipos de máscaras predefinidas
|
|
78
|
+
*/
|
|
79
|
+
type PredefinedMask = 'phone' | 'phone-us' | 'phone-international' | 'date' | 'date-us' | 'date-eu' | 'credit-card' | 'ssn' | 'zip-code' | 'currency' | 'percentage' | 'time' | 'datetime';
|
|
80
|
+
/**
|
|
81
|
+
* Máscara personalizada con patrón
|
|
82
|
+
*/
|
|
83
|
+
interface CustomMask {
|
|
84
|
+
pattern: string;
|
|
85
|
+
placeholder?: string;
|
|
86
|
+
transform?: (value: string) => string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Configuración de máscara
|
|
90
|
+
*/
|
|
91
|
+
interface MaskConfig {
|
|
92
|
+
type?: PredefinedMask;
|
|
93
|
+
custom?: CustomMask;
|
|
94
|
+
keepFormat?: boolean;
|
|
95
|
+
showMaskOnFocus?: boolean;
|
|
96
|
+
showMaskOnHover?: boolean;
|
|
97
|
+
}
|
|
53
98
|
/**
|
|
54
99
|
* Campo base
|
|
55
100
|
*/
|
|
@@ -64,6 +109,12 @@ interface BaseField {
|
|
|
64
109
|
disabled?: boolean;
|
|
65
110
|
hidden?: boolean;
|
|
66
111
|
description?: string;
|
|
112
|
+
dependencies?: FieldDependencies;
|
|
113
|
+
conditionalValidations?: Array<{
|
|
114
|
+
condition: FieldCondition | FieldCondition[];
|
|
115
|
+
validations: Validation[];
|
|
116
|
+
}>;
|
|
117
|
+
mask?: MaskConfig;
|
|
67
118
|
}
|
|
68
119
|
/**
|
|
69
120
|
* Campo de texto
|
|
@@ -285,6 +336,15 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
285
336
|
* Maneja el cambio de un campo
|
|
286
337
|
*/
|
|
287
338
|
private handleFieldChange;
|
|
339
|
+
private dependencyRenderTimeout;
|
|
340
|
+
/**
|
|
341
|
+
* Re-renderiza campos dependientes
|
|
342
|
+
*/
|
|
343
|
+
private renderDependentFields;
|
|
344
|
+
/**
|
|
345
|
+
* Emite evento de cambio de dependencia
|
|
346
|
+
*/
|
|
347
|
+
private emitDependencyChange;
|
|
288
348
|
/**
|
|
289
349
|
* Maneja el blur de un campo
|
|
290
350
|
*/
|