release: WRNexusJS 0.5.10

This commit is contained in:
2026-07-30 13:36:29 +05:30
parent 8fc6f15402
commit d1b0c55b53
159 changed files with 7509 additions and 604 deletions
+27 -5
View File
@@ -415,7 +415,12 @@
}
function toggleItem(state, itemId, button) {
if (state.config.disabled || state.status !== "ready") return;
if (state.config.disabled || (state.status !== "ready" && state.status !== "incorrect")) return;
// An incorrect answer is still the same usable challenge until the server
// expires it or exhausts its attempts. Let the user amend the selection
// immediately and clear the stale error/locked control state.
if (state.status === "incorrect") setStatus(state, "ready", "");
var index = state.selections.indexOf(itemId);
var selected = index >= 0;
@@ -867,10 +872,8 @@
});
}
function onFormSubmit(state, event) {
if (!state.config.required || state.responseToken) return;
event.preventDefault();
event.stopImmediatePropagation();
function passesSubmitGuard(state) {
if (!state.config.required || state.responseToken) return true;
setStatus(state, "incorrect", state.config.requiredMessage);
emit(state, "failure", { code: "missing-input" });
var target =
@@ -878,6 +881,15 @@
state.root.querySelector("[data-captcha-not-robot-button]") ||
state.root.querySelector("[data-captcha-verify]");
if (target && typeof target.focus === "function") target.focus();
return false;
}
function onFormSubmit(state, event) {
// Schema-backed forms run this guard after their ordinary fields validate.
if (state.form && state.form.__wireValidateBound) return;
if (passesSubmitGuard(state)) return;
event.preventDefault();
event.stopImmediatePropagation();
}
function initialize(root) {
@@ -963,6 +975,11 @@
});
if (state.form) {
state.submitGuard = function () {
return passesSubmitGuard(state);
};
state.form.__wireSubmitGuards = state.form.__wireSubmitGuards || [];
state.form.__wireSubmitGuards.push(state.submitGuard);
state.formSubmitListener = function (event) {
onFormSubmit(state, event);
};
@@ -1018,6 +1035,11 @@
if (state.form && state.formSubmitListener) {
state.form.removeEventListener("submit", state.formSubmitListener, true);
}
if (state.form && state.form.__wireSubmitGuards && state.submitGuard) {
state.form.__wireSubmitGuards = state.form.__wireSubmitGuards.filter(function (guard) {
return guard !== state.submitGuard;
});
}
if (state.form && state.formSuccessListener) {
state.form.removeEventListener("wire:success", state.formSuccessListener);
}