@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.js
CHANGED
|
@@ -777,6 +777,7 @@ var ModalRenderer = class {
|
|
|
777
777
|
showError(message) {
|
|
778
778
|
if (!this.shadowRoot) return;
|
|
779
779
|
this.clearError();
|
|
780
|
+
this.setSubmitLoading(false);
|
|
780
781
|
const errorEl = this.shadowRoot.getElementById("email-form");
|
|
781
782
|
if (errorEl) {
|
|
782
783
|
const errDiv = document.createElement("div");
|
|
@@ -786,6 +787,21 @@ var ModalRenderer = class {
|
|
|
786
787
|
errorEl.appendChild(errDiv);
|
|
787
788
|
}
|
|
788
789
|
}
|
|
790
|
+
setSubmitLoading(loading) {
|
|
791
|
+
if (!this.shadowRoot) return;
|
|
792
|
+
const btn = this.shadowRoot.querySelector(".submit-btn");
|
|
793
|
+
if (!btn) return;
|
|
794
|
+
if (loading) {
|
|
795
|
+
btn.dataset.originalText = btn.textContent || "";
|
|
796
|
+
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>';
|
|
797
|
+
btn.disabled = true;
|
|
798
|
+
btn.style.opacity = "0.7";
|
|
799
|
+
} else {
|
|
800
|
+
btn.innerHTML = btn.dataset.originalText || "Continue";
|
|
801
|
+
btn.disabled = false;
|
|
802
|
+
btn.style.opacity = "1";
|
|
803
|
+
}
|
|
804
|
+
}
|
|
789
805
|
showBanner(message, type = "error") {
|
|
790
806
|
if (!this.shadowRoot) return;
|
|
791
807
|
this.clearBanner();
|
|
@@ -1694,6 +1710,7 @@ var ModalRenderer = class {
|
|
|
1694
1710
|
if (form) {
|
|
1695
1711
|
form.addEventListener("submit", (e) => {
|
|
1696
1712
|
e.preventDefault();
|
|
1713
|
+
this.setSubmitLoading(true);
|
|
1697
1714
|
const formData = new FormData(form);
|
|
1698
1715
|
this.onEmailSubmit(
|
|
1699
1716
|
formData.get("email"),
|
|
@@ -3428,6 +3445,7 @@ var Authon = class {
|
|
|
3428
3445
|
if (isSignUp) {
|
|
3429
3446
|
this.signUpWithEmail(email, password, { turnstileToken }).then((result) => {
|
|
3430
3447
|
if ("needsVerification" in result && result.needsVerification) {
|
|
3448
|
+
this.modal?.setSubmitLoading(false);
|
|
3431
3449
|
this.modal?.showVerificationInput(email, async (code) => {
|
|
3432
3450
|
try {
|
|
3433
3451
|
await this.verifyEmail(email, code);
|
|
@@ -3444,6 +3462,7 @@ var Authon = class {
|
|
|
3444
3462
|
}
|
|
3445
3463
|
}).catch((err) => {
|
|
3446
3464
|
this.modal?.resetTurnstile?.();
|
|
3465
|
+
this.modal?.setSubmitLoading(false);
|
|
3447
3466
|
const msg = err instanceof Error ? err.message : String(err);
|
|
3448
3467
|
this.modal?.showError(msg || "Authentication failed");
|
|
3449
3468
|
this.emit("error", err instanceof Error ? err : new Error(msg));
|
|
@@ -3451,6 +3470,7 @@ var Authon = class {
|
|
|
3451
3470
|
} else {
|
|
3452
3471
|
this.signInWithEmail(email, password, turnstileToken).then((result) => {
|
|
3453
3472
|
if ("needsVerification" in result && result.needsVerification) {
|
|
3473
|
+
this.modal?.setSubmitLoading(false);
|
|
3454
3474
|
this.modal?.showVerificationInput(email, async (code) => {
|
|
3455
3475
|
try {
|
|
3456
3476
|
await this.verifyEmail(email, code);
|
|
@@ -3467,6 +3487,7 @@ var Authon = class {
|
|
|
3467
3487
|
}
|
|
3468
3488
|
}).catch((err) => {
|
|
3469
3489
|
this.modal?.resetTurnstile?.();
|
|
3490
|
+
this.modal?.setSubmitLoading(false);
|
|
3470
3491
|
const msg = err instanceof Error ? err.message : String(err);
|
|
3471
3492
|
this.modal?.showError(msg || "Authentication failed");
|
|
3472
3493
|
this.emit("error", err instanceof Error ? err : new Error(msg));
|