@authon/js 0.7.1 → 0.7.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/dist/index.cjs +21 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -809,6 +809,7 @@ var ModalRenderer = class {
|
|
|
809
809
|
showError(message) {
|
|
810
810
|
if (!this.shadowRoot) return;
|
|
811
811
|
this.clearError();
|
|
812
|
+
this.setSubmitLoading(false);
|
|
812
813
|
const errorEl = this.shadowRoot.getElementById("email-form");
|
|
813
814
|
if (errorEl) {
|
|
814
815
|
const errDiv = document.createElement("div");
|
|
@@ -818,6 +819,21 @@ var ModalRenderer = class {
|
|
|
818
819
|
errorEl.appendChild(errDiv);
|
|
819
820
|
}
|
|
820
821
|
}
|
|
822
|
+
setSubmitLoading(loading) {
|
|
823
|
+
if (!this.shadowRoot) return;
|
|
824
|
+
const btn = this.shadowRoot.querySelector(".submit-btn");
|
|
825
|
+
if (!btn) return;
|
|
826
|
+
if (loading) {
|
|
827
|
+
btn.dataset.originalText = btn.textContent || "";
|
|
828
|
+
btn.innerHTML = '<span style="display:inline-flex;align-items:center;gap:6px"><svg width="14" height="14" viewBox="0 0 14 14" style="animation:spin 0.8s linear infinite"><circle cx="7" cy="7" r="5" fill="none" stroke="currentColor" stroke-width="2" opacity="0.3"/><path d="M7 2a5 5 0 0 1 5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></span>';
|
|
829
|
+
btn.disabled = true;
|
|
830
|
+
btn.style.opacity = "0.7";
|
|
831
|
+
} else {
|
|
832
|
+
btn.innerHTML = btn.dataset.originalText || "Continue";
|
|
833
|
+
btn.disabled = false;
|
|
834
|
+
btn.style.opacity = "1";
|
|
835
|
+
}
|
|
836
|
+
}
|
|
821
837
|
showBanner(message, type = "error") {
|
|
822
838
|
if (!this.shadowRoot) return;
|
|
823
839
|
this.clearBanner();
|
|
@@ -1726,6 +1742,7 @@ var ModalRenderer = class {
|
|
|
1726
1742
|
if (form) {
|
|
1727
1743
|
form.addEventListener("submit", (e) => {
|
|
1728
1744
|
e.preventDefault();
|
|
1745
|
+
this.setSubmitLoading(true);
|
|
1729
1746
|
const formData = new FormData(form);
|
|
1730
1747
|
this.onEmailSubmit(
|
|
1731
1748
|
formData.get("email"),
|
|
@@ -3460,6 +3477,7 @@ var Authon = class {
|
|
|
3460
3477
|
if (isSignUp) {
|
|
3461
3478
|
this.signUpWithEmail(email, password, { turnstileToken }).then((result) => {
|
|
3462
3479
|
if ("needsVerification" in result && result.needsVerification) {
|
|
3480
|
+
this.modal?.setSubmitLoading(false);
|
|
3463
3481
|
this.modal?.showVerificationInput(email, async (code) => {
|
|
3464
3482
|
try {
|
|
3465
3483
|
await this.verifyEmail(email, code);
|
|
@@ -3476,6 +3494,7 @@ var Authon = class {
|
|
|
3476
3494
|
}
|
|
3477
3495
|
}).catch((err) => {
|
|
3478
3496
|
this.modal?.resetTurnstile?.();
|
|
3497
|
+
this.modal?.setSubmitLoading(false);
|
|
3479
3498
|
const msg = err instanceof Error ? err.message : String(err);
|
|
3480
3499
|
this.modal?.showError(msg || "Authentication failed");
|
|
3481
3500
|
this.emit("error", err instanceof Error ? err : new Error(msg));
|
|
@@ -3483,6 +3502,7 @@ var Authon = class {
|
|
|
3483
3502
|
} else {
|
|
3484
3503
|
this.signInWithEmail(email, password, turnstileToken).then((result) => {
|
|
3485
3504
|
if ("needsVerification" in result && result.needsVerification) {
|
|
3505
|
+
this.modal?.setSubmitLoading(false);
|
|
3486
3506
|
this.modal?.showVerificationInput(email, async (code) => {
|
|
3487
3507
|
try {
|
|
3488
3508
|
await this.verifyEmail(email, code);
|
|
@@ -3499,6 +3519,7 @@ var Authon = class {
|
|
|
3499
3519
|
}
|
|
3500
3520
|
}).catch((err) => {
|
|
3501
3521
|
this.modal?.resetTurnstile?.();
|
|
3522
|
+
this.modal?.setSubmitLoading(false);
|
|
3502
3523
|
const msg = err instanceof Error ? err.message : String(err);
|
|
3503
3524
|
this.modal?.showError(msg || "Authentication failed");
|
|
3504
3525
|
this.emit("error", err instanceof Error ? err : new Error(msg));
|