@kalel1500/kalion-js 0.14.0-beta.1 → 0.15.1-beta.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/dist/kalion-js.common.js +50 -76
- package/dist/kalion-js.common.js.map +1 -1
- package/dist/kalion-js.d.ts +21 -28
- package/dist/kalion-js.js +50 -75
- package/dist/kalion-js.js.map +1 -1
- package/package.json +1 -1
package/dist/kalion-js.common.js
CHANGED
|
@@ -440,22 +440,6 @@ var Component = class {
|
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
442
|
//#endregion
|
|
443
|
-
//#region src/app/exceptions/CannotOpenModalException.ts
|
|
444
|
-
var CannotOpenModalException = class extends Error {
|
|
445
|
-
constructor(msg) {
|
|
446
|
-
super(msg);
|
|
447
|
-
this.name = "CannotOpenModalException";
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region src/app/exceptions/CannotOpenModalWarning.ts
|
|
452
|
-
var CannotOpenModalWarning = class extends Error {
|
|
453
|
-
constructor(msg) {
|
|
454
|
-
super(msg);
|
|
455
|
-
this.name = "CannotOpenModalWarning";
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
//#endregion
|
|
459
443
|
//#region src/app/exceptions/InvalidValueException.ts
|
|
460
444
|
var InvalidValueException = class extends Error {
|
|
461
445
|
constructor(message) {
|
|
@@ -508,7 +492,8 @@ var FModal = class FModal {
|
|
|
508
492
|
$modalElement;
|
|
509
493
|
$spinnerElements;
|
|
510
494
|
$messageElements;
|
|
511
|
-
static
|
|
495
|
+
static registryAbortClick = /* @__PURE__ */ new Map();
|
|
496
|
+
static registryAbortChange = /* @__PURE__ */ new Map();
|
|
512
497
|
static registryModal = /* @__PURE__ */ new Map();
|
|
513
498
|
constructor(id, options) {
|
|
514
499
|
this.id = id;
|
|
@@ -549,8 +534,10 @@ var FModal = class FModal {
|
|
|
549
534
|
...options?.instanceOptions
|
|
550
535
|
});
|
|
551
536
|
this.removeListener();
|
|
552
|
-
const
|
|
553
|
-
|
|
537
|
+
const abortControllerClick = new AbortController();
|
|
538
|
+
const abortControllerChange = new AbortController();
|
|
539
|
+
FModal.registryAbortClick.set(id, abortControllerClick);
|
|
540
|
+
FModal.registryAbortChange.set(id, abortControllerChange);
|
|
554
541
|
FModal.registryModal.set(id, this.modal);
|
|
555
542
|
this.$modalElement?.addEventListener("click", async (e) => {
|
|
556
543
|
const target = e.target;
|
|
@@ -578,7 +565,11 @@ var FModal = class FModal {
|
|
|
578
565
|
}
|
|
579
566
|
}
|
|
580
567
|
if (options?.onModalClick) options?.onModalClick(this, target);
|
|
581
|
-
}, { signal:
|
|
568
|
+
}, { signal: abortControllerClick.signal });
|
|
569
|
+
this.$modalElement?.addEventListener("change", async (e) => {
|
|
570
|
+
const target = e.target;
|
|
571
|
+
if (options?.onModalChange) options?.onModalChange(this, target);
|
|
572
|
+
}, { signal: abortControllerChange.signal });
|
|
582
573
|
}
|
|
583
574
|
hide() {
|
|
584
575
|
this.modal.hide();
|
|
@@ -599,10 +590,15 @@ var FModal = class FModal {
|
|
|
599
590
|
FModal.removeListener(this.id);
|
|
600
591
|
}
|
|
601
592
|
static removeListener(id) {
|
|
602
|
-
const
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
FModal.
|
|
593
|
+
const abortControllerClick = FModal.registryAbortClick.get(id);
|
|
594
|
+
if (abortControllerClick) {
|
|
595
|
+
abortControllerClick.abort();
|
|
596
|
+
FModal.registryAbortClick.delete(id);
|
|
597
|
+
}
|
|
598
|
+
const abortControllerChange = FModal.registryAbortChange.get(id);
|
|
599
|
+
if (abortControllerChange) {
|
|
600
|
+
abortControllerChange.abort();
|
|
601
|
+
FModal.registryAbortChange.delete(id);
|
|
606
602
|
}
|
|
607
603
|
}
|
|
608
604
|
showMessage({ message, type, autoHide = false, hideAfter = 3e3 }) {
|
|
@@ -4441,26 +4437,20 @@ var SModal = class SModal {
|
|
|
4441
4437
|
static colorRed = "#d33";
|
|
4442
4438
|
static colorGray = "#aaa";
|
|
4443
4439
|
static isPendingLoading = false;
|
|
4444
|
-
static
|
|
4445
|
-
if (g.errorModalIsShowed)
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
return callback();
|
|
4451
|
-
} catch (e) {
|
|
4452
|
-
if (e instanceof CannotOpenModalException || e instanceof CannotOpenModalWarning) g.consoleInfo(e.message);
|
|
4453
|
-
else throw e;
|
|
4454
|
-
return Promise.reject();
|
|
4440
|
+
static tryOpen(callback, { isUpdate = false, ignorePendingLoading = false } = {}) {
|
|
4441
|
+
if (g.errorModalIsShowed) {
|
|
4442
|
+
g.consoleInfo("Se ha intentado abrir un modal cuando hay un modal de error abierto");
|
|
4443
|
+
const rejected = Promise.reject();
|
|
4444
|
+
rejected.catch(() => {});
|
|
4445
|
+
return rejected;
|
|
4455
4446
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
if (e instanceof CannotOpenModalException || e instanceof CannotOpenModalWarning) g.consoleInfo(e.message);
|
|
4462
|
-
else throw e;
|
|
4447
|
+
if (!ignorePendingLoading && !isUpdate && SModal.isPendingLoading) {
|
|
4448
|
+
g.consoleInfo("Se ha intentado abrir un modal cuando hay un modal de loading pendiente");
|
|
4449
|
+
const rejected = Promise.reject();
|
|
4450
|
+
rejected.catch(() => {});
|
|
4451
|
+
return rejected;
|
|
4463
4452
|
}
|
|
4453
|
+
return callback();
|
|
4464
4454
|
}
|
|
4465
4455
|
static Toast = import_sweetalert2.default.mixin({
|
|
4466
4456
|
toast: true,
|
|
@@ -4474,8 +4464,7 @@ var SModal = class SModal {
|
|
|
4474
4464
|
}
|
|
4475
4465
|
});
|
|
4476
4466
|
static toastInfo(options = {}) {
|
|
4477
|
-
return
|
|
4478
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4467
|
+
return this.tryOpen(() => {
|
|
4479
4468
|
return SModal.Toast.fire({
|
|
4480
4469
|
icon: "info",
|
|
4481
4470
|
title: "Your work has been saved",
|
|
@@ -4484,8 +4473,7 @@ var SModal = class SModal {
|
|
|
4484
4473
|
});
|
|
4485
4474
|
}
|
|
4486
4475
|
static toastSuccess(options = {}) {
|
|
4487
|
-
return
|
|
4488
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4476
|
+
return this.tryOpen(() => {
|
|
4489
4477
|
return SModal.Toast.fire({
|
|
4490
4478
|
icon: "success",
|
|
4491
4479
|
title: "Your work has been saved",
|
|
@@ -4494,8 +4482,7 @@ var SModal = class SModal {
|
|
|
4494
4482
|
});
|
|
4495
4483
|
}
|
|
4496
4484
|
static toastError(options = {}) {
|
|
4497
|
-
return
|
|
4498
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4485
|
+
return this.tryOpen(() => {
|
|
4499
4486
|
return SModal.Toast.fire({
|
|
4500
4487
|
icon: "error",
|
|
4501
4488
|
title: "Something error occurred",
|
|
@@ -4504,8 +4491,7 @@ var SModal = class SModal {
|
|
|
4504
4491
|
});
|
|
4505
4492
|
}
|
|
4506
4493
|
static toastBottom(options = {}) {
|
|
4507
|
-
return
|
|
4508
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4494
|
+
return this.tryOpen(() => {
|
|
4509
4495
|
return SModal.Toast.fire({
|
|
4510
4496
|
icon: "success",
|
|
4511
4497
|
title: "Your work has been saved",
|
|
@@ -4520,8 +4506,7 @@ var SModal = class SModal {
|
|
|
4520
4506
|
* del objeto los sobreescribe directamente.
|
|
4521
4507
|
*/
|
|
4522
4508
|
static toastBoth({ success, iconOk = "success", iconNok = "error", titleOk = "Your work has been saved", titleNok = "Something error occurred", timerOk = 3e3, timerNok = 4e3, ...swalOptions }) {
|
|
4523
|
-
return
|
|
4524
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4509
|
+
return this.tryOpen(() => {
|
|
4525
4510
|
return SModal.Toast.fire({
|
|
4526
4511
|
icon: success ? iconOk : iconNok,
|
|
4527
4512
|
title: success ? titleOk : titleNok,
|
|
@@ -4532,14 +4517,12 @@ var SModal = class SModal {
|
|
|
4532
4517
|
});
|
|
4533
4518
|
}
|
|
4534
4519
|
static basic(options = {}) {
|
|
4535
|
-
return
|
|
4536
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4520
|
+
return this.tryOpen(() => {
|
|
4537
4521
|
return import_sweetalert2.default.fire(options);
|
|
4538
4522
|
});
|
|
4539
4523
|
}
|
|
4540
4524
|
static success(options = {}) {
|
|
4541
|
-
return
|
|
4542
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4525
|
+
return this.tryOpen(() => {
|
|
4543
4526
|
return import_sweetalert2.default.fire({
|
|
4544
4527
|
icon: "success",
|
|
4545
4528
|
title: "Correcto",
|
|
@@ -4552,8 +4535,7 @@ var SModal = class SModal {
|
|
|
4552
4535
|
});
|
|
4553
4536
|
}
|
|
4554
4537
|
static error(options = {}, ignorePendingLoading = false) {
|
|
4555
|
-
return
|
|
4556
|
-
SModal.mustAbortIfIsAlreadyOpen({ ignorePendingLoading });
|
|
4538
|
+
return this.tryOpen(() => {
|
|
4557
4539
|
return import_sweetalert2.default.fire({
|
|
4558
4540
|
icon: "error",
|
|
4559
4541
|
title: "Ups... Algo ha ido mal",
|
|
@@ -4563,11 +4545,10 @@ var SModal = class SModal {
|
|
|
4563
4545
|
allowOutsideClick: false,
|
|
4564
4546
|
...options
|
|
4565
4547
|
});
|
|
4566
|
-
});
|
|
4548
|
+
}, { ignorePendingLoading });
|
|
4567
4549
|
}
|
|
4568
4550
|
static confirm(options = {}) {
|
|
4569
|
-
return
|
|
4570
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4551
|
+
return this.tryOpen(() => {
|
|
4571
4552
|
return import_sweetalert2.default.fire({
|
|
4572
4553
|
title: "Confirmar",
|
|
4573
4554
|
html: "¿Seguro que quieres realizar la acción?",
|
|
@@ -4584,8 +4565,7 @@ var SModal = class SModal {
|
|
|
4584
4565
|
});
|
|
4585
4566
|
}
|
|
4586
4567
|
static loading(options = {}) {
|
|
4587
|
-
return
|
|
4588
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4568
|
+
return this.tryOpen(() => {
|
|
4589
4569
|
SModal.isPendingLoading = true;
|
|
4590
4570
|
const callerWillOpen = options.willOpen;
|
|
4591
4571
|
const willOpen = async (popup) => {
|
|
@@ -4604,8 +4584,7 @@ var SModal = class SModal {
|
|
|
4604
4584
|
});
|
|
4605
4585
|
}
|
|
4606
4586
|
static doActionWhileLoading({ ajaxUrl, ajaxType, ajaxParams, footerOnFail, ...swalOptions }) {
|
|
4607
|
-
return
|
|
4608
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4587
|
+
return this.tryOpen(() => {
|
|
4609
4588
|
SModal.isPendingLoading = true;
|
|
4610
4589
|
return import_sweetalert2.default.fire({
|
|
4611
4590
|
title: "Calculando...",
|
|
@@ -4644,8 +4623,7 @@ var SModal = class SModal {
|
|
|
4644
4623
|
});
|
|
4645
4624
|
}
|
|
4646
4625
|
static confirmAfterFetchSuccess({ ajaxUrl, ajaxType = "GET", ajaxParams, footerOnFail, ...swalOptions }) {
|
|
4647
|
-
return
|
|
4648
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4626
|
+
return this.tryOpen(() => {
|
|
4649
4627
|
return import_sweetalert2.default.fire({
|
|
4650
4628
|
title: "Confirmar",
|
|
4651
4629
|
width: 850,
|
|
@@ -4687,11 +4665,10 @@ var SModal = class SModal {
|
|
|
4687
4665
|
});
|
|
4688
4666
|
}
|
|
4689
4667
|
static update({ hideLoading, ...swalOptions } = {}) {
|
|
4690
|
-
|
|
4691
|
-
SModal.mustAbortIfIsAlreadyOpen({ isUpdate: true });
|
|
4668
|
+
this.tryOpen(() => {
|
|
4692
4669
|
if (hideLoading === true) import_sweetalert2.default.hideLoading();
|
|
4693
4670
|
import_sweetalert2.default.update(swalOptions);
|
|
4694
|
-
});
|
|
4671
|
+
}, { isUpdate: true });
|
|
4695
4672
|
}
|
|
4696
4673
|
static updateSuccess(options = {}) {
|
|
4697
4674
|
SModal.update({
|
|
@@ -4714,8 +4691,7 @@ var SModal = class SModal {
|
|
|
4714
4691
|
});
|
|
4715
4692
|
}
|
|
4716
4693
|
static input({ liveValidationEnabled = false, getValidationMessage = () => null, preConfirm_url, preConfirm_type = "GET", preConfirm_params = {}, preConfirm_inputParamName = void 0, preConfirm_keepOpenOnSuccess = false, preConfirm_ajaxOkCode = void 0, ...swalOptions }) {
|
|
4717
|
-
return
|
|
4718
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4694
|
+
return this.tryOpen(() => {
|
|
4719
4695
|
const inputId = swalOptions.inputAttributes?.["data-id"] ?? "inpName";
|
|
4720
4696
|
const inputType = swalOptions.input ?? "textarea";
|
|
4721
4697
|
const inputPassValidation = (value) => getValidationMessage(value) === null;
|
|
@@ -4801,8 +4777,7 @@ var SModal = class SModal {
|
|
|
4801
4777
|
});
|
|
4802
4778
|
}
|
|
4803
4779
|
static blade({ ajaxUrl, jsActionsInModal = () => {}, funcParam = {}, ...swalOptions }) {
|
|
4804
|
-
return
|
|
4805
|
-
SModal.mustAbortIfIsAlreadyOpen();
|
|
4780
|
+
return this.tryOpen(() => {
|
|
4806
4781
|
return import_sweetalert2.default.fire({
|
|
4807
4782
|
width: 850,
|
|
4808
4783
|
showConfirmButton: false,
|
|
@@ -6493,8 +6468,6 @@ var UtilitiesServiceProvider = class {
|
|
|
6493
6468
|
//#endregion
|
|
6494
6469
|
exports.AlertType = AlertType;
|
|
6495
6470
|
exports.Btn = Btn;
|
|
6496
|
-
exports.CannotOpenModalException = CannotOpenModalException;
|
|
6497
|
-
exports.CannotOpenModalWarning = CannotOpenModalWarning;
|
|
6498
6471
|
exports.CheckableProcess = CheckableProcess;
|
|
6499
6472
|
exports.Component = Component;
|
|
6500
6473
|
exports.Constants = Constants;
|
|
@@ -6529,5 +6502,6 @@ exports.Ttable = Ttable;
|
|
|
6529
6502
|
exports.Url = Url;
|
|
6530
6503
|
exports.UtilitiesServiceProvider = UtilitiesServiceProvider;
|
|
6531
6504
|
exports.g = g;
|
|
6505
|
+
exports.handleFlowbiteInit = handleFlowbiteInit;
|
|
6532
6506
|
|
|
6533
6507
|
//# sourceMappingURL=kalion-js.common.js.map
|