@livenetworks/ashlar 2.0.5 → 2.0.6

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.
@@ -89,28 +89,31 @@ No payload attributes → `lnFill(form, null)` → form resets (calls `this.rese
89
89
 
90
90
  ---
91
91
 
92
- ## 4. Composing with `data-ln-modal-for`
92
+ ## 4. Composing with `data-ln-modal-for` and `data-ln-modal-mode`
93
93
 
94
- `ln-fill` intentionally does NOT call `e.preventDefault()`. A trigger may
95
- carry both `data-ln-fill-form` and `data-ln-modal-for` — both document
96
- listeners fire on the same click independently.
94
+ `ln-fill` intentionally does NOT call `e.preventDefault()`. A trigger may carry both `data-ln-fill-form` and `data-ln-modal-for` (as well as `data-ln-modal-mode="new|edit"`) — both document listeners fire on the same click independently. Triggers can be authored on `<button>` elements or `<a href="#...">` anchor links.
97
95
 
98
96
  ```html
99
- <!-- One button fills the form AND opens the modal -->
100
- <button
97
+ <!-- One button opens the modal in "edit" mode AND fills the form -->
98
+ <button type="button"
101
99
  data-ln-modal-for="event-modal"
100
+ data-ln-modal-mode="edit"
102
101
  data-ln-fill-form="event-form"
103
102
  data-ln-fill-event-id="42"
104
103
  data-ln-fill-title="Annual Conference"
105
104
  >Edit</button>
105
+
106
+ <!-- New button opens the modal in "new" mode AND resets the form -->
107
+ <button type="button"
108
+ data-ln-modal-for="event-modal"
109
+ data-ln-modal-mode="new"
110
+ data-ln-fill-form="event-form"
111
+ >New Event</button>
106
112
  ```
107
113
 
108
114
  Order of side-effects per click (both listeners are on `document`):
109
- 1. `ln-modal` click listener → opens modal, sets `data-ln-modal-mode`.
110
- 2. `ln-fill` click listener → fills form via `lnFill(form, record)`.
111
-
112
- ### Double-Fill Prevention for Hash-Bound triggers
113
- If a clickable trigger is an anchor link that points to a hash segment (i.e., its `href` attribute contains `#`, such as `<a href="#event-modal:42" ...>`), `ln-fill`'s click listener will **ignore** the click. The fill process is instead delegated entirely to the `ln-ui-coordinator`, which will map the resulting hash change and `ln-modal:open` event to an `ln-fill:request` event. This prevents redundant, parallel form-filling operations.
115
+ 1. `ln-modal` click listener → transfers `data-ln-modal-mode` and opens modal (`data-ln-modal="open"`).
116
+ 2. `ln-fill` click listener → extracts attributes and calls `lnCore.lnFill(form, record)` (or `lnFill(form, null)` when no attributes are present, resetting the form for "new" mode).
114
117
 
115
118
  ---
116
119
 
@@ -1 +1 @@
1
- (function(){"use strict";function S(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const n=e.closest("[data-ln-debug]");return!(!n||typeof document<"u"&&n===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...n){if(typeof n[0]=="string"&&(n[0].startsWith("[ln-")||n[0].startsWith("[lnCore"))){let u=null;for(let s=1;s<n.length;s++)if(n[s]&&n[s].nodeType===1){u=n[s];break}if(!S(u))return}e.apply(console,n)}}function A(e,n,r){const u=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",n,e,u),e.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:u}))}function p(e,n){if(!document.body){document.addEventListener("DOMContentLoaded",function(){p(e,n)}),console.warn("["+n+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}const C={};function _(e,n){C[e]=n}function k(e){return C[e]||{ingress:n=>n,egress:n=>n}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=_,window.lnCore.getDataMapper=k);function E(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,p(function(){new MutationObserver(function(){A(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const g={};function L(e,n){if(!e||typeof n!="object")return;const r=e.toLowerCase().split("-")[0];g[r]=n}function F(e){if(!e)return null;const n=e.toLowerCase().split("-")[0];return g[n]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=L,window.lnCore.getLocaleFallback=F,window.lnCore.ensureLocaleObserver=E);const w={};function v(e,n){w[e]||(w[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=w[e];return r?r.content.cloneNode(!0):(console.warn("["+(n||"ln-core")+'] Template "'+e+'" not found'),null)}function b(e,n){if(!e||!n)return e;const r=e.querySelectorAll("[data-ln-field]");for(let t=0;t<r.length;t++){const i=r[t],o=i.getAttribute("data-ln-field");n[o]!=null&&(i.textContent=n[o])}const u=e.querySelectorAll("[data-ln-attr]");for(let t=0;t<u.length;t++){const i=u[t],o=i.getAttribute("data-ln-attr").split(",");for(let c=0;c<o.length;c++){const d=o[c].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),a=d[1].trim();n[a]!=null&&i.setAttribute(f,n[a])}}const s=e.querySelectorAll("[data-ln-show]");for(let t=0;t<s.length;t++){const i=s[t],o=i.getAttribute("data-ln-show");o in n&&i.classList.toggle("hidden",!n[o])}const l=e.querySelectorAll("[data-ln-class]");for(let t=0;t<l.length;t++){const i=l[t],o=i.getAttribute("data-ln-class").split(",");for(let c=0;c<o.length;c++){const d=o[c].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),a=d[1].trim();a in n&&i.classList.toggle(f,!!n[a])}}return e}function x(e,n){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,n??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:n??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let u=0;u<r.length;u++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[u],n??null),r[u].dispatchEvent(new CustomEvent("ln-fill",{detail:n??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)b(e.target,e.detail);else{const n=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<n.length;r++)n[r].textContent=""}})));function m(e,n){if(!e||!n)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const l=r.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(t,i){return n[i]!==void 0?n[i]:""}))}const u=function(l,t){return n[t]!==void 0?n[t]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let l=0;l<s.length;l++){const t=s[l],i=t.attributes;for(let o=0;o<i.length;o++){const c=i[o];c.value.indexOf("{{")!==-1&&t.setAttribute(c.name,c.value.replace(/\{\{\s*(\w+)\s*\}\}/g,u))}}return e}function D(e,n,r,u,s,l){const t={};for(let o=0;o<e.children.length;o++){const c=e.children[o],d=c.getAttribute("data-ln-render-key");d&&(t[d]=c)}const i=document.createDocumentFragment();for(let o=0;o<n.length;o++){const c=n[o],d=String(u(c));let f=t[d];if(f)s(f,c,o);else{const a=v(r,l);if(!a||(m(a,c),f=a.firstElementChild,!f))continue;f.setAttribute("data-ln-render-key",d),s(f,c,o)}i.appendChild(f)}e.textContent="",e.appendChild(i)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=m,window.lnCore.fill=b,window.lnCore.lnFill=x,window.lnCore.renderList=D),typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function y(e){return(e||"").replace(/^#/,"")}function h(e){const n=e===void 0?location.hash:e,r={},u=y(n);if(!u)return r;const s=u.split("&");for(let l=0;l<s.length;l++){const t=s[l];if(!t)continue;const i=t.indexOf(":"),o=i>-1?t.slice(0,i):t,c=i>-1?t.slice(i+1):"";if(o)try{r[o]=decodeURIComponent(c)}catch{r[o]=c}}return r}function O(e){if(!e)return null;const n=h();return e in n?n[e]:null}function B(e,n){if(!e)return;const r=h();n==null?delete r[e]:r[e]=String(n);const s=Object.keys(r).map(function(l){const t=r[l];return t===""?l:l+":"+encodeURIComponent(t)}).join("&");y(location.hash)!==s&&(location.hash=s)}function I(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function T(e,n){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const u=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return u?n?u+"-"+n:u:n||null}function q(e,n){return!n||n==="none"||e===null||e===void 0?null:String(e)+"."+n}function W(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function M(e,n){return!e||!Array.isArray(n)||n.length===0?null:e+":"+n.map(encodeURIComponent).join(",")}function j(e){if(!e||typeof e!="string")return null;const n=e.indexOf(":");if(n===-1)return null;const r=e.slice(0,n),u=e.slice(n+1),s=u?u.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:r,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=h,window.lnCore.hashGet=O,window.lnCore.hashSet=B,window.lnCore.hashLinkClick=I,window.lnCore.resolveHashNamespace=T,window.lnCore.hashSortEncode=q,window.lnCore.hashSortDecode=W,window.lnCore.hashFilterEncode=M,window.lnCore.hashFilterDecode=j),(function(){const e="lnFill";if(window[e]!==void 0)return;const n={lnFillForm:!0,lnFillStore:!0};function r(s){const l={},t=s.dataset;for(const i in t){if(!i.startsWith("lnFill")||n[i])continue;const o=i.slice(6);o&&(l[o.charAt(0).toLowerCase()+o.slice(1)]=t[i])}return l}function u(s,l){const t=window.CSS&&CSS.escape?CSS.escape(l):l,i=document.querySelectorAll('[data-ln-fill-id="'+t+'"]');if(i.length===0)return null;for(let o=0;o<i.length;o++){const c=i[o].getAttribute("data-ln-fill-form");if(c){const d=document.getElementById(c);if(d&&s.contains(d))return i[o]}}return i[0]}document.addEventListener("click",function(s){if(s.ctrlKey||s.metaKey||s.button===1)return;const l=s.target.closest("[data-ln-fill-form]");if(!l)return;const t=l.getAttribute("href");if(t&&t.indexOf("#")!==-1)return;const i=l.getAttribute("data-ln-fill-form"),o=document.getElementById(i);if(!o)return;const c=r(l),d=Object.keys(c).length>0;window.lnCore.lnFill(o,d?c:null)}),document.addEventListener("ln-fill:request",function(s){const l=s.detail;if(!l)return;const t=s.target,i=l.id;if(i==null){window.lnCore.lnFill(t,null);return}const o=u(t,i);if(!o)return;const c=r(o);window.lnCore.lnFill(t,c)}),window[e]=!0})()})();
1
+ (function(){"use strict";function S(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const n=e.closest("[data-ln-debug]");return!(!n||typeof document<"u"&&n===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...n){if(typeof n[0]=="string"&&(n[0].startsWith("[ln-")||n[0].startsWith("[lnCore"))){let u=null;for(let s=1;s<n.length;s++)if(n[s]&&n[s].nodeType===1){u=n[s];break}if(!S(u))return}e.apply(console,n)}}function A(e,n,r){const u=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",n,e,u),e.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:u}))}function p(e,n){if(!document.body){document.addEventListener("DOMContentLoaded",function(){p(e,n)}),console.warn("["+n+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}const C={};function _(e,n){C[e]=n}function k(e){return C[e]||{ingress:n=>n,egress:n=>n}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=_,window.lnCore.getDataMapper=k);function E(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,p(function(){new MutationObserver(function(){A(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const g={};function L(e,n){if(!e||typeof n!="object")return;const r=e.toLowerCase().split("-")[0];g[r]=n}function F(e){if(!e)return null;const n=e.toLowerCase().split("-")[0];return g[n]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=L,window.lnCore.getLocaleFallback=F,window.lnCore.ensureLocaleObserver=E);const w={};function v(e,n){w[e]||(w[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=w[e];return r?r.content.cloneNode(!0):(console.warn("["+(n||"ln-core")+'] Template "'+e+'" not found'),null)}function b(e,n){if(!e||!n)return e;const r=e.querySelectorAll("[data-ln-field]");for(let t=0;t<r.length;t++){const i=r[t],o=i.getAttribute("data-ln-field");n[o]!=null&&(i.textContent=n[o])}const u=e.querySelectorAll("[data-ln-attr]");for(let t=0;t<u.length;t++){const i=u[t],o=i.getAttribute("data-ln-attr").split(",");for(let c=0;c<o.length;c++){const d=o[c].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),a=d[1].trim();n[a]!=null&&i.setAttribute(f,n[a])}}const s=e.querySelectorAll("[data-ln-show]");for(let t=0;t<s.length;t++){const i=s[t],o=i.getAttribute("data-ln-show");o in n&&i.classList.toggle("hidden",!n[o])}const l=e.querySelectorAll("[data-ln-class]");for(let t=0;t<l.length;t++){const i=l[t],o=i.getAttribute("data-ln-class").split(",");for(let c=0;c<o.length;c++){const d=o[c].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),a=d[1].trim();a in n&&i.classList.toggle(f,!!n[a])}}return e}function D(e,n){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,n??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:n??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let u=0;u<r.length;u++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[u],n??null),r[u].dispatchEvent(new CustomEvent("ln-fill",{detail:n??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)b(e.target,e.detail);else{const n=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<n.length;r++)n[r].textContent=""}})));function m(e,n){if(!e||!n)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const l=r.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(t,i){return n[i]!==void 0?n[i]:""}))}const u=function(l,t){return n[t]!==void 0?n[t]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let l=0;l<s.length;l++){const t=s[l],i=t.attributes;for(let o=0;o<i.length;o++){const c=i[o];c.value.indexOf("{{")!==-1&&t.setAttribute(c.name,c.value.replace(/\{\{\s*(\w+)\s*\}\}/g,u))}}return e}function x(e,n,r,u,s,l){const t={};for(let o=0;o<e.children.length;o++){const c=e.children[o],d=c.getAttribute("data-ln-render-key");d&&(t[d]=c)}const i=document.createDocumentFragment();for(let o=0;o<n.length;o++){const c=n[o],d=String(u(c));let f=t[d];if(f)s(f,c,o);else{const a=v(r,l);if(!a||(m(a,c),f=a.firstElementChild,!f))continue;f.setAttribute("data-ln-render-key",d),s(f,c,o)}i.appendChild(f)}e.textContent="",e.appendChild(i)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=m,window.lnCore.fill=b,window.lnCore.lnFill=D,window.lnCore.renderList=x),typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function y(e){return(e||"").replace(/^#/,"")}function h(e){const n=e===void 0?location.hash:e,r={},u=y(n);if(!u)return r;const s=u.split("&");for(let l=0;l<s.length;l++){const t=s[l];if(!t)continue;const i=t.indexOf(":"),o=i>-1?t.slice(0,i):t,c=i>-1?t.slice(i+1):"";if(o)try{r[o]=decodeURIComponent(c)}catch{r[o]=c}}return r}function O(e){if(!e)return null;const n=h();return e in n?n[e]:null}function B(e,n){if(!e)return;const r=h();n==null?delete r[e]:r[e]=String(n);const s=Object.keys(r).map(function(l){const t=r[l];return t===""?l:l+":"+encodeURIComponent(t)}).join("&");y(location.hash)!==s&&(location.hash=s)}function I(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function T(e,n){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const u=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return u?n?u+"-"+n:u:n||null}function q(e,n){return!n||n==="none"||e===null||e===void 0?null:String(e)+"."+n}function W(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function M(e,n){return!e||!Array.isArray(n)||n.length===0?null:e+":"+n.map(encodeURIComponent).join(",")}function j(e){if(!e||typeof e!="string")return null;const n=e.indexOf(":");if(n===-1)return null;const r=e.slice(0,n),u=e.slice(n+1),s=u?u.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:r,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=h,window.lnCore.hashGet=O,window.lnCore.hashSet=B,window.lnCore.hashLinkClick=I,window.lnCore.resolveHashNamespace=T,window.lnCore.hashSortEncode=q,window.lnCore.hashSortDecode=W,window.lnCore.hashFilterEncode=M,window.lnCore.hashFilterDecode=j),(function(){const e="lnFill";if(window[e]!==void 0)return;const n={lnFillForm:!0,lnFillStore:!0};function r(s){const l={},t=s.dataset;for(const i in t){if(!i.startsWith("lnFill")||n[i])continue;const o=i.slice(6);o&&(l[o.charAt(0).toLowerCase()+o.slice(1)]=t[i])}return l}function u(s,l){const t=window.CSS&&CSS.escape?CSS.escape(l):l,i=document.querySelectorAll('[data-ln-fill-id="'+t+'"]');if(i.length===0)return null;for(let o=0;o<i.length;o++){const c=i[o].getAttribute("data-ln-fill-form");if(c){const d=document.getElementById(c);if(d&&s.contains(d))return i[o]}}return i[0]}document.addEventListener("click",function(s){if(s.ctrlKey||s.metaKey||s.button===1)return;const l=s.target.closest("[data-ln-fill-form]");if(!l)return;const t=l.getAttribute("data-ln-fill-form"),i=document.getElementById(t);if(!i)return;const o=r(l),c=Object.keys(o).length>0;window.lnCore.lnFill(i,c?o:null)}),document.addEventListener("ln-fill:request",function(s){const l=s.detail;if(!l)return;const t=s.target,i=l.id;if(i==null){window.lnCore.lnFill(t,null);return}const o=u(t,i);if(!o)return;const c=r(o);window.lnCore.lnFill(t,c)}),window[e]=!0})()})();
@@ -50,12 +50,6 @@ import { } from '../../ln-core';
50
50
  const trigger = e.target.closest('[data-ln-fill-form]');
51
51
  if (!trigger) return;
52
52
 
53
- // Prevent double fill: if this trigger is a hash-bound anchor (e.g. href="#user-modal:142"),
54
- // we skip the click-based fill. The resulting hash change will trigger ln-modal:open,
55
- // and the ln-ui-coordinator will request the fill via ln-fill:request.
56
- const href = trigger.getAttribute('href');
57
- if (href && href.indexOf('#') !== -1) return;
58
-
59
53
  // No e.preventDefault() — the same click may also be handled by
60
54
  // [data-ln-modal-for] listener in ln-modal. Leave it alone.
61
55
 
@@ -24,15 +24,33 @@ In `ln-ashlar`, the core design principle is **Three-Layer Architecture** and **
24
24
  Triggers and modals are paired by ID. The overlay has `class="ln-modal"` and `data-ln-modal`.
25
25
 
26
26
  ```html
27
- <!-- Trigger button -->
28
- <button data-ln-modal-for="user-modal">Add User</button>
27
+ <!-- Trigger: New (opens modal in "new" mode and resets form) -->
28
+ <button type="button"
29
+ data-ln-modal-for="user-modal"
30
+ data-ln-modal-mode="new"
31
+ data-ln-fill-form="user-form">
32
+ Add User
33
+ </button>
34
+
35
+ <!-- Trigger: Edit (opens modal in "edit" mode and fills form) -->
36
+ <button type="button"
37
+ data-ln-modal-for="user-modal"
38
+ data-ln-modal-mode="edit"
39
+ data-ln-fill-form="user-form"
40
+ data-ln-fill-id="42"
41
+ data-ln-fill-name="Ada Lovelace">
42
+ Edit User
43
+ </button>
29
44
 
30
45
  <!-- Modal overlay -->
31
- <dialog class="ln-modal" data-ln-modal id="user-modal">
32
- <form>
33
- <!-- Header -->
46
+ <dialog class="ln-modal" data-ln-modal data-ln-modal-mode="new" id="user-modal">
47
+ <form id="user-form" data-ln-form>
48
+ <!-- Header with mode-conditional title -->
34
49
  <header>
35
- <h3>Add User</h3>
50
+ <h3 data-ln-fillable>
51
+ <span data-ln-modal-when="new">Add User</span>
52
+ <span data-ln-modal-when="edit">Edit User — <span data-ln-field="name"></span></span>
53
+ </h3>
36
54
  <button type="button" data-ln-modal-close aria-label="Close">
37
55
  <svg class="ln-icon" aria-hidden="true"><use href="#ln-icon-x"></use></svg>
38
56
  </button>
@@ -40,6 +58,7 @@ Triggers and modals are paired by ID. The overlay has `class="ln-modal"` and `da
40
58
 
41
59
  <!-- Scrollable content -->
42
60
  <main>
61
+ <input type="hidden" name="id">
43
62
  <label>Name <input type="text" name="name" autofocus></label>
44
63
  </main>
45
64
 
@@ -54,7 +73,8 @@ Triggers and modals are paired by ID. The overlay has `class="ln-modal"` and `da
54
73
 
55
74
  ### Key Anatomy Rules
56
75
  - **The Overlay (`data-ln-modal`)**: Driven by the value `"open"` (open) and `"close"` (closed).
57
- - **The Trigger (`data-ln-modal-for="id"`)**: Placed on buttons/links to request toggling modal display.
76
+ - **The Trigger (`data-ln-modal-for="id"`)**: Placed on buttons/links to open target modal directly.
77
+ - **The Mode Switch (`data-ln-modal-mode="new|edit"`)**: Transferred from trigger to modal on click. Displays child elements with matching `[data-ln-modal-when="new|edit"]`. Automatically resets to `"new"` upon closing.
58
78
  - **The Dismiss button (`data-ln-modal-close`)**: Placed on cancel or close buttons to request close.
59
79
  - **Focus Override (`autofocus`)**: Place on any form field to override default focus placement on open.
60
80
 
@@ -87,6 +107,7 @@ const isOpen = modal.lnModal.isOpen; // Returns true/false
87
107
  ### Attributes
88
108
  - `data-ln-modal`: Placed on the overlay element. Value `"open"` = open; `"close"` = closed.
89
109
  - `data-ln-modal-for="id"`: Placed on trigger elements referencing the modal ID.
110
+ - `data-ln-modal-mode="new|edit"`: Placed on trigger elements or modal dialog to specify mode (toggles `[data-ln-modal-when="new|edit"]` child elements).
90
111
  - `data-ln-modal-close`: Placed on any close trigger inside the modal.
91
112
 
92
113
  ---
@@ -163,7 +184,7 @@ Coordinators (such as `ln-ui-coordinator`) intercept hash changes and coordinate
163
184
 
164
185
  ## 🔧 Internals
165
186
 
166
- Source: `components/ln-modal/src/ln-modal.js` (native `<dialog>`-backed). `ln-modal` operates autonomously: trigger buttons (`data-ln-modal-for`), dismiss buttons (`data-ln-modal-close`), and backdrop dismissals are handled directly by the component without requiring external coordinators. Hash-addressing and form-fill orchestration remain optional enhancements handled when `components/ln-ui-coordinator/src/ln-ui-coordinator.js` is present.
187
+ Source: `components/ln-modal/src/ln-modal.js` (native `<dialog>`-backed). `ln-modal` operates autonomously: trigger buttons (`data-ln-modal-for`), dismiss buttons (`data-ln-modal-close`), and native ESC cancellation are handled directly by the component without requiring external coordinators. Mode switching (`data-ln-modal-mode="new|edit"`) is synchronized declaratively from triggers to modal dialogs.
167
188
 
168
189
  ### Single source of truth
169
190
 
@@ -1 +1 @@
1
- (function(){"use strict";function x(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function k(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let o=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){o=t[l];break}if(!k(o))return}e.apply(console,t)}}function y(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}function R(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o);const l=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:o});return e.dispatchEvent(l),l}function A(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){A(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function S(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function K(e){return!!(!e||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||typeof e.button=="number"&&e.button!==0)}function U(e){return!!(!e||e.disabled||typeof e.getAttribute=="function"&&e.getAttribute("aria-disabled")==="true"||typeof e.closest=="function"&&e.closest("[inert]"))}const D={};function G(e,t){D[e]=t}function Q(e){return D[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=G,window.lnCore.getDataMapper=Q);function P(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,A(function(){new MutationObserver(function(){y(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const $={};function J(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];$[n]=t}function z(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return $[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=J,window.lnCore.getLocaleFallback=z,window.lnCore.ensureLocaleObserver=P);const O={};function X(e,t){O[e]||(O[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=O[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function M(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let r=0;r<n.length;r++){const c=n[r],s=c.getAttribute("data-ln-field");t[s]!=null&&(c.textContent=t[s])}const o=e.querySelectorAll("[data-ln-attr]");for(let r=0;r<o.length;r++){const c=o[r],s=c.getAttribute("data-ln-attr").split(",");for(let u=0;u<s.length;u++){const f=s[u].trim().split(":");if(f.length!==2)continue;const d=f[0].trim(),a=f[1].trim();t[a]!=null&&c.setAttribute(d,t[a])}}const l=e.querySelectorAll("[data-ln-show]");for(let r=0;r<l.length;r++){const c=l[r],s=c.getAttribute("data-ln-show");s in t&&c.classList.toggle("hidden",!t[s])}const i=e.querySelectorAll("[data-ln-class]");for(let r=0;r<i.length;r++){const c=i[r],s=c.getAttribute("data-ln-class").split(",");for(let u=0;u<s.length;u++){const f=s[u].trim().split(":");if(f.length!==2)continue;const d=f[0].trim(),a=f[1].trim();a in t&&c.classList.toggle(d,!!t[a])}}return e}function Y(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let o=0;o<n.length;o++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[o],t??null),n[o].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)M(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function B(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const i=n.currentNode;i.textContent.indexOf("{{")!==-1&&(i.textContent=i.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(r,c){return t[c]!==void 0?t[c]:""}))}const o=function(i,r){return t[r]!==void 0?t[r]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let i=0;i<l.length;i++){const r=l[i],c=r.attributes;for(let s=0;s<c.length;s++){const u=c[s];u.value.indexOf("{{")!==-1&&r.setAttribute(u.name,u.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function Z(e,t,n,o,l,i){const r={};for(let s=0;s<e.children.length;s++){const u=e.children[s],f=u.getAttribute("data-ln-render-key");f&&(r[f]=u)}const c=document.createDocumentFragment();for(let s=0;s<t.length;s++){const u=t[s],f=String(o(u));let d=r[f];if(d)l(d,u,s);else{const a=X(n,i);if(!a||(B(a,u),d=a.firstElementChild,!d))continue;d.setAttribute("data-ln-render-key",f),l(d,u,s)}c.appendChild(d)}e.textContent="",e.appendChild(c)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=B,window.lnCore.fill=M,window.lnCore.lnFill=Y,window.lnCore.renderList=Z);function F(e,t,n,o,l){if(!e||t===null)return!0;const i=o||"ln-component",r=e.type;if(r==="trigger"||r==="marker"||r==="string"||r==="list"||!r||t===""&&e.fallback!==void 0)return!0;const c=s=>{l?console.warn(s,l):console.warn(s)};if(r==="boolean"){const s=t.trim().toLowerCase();return s!==""&&s!=="true"&&s!=="false"&&s!=="1"&&s!=="0"?(c(`[${i}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(r==="enum"){const s=e.values||[];return s.includes(t)?!0:(c(`[${i}] Invalid value "${t}" for attribute "${n}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(r==="integer"){if(!/^-?\d+$/.test(t))return c(`[${i}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(c(`[${i}] Value ${s} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(c(`[${i}] Value ${s} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(r==="float")return isNaN(Number(t))?(c(`[${i}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(r==="json")try{return JSON.parse(t),!0}catch(s){return c(`[${i}] Invalid JSON for attribute "${n}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function ee(e){const t={};for(const n in e){const o=e[n];o&&o.effect&&(t[n]=o.effect)}return Object.keys(t).length?t:null}function te(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function E(e,t,n,o){if(e.nodeType!==1)return;const i=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",r=Array.from(e.querySelectorAll(i));e.matches&&e.matches(i)&&r.push(e);for(const c of r)if(!c[n]){window.lnCore._persistSink&&c.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(c,t);try{c[n]=new o(c)}catch(s){console.error("["+n+"] init failed",c,s)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function ne(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function oe(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function W(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function re(e){const t=W(),n=e.observed||[];for(let o=0;o<n.length;o++){const l=n[o];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const o in e.attributes){t.byDeclaredAttr.has(o)||t.byDeclaredAttr.set(o,[]);const l=t.byDeclaredAttr.get(o);l.some(i=>i.componentTag===e.componentTag)||l.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=te(e);if(o===null)t.reactiveWildcard.push(e);else for(const l of o)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function j(e,t,n,o){for(let l=0;l<e.length;l++){const i=e[l];if(!t[i.attribute])continue;const r=i.effects&&i.effects[n];r?r(t,n,o):i.onAttrChange&&(!i.declared||i.declared.has(n))&&i.onAttrChange(t,n,o)}}function ie(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=W(),l=o.byAttr.get(n);if(x()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&k(t)){const i=o.byDeclaredAttr.get(n),r=t.getAttribute(n);for(let c=0;c<i.length;c++)F(i[c].spec,r,n,i[c].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||l)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const i=o.byReactive.get(n);i&&j(i,t,n,e.oldValue),o.reactiveWildcard.length&&j(o.reactiveWildcard,t,n,e.oldValue)}if(l)for(let i=0;i<l.length;i++){const r=l[i];if(r.handler){r.handler(t,n,e.oldValue);continue}r.onAttributeChange&&t[r.attribute]?r.onAttributeChange(t,n):(E(t,r.selector,r.attribute,r.ComponentFn),r.onInit&&r.onInit(t))}}function le(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,A(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{ie(t[n])}catch(o){console.error("[ln-core] mutation handler failed",t[n].target,o)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function N(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function se(e){const t=N();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const l=o.query,i=e.target.nodeType===1?e.target.matches(l)?e.target:e.target.closest(l):e.target.parentElement?e.target.parentElement.closest(l):null;i&&o.onSubtreeChange(i,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let l=0;l<t.length;l++){const i=t[l];E(o,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let l=0;l<t.length;l++){const i=t[l],r=i.query,c=Array.from(o.querySelectorAll(r));o.matches&&o.matches(r)&&c.push(o);for(let s=0;s<c.length;s++){const u=c[s];if(!document.contains(u)){const f=u[i.attribute];if(f&&typeof f.destroy=="function")try{f.destroy()}catch(d){console.error("["+i.attribute+"] destroy failed",u,d)}delete u[i.attribute]}}}}}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,A(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{se(o)}catch(l){console.error("[ln-core] lifecycle handler failed",o.target,l)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ce(e,t,n,o,l={}){const i=l.extraAttributes||[],r=l.onAttributeChange||null,c=l.onSubtreeChange||null,s=l.onInit||null,u=l.onAttrChange||null,f=l.effects||null,d=l.attributes||null,a=d?ee(d):f,w=d?new Set(Object.keys(d)):null,b=l.persist||null;function g(m){const h=m||document.body;if(E(h,e,t,n),d&&x())for(const C in d){const me=d[C],I=Array.from(h.querySelectorAll("["+C+"]"));h.matches&&h.matches("["+C+"]")&&I.push(h);for(let q=0;q<I.length;q++){const T=I[q];k(T)&&F(me,T.getAttribute(C),C,o,T)}}s&&s(h)}const p=[];if(e.indexOf("[")!==-1){const m=/\[([\w-]+)/g;let h;for(;(h=m.exec(e))!==null;)p.push(h[1])}else p.push(e);re({selector:e,attribute:t,componentTag:o,attributes:d,ComponentFn:n,onInit:s,observed:p.concat(i),onAttributeChange:r,onAttrChange:u,effects:a,declared:w,persist:b}),le();const _=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";N().push({selector:e,attribute:t,ComponentFn:n,onInit:s,onSubtreeChange:c,query:_}),de(),window[t]=g;function v(){ne()>0?oe(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",v):v(),g}function V(e){return(e||"").replace(/^#/,"")}function L(e){const t=e===void 0?location.hash:e,n={},o=V(t);if(!o)return n;const l=o.split("&");for(let i=0;i<l.length;i++){const r=l[i];if(!r)continue;const c=r.indexOf(":"),s=c>-1?r.slice(0,c):r,u=c>-1?r.slice(c+1):"";if(s)try{n[s]=decodeURIComponent(u)}catch{n[s]=u}}return n}function ue(e){if(!e)return null;const t=L();return e in t?t[e]:null}function ae(e,t){if(!e)return;const n=L();t==null?delete n[e]:n[e]=String(t);const l=Object.keys(n).map(function(i){const r=n[i];return r===""?i:i+":"+encodeURIComponent(r)}).join("&");V(location.hash)!==l&&(location.hash=l)}function fe(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function we(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const o=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return o?t?o+"-"+t:o:t||null}function be(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function he(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function pe(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function ge(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),o=e.slice(t+1),l=o?o.split(",").map(function(i){try{return decodeURIComponent(i)}catch{return i}}).filter(Boolean):[];return{key:n,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=L,window.lnCore.hashGet=ue,window.lnCore.hashSet=ae,window.lnCore.hashLinkClick=fe,window.lnCore.resolveHashNamespace=we,window.lnCore.hashSortEncode=be,window.lnCore.hashSortDecode=he,window.lnCore.hashFilterEncode=pe,window.lnCore.hashFilterDecode=ge),(function(){const e="data-ln-modal",t="lnModal",n="data-ln-modal-for",o="data-ln-modal-close";if(window[t]!==void 0)return;const l={"data-ln-modal":{type:"enum",values:["open","close"],fallback:"close",effect:f,description:"Control state of the modal dialog"},"data-ln-modal-for":{type:"string",description:"Target modal ID to open on trigger click"},"data-ln-modal-close":{type:"trigger",description:"Click dismiss trigger inside the modal"}},i=new Set;let r=null;function c(){r||(r=function(d){if(K(d))return;const a=d.target.closest("["+n+"]");if(!a||U(a))return;const w=a.getAttribute(n);if(!w)return;const b=document.getElementById(w)||document.querySelector("["+e+'="'+w+'"]');!b||!b[t]||(d.preventDefault(),a.hasAttribute("data-ln-modal-mode")&&b.setAttribute("data-ln-modal-mode",a.getAttribute("data-ln-modal-mode")),b.setAttribute(e,"open"))},document.addEventListener("click",r))}function s(){i.size>0||!r||(document.removeEventListener("click",r),r=null)}function u(d){this.dom=d,this.isOpen=d.getAttribute(e)==="open";const a=this;return this._onRequestOpen=function(){a.dom.setAttribute(e,"open")},this._onRequestClose=function(){a.dom.setAttribute(e,"close")},this._onCancel=function(w){w.preventDefault(),a.dom.setAttribute(e,"close")},this._onClickClose=function(w){const b=w.target.closest("["+o+"]");b&&a.dom.contains(b)&&(w.preventDefault(),a.dom.setAttribute(e,"close"))},this.dom.addEventListener("ln-modal:request-open",this._onRequestOpen),this.dom.addEventListener("ln-modal:request-close",this._onRequestClose),this.dom.addEventListener("cancel",this._onCancel),this.dom.addEventListener("click",this._onClickClose),i.add(this),c(),this.isOpen&&(typeof this.dom.showModal=="function"&&this.dom.showModal(),document.body.classList.add("ln-modal-open"),y(this.dom,"ln-modal:open",{modalId:this.dom.id,target:this.dom})),this}u.prototype.open=function(){this.dom.setAttribute(e,"open")},u.prototype.close=function(){this.dom.setAttribute(e,"close")},u.prototype.toggle=function(){const d=this.dom.getAttribute(e);this.dom.setAttribute(e,d==="open"?"close":"open")},u.prototype.destroy=function(){if(this.dom[t]){if(this.dom.removeEventListener("ln-modal:request-open",this._onRequestOpen),this.dom.removeEventListener("ln-modal:request-close",this._onRequestClose),this.dom.removeEventListener("cancel",this._onCancel),this.dom.removeEventListener("click",this._onClickClose),i.delete(this),s(),this.isOpen){const d=this.dom;Array.prototype.some.call(document.querySelectorAll("["+e+'="open"]'),function(w){return w!==d})||document.body.classList.remove("ln-modal-open")}delete this.dom[t]}};function f(d){const a=d[t];if(!a)return;const b=d.getAttribute(e)==="open";if(b!==a.isOpen)if(b){if(R(d,"ln-modal:before-open",{modalId:d.id,target:d}).defaultPrevented){d.setAttribute(e,"close");return}a.isOpen=!0,document.body.classList.add("ln-modal-open"),typeof d.showModal=="function"&&d.showModal();const p=d.querySelector("[autofocus]");if(p&&S(p))p.focus();else{const H=d.querySelectorAll('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled])'),_=Array.prototype.find.call(H,S);if(_)_.focus();else{const v=d.querySelectorAll("a[href], button:not([disabled])"),m=Array.prototype.find.call(v,S);m&&m.focus()}}y(d,"ln-modal:open",{modalId:d.id,target:d})}else{if(R(d,"ln-modal:before-close",{modalId:d.id,target:d}).defaultPrevented){d.setAttribute(e,"open");return}a.isOpen=!1,y(d,"ln-modal:close",{modalId:d.id,target:d}),typeof d.close=="function"&&d.close(),document.querySelector("["+e+'="open"]')||document.body.classList.remove("ln-modal-open")}}ce(e,t,u,"ln-modal",{attributes:l})})()})();
1
+ (function(){"use strict";function x(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function k(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let o=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){o=t[l];break}if(!k(o))return}e.apply(console,t)}}function y(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}function R(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o);const l=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:o});return e.dispatchEvent(l),l}function A(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){A(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function S(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function K(e){return!!(!e||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||typeof e.button=="number"&&e.button!==0)}function U(e){return!!(!e||e.disabled||typeof e.getAttribute=="function"&&e.getAttribute("aria-disabled")==="true"||typeof e.closest=="function"&&e.closest("[inert]"))}const D={};function G(e,t){D[e]=t}function Q(e){return D[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=G,window.lnCore.getDataMapper=Q);function P(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,A(function(){new MutationObserver(function(){y(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const $={};function J(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];$[n]=t}function z(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return $[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=J,window.lnCore.getLocaleFallback=z,window.lnCore.ensureLocaleObserver=P);const O={};function X(e,t){O[e]||(O[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=O[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function M(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let r=0;r<n.length;r++){const c=n[r],s=c.getAttribute("data-ln-field");t[s]!=null&&(c.textContent=t[s])}const o=e.querySelectorAll("[data-ln-attr]");for(let r=0;r<o.length;r++){const c=o[r],s=c.getAttribute("data-ln-attr").split(",");for(let u=0;u<s.length;u++){const f=s[u].trim().split(":");if(f.length!==2)continue;const d=f[0].trim(),a=f[1].trim();t[a]!=null&&c.setAttribute(d,t[a])}}const l=e.querySelectorAll("[data-ln-show]");for(let r=0;r<l.length;r++){const c=l[r],s=c.getAttribute("data-ln-show");s in t&&c.classList.toggle("hidden",!t[s])}const i=e.querySelectorAll("[data-ln-class]");for(let r=0;r<i.length;r++){const c=i[r],s=c.getAttribute("data-ln-class").split(",");for(let u=0;u<s.length;u++){const f=s[u].trim().split(":");if(f.length!==2)continue;const d=f[0].trim(),a=f[1].trim();a in t&&c.classList.toggle(d,!!t[a])}}return e}function Y(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let o=0;o<n.length;o++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[o],t??null),n[o].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)M(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function B(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const i=n.currentNode;i.textContent.indexOf("{{")!==-1&&(i.textContent=i.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(r,c){return t[c]!==void 0?t[c]:""}))}const o=function(i,r){return t[r]!==void 0?t[r]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let i=0;i<l.length;i++){const r=l[i],c=r.attributes;for(let s=0;s<c.length;s++){const u=c[s];u.value.indexOf("{{")!==-1&&r.setAttribute(u.name,u.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function Z(e,t,n,o,l,i){const r={};for(let s=0;s<e.children.length;s++){const u=e.children[s],f=u.getAttribute("data-ln-render-key");f&&(r[f]=u)}const c=document.createDocumentFragment();for(let s=0;s<t.length;s++){const u=t[s],f=String(o(u));let d=r[f];if(d)l(d,u,s);else{const a=X(n,i);if(!a||(B(a,u),d=a.firstElementChild,!d))continue;d.setAttribute("data-ln-render-key",f),l(d,u,s)}c.appendChild(d)}e.textContent="",e.appendChild(c)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=B,window.lnCore.fill=M,window.lnCore.lnFill=Y,window.lnCore.renderList=Z);function F(e,t,n,o,l){if(!e||t===null)return!0;const i=o||"ln-component",r=e.type;if(r==="trigger"||r==="marker"||r==="string"||r==="list"||!r||t===""&&e.fallback!==void 0)return!0;const c=s=>{l?console.warn(s,l):console.warn(s)};if(r==="boolean"){const s=t.trim().toLowerCase();return s!==""&&s!=="true"&&s!=="false"&&s!=="1"&&s!=="0"?(c(`[${i}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(r==="enum"){const s=e.values||[];return s.includes(t)?!0:(c(`[${i}] Invalid value "${t}" for attribute "${n}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(r==="integer"){if(!/^-?\d+$/.test(t))return c(`[${i}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(c(`[${i}] Value ${s} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(c(`[${i}] Value ${s} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(r==="float")return isNaN(Number(t))?(c(`[${i}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(r==="json")try{return JSON.parse(t),!0}catch(s){return c(`[${i}] Invalid JSON for attribute "${n}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function ee(e){const t={};for(const n in e){const o=e[n];o&&o.effect&&(t[n]=o.effect)}return Object.keys(t).length?t:null}function te(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function E(e,t,n,o){if(e.nodeType!==1)return;const i=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",r=Array.from(e.querySelectorAll(i));e.matches&&e.matches(i)&&r.push(e);for(const c of r)if(!c[n]){window.lnCore._persistSink&&c.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(c,t);try{c[n]=new o(c)}catch(s){console.error("["+n+"] init failed",c,s)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function ne(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function oe(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function W(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function re(e){const t=W(),n=e.observed||[];for(let o=0;o<n.length;o++){const l=n[o];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const o in e.attributes){t.byDeclaredAttr.has(o)||t.byDeclaredAttr.set(o,[]);const l=t.byDeclaredAttr.get(o);l.some(i=>i.componentTag===e.componentTag)||l.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=te(e);if(o===null)t.reactiveWildcard.push(e);else for(const l of o)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function j(e,t,n,o){for(let l=0;l<e.length;l++){const i=e[l];if(!t[i.attribute])continue;const r=i.effects&&i.effects[n];r?r(t,n,o):i.onAttrChange&&(!i.declared||i.declared.has(n))&&i.onAttrChange(t,n,o)}}function ie(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=W(),l=o.byAttr.get(n);if(x()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&k(t)){const i=o.byDeclaredAttr.get(n),r=t.getAttribute(n);for(let c=0;c<i.length;c++)F(i[c].spec,r,n,i[c].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||l)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const i=o.byReactive.get(n);i&&j(i,t,n,e.oldValue),o.reactiveWildcard.length&&j(o.reactiveWildcard,t,n,e.oldValue)}if(l)for(let i=0;i<l.length;i++){const r=l[i];if(r.handler){r.handler(t,n,e.oldValue);continue}r.onAttributeChange&&t[r.attribute]?r.onAttributeChange(t,n):(E(t,r.selector,r.attribute,r.ComponentFn),r.onInit&&r.onInit(t))}}function le(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,A(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{ie(t[n])}catch(o){console.error("[ln-core] mutation handler failed",t[n].target,o)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function N(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function se(e){const t=N();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const l=o.query,i=e.target.nodeType===1?e.target.matches(l)?e.target:e.target.closest(l):e.target.parentElement?e.target.parentElement.closest(l):null;i&&o.onSubtreeChange(i,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let l=0;l<t.length;l++){const i=t[l];E(o,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let l=0;l<t.length;l++){const i=t[l],r=i.query,c=Array.from(o.querySelectorAll(r));o.matches&&o.matches(r)&&c.push(o);for(let s=0;s<c.length;s++){const u=c[s];if(!document.contains(u)){const f=u[i.attribute];if(f&&typeof f.destroy=="function")try{f.destroy()}catch(d){console.error("["+i.attribute+"] destroy failed",u,d)}delete u[i.attribute]}}}}}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,A(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{se(o)}catch(l){console.error("[ln-core] lifecycle handler failed",o.target,l)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ce(e,t,n,o,l={}){const i=l.extraAttributes||[],r=l.onAttributeChange||null,c=l.onSubtreeChange||null,s=l.onInit||null,u=l.onAttrChange||null,f=l.effects||null,d=l.attributes||null,a=d?ee(d):f,b=d?new Set(Object.keys(d)):null,w=l.persist||null;function m(g){const h=g||document.body;if(E(h,e,t,n),d&&x())for(const C in d){const ge=d[C],I=Array.from(h.querySelectorAll("["+C+"]"));h.matches&&h.matches("["+C+"]")&&I.push(h);for(let q=0;q<I.length;q++){const T=I[q];k(T)&&F(ge,T.getAttribute(C),C,o,T)}}s&&s(h)}const p=[];if(e.indexOf("[")!==-1){const g=/\[([\w-]+)/g;let h;for(;(h=g.exec(e))!==null;)p.push(h[1])}else p.push(e);re({selector:e,attribute:t,componentTag:o,attributes:d,ComponentFn:n,onInit:s,observed:p.concat(i),onAttributeChange:r,onAttrChange:u,effects:a,declared:b,persist:w}),le();const _=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";N().push({selector:e,attribute:t,ComponentFn:n,onInit:s,onSubtreeChange:c,query:_}),de(),window[t]=m;function v(){ne()>0?oe(function(){m(document.body)}):m(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",v):v(),m}function V(e){return(e||"").replace(/^#/,"")}function L(e){const t=e===void 0?location.hash:e,n={},o=V(t);if(!o)return n;const l=o.split("&");for(let i=0;i<l.length;i++){const r=l[i];if(!r)continue;const c=r.indexOf(":"),s=c>-1?r.slice(0,c):r,u=c>-1?r.slice(c+1):"";if(s)try{n[s]=decodeURIComponent(u)}catch{n[s]=u}}return n}function ue(e){if(!e)return null;const t=L();return e in t?t[e]:null}function ae(e,t){if(!e)return;const n=L();t==null?delete n[e]:n[e]=String(t);const l=Object.keys(n).map(function(i){const r=n[i];return r===""?i:i+":"+encodeURIComponent(r)}).join("&");V(location.hash)!==l&&(location.hash=l)}function fe(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function we(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const o=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return o?t?o+"-"+t:o:t||null}function be(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function he(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function pe(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function me(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),o=e.slice(t+1),l=o?o.split(",").map(function(i){try{return decodeURIComponent(i)}catch{return i}}).filter(Boolean):[];return{key:n,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=L,window.lnCore.hashGet=ue,window.lnCore.hashSet=ae,window.lnCore.hashLinkClick=fe,window.lnCore.resolveHashNamespace=we,window.lnCore.hashSortEncode=be,window.lnCore.hashSortDecode=he,window.lnCore.hashFilterEncode=pe,window.lnCore.hashFilterDecode=me),(function(){const e="data-ln-modal",t="lnModal",n="data-ln-modal-for",o="data-ln-modal-close";if(window[t]!==void 0)return;const l={"data-ln-modal":{type:"enum",values:["open","close"],fallback:"close",effect:f,description:"Control state of the modal dialog"},"data-ln-modal-for":{type:"string",description:"Target modal ID to open on trigger click"},"data-ln-modal-mode":{type:"enum",values:["new","edit"],fallback:"new",description:"Operational mode of the modal (new vs edit)"},"data-ln-modal-close":{type:"trigger",description:"Click dismiss trigger inside the modal"}},i=new Set;let r=null;function c(){r||(r=function(d){if(K(d))return;const a=d.target.closest("["+n+"]");if(!a||U(a))return;const b=a.getAttribute(n);if(!b)return;const w=document.getElementById(b)||document.querySelector("["+e+'="'+b+'"]');!w||!w[t]||(d.preventDefault(),a.hasAttribute("data-ln-modal-mode")?w.setAttribute("data-ln-modal-mode",a.getAttribute("data-ln-modal-mode")):w.hasAttribute("data-ln-modal-mode")&&w.setAttribute("data-ln-modal-mode","new"),w.setAttribute(e,"open"))},document.addEventListener("click",r))}function s(){i.size>0||!r||(document.removeEventListener("click",r),r=null)}function u(d){this.dom=d,this.isOpen=d.getAttribute(e)==="open";const a=this;return this._onRequestOpen=function(){a.dom.setAttribute(e,"open")},this._onRequestClose=function(){a.dom.setAttribute(e,"close")},this._onCancel=function(b){b.preventDefault(),a.dom.setAttribute(e,"close")},this._onClickClose=function(b){const w=b.target.closest("["+o+"]");w&&a.dom.contains(w)&&(b.preventDefault(),a.dom.setAttribute(e,"close"))},this.dom.addEventListener("ln-modal:request-open",this._onRequestOpen),this.dom.addEventListener("ln-modal:request-close",this._onRequestClose),this.dom.addEventListener("cancel",this._onCancel),this.dom.addEventListener("click",this._onClickClose),i.add(this),c(),this.isOpen&&(typeof this.dom.showModal=="function"&&this.dom.showModal(),document.body.classList.add("ln-modal-open"),y(this.dom,"ln-modal:open",{modalId:this.dom.id,target:this.dom})),this}u.prototype.open=function(){this.dom.setAttribute(e,"open")},u.prototype.close=function(){this.dom.setAttribute(e,"close")},u.prototype.toggle=function(){const d=this.dom.getAttribute(e);this.dom.setAttribute(e,d==="open"?"close":"open")},u.prototype.destroy=function(){if(this.dom[t]){if(this.dom.removeEventListener("ln-modal:request-open",this._onRequestOpen),this.dom.removeEventListener("ln-modal:request-close",this._onRequestClose),this.dom.removeEventListener("cancel",this._onCancel),this.dom.removeEventListener("click",this._onClickClose),i.delete(this),s(),this.isOpen){const d=this.dom;Array.prototype.some.call(document.querySelectorAll("["+e+'="open"]'),function(b){return b!==d})||document.body.classList.remove("ln-modal-open")}delete this.dom[t]}};function f(d){const a=d[t];if(!a)return;const w=d.getAttribute(e)==="open";if(w!==a.isOpen)if(w){if(R(d,"ln-modal:before-open",{modalId:d.id,target:d}).defaultPrevented){d.setAttribute(e,"close");return}a.isOpen=!0,document.body.classList.add("ln-modal-open"),typeof d.showModal=="function"&&d.showModal();const p=d.querySelector("[autofocus]");if(p&&S(p))p.focus();else{const H=d.querySelectorAll('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled])'),_=Array.prototype.find.call(H,S);if(_)_.focus();else{const v=d.querySelectorAll("a[href], button:not([disabled])"),g=Array.prototype.find.call(v,S);g&&g.focus()}}y(d,"ln-modal:open",{modalId:d.id,target:d})}else{if(R(d,"ln-modal:before-close",{modalId:d.id,target:d}).defaultPrevented){d.setAttribute(e,"open");return}a.isOpen=!1,d.hasAttribute("data-ln-modal-mode")&&d.setAttribute("data-ln-modal-mode","new"),y(d,"ln-modal:close",{modalId:d.id,target:d}),typeof d.close=="function"&&d.close(),document.querySelector("["+e+'="open"]')||document.body.classList.remove("ln-modal-open")}}ce(e,t,u,"ln-modal",{attributes:l})})()})();
@@ -46,7 +46,14 @@
46
46
  "sources": [
47
47
  "ln-modal.scss",
48
48
  "src/ln-modal.js"
49
- ]
49
+ ],
50
+ "type": "enum",
51
+ "values": [
52
+ "new",
53
+ "edit"
54
+ ],
55
+ "fallback": "new",
56
+ "description": "Operational mode of the modal (new vs edit)"
50
57
  },
51
58
  "data-ln-modal-when": {
52
59
  "direction": null,
@@ -21,6 +21,12 @@ import { registerComponent, dispatch, dispatchCancelable, isVisible, shouldIgnor
21
21
  type: 'string',
22
22
  description: 'Target modal ID to open on trigger click'
23
23
  },
24
+ 'data-ln-modal-mode': {
25
+ type: 'enum',
26
+ values: ['new', 'edit'],
27
+ fallback: 'new',
28
+ description: 'Operational mode of the modal (new vs edit)'
29
+ },
24
30
  'data-ln-modal-close': {
25
31
  type: 'trigger',
26
32
  description: 'Click dismiss trigger inside the modal'
@@ -47,6 +53,8 @@ import { registerComponent, dispatch, dispatchCancelable, isVisible, shouldIgnor
47
53
  e.preventDefault();
48
54
  if (trigger.hasAttribute('data-ln-modal-mode')) {
49
55
  target.setAttribute('data-ln-modal-mode', trigger.getAttribute('data-ln-modal-mode'));
56
+ } else if (target.hasAttribute('data-ln-modal-mode')) {
57
+ target.setAttribute('data-ln-modal-mode', 'new');
50
58
  }
51
59
  target.setAttribute(DOM_SELECTOR, 'open');
52
60
  };
@@ -191,6 +199,9 @@ import { registerComponent, dispatch, dispatchCancelable, isVisible, shouldIgnor
191
199
  return;
192
200
  }
193
201
  instance.isOpen = false;
202
+ if (el.hasAttribute('data-ln-modal-mode')) {
203
+ el.setAttribute('data-ln-modal-mode', 'new');
204
+ }
194
205
  dispatch(el, 'ln-modal:close', { modalId: el.id, target: el });
195
206
 
196
207
  if (typeof el.close === 'function') el.close();
@@ -795,7 +795,15 @@
795
795
  },
796
796
  {
797
797
  "name": "data-ln-modal-mode",
798
- "description": "data-ln-modal-mode attribute"
798
+ "description": "Operational mode of the modal (new vs edit)",
799
+ "values": [
800
+ {
801
+ "name": "edit"
802
+ },
803
+ {
804
+ "name": "new"
805
+ }
806
+ ]
799
807
  },
800
808
  {
801
809
  "name": "data-ln-modal-when",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livenetworks/ashlar",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "LiveNetworks unified frontend library - CSS framework and vanilla JS components",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Live Networks",
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@livenetworks/ashlar",
4
- "version": "2.0.5",
4
+ "version": "2.0.6",
5
5
  "framework": "html",
6
6
  "contributions": {
7
7
  "html": {
@@ -1061,9 +1061,13 @@
1061
1061
  },
1062
1062
  {
1063
1063
  "name": "data-ln-modal-mode",
1064
- "description": "data-ln-modal-mode attribute",
1064
+ "description": "Operational mode of the modal (new vs edit)",
1065
1065
  "value": {
1066
- "type": "string"
1066
+ "type": "enum",
1067
+ "items": [
1068
+ "edit",
1069
+ "new"
1070
+ ]
1067
1071
  }
1068
1072
  },
1069
1073
  {