diff --git a/cmd/template/advanced/files/htmx/htmx.min.js.tmpl b/cmd/template/advanced/files/htmx/htmx.min.js.tmpl index 39250e01..2489c7d3 100644 --- a/cmd/template/advanced/files/htmx/htmx.min.js.tmpl +++ b/cmd/template/advanced/files/htmx/htmx.min.js.tmpl @@ -65,14 +65,15 @@ var htmx = (function () { ], allowNestedOobSwaps: true, historyRestoreAsHxRequest: true, + reportValidityOfForms: false, }, parseInterval: null, location: location, _: null, - version: "2.0.6", + version: "2.0.7", }; - Q.onLoad = j; - Q.process = Ft; + Q.onLoad = V; + Q.process = Mt; Q.on = xe; Q.off = be; Q.trigger = ae; @@ -80,16 +81,16 @@ var htmx = (function () { Q.find = f; Q.findAll = x; Q.closest = g; - Q.remove = z; + Q.remove = _; Q.addClass = K; Q.removeClass = G; Q.toggleClass = W; Q.takeClass = Z; - Q.swap = $e; - Q.defineExtension = zn; - Q.removeExtension = $n; - Q.logAll = V; - Q.logNone = _; + Q.swap = ze; + Q.defineExtension = _n; + Q.removeExtension = zn; + Q.logAll = j; + Q.logNone = $; Q.parseInterval = d; Q._ = e; const n = { @@ -98,7 +99,7 @@ var htmx = (function () { canAccessLocalStorage: B, findThisElement: Se, filterValues: yn, - swap: $e, + swap: ze, hasAttribute: s, getAttributeValue: a, getClosestAttributeValue: ne, @@ -119,7 +120,7 @@ var htmx = (function () { shouldCancel: ht, triggerEvent: ae, triggerErrorEvent: fe, - withExtensions: jt, + withExtensions: Vt, }; const de = ["get", "post", "put", "delete", "patch"]; const T = de @@ -311,7 +312,7 @@ var htmx = (function () { } return n; } - function M(t) { + function F(t) { const n = []; if (t) { for (let e = 0; e < t.length; e++) { @@ -327,7 +328,7 @@ var htmx = (function () { } } } - function F(e) { + function M(e) { const t = e.getBoundingClientRect(); const n = t.top; const r = t.bottom; @@ -380,20 +381,20 @@ var htmx = (function () { return eval(e); }); } - function j(t) { + function V(t) { const e = Q.on("htmx:load", function (e) { t(e.detail.elt); }); return e; } - function V() { + function j() { Q.logger = function (e, t, n) { if (console) { console.log(t, e, n); } }; } - function _() { + function $() { Q.logger = null; } function f(e, t) { @@ -413,11 +414,11 @@ var htmx = (function () { function b() { return window; } - function z(e, t) { + function _(e, t) { e = w(e); if (t) { b().setTimeout(function () { - z(e); + _(e); e = null; }, t); } else { @@ -427,7 +428,7 @@ var htmx = (function () { function ce(e) { return e instanceof Element ? e : null; } - function $(e) { + function z(e) { return e instanceof HTMLElement ? e : null; } function J(e) { @@ -568,7 +569,7 @@ var htmx = (function () { if (s.length > 0) { const e = s.join(","); const c = p(y(t, !!n)); - i.push(...M(c.querySelectorAll(e))); + i.push(...F(c.querySelectorAll(e))); } return i; } @@ -682,7 +683,7 @@ var htmx = (function () { return Q.config.attributesToSettle.includes(e); } function Oe(t, n) { - ie(t.attributes, function (e) { + ie(Array.from(t.attributes), function (e) { if (!n.hasAttribute(e.name) && Ce(e.name)) { t.removeAttribute(e.name); } @@ -735,7 +736,7 @@ var htmx = (function () { e = r.target; if (r.shouldSwap) { qe(t); - _e(s, e, e, t, i); + $e(s, e, e, t, i); Te(); } ie(i.elts, function (e) { @@ -802,14 +803,14 @@ var htmx = (function () { function Le(e) { return function () { G(e, Q.config.addedClass); - Ft(ce(e)); + Mt(ce(e)); Ne(p(e)); ae(e, "htmx:load"); }; } function Ne(e) { const t = "[autofocus]"; - const n = $(h(e, t) ? e : e.querySelector(t)); + const n = z(h(e, t) ? e : e.querySelector(t)); if (n != null) { n.focus(); } @@ -877,9 +878,9 @@ var htmx = (function () { S(e); }); } - function Me(t, e, n) { + function Fe(t, e, n) { if (t.tagName === "BODY") { - return Ve(t, e, n); + return je(t, e, n); } let r; const o = t.previousSibling; @@ -905,7 +906,7 @@ var htmx = (function () { S(t); t.remove(); } - function Fe(e, t, n) { + function Me(e, t, n) { return c(e, e.firstChild, t, n); } function Xe(e, t, n) { @@ -917,14 +918,14 @@ var htmx = (function () { function Ue(e, t, n) { return c(u(e), e.nextSibling, t, n); } - function je(e) { + function Ve(e) { S(e); const t = u(e); if (t) { return t.removeChild(e); } } - function Ve(e, t, n) { + function je(e, t, n) { const r = e.firstChild; c(e, r, t, n); if (r) { @@ -936,15 +937,15 @@ var htmx = (function () { e.removeChild(r); } } - function _e(t, e, n, r, o) { + function $e(t, e, n, r, o) { switch (t) { case "none": return; case "outerHTML": - Me(n, r, o); + Fe(n, r, o); return; case "afterbegin": - Fe(n, r, o); + Me(n, r, o); return; case "beforebegin": Xe(n, r, o); @@ -956,7 +957,7 @@ var htmx = (function () { Ue(n, r, o); return; case "delete": - je(n); + Ve(n); return; default: var i = Jn(e); @@ -983,13 +984,13 @@ var htmx = (function () { } } if (t === "innerHTML") { - Ve(n, r, o); + je(n, r, o); } else { - _e(Q.config.defaultSwapStyle, e, n, r, o); + $e(Q.config.defaultSwapStyle, e, n, r, o); } } } - function ze(e, n, r) { + function _e(e, n, r) { var t = x(e, "[hx-swap-oob], [data-hx-swap-oob]"); ie(t, function (e) { if (Q.config.allowNestedOobSwaps || e.parentElement === null) { @@ -1004,7 +1005,7 @@ var htmx = (function () { }); return t.length > 0; } - function $e(h, d, p, g) { + function ze(h, d, p, g) { if (!g) { g = {}; } @@ -1045,9 +1046,9 @@ var htmx = (function () { } } } - ze(n, o, r); + _e(n, o, r); ie(x(n, "template"), function (e) { - if (e.content && ze(e.content, o, r)) { + if (e.content && _e(e.content, o, r)) { e.remove(); } }); @@ -1059,7 +1060,7 @@ var htmx = (function () { n = u; } qe(n); - _e(p.swapStyle, g.contextElement, h, n, o); + $e(p.swapStyle, g.contextElement, h, n, o); Te(); } if (t.elt && !se(t.elt) && ee(t.elt, "id")) { @@ -1470,21 +1471,16 @@ var htmx = (function () { } } function ht(e, t) { - if (e.type === "submit" || e.type === "click") { - t = ce(e.target) || t; - if (t.tagName === "FORM") { - return true; - } - if (t.form && t.type === "submit") { + if (e.type === "submit" && t.tagName === "FORM") { + return true; + } else if (e.type === "click") { + const n = t.closest('input[type="submit"], button'); + if (n && n.form && n.type === "submit") { return true; } - t = t.closest("a"); - if ( - t && - t.href && - (t.getAttribute("href") === "#" || - t.getAttribute("href").indexOf("#") !== 0) - ) { + const r = t.closest("a"); + const o = /^#.+/; + if (r && r.href && !o.test(r.getAttribute("href"))) { return true; } } @@ -1539,7 +1535,7 @@ var htmx = (function () { if (dt(l, e)) { return; } - if (f || ht(e, l)) { + if (f || ht(e, i)) { e.preventDefault(); } if (pt(u, l, e)) { @@ -1633,7 +1629,7 @@ var htmx = (function () { } } function bt(e) { - if (!s(e, "data-hx-revealed") && F(e)) { + if (!s(e, "data-hx-revealed") && M(e)) { e.setAttribute("data-hx-revealed", "true"); const t = oe(e); if (t.initHash) { @@ -1767,8 +1763,8 @@ var htmx = (function () { const n = ", [hx-boost] a, [data-hx-boost] a, a[hx-boost], a[data-hx-boost]"; const r = []; - for (const i in Vn) { - const s = Vn[i]; + for (const i in jn) { + const s = jn[i]; if (s.getSelectors) { var t = s.getSelectors(); if (t) { @@ -1816,6 +1812,9 @@ var htmx = (function () { return; } const n = Lt(t); + if (!n) { + return; + } return oe(n); } function It(e) { @@ -1885,7 +1884,7 @@ var htmx = (function () { n.firstInitCompleted = true; ae(t, "htmx:afterProcessNode"); } - function Mt(e) { + function Ft(e) { if (!(e instanceof Element)) { return false; } @@ -1898,14 +1897,14 @@ var htmx = (function () { } return false; } - function Ft(e) { + function Mt(e) { e = w(e); if (ft(e)) { S(e); return; } const t = []; - if (Mt(e)) { + if (Ft(e)) { t.push(e); } ie(Ht(e), function (e) { @@ -1913,7 +1912,7 @@ var htmx = (function () { S(e); return; } - if (Mt(e)) { + if (Ft(e)) { t.push(e); } }); @@ -1937,7 +1936,7 @@ var htmx = (function () { function Ut(e) { return e === "htmx:afterProcessNode"; } - function jt(e, t, n) { + function Vt(e, t, n) { ie(Jn(e, [], n), function (e) { try { t(e); @@ -1969,23 +1968,23 @@ var htmx = (function () { const s = Bt(i, r.detail); o = o && e.dispatchEvent(s); } - jt(ce(e), function (e) { + Vt(ce(e), function (e) { o = o && e.onEvent(t, r) !== false && !r.defaultPrevented; }); return o; } - let Vt = location.pathname + location.search; - function _t(e) { - Vt = e; + let jt = location.pathname + location.search; + function $t(e) { + jt = e; if (B()) { sessionStorage.setItem("htmx-current-path-for-history", e); } } - function zt() { + function _t() { const e = te().querySelector("[hx-history-elt],[data-hx-history-elt]"); return e || te().body; } - function $t(t, e) { + function zt(t, e) { if (!B()) { return; } @@ -2045,8 +2044,8 @@ var htmx = (function () { return n.innerHTML; } function Gt() { - const e = zt(); - let t = Vt; + const e = _t(); + let t = jt; if (B()) { t = sessionStorage.getItem("htmx-current-path-for-history"); } @@ -2056,7 +2055,7 @@ var htmx = (function () { ); if (!n) { ae(te().body, "htmx:beforeHistorySave", { path: t, historyElt: e }); - $t(t, e); + zt(t, e); } if (Q.config.historyEnabled) history.replaceState({ htmx: true }, te().title, location.href); @@ -2071,11 +2070,11 @@ var htmx = (function () { if (Q.config.historyEnabled) { history.pushState({ htmx: true }, "", e); } - _t(e); + $t(e); } function Zt(e) { if (Q.config.historyEnabled) history.replaceState({ htmx: true }, "", e); - _t(e); + $t(e); } function Yt(e) { ie(e, function (e) { @@ -2085,7 +2084,7 @@ var htmx = (function () { function Qt(e) { const t = new XMLHttpRequest(); const n = { swapStyle: "innerHTML", swapDelay: 0, settleDelay: 0 }; - const r = { path: e, xhr: t, historyElt: zt(), swapSpec: n }; + const r = { path: e, xhr: t, historyElt: _t(), swapSpec: n }; t.open("GET", e, true); if (Q.config.historyRestoreAsHxRequest) { t.setRequestHeader("HX-Request", "true"); @@ -2096,11 +2095,11 @@ var htmx = (function () { if (this.status >= 200 && this.status < 400) { r.response = this.response; ae(te().body, "htmx:historyCacheMissLoad", r); - $e(r.historyElt, r.response, n, { + ze(r.historyElt, r.response, n, { contextElement: r.historyElt, historyRequest: true, }); - _t(r.path); + $t(r.path); ae(te().body, "htmx:historyRestore", { path: e, cacheMiss: true, @@ -2125,13 +2124,13 @@ var htmx = (function () { settleDelay: 0, scroll: t.scroll, }; - const r = { path: e, item: t, historyElt: zt(), swapSpec: n }; + const r = { path: e, item: t, historyElt: _t(), swapSpec: n }; if (ae(te().body, "htmx:historyCacheHit", r)) { - $e(r.historyElt, t.content, n, { + ze(r.historyElt, t.content, n, { contextElement: r.historyElt, title: t.title, }); - _t(r.path); + $t(r.path); ae(te().body, "htmx:historyRestore", r); } } else { @@ -2244,12 +2243,12 @@ var htmx = (function () { } function un(e) { if (e instanceof HTMLSelectElement && e.multiple) { - return M(e.querySelectorAll("option:checked")).map(function (e) { + return F(e.querySelectorAll("option:checked")).map(function (e) { return e.value; }); } if (e instanceof HTMLInputElement && e.files) { - return M(e.files); + return F(e.files); } return e.value; } @@ -2290,11 +2289,17 @@ var htmx = (function () { if (n.willValidate) { ae(n, "htmx:validation:validate"); if (!n.checkValidity()) { + if ( + ae(n, "htmx:validation:failed", { + message: n.validationMessage, + validity: n.validity, + }) && + !t.length && + Q.config.reportValidityOfForms + ) { + n.reportValidity(); + } t.push({ elt: n, message: n.validationMessage, validity: n.validity }); - ae(n, "htmx:validation:failed", { - message: n.validationMessage, - validity: n.validity, - }); } } } @@ -2473,7 +2478,7 @@ var htmx = (function () { } function wn(t, n, r) { let o = null; - jt(n, function (e) { + Vt(n, function (e) { if (o == null) { o = e.encodeParameters(t, r, n); } @@ -2800,8 +2805,8 @@ var htmx = (function () { if (r == null) { r = te().body; } - const M = i.handler || jn; - const F = i.select || null; + const F = i.handler || Vn; + const M = i.select || null; if (!se(r)) { re(s); return e; @@ -2952,12 +2957,12 @@ var htmx = (function () { } const U = dn(r, t); let b = U.errors; - const j = U.formData; + const V = U.formData; if (i.values) { - hn(j, Pn(i.values)); + hn(V, Pn(i.values)); } - const V = Pn(Tn(r, o)); - const v = hn(j, V); + const j = Pn(Tn(r, o)); + const v = hn(V, j); let w = yn(v, r); if (Q.config.getCacheBusterParam && t === "get") { w.set("org.htmx.cache-buster", ee(c, "id") || "true"); @@ -2966,10 +2971,10 @@ var htmx = (function () { n = location.href; } const S = Cn(r, "hx-request"); - const _ = oe(r).boosted; + const $ = oe(r).boosted; let E = Q.config.methodsThatUseUrlParams.indexOf(t) >= 0; const C = { - boosted: _, + boosted: $, useUrlParams: E, formData: w, parameters: kn(w), @@ -3003,12 +3008,12 @@ var htmx = (function () { m(); return e; } - const z = n.split("#"); - const $ = z[0]; - const O = z[1]; + const _ = n.split("#"); + const z = _[0]; + const O = _[1]; let R = n; if (E) { - R = $; + R = z; const Z = !w.keys().next().done; if (Z) { if (R.indexOf("?") < 0) { @@ -3046,8 +3051,8 @@ var htmx = (function () { target: c, requestConfig: C, etc: i, - boosted: _, - select: F, + boosted: $, + select: M, pathInfo: { requestPath: n, finalRequestPath: R, @@ -3059,7 +3064,7 @@ var htmx = (function () { try { const t = Nn(r); H.pathInfo.responsePath = An(g); - M(r, H); + F(r, H); if (H.keepIndicators !== true) { rn(T, q); } @@ -3130,7 +3135,7 @@ var htmx = (function () { g.send(J); return e; } - function Mn(e, t) { + function Fn(e, t) { const n = t.xhr; let r = null; let o = null; @@ -3183,14 +3188,14 @@ var htmx = (function () { return {}; } } - function Fn(e, t) { + function Mn(e, t) { var n = new RegExp(e.code); return n.test(t.toString(10)); } function Xn(e) { for (var t = 0; t < Q.config.responseHandling.length; t++) { var n = Q.config.responseHandling[t]; - if (Fn(n, e.status)) { + if (Mn(n, e.status)) { return n; } } @@ -3217,7 +3222,7 @@ var htmx = (function () { } return n; } - function jn(t, e) { + function Vn(t, e) { const n = e.xhr; let r = e.target; const o = e.etc; @@ -3253,7 +3258,7 @@ var htmx = (function () { Q.location.reload(); return; } - const c = Mn(t, e); + const c = Fn(t, e); const u = Xn(n); const f = u.swap; let a = !!u.error; @@ -3299,7 +3304,7 @@ var htmx = (function () { if (n.status === 286) { lt(t); } - jt(t, function (e) { + Vt(t, function (e) { g = e.transformResponse(g, n, t); }); if (c.type) { @@ -3318,7 +3323,7 @@ var htmx = (function () { } const x = ne(t, "hx-select-oob"); const b = ne(t, "hx-select"); - $e(r, g, y, { + ze(r, g, y, { select: d === "unset" ? null : d || b, selectOOB: x, eventInfo: e, @@ -3373,8 +3378,8 @@ var htmx = (function () { ); } } - const Vn = {}; - function _n() { + const jn = {}; + function $n() { return { init: function (e) { return null; @@ -3399,14 +3404,14 @@ var htmx = (function () { }, }; } - function zn(e, t) { + function _n(e, t) { if (t.init) { t.init(n); } - Vn[e] = le(_n(), t); + jn[e] = le($n(), t); } - function $n(e) { - delete Vn[e]; + function zn(e) { + delete jn[e]; } function Jn(e, n, r) { if (n == undefined) { @@ -3427,7 +3432,7 @@ var htmx = (function () { return; } if (r.indexOf(e) < 0) { - const t = Vn[e]; + const t = jn[e]; if (t && n.indexOf(t) < 0) { n.push(t); } @@ -3452,21 +3457,14 @@ var htmx = (function () { const e = Q.config.inlineStyleNonce ? ` nonce="${Q.config.inlineStyleNonce}"` : ""; + const t = Q.config.indicatorClass; + const n = Q.config.requestClass; te().head.insertAdjacentHTML( "beforeend", - " ." + - Q.config.indicatorClass + - "{opacity:0} ." + - Q.config.requestClass + - " ." + - Q.config.indicatorClass + - "{opacity:1; transition: opacity 200ms ease-in;} ." + - Q.config.requestClass + - "." + - Q.config.indicatorClass + - "{opacity:1; transition: opacity 200ms ease-in;} ", + `` + + `.${t}{opacity:0;visibility: hidden} ` + + `.${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}` + + "", ); } } @@ -3488,7 +3486,7 @@ var htmx = (function () { Yn(); Wn(); let e = te().body; - Ft(e); + Mt(e); const t = te().querySelectorAll( "[hx-trigger='restored'],[data-hx-trigger='restored']", );