easy-forms-core 1.1.3 → 1.1.6
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/dist/easy-form.d.ts +79 -2
- package/dist/easy-form.js +469 -13
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +146 -3
- package/dist/index.js +473 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/easy-form.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type FieldType = 'text' | 'email' | 'number' | 'password' | 'textarea' | 'select
|
|
|
5
5
|
/**
|
|
6
6
|
* Tipos de validaciones soportadas
|
|
7
7
|
*/
|
|
8
|
-
type ValidationType = 'required' | 'email' | 'minLength' | 'maxLength' | 'min' | 'max' | 'pattern' | 'custom';
|
|
8
|
+
type ValidationType = 'required' | 'email' | 'minLength' | 'maxLength' | 'min' | 'max' | 'pattern' | 'custom' | 'noInjection';
|
|
9
9
|
/**
|
|
10
10
|
* Operadores de condición
|
|
11
11
|
*/
|
|
@@ -50,10 +50,13 @@ interface CustomValidation extends BaseValidation {
|
|
|
50
50
|
type: 'custom';
|
|
51
51
|
validator: (value: any) => boolean | Promise<boolean>;
|
|
52
52
|
}
|
|
53
|
+
interface NoInjectionValidation extends BaseValidation {
|
|
54
|
+
type: 'noInjection';
|
|
55
|
+
}
|
|
53
56
|
/**
|
|
54
57
|
* Unión de todas las validaciones
|
|
55
58
|
*/
|
|
56
|
-
type Validation = RequiredValidation | EmailValidation | MinLengthValidation | MaxLengthValidation | MinValidation | MaxValidation | PatternValidation | CustomValidation;
|
|
59
|
+
type Validation = RequiredValidation | EmailValidation | MinLengthValidation | MaxLengthValidation | MinValidation | MaxValidation | PatternValidation | CustomValidation | NoInjectionValidation;
|
|
57
60
|
/**
|
|
58
61
|
* Condición individual para campos
|
|
59
62
|
*/
|
|
@@ -109,6 +112,8 @@ interface BaseField {
|
|
|
109
112
|
disabled?: boolean;
|
|
110
113
|
hidden?: boolean;
|
|
111
114
|
description?: string;
|
|
115
|
+
/** Si true, no se aplica validación anti-inyección automática */
|
|
116
|
+
skipInjectionValidation?: boolean;
|
|
112
117
|
dependencies?: FieldDependencies;
|
|
113
118
|
conditionalValidations?: Array<{
|
|
114
119
|
condition: FieldCondition | FieldCondition[];
|
|
@@ -302,6 +307,19 @@ interface FormColors {
|
|
|
302
307
|
* Template names available
|
|
303
308
|
*/
|
|
304
309
|
type TemplateName = 'login' | 'register' | 'otp' | 'contact' | 'password-reset' | 'password-change' | 'profile' | 'checkout' | 'feedback' | 'subscription' | 'booking' | 'review';
|
|
310
|
+
/**
|
|
311
|
+
* Configuración del botón de submit
|
|
312
|
+
*/
|
|
313
|
+
interface SubmitButtonConfig {
|
|
314
|
+
/** Si false, no se muestra el botón (submit programático) */
|
|
315
|
+
visible?: boolean;
|
|
316
|
+
/** Texto del botón (default: "Enviar") */
|
|
317
|
+
text?: string;
|
|
318
|
+
/** Ancho del botón: "auto", "100%", "200px", etc. (default: "auto") */
|
|
319
|
+
width?: string;
|
|
320
|
+
/** Alineación: "left" | "center" | "right" (default: "left") */
|
|
321
|
+
align?: 'left' | 'center' | 'right';
|
|
322
|
+
}
|
|
305
323
|
/**
|
|
306
324
|
* Schema del formulario
|
|
307
325
|
*/
|
|
@@ -309,6 +327,8 @@ interface FormSchema {
|
|
|
309
327
|
fields?: Field[];
|
|
310
328
|
steps?: Step[];
|
|
311
329
|
initialData?: Record<string, any>;
|
|
330
|
+
/** Configuración del botón de submit (también puede definirse vía atributo submit-button) */
|
|
331
|
+
submitButton?: SubmitButtonConfig;
|
|
312
332
|
}
|
|
313
333
|
/**
|
|
314
334
|
* Componente personalizado para inyección
|
|
@@ -339,6 +359,8 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
339
359
|
protected shadow: ShadowRoot;
|
|
340
360
|
private customComponents;
|
|
341
361
|
private isRendering;
|
|
362
|
+
private attemptsLock;
|
|
363
|
+
private lockCountdownInterval;
|
|
342
364
|
static get observedAttributes(): string[];
|
|
343
365
|
constructor();
|
|
344
366
|
/**
|
|
@@ -365,6 +387,30 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
365
387
|
* Establece los campos adicionales para extender el template
|
|
366
388
|
*/
|
|
367
389
|
set templateExtend(value: Field[] | null);
|
|
390
|
+
/**
|
|
391
|
+
* Máximo de intentos antes de bloquear (para AttemptsLock)
|
|
392
|
+
*/
|
|
393
|
+
get maxAttempts(): number | null;
|
|
394
|
+
set maxAttempts(value: number | null);
|
|
395
|
+
/**
|
|
396
|
+
* Duración del bloqueo en minutos (default: 5)
|
|
397
|
+
*/
|
|
398
|
+
get blockDurationMinutes(): number | null;
|
|
399
|
+
set blockDurationMinutes(value: number | null);
|
|
400
|
+
/**
|
|
401
|
+
* Clave para persistir intentos en sessionStorage
|
|
402
|
+
*/
|
|
403
|
+
get attemptsStorageKey(): string | null;
|
|
404
|
+
set attemptsStorageKey(value: string | null);
|
|
405
|
+
/**
|
|
406
|
+
* Configuración del botón de submit (desde atributo o schema)
|
|
407
|
+
*/
|
|
408
|
+
get submitButton(): SubmitButtonConfig | null;
|
|
409
|
+
set submitButton(value: SubmitButtonConfig | null);
|
|
410
|
+
/**
|
|
411
|
+
* Obtiene la configuración efectiva del botón submit (atributo > schema > defaults)
|
|
412
|
+
*/
|
|
413
|
+
private getSubmitButtonConfig;
|
|
368
414
|
/**
|
|
369
415
|
* Se llama cuando el componente se conecta al DOM
|
|
370
416
|
*/
|
|
@@ -373,6 +419,10 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
373
419
|
* Se llama cuando un atributo cambia
|
|
374
420
|
*/
|
|
375
421
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
422
|
+
/**
|
|
423
|
+
* Configura el AttemptsLock según los atributos actuales
|
|
424
|
+
*/
|
|
425
|
+
private setupAttemptsLock;
|
|
376
426
|
/**
|
|
377
427
|
* Maneja el cambio de schema
|
|
378
428
|
*/
|
|
@@ -385,6 +435,11 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
385
435
|
* Renderiza el formulario
|
|
386
436
|
*/
|
|
387
437
|
private render;
|
|
438
|
+
/**
|
|
439
|
+
* Actualiza el overlay de bloqueo por intentos
|
|
440
|
+
*/
|
|
441
|
+
private updateLockOverlay;
|
|
442
|
+
private stopLockCountdown;
|
|
388
443
|
/**
|
|
389
444
|
* Actualiza el overlay de loading sobre el formulario
|
|
390
445
|
*/
|
|
@@ -467,6 +522,28 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
467
522
|
* Resetea el formulario a sus valores iniciales
|
|
468
523
|
*/
|
|
469
524
|
reset(): void;
|
|
525
|
+
/**
|
|
526
|
+
* Incrementa el contador de intentos (para bloqueo por intentos fallidos).
|
|
527
|
+
* El consumidor debe llamar esto cuando la API/login falle.
|
|
528
|
+
*/
|
|
529
|
+
incrementAttempts(): void;
|
|
530
|
+
/**
|
|
531
|
+
* Resetea el contador de intentos y desbloquea el formulario.
|
|
532
|
+
*/
|
|
533
|
+
resetAttempts(): void;
|
|
534
|
+
/**
|
|
535
|
+
* Retorna true si el formulario está bloqueado por intentos.
|
|
536
|
+
*/
|
|
537
|
+
isLocked(): boolean;
|
|
538
|
+
/**
|
|
539
|
+
* Retorna los milisegundos restantes del bloqueo, o 0 si no está bloqueado.
|
|
540
|
+
*/
|
|
541
|
+
getRemainingBlockTimeMs(): number;
|
|
542
|
+
/**
|
|
543
|
+
* Dispara el submit del formulario programáticamente.
|
|
544
|
+
* Útil cuando el botón submit está oculto (visible: false).
|
|
545
|
+
*/
|
|
546
|
+
requestSubmit(): void;
|
|
470
547
|
/**
|
|
471
548
|
* Limpia todos los valores del formulario
|
|
472
549
|
*/
|