easy-forms-core 1.0.7 → 1.0.9
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 +44 -0
- package/dist/easy-form.js +90 -0
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +90 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/easy-form.d.ts
CHANGED
|
@@ -459,6 +459,50 @@ declare class EasyForm extends BrowserHTMLElement {
|
|
|
459
459
|
* Registra componentes personalizados
|
|
460
460
|
*/
|
|
461
461
|
registerComponents(components: ComponentRegistry): void;
|
|
462
|
+
/**
|
|
463
|
+
* Resetea el formulario a sus valores iniciales
|
|
464
|
+
*/
|
|
465
|
+
reset(): void;
|
|
466
|
+
/**
|
|
467
|
+
* Limpia todos los valores del formulario
|
|
468
|
+
*/
|
|
469
|
+
clear(): void;
|
|
470
|
+
/**
|
|
471
|
+
* Obtiene todos los valores del formulario
|
|
472
|
+
*/
|
|
473
|
+
getValues(): Record<string, any>;
|
|
474
|
+
/**
|
|
475
|
+
* Obtiene el valor de un campo específico
|
|
476
|
+
*/
|
|
477
|
+
getValue(fieldName: string): any;
|
|
478
|
+
/**
|
|
479
|
+
* Establece el valor de un campo específico
|
|
480
|
+
*/
|
|
481
|
+
setValue(fieldName: string, value: any): Promise<void>;
|
|
482
|
+
/**
|
|
483
|
+
* Establece múltiples valores a la vez
|
|
484
|
+
*/
|
|
485
|
+
setValues(values: Record<string, any>): Promise<void>;
|
|
486
|
+
/**
|
|
487
|
+
* Valida el formulario completo
|
|
488
|
+
*/
|
|
489
|
+
validate(): Promise<Record<string, string[]>>;
|
|
490
|
+
/**
|
|
491
|
+
* Valida un campo específico
|
|
492
|
+
*/
|
|
493
|
+
validateField(fieldName: string): Promise<string[]>;
|
|
494
|
+
/**
|
|
495
|
+
* Obtiene todos los errores del formulario
|
|
496
|
+
*/
|
|
497
|
+
getErrors(): Record<string, string[]>;
|
|
498
|
+
/**
|
|
499
|
+
* Obtiene los errores de un campo específico
|
|
500
|
+
*/
|
|
501
|
+
getFieldErrors(fieldName: string): string[];
|
|
502
|
+
/**
|
|
503
|
+
* Verifica si el formulario es válido
|
|
504
|
+
*/
|
|
505
|
+
isValid(): boolean;
|
|
462
506
|
/**
|
|
463
507
|
* Obtiene el tema del formulario
|
|
464
508
|
*/
|
package/dist/easy-form.js
CHANGED
|
@@ -272,6 +272,7 @@ function getBaseStyles(colors) {
|
|
|
272
272
|
color: var(--easy-form-text);
|
|
273
273
|
background: var(--easy-form-background);
|
|
274
274
|
transition: all 0.2s ease;
|
|
275
|
+
box-sizing: border-box;
|
|
275
276
|
}
|
|
276
277
|
input[type="checkbox"],
|
|
277
278
|
input[type="radio"] {
|
|
@@ -4497,6 +4498,95 @@ var EasyForm = class extends BrowserHTMLElement {
|
|
|
4497
4498
|
this.customComponents = { ...this.customComponents, ...components };
|
|
4498
4499
|
registerComponents(components);
|
|
4499
4500
|
}
|
|
4501
|
+
/**
|
|
4502
|
+
* Resetea el formulario a sus valores iniciales
|
|
4503
|
+
*/
|
|
4504
|
+
reset() {
|
|
4505
|
+
this.stateManager.reset();
|
|
4506
|
+
this.render();
|
|
4507
|
+
}
|
|
4508
|
+
/**
|
|
4509
|
+
* Limpia todos los valores del formulario
|
|
4510
|
+
*/
|
|
4511
|
+
clear() {
|
|
4512
|
+
const schema = this.schema;
|
|
4513
|
+
const templateName = this.template;
|
|
4514
|
+
let currentSchema = null;
|
|
4515
|
+
if (templateName) {
|
|
4516
|
+
currentSchema = this.getSchemaFromTemplate(templateName);
|
|
4517
|
+
} else {
|
|
4518
|
+
currentSchema = schema;
|
|
4519
|
+
}
|
|
4520
|
+
if (currentSchema) {
|
|
4521
|
+
this.stateManager.initializeSchema(currentSchema, {});
|
|
4522
|
+
this.render();
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Obtiene todos los valores del formulario
|
|
4527
|
+
*/
|
|
4528
|
+
getValues() {
|
|
4529
|
+
return this.stateManager.getState().values;
|
|
4530
|
+
}
|
|
4531
|
+
/**
|
|
4532
|
+
* Obtiene el valor de un campo específico
|
|
4533
|
+
*/
|
|
4534
|
+
getValue(fieldName) {
|
|
4535
|
+
return this.stateManager.getValue(fieldName);
|
|
4536
|
+
}
|
|
4537
|
+
/**
|
|
4538
|
+
* Establece el valor de un campo específico
|
|
4539
|
+
*/
|
|
4540
|
+
async setValue(fieldName, value) {
|
|
4541
|
+
await this.stateManager.setValue(fieldName, value);
|
|
4542
|
+
this.render();
|
|
4543
|
+
}
|
|
4544
|
+
/**
|
|
4545
|
+
* Establece múltiples valores a la vez
|
|
4546
|
+
*/
|
|
4547
|
+
async setValues(values) {
|
|
4548
|
+
for (const [fieldName, value] of Object.entries(values)) {
|
|
4549
|
+
await this.stateManager.setValue(fieldName, value);
|
|
4550
|
+
}
|
|
4551
|
+
this.render();
|
|
4552
|
+
}
|
|
4553
|
+
/**
|
|
4554
|
+
* Valida el formulario completo
|
|
4555
|
+
*/
|
|
4556
|
+
async validate() {
|
|
4557
|
+
const errors = await this.stateManager.validateForm();
|
|
4558
|
+
this.render();
|
|
4559
|
+
if (Object.keys(errors).length > 0) {
|
|
4560
|
+
this.emitError(errors);
|
|
4561
|
+
}
|
|
4562
|
+
return errors;
|
|
4563
|
+
}
|
|
4564
|
+
/**
|
|
4565
|
+
* Valida un campo específico
|
|
4566
|
+
*/
|
|
4567
|
+
async validateField(fieldName) {
|
|
4568
|
+
await this.stateManager.validateField(fieldName);
|
|
4569
|
+
this.updateSingleField(fieldName);
|
|
4570
|
+
return this.stateManager.getErrors(fieldName);
|
|
4571
|
+
}
|
|
4572
|
+
/**
|
|
4573
|
+
* Obtiene todos los errores del formulario
|
|
4574
|
+
*/
|
|
4575
|
+
getErrors() {
|
|
4576
|
+
return this.stateManager.getAllErrors();
|
|
4577
|
+
}
|
|
4578
|
+
/**
|
|
4579
|
+
* Obtiene los errores de un campo específico
|
|
4580
|
+
*/
|
|
4581
|
+
getFieldErrors(fieldName) {
|
|
4582
|
+
return this.stateManager.getErrors(fieldName);
|
|
4583
|
+
}
|
|
4584
|
+
/**
|
|
4585
|
+
* Verifica si el formulario es válido
|
|
4586
|
+
*/
|
|
4587
|
+
isValid() {
|
|
4588
|
+
return this.stateManager.getState().isValid;
|
|
4589
|
+
}
|
|
4500
4590
|
/**
|
|
4501
4591
|
* Obtiene el tema del formulario
|
|
4502
4592
|
*/
|