@livenetworks/ashlar 1.6.0 → 1.6.1
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/js/ln-confirm/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A zero-dependency, ultra-lightweight **Interaction Gate Primitive** (~131 lines
|
|
|
7
7
|
## 🧭 Philosophy & Architecture
|
|
8
8
|
|
|
9
9
|
1. **In-Place Morphing:** Instead of launching heavy, separate dialogs or using frozen, unstyleable `window.confirm()` scripts, confirmation lives **directly on the target button**. It preserves structural styling while using CSS mixins to display temporary labels or icon tooltips.
|
|
10
|
-
2. **Platform Event Release:** `ln-confirm` does not implement a custom `accept` handler. The acceptance is the standard platform `click` event. On the second click, the component steps out of the way
|
|
10
|
+
2. **Platform Event Release:** `ln-confirm` does not implement a custom `accept` handler. The acceptance is the standard platform `click` event. On the second click, the component steps out of the way of the *default action* — form submissions (`type="submit"`), links (`href`), or custom AJAX click listeners execute natively. It does **not** step out of the way of propagation: the click stops at the button on both clicks, so an ancestor click surface never sees it.
|
|
11
11
|
3. **Graceful Auto-Revert:** The gate is timed. When armed, a countdown timer is scheduled. If a second click does not arrive within the window, the button cleanly reverts to its idle text or icon state.
|
|
12
12
|
|
|
13
13
|
---
|
|
@@ -121,9 +121,12 @@ The click handler branches on `this.confirming`.
|
|
|
121
121
|
- `_enterConfirm()`: set `confirming`, write `data-confirming="true"` (CSS hook), swap the button to its confirm presentation (see Modes), schedule the auto-revert timer, dispatch `ln-confirm:waiting`.
|
|
122
122
|
|
|
123
123
|
**Second click** (`confirming === true`) — accept:
|
|
124
|
-
- No `preventDefault
|
|
124
|
+
- No `preventDefault` — the click runs its native default (form submit, link nav, existing handler) unmodified. That is the whole design: insert a checkpoint, then step out.
|
|
125
|
+
- `stopPropagation()` — the click is contained at the button, exactly as on the first click. Without it the accepting click reaches ancestor click surfaces (a clickable card, a row handler) and fires *their* action alongside the confirmed one. Deliberately **not** `stopImmediatePropagation`: same-element listeners are the accept path and must run.
|
|
125
126
|
- `_reset()` runs **synchronously before the handler returns**, so the button is visually reverted in the same frame the action proceeds — no flash of the armed state. A `_submitted` flag guards against a synthetic re-entrant click inside the same handler.
|
|
126
127
|
|
|
128
|
+
Containment covers listener-based ancestors. It does not cover an ancestor `<a href>`: navigation is activation behavior, cancelled only by `preventDefault` — which would also cancel the confirmed action. Don't nest the button inside the anchor; see [ln-link](../ln-link/README.md), which skips clicks originating from `button`.
|
|
129
|
+
|
|
127
130
|
There is deliberately no `ln-confirm:accept` event and no second-click cancel signal — "accept" is just the native click; listen on the form `submit`, the link, or the button `click`.
|
|
128
131
|
|
|
129
132
|
### Construction-time snapshot
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";if(typeof window<"u"){const t=console.warn;console.warn=function(...e){typeof e[0]=="string"&&(e[0].startsWith("[ln-")||e[0].startsWith("[lnCore"))&&!(document.documentElement.hasAttribute("data-ln-debug")||document.body&&document.body.hasAttribute("data-ln-debug"))||t.apply(console,e)}}const p={};function D(t,e){p[t]||(p[t]=document.querySelector('[data-ln-template="'+t+'"]'));const o=p[t];return o?o.content.cloneNode(!0):(console.warn("["+(e||"ln-core")+'] Template "'+t+'" not found'),null)}function M(t,e,o){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:o||{}}))}function C(t,e){if(!t||!e)return t;const o=t.querySelectorAll("[data-ln-field]");for(let i=0;i<o.length;i++){const n=o[i],r=n.getAttribute("data-ln-field");e[r]!=null&&(n.textContent=e[r])}const u=t.querySelectorAll("[data-ln-attr]");for(let i=0;i<u.length;i++){const n=u[i],r=n.getAttribute("data-ln-attr").split(",");for(let s=0;s<r.length;s++){const c=r[s].trim().split(":");if(c.length!==2)continue;const d=c[0].trim(),f=c[1].trim();e[f]!=null&&n.setAttribute(d,e[f])}}const a=t.querySelectorAll("[data-ln-show]");for(let i=0;i<a.length;i++){const n=a[i],r=n.getAttribute("data-ln-show");r in e&&n.classList.toggle("hidden",!e[r])}const l=t.querySelectorAll("[data-ln-class]");for(let i=0;i<l.length;i++){const n=l[i],r=n.getAttribute("data-ln-class").split(",");for(let s=0;s<r.length;s++){const c=r[s].trim().split(":");if(c.length!==2)continue;const d=c[0].trim(),f=c[1].trim();f in e&&n.classList.toggle(d,!!e[f])}}return t}function q(t,e){t.matches&&t.matches("[data-ln-form], [data-ln-fillable]")&&t.dispatchEvent(new CustomEvent("ln-fill",{detail:e??null,bubbles:!0}));const o=t.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let u=0;u<o.length;u++)o[u].dispatchEvent(new CustomEvent("ln-fill",{detail:e??null,bubbles:!0}));return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(t){if(!(!t.target.matches||!t.target.matches("[data-ln-fillable]")))if(t.detail)C(t.target,t.detail);else{const e=t.target.querySelectorAll("[data-ln-field]");for(let o=0;o<e.length;o++)e[o].textContent=""}})));function T(t,e){if(!t||!e)return t;const o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const l=o.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(i,n){return e[n]!==void 0?e[n]:""}))}const u=function(l,i){return e[i]!==void 0?e[i]:""},a=Array.from(t.querySelectorAll("*"));t.nodeType===1&&a.push(t);for(let l=0;l<a.length;l++){const i=a[l],n=i.attributes;for(let r=0;r<n.length;r++){const s=n[r];s.value.indexOf("{{")!==-1&&i.setAttribute(s.name,s.value.replace(/\{\{\s*(\w+)\s*\}\}/g,u))}}return t}function I(t,e,o,u,a,l){const i={};for(let r=0;r<t.children.length;r++){const s=t.children[r],c=s.getAttribute("data-ln-key");c&&(i[c]=s)}const n=document.createDocumentFragment();for(let r=0;r<e.length;r++){const s=e[r],c=String(u(s));let d=i[c];if(d)a(d,s,r);else{const f=D(o,l);if(!f||(T(f,s),d=f.firstElementChild,!d))continue;d.setAttribute("data-ln-key",c),a(d,s,r)}n.appendChild(d)}t.textContent="",t.appendChild(n)}function x(t,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){x(t,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function b(t,e,o,u){if(t.nodeType!==1)return;const l=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",i=Array.from(t.querySelectorAll(l));t.matches&&t.matches(l)&&i.push(t);for(const n of i)n[o]||(n[o]=new u(n))}function N(t,e,o,u,a={}){const l=a.extraAttributes||[],i=a.onAttributeChange||null,n=a.onInit||null;function r(s){const c=s||document.body;b(c,t,e,o),n&&n(c)}return x(function(){const s=new MutationObserver(function(d){for(let f=0;f<d.length;f++){const h=d[f];if(h.type==="childList"){for(let g=0;g<h.addedNodes.length;g++){const m=h.addedNodes[g];m.nodeType===1&&(b(m,t,e,o),n&&n(m))}for(let g=0;g<h.removedNodes.length;g++){const m=h.removedNodes[g];if(m.nodeType===1){const S=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",y=Array.from(m.querySelectorAll(S));m.matches&&m.matches(S)&&y.push(m);for(let A=0;A<y.length;A++){const O=y[A];if(!document.contains(O)){const v=O[e];v&&typeof v.destroy=="function"&&v.destroy()}}}}}else h.type==="attributes"&&(i&&h.target[e]?i(h.target,h.attributeName):(b(h.target,t,e,o),n&&n(h.target)))}});let c=[];if(t.indexOf("[")!==-1){const d=/\[([\w-]+)/g;let f;for(;(f=d.exec(t))!==null;)c.push(f[1])}else c.push(t);s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:c.concat(l)})},u),window[e]=r,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){r(document.body)}):r(document.body),r}const E={};function F(t,e){E[t]=e}function j(t){return E[t]||{ingress:e=>e,egress:e=>e}}const L={};function _(t,e){if(!t||typeof e!="object")return;const o=t.toLowerCase().split("-")[0];L[o]=e}function B(t){if(!t)return null;const e=t.toLowerCase().split("-")[0];return L[e]||null}_("mk",{monthsLong:["јануари","февруари","март","април","мај","јуни","јули","август","септември","октомври","ноември","декември"],monthsShort:["јан","фев","мар","апр","мај","јун","јул","авг","септ","окт","ноем","дек"],daysLong:["недела","понеделник","вторник","среда","четврток","петок","сабота"],daysShort:["нед","пон","вт","ср","чет","пет","саб"]}),typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=F,window.lnCore.getDataMapper=j,window.lnCore.registerLocaleFallback=_,window.lnCore.getLocaleFallback=B,window.lnCore.fillTemplate=T,window.lnCore.fill=C,window.lnCore.lnFill=q,window.lnCore.renderList=I);function k(t){return(t||"").replace(/^#/,"")}function w(t){const e=t===void 0?location.hash:t,o={},u=k(e);if(!u)return o;const a=u.split("&");for(let l=0;l<a.length;l++){const i=a[l];if(!i)continue;const n=i.indexOf(":"),r=n>-1?i.slice(0,n):i,s=n>-1?i.slice(n+1):"";if(r)try{o[r]=decodeURIComponent(s)}catch{o[r]=s}}return o}function W(t){if(!t)return null;const e=w();return t in e?e[t]:null}function H(t,e){if(!t)return;const o=w();e==null?delete o[t]:o[t]=String(e);const a=Object.keys(o).map(function(l){const i=o[l];return i===""?l:l+":"+encodeURIComponent(i)}).join("&");k(location.hash)!==a&&(location.hash=a)}function R(t){return t.button===1||t.ctrlKey||t.metaKey||t.shiftKey?!1:(t.preventDefault(),!0)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=w,window.lnCore.hashGet=W,window.lnCore.hashSet=H,window.lnCore.hashLinkClick=R),(function(){const t="data-ln-confirm",e="lnConfirm",o="data-ln-confirm-timeout";if(window[e]!==void 0)return;function a(...i){(document.documentElement.hasAttribute("data-ln-debug")||document.body&&document.body.hasAttribute("data-ln-debug"))&&console.warn("[ln-confirm]",...i)}function l(i){a("constructor called on",i),this.dom=i,this.confirming=!1,this.revertTimer=null,this._submitted=!1,this.idleEl=i.querySelector("[data-ln-confirm-idle]"),this.activeEl=i.querySelector("[data-ln-confirm-active]"),this.isTwoElementMode=!!(this.idleEl||this.activeEl),this.isTwoElementMode?(this.originalText="",this.confirmText=""):(this.originalText=i.textContent.trim(),this.confirmText=i.getAttribute(t)||"Confirm?");const n=this;return this._onClick=function(r){if(a("click handler, confirming:",n.confirming,"submitted:",n._submitted,"target:",r.target),!n.confirming)r.preventDefault(),r.stopImmediatePropagation(),n._enterConfirm();else{if(n._submitted)return;n._submitted=!0,n._reset()}},i.addEventListener("click",this._onClick),this}l.prototype._getTimeout=function(){const i=parseFloat(this.dom.getAttribute(o));return isNaN(i)||i<=0?3:i},l.prototype._enterConfirm=function(){if(this.confirming=!0,this.dom.setAttribute("data-confirming","true"),this.originalAriaLabel=this.dom.getAttribute("aria-label"),this.originalAriaLive=this.dom.getAttribute("aria-live"),this.isTwoElementMode){this.idleEl&&this.idleEl.setAttribute("hidden","true"),this.activeEl&&this.activeEl.removeAttribute("hidden");const n=this.activeEl?this.activeEl.textContent.trim():"";n&&(this.dom.setAttribute("aria-label",n),this.dom.setAttribute("aria-live","polite"))}else{var i=this.dom.querySelector("svg.ln-icon use");i&&this.originalText===""?(this.isIconButton=!0,this.originalIconHref=i.getAttribute("href"),i.setAttribute("href","#ln-icon-check"),this.dom.classList.add("ln-confirm-tooltip"),this.dom.setAttribute("data-tooltip-text",this.confirmText),this.dom.setAttribute("aria-label",this.confirmText),this.dom.setAttribute("aria-live","polite")):this.dom.textContent=this.confirmText}this._startTimer(),M(this.dom,"ln-confirm:waiting",{target:this.dom})},l.prototype._startTimer=function(){this.revertTimer&&clearTimeout(this.revertTimer);const i=this,n=this._getTimeout()*1e3;this.revertTimer=setTimeout(function(){i._reset()},n)},l.prototype._reset=function(){if(this._submitted=!1,this.confirming=!1,this.dom.removeAttribute("data-confirming"),this.isTwoElementMode)this.idleEl&&this.idleEl.removeAttribute("hidden"),this.activeEl&&this.activeEl.setAttribute("hidden","true");else if(this.isIconButton){var i=this.dom.querySelector("svg.ln-icon use");i&&this.originalIconHref&&i.setAttribute("href",this.originalIconHref),this.dom.classList.remove("ln-confirm-tooltip"),this.dom.removeAttribute("data-tooltip-text"),this.isIconButton=!1,this.originalIconHref=null}else this.dom.textContent=this.originalText;this.originalAriaLabel!==null&&this.originalAriaLabel!==void 0?this.dom.setAttribute("aria-label",this.originalAriaLabel):this.dom.removeAttribute("aria-label"),this.originalAriaLabel=null,this.originalAriaLive!==null&&this.originalAriaLive!==void 0?this.dom.setAttribute("aria-live",this.originalAriaLive):this.dom.removeAttribute("aria-live"),this.originalAriaLive=null,this.revertTimer&&(clearTimeout(this.revertTimer),this.revertTimer=null)},l.prototype.destroy=function(){a("destroy called on",this.dom),this.dom[e]&&(this.confirming&&this._reset(),this.dom.removeEventListener("click",this._onClick),delete this.dom[e])},N(t,e,l,"ln-confirm")})()})();
|
|
1
|
+
(function(){"use strict";if(typeof window<"u"){const t=console.warn;console.warn=function(...e){typeof e[0]=="string"&&(e[0].startsWith("[ln-")||e[0].startsWith("[lnCore"))&&!(document.documentElement.hasAttribute("data-ln-debug")||document.body&&document.body.hasAttribute("data-ln-debug"))||t.apply(console,e)}}const p={};function D(t,e){p[t]||(p[t]=document.querySelector('[data-ln-template="'+t+'"]'));const o=p[t];return o?o.content.cloneNode(!0):(console.warn("["+(e||"ln-core")+'] Template "'+t+'" not found'),null)}function M(t,e,o){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:o||{}}))}function C(t,e){if(!t||!e)return t;const o=t.querySelectorAll("[data-ln-field]");for(let i=0;i<o.length;i++){const n=o[i],r=n.getAttribute("data-ln-field");e[r]!=null&&(n.textContent=e[r])}const u=t.querySelectorAll("[data-ln-attr]");for(let i=0;i<u.length;i++){const n=u[i],r=n.getAttribute("data-ln-attr").split(",");for(let s=0;s<r.length;s++){const c=r[s].trim().split(":");if(c.length!==2)continue;const d=c[0].trim(),f=c[1].trim();e[f]!=null&&n.setAttribute(d,e[f])}}const a=t.querySelectorAll("[data-ln-show]");for(let i=0;i<a.length;i++){const n=a[i],r=n.getAttribute("data-ln-show");r in e&&n.classList.toggle("hidden",!e[r])}const l=t.querySelectorAll("[data-ln-class]");for(let i=0;i<l.length;i++){const n=l[i],r=n.getAttribute("data-ln-class").split(",");for(let s=0;s<r.length;s++){const c=r[s].trim().split(":");if(c.length!==2)continue;const d=c[0].trim(),f=c[1].trim();f in e&&n.classList.toggle(d,!!e[f])}}return t}function q(t,e){t.matches&&t.matches("[data-ln-form], [data-ln-fillable]")&&t.dispatchEvent(new CustomEvent("ln-fill",{detail:e??null,bubbles:!0}));const o=t.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let u=0;u<o.length;u++)o[u].dispatchEvent(new CustomEvent("ln-fill",{detail:e??null,bubbles:!0}));return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(t){if(!(!t.target.matches||!t.target.matches("[data-ln-fillable]")))if(t.detail)C(t.target,t.detail);else{const e=t.target.querySelectorAll("[data-ln-field]");for(let o=0;o<e.length;o++)e[o].textContent=""}})));function T(t,e){if(!t||!e)return t;const o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const l=o.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(i,n){return e[n]!==void 0?e[n]:""}))}const u=function(l,i){return e[i]!==void 0?e[i]:""},a=Array.from(t.querySelectorAll("*"));t.nodeType===1&&a.push(t);for(let l=0;l<a.length;l++){const i=a[l],n=i.attributes;for(let r=0;r<n.length;r++){const s=n[r];s.value.indexOf("{{")!==-1&&i.setAttribute(s.name,s.value.replace(/\{\{\s*(\w+)\s*\}\}/g,u))}}return t}function I(t,e,o,u,a,l){const i={};for(let r=0;r<t.children.length;r++){const s=t.children[r],c=s.getAttribute("data-ln-key");c&&(i[c]=s)}const n=document.createDocumentFragment();for(let r=0;r<e.length;r++){const s=e[r],c=String(u(s));let d=i[c];if(d)a(d,s,r);else{const f=D(o,l);if(!f||(T(f,s),d=f.firstElementChild,!d))continue;d.setAttribute("data-ln-key",c),a(d,s,r)}n.appendChild(d)}t.textContent="",t.appendChild(n)}function x(t,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){x(t,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function b(t,e,o,u){if(t.nodeType!==1)return;const l=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",i=Array.from(t.querySelectorAll(l));t.matches&&t.matches(l)&&i.push(t);for(const n of i)n[o]||(n[o]=new u(n))}function N(t,e,o,u,a={}){const l=a.extraAttributes||[],i=a.onAttributeChange||null,n=a.onInit||null;function r(s){const c=s||document.body;b(c,t,e,o),n&&n(c)}return x(function(){const s=new MutationObserver(function(d){for(let f=0;f<d.length;f++){const h=d[f];if(h.type==="childList"){for(let g=0;g<h.addedNodes.length;g++){const m=h.addedNodes[g];m.nodeType===1&&(b(m,t,e,o),n&&n(m))}for(let g=0;g<h.removedNodes.length;g++){const m=h.removedNodes[g];if(m.nodeType===1){const S=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",y=Array.from(m.querySelectorAll(S));m.matches&&m.matches(S)&&y.push(m);for(let A=0;A<y.length;A++){const O=y[A];if(!document.contains(O)){const v=O[e];v&&typeof v.destroy=="function"&&v.destroy()}}}}}else h.type==="attributes"&&(i&&h.target[e]?i(h.target,h.attributeName):(b(h.target,t,e,o),n&&n(h.target)))}});let c=[];if(t.indexOf("[")!==-1){const d=/\[([\w-]+)/g;let f;for(;(f=d.exec(t))!==null;)c.push(f[1])}else c.push(t);s.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:c.concat(l)})},u),window[e]=r,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){r(document.body)}):r(document.body),r}const E={};function F(t,e){E[t]=e}function j(t){return E[t]||{ingress:e=>e,egress:e=>e}}const L={};function _(t,e){if(!t||typeof e!="object")return;const o=t.toLowerCase().split("-")[0];L[o]=e}function B(t){if(!t)return null;const e=t.toLowerCase().split("-")[0];return L[e]||null}_("mk",{monthsLong:["јануари","февруари","март","април","мај","јуни","јули","август","септември","октомври","ноември","декември"],monthsShort:["јан","фев","мар","апр","мај","јун","јул","авг","септ","окт","ноем","дек"],daysLong:["недела","понеделник","вторник","среда","четврток","петок","сабота"],daysShort:["нед","пон","вт","ср","чет","пет","саб"]}),typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=F,window.lnCore.getDataMapper=j,window.lnCore.registerLocaleFallback=_,window.lnCore.getLocaleFallback=B,window.lnCore.fillTemplate=T,window.lnCore.fill=C,window.lnCore.lnFill=q,window.lnCore.renderList=I);function k(t){return(t||"").replace(/^#/,"")}function w(t){const e=t===void 0?location.hash:t,o={},u=k(e);if(!u)return o;const a=u.split("&");for(let l=0;l<a.length;l++){const i=a[l];if(!i)continue;const n=i.indexOf(":"),r=n>-1?i.slice(0,n):i,s=n>-1?i.slice(n+1):"";if(r)try{o[r]=decodeURIComponent(s)}catch{o[r]=s}}return o}function W(t){if(!t)return null;const e=w();return t in e?e[t]:null}function H(t,e){if(!t)return;const o=w();e==null?delete o[t]:o[t]=String(e);const a=Object.keys(o).map(function(l){const i=o[l];return i===""?l:l+":"+encodeURIComponent(i)}).join("&");k(location.hash)!==a&&(location.hash=a)}function R(t){return t.button===1||t.ctrlKey||t.metaKey||t.shiftKey?!1:(t.preventDefault(),!0)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=w,window.lnCore.hashGet=W,window.lnCore.hashSet=H,window.lnCore.hashLinkClick=R),(function(){const t="data-ln-confirm",e="lnConfirm",o="data-ln-confirm-timeout";if(window[e]!==void 0)return;function a(...i){(document.documentElement.hasAttribute("data-ln-debug")||document.body&&document.body.hasAttribute("data-ln-debug"))&&console.warn("[ln-confirm]",...i)}function l(i){a("constructor called on",i),this.dom=i,this.confirming=!1,this.revertTimer=null,this._submitted=!1,this.idleEl=i.querySelector("[data-ln-confirm-idle]"),this.activeEl=i.querySelector("[data-ln-confirm-active]"),this.isTwoElementMode=!!(this.idleEl||this.activeEl),this.isTwoElementMode?(this.originalText="",this.confirmText=""):(this.originalText=i.textContent.trim(),this.confirmText=i.getAttribute(t)||"Confirm?");const n=this;return this._onClick=function(r){if(a("click handler, confirming:",n.confirming,"submitted:",n._submitted,"target:",r.target),!n.confirming)r.preventDefault(),r.stopImmediatePropagation(),n._enterConfirm();else{if(n._submitted)return;n._submitted=!0,r.stopPropagation(),n._reset()}},i.addEventListener("click",this._onClick),this}l.prototype._getTimeout=function(){const i=parseFloat(this.dom.getAttribute(o));return isNaN(i)||i<=0?3:i},l.prototype._enterConfirm=function(){if(this.confirming=!0,this.dom.setAttribute("data-confirming","true"),this.originalAriaLabel=this.dom.getAttribute("aria-label"),this.originalAriaLive=this.dom.getAttribute("aria-live"),this.isTwoElementMode){this.idleEl&&this.idleEl.setAttribute("hidden","true"),this.activeEl&&this.activeEl.removeAttribute("hidden");const n=this.activeEl?this.activeEl.textContent.trim():"";n&&(this.dom.setAttribute("aria-label",n),this.dom.setAttribute("aria-live","polite"))}else{var i=this.dom.querySelector("svg.ln-icon use");i&&this.originalText===""?(this.isIconButton=!0,this.originalIconHref=i.getAttribute("href"),i.setAttribute("href","#ln-icon-check"),this.dom.classList.add("ln-confirm-tooltip"),this.dom.setAttribute("data-tooltip-text",this.confirmText),this.dom.setAttribute("aria-label",this.confirmText),this.dom.setAttribute("aria-live","polite")):this.dom.textContent=this.confirmText}this._startTimer(),M(this.dom,"ln-confirm:waiting",{target:this.dom})},l.prototype._startTimer=function(){this.revertTimer&&clearTimeout(this.revertTimer);const i=this,n=this._getTimeout()*1e3;this.revertTimer=setTimeout(function(){i._reset()},n)},l.prototype._reset=function(){if(this._submitted=!1,this.confirming=!1,this.dom.removeAttribute("data-confirming"),this.isTwoElementMode)this.idleEl&&this.idleEl.removeAttribute("hidden"),this.activeEl&&this.activeEl.setAttribute("hidden","true");else if(this.isIconButton){var i=this.dom.querySelector("svg.ln-icon use");i&&this.originalIconHref&&i.setAttribute("href",this.originalIconHref),this.dom.classList.remove("ln-confirm-tooltip"),this.dom.removeAttribute("data-tooltip-text"),this.isIconButton=!1,this.originalIconHref=null}else this.dom.textContent=this.originalText;this.originalAriaLabel!==null&&this.originalAriaLabel!==void 0?this.dom.setAttribute("aria-label",this.originalAriaLabel):this.dom.removeAttribute("aria-label"),this.originalAriaLabel=null,this.originalAriaLive!==null&&this.originalAriaLive!==void 0?this.dom.setAttribute("aria-live",this.originalAriaLive):this.dom.removeAttribute("aria-live"),this.originalAriaLive=null,this.revertTimer&&(clearTimeout(this.revertTimer),this.revertTimer=null)},l.prototype.destroy=function(){a("destroy called on",this.dom),this.dom[e]&&(this.confirming&&this._reset(),this.dom.removeEventListener("click",this._onClick),delete this.dom[e])},N(t,e,l,"ln-confirm")})()})();
|
|
@@ -48,7 +48,11 @@ import { registerComponent, dispatch } from '../../ln-core';
|
|
|
48
48
|
} else {
|
|
49
49
|
if (self._submitted) return;
|
|
50
50
|
self._submitted = true;
|
|
51
|
-
// Second click —
|
|
51
|
+
// Second click — the gate opens for THIS button's own default
|
|
52
|
+
// action (submit / href), but the click still must not reach
|
|
53
|
+
// an ancestor click surface. Same containment as the first
|
|
54
|
+
// click, without cancelling the action being confirmed.
|
|
55
|
+
e.stopPropagation();
|
|
52
56
|
self._reset();
|
|
53
57
|
}
|
|
54
58
|
};
|