@livenetworks/ashlar 1.4.0 → 1.5.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-accordion/ln-accordion.js +1 -1
- package/js/ln-api-connector/ln-api-connector.js +1 -1
- package/js/ln-autoresize/ln-autoresize.js +1 -1
- package/js/ln-autosave/ln-autosave.js +1 -1
- package/js/ln-circular-progress/ln-circular-progress.js +1 -1
- package/js/ln-confirm/ln-confirm.js +1 -1
- package/js/ln-core/helpers.js +6 -3
- package/js/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
- package/js/ln-data-coordinator/ln-data-coordinator.js +1 -1
- package/js/ln-data-store/ln-data-store.js +1 -1
- package/js/ln-data-table/ln-data-table.js +1 -1
- package/js/ln-data-table/src/ln-data-table.js +0 -16
- package/js/ln-date/ln-date.js +1 -1
- package/js/ln-dropdown/ln-dropdown.js +1 -1
- package/js/ln-filter/README.md +99 -99
- package/js/ln-filter/ln-filter.js +1 -1
- package/js/ln-form/ln-form.js +1 -1
- package/js/ln-modal/ln-modal.js +1 -1
- package/js/ln-number/ln-number.js +1 -1
- package/js/ln-popover/ln-popover.js +1 -1
- package/js/ln-search/ln-search.js +1 -1
- package/js/ln-sortable/ln-sortable.js +1 -1
- package/js/ln-table/ln-table-sort.js +1 -1
- package/js/ln-table/ln-table.js +1 -1
- package/js/ln-table/src/ln-table-sort.js +156 -168
- package/js/ln-tabs/ln-tabs.js +1 -1
- package/js/ln-time/ln-time.js +1 -1
- package/js/ln-toggle/ln-toggle.js +1 -1
- package/js/ln-tooltip/ln-tooltip.js +1 -1
- package/js/ln-translations/ln-translations.js +1 -1
- package/js/ln-validate/ln-validate.js +1 -1
- package/package.json +3 -2
- package/scss/components/_filter.scss +25 -0
- package/scss/components/_ln-table.scss +1 -2
- package/scss/components/_table.scss +55 -1
- package/scss/config/mixins/_diagnostics.scss +37 -0
- package/scss/config/mixins/_filter.scss +49 -0
- package/scss/config/mixins/_index.scss +2 -1
- package/scss/config/mixins/_ln-table.scss +10 -91
- package/scss/config/mixins/_table.scss +202 -33
- package/scss/ln-ashlar-dev.scss +21 -0
- package/scss/ln-ashlar.scss +1 -1
- package/scss/components/_data-table.scss +0 -83
- package/scss/config/mixins/_data-table.scss +0 -346
package/js/ln-table/ln-table.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function b(o,l,y){o.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:y||{}}))}function C(o,l){if(!document.body){document.addEventListener("DOMContentLoaded",function(){C(o,l)}),console.warn("["+l+'] Script loaded before <body> — add "defer" to your <script> tag');return}o()}function T(o,l,y,g){if(o.nodeType!==1)return;const w=l.indexOf("[")!==-1||l.indexOf(".")!==-1||l.indexOf("#")!==-1?l:"["+l+"]",m=Array.from(o.querySelectorAll(w));o.matches&&o.matches(w)&&m.push(o);for(const h of m)h[y]||(h[y]=new g(h))}function L(o,l,y,g,v={}){const w=v.extraAttributes||[],m=v.onAttributeChange||null,h=v.onInit||null;function e(d){const t=d||document.body;T(t,o,l,y),h&&h(t)}return C(function(){const d=new MutationObserver(function(n){for(let u=0;u<n.length;u++){const i=n[u];if(i.type==="childList"){for(let c=0;c<i.addedNodes.length;c++){const r=i.addedNodes[c];r.nodeType===1&&(T(r,o,l,y),h&&h(r))}for(let c=0;c<i.removedNodes.length;c++){const r=i.removedNodes[c];if(r.nodeType===1){const a=o.indexOf("[")!==-1||o.indexOf(".")!==-1||o.indexOf("#")!==-1?o:"["+o+"]",f=Array.from(r.querySelectorAll(a));r.matches&&r.matches(a)&&f.push(r);for(let _=0;_<f.length;_++){const p=f[_][l];p&&typeof p.destroy=="function"&&p.destroy()}}}}else i.type==="attributes"&&(m&&i.target[l]?m(i.target,i.attributeName):(T(i.target,o,l,y),h&&h(i.target)))}});let t=[];if(o.indexOf("[")!==-1){const n=/\[([\w-]+)/g;let u;for(;(u=n.exec(o))!==null;)t.push(u[1])}else t.push(o);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.concat(w)})},g),window[l]=e,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){e(document.body)}):e(document.body),e}const A={};function O(o,l){A[o]=l}function x(o){return A[o]||{ingress:l=>l,egress:l=>l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=O,window.lnCore.getDataMapper=x),(function(){const o="data-ln-table",l="lnTable",y="data-ln-sort",g="data-ln-table-empty";if(window[l]!==void 0)return;const m=typeof Intl<"u"?new Intl.Collator(document.documentElement.lang||void 0,{sensitivity:"base"}):null;function h(e){this.dom=e,this.table=e.querySelector("table"),this.tbody=e.querySelector("tbody"),this.thead=e.querySelector("thead");const d=this.thead?this.thead.querySelector("tr:last-child"):null;this.ths=d?Array.from(d.querySelectorAll("th")):[],this._data=[],this._filteredData=[],this._searchTerm="",this._sortCol=-1,this._sortDir=null,this._sortType=null,this._columnFilters={},this._virtual=!1,this._rowHeight=0,this._vStart=-1,this._vEnd=-1,this._rafId=null,this._scrollHandler=null,this._colgroup=null;const t=this;return this._emptyTbodyObserver=null,this.tbody&&this.tbody.rows.length>0?this._parseRows():this.tbody&&(this._emptyTbodyObserver=new MutationObserver(function(){t.tbody.rows.length>0&&(t._emptyTbodyObserver.disconnect(),t._emptyTbodyObserver=null,t._parseRows())}),this._emptyTbodyObserver.observe(this.tbody,{childList:!0})),this._onSearch=function(n){n.preventDefault(),t._searchTerm=n.detail.term,t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),b(e,"ln-table:filter",{term:t._searchTerm,matched:t._filteredData.length,total:t._data.length})},e.addEventListener("ln-search:change",this._onSearch),this._onSort=function(n){t._sortCol=n.detail.direction===null?-1:n.detail.column,t._sortDir=n.detail.direction,t._sortType=n.detail.sortType,t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),b(e,"ln-table:sorted",{column:n.detail.column,direction:n.detail.direction,matched:t._filteredData.length,total:t._data.length})},e.addEventListener("ln-table:sort",this._onSort),this._onColumnFilter=function(n){const u=n.detail.key;let i=!1;for(let s=0;s<t.ths.length;s++)if(t.ths[s].getAttribute("data-ln-filter-col")===u){i=!0;break}if(!i)return;const c=n.detail.values;if(!c||c.length===0)delete t._columnFilters[u];else{const s=[];for(let a=0;a<c.length;a++)s.push(c[a].toLowerCase());t._columnFilters[u]=s}const r=t.dom.querySelector('th[data-ln-filter-col="'+u+'"]');r&&(c&&c.length>0?r.setAttribute("data-ln-filter-active",""):r.removeAttribute("data-ln-filter-active")),t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),b(e,"ln-table:filter",{term:t._searchTerm,matched:t._filteredData.length,total:t._data.length})},e.addEventListener("ln-filter:changed",this._onColumnFilter),this._onClear=function(n){if(!n.target.closest("[data-ln-table-clear]"))return;t._searchTerm="";const i=document.querySelector('[data-ln-search="'+e.id+'"]');if(i){const r=i.tagName==="INPUT"?i:i.querySelector("input");r&&(r.value="")}t._columnFilters={};for(let r=0;r<t.ths.length;r++)t.ths[r].removeAttribute("data-ln-filter-active");const c=document.querySelectorAll('[data-ln-filter="'+e.id+'"]');for(let r=0;r<c.length;r++){const s=c[r].querySelector("[data-ln-filter-reset]");s&&(s.checked=!0,s.dispatchEvent(new Event("change",{bubbles:!0})))}t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),b(e,"ln-table:filter",{term:"",matched:t._filteredData.length,total:t._data.length})},e.addEventListener("click",this._onClear),this}h.prototype._parseRows=function(){const e=this.tbody.rows,d=this.ths;this._data=[];const t=[];for(let n=0;n<d.length;n++)t[n]=d[n].getAttribute(y);e.length>0&&(this._rowHeight=e[0].offsetHeight||40),this._lockColumnWidths();for(let n=0;n<e.length;n++){const u=e[n],i=[],c=[],r=[];for(let s=0;s<u.cells.length;s++){const a=u.cells[s],f=a.textContent.trim(),_=a.hasAttribute("data-ln-value")?a.getAttribute("data-ln-value"):f,p=t[s];c[s]=f.toLowerCase(),p==="number"||p==="date"?i[s]=parseFloat(_)||0:p==="string"?i[s]=String(_):i[s]=null,s<u.cells.length-1&&r.push(f.toLowerCase())}this._data.push({sortKeys:i,rawTexts:c,html:u.outerHTML,searchText:r.join(" ")})}this._filteredData=this._data.slice(),this._render(),b(this.dom,"ln-table:ready",{total:this._data.length})},h.prototype._applyFilterAndSort=function(){const e=this._searchTerm,d=this._columnFilters,t=Object.keys(d).length>0,n=this.ths,u={};if(t)for(let a=0;a<n.length;a++){const f=n[a].getAttribute("data-ln-filter-col");f&&(u[f]=a)}if(!e&&!t?this._filteredData=this._data.slice():this._filteredData=this._data.filter(function(a){if(e&&a.searchText.indexOf(e)===-1)return!1;if(t)for(const f in d){const _=u[f];if(_!==void 0&&d[f].indexOf(a.rawTexts[_])===-1)return!1}return!0}),this._sortCol<0||!this._sortDir)return;const i=this._sortCol,c=this._sortDir==="desc"?-1:1,r=this._sortType==="number"||this._sortType==="date",s=m?m.compare:function(a,f){return a<f?-1:a>f?1:0};this._filteredData.sort(function(a,f){const _=a.sortKeys[i],p=f.sortKeys[i];return r?(_-p)*c:s(_,p)*c})},h.prototype._lockColumnWidths=function(){if(!this.table||!this.thead||this._colgroup)return;const e=document.createElement("colgroup");this.ths.forEach(function(d){const t=document.createElement("col");t.style.width=d.offsetWidth+"px",e.appendChild(t)}),this.table.insertBefore(e,this.table.firstChild),this.table.style.tableLayout="fixed",this._colgroup=e},h.prototype._render=function(){if(!this.tbody)return;const e=this._filteredData.length;e===0&&(this._searchTerm||Object.keys(this._columnFilters).length>0)?(this._disableVirtualScroll(),this._showEmptyState()):e>200?(this._enableVirtualScroll(),this._renderVirtual()):(this._disableVirtualScroll(),this._renderAll())},h.prototype._renderAll=function(){const e=[],d=this._filteredData;for(let t=0;t<d.length;t++)e.push(d[t].html);this.tbody.innerHTML=e.join("")},h.prototype._enableVirtualScroll=function(){if(this._virtual)return;this._virtual=!0;const e=this;this._scrollHandler=function(){e._rafId||(e._rafId=requestAnimationFrame(function(){e._rafId=null,e._renderVirtual()}))},window.addEventListener("scroll",this._scrollHandler,{passive:!0}),window.addEventListener("resize",this._scrollHandler,{passive:!0})},h.prototype._disableVirtualScroll=function(){this._virtual&&(this._virtual=!1,this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),window.removeEventListener("resize",this._scrollHandler),this._scrollHandler=null),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._vStart=-1,this._vEnd=-1)},h.prototype._renderVirtual=function(){const e=this._filteredData,d=e.length,t=this._rowHeight;if(!t||!d)return;const u=this.table.getBoundingClientRect().top+window.scrollY,i=this.thead?this.thead.offsetHeight:0,c=u+i,r=window.scrollY-c,s=Math.max(0,Math.floor(r/t)-15),a=Math.min(s+Math.ceil(window.innerHeight/t)+30,d);if(s===this._vStart&&a===this._vEnd)return;this._vStart=s,this._vEnd=a;const f=this.ths.length||1,_=s*t,p=(d-a)*t;let S="";_>0&&(S+='<tr class="ln-table__spacer" aria-hidden="true"><td colspan="'+f+'" style="height:'+_+'px;padding:0;border:none"></td></tr>');for(let E=s;E<a;E++)S+=e[E].html;p>0&&(S+='<tr class="ln-table__spacer" aria-hidden="true"><td colspan="'+f+'" style="height:'+p+'px;padding:0;border:none"></td></tr>'),this.tbody.innerHTML=S},h.prototype._showEmptyState=function(){const e=this.ths.length||1,d=this.dom.querySelector("template["+g+"]"),t=document.createElement("td");t.setAttribute("colspan",String(e)),d&&t.appendChild(document.importNode(d.content,!0));const n=document.createElement("tr");n.className="ln-table__empty",n.appendChild(t),this.tbody.innerHTML="",this.tbody.appendChild(n),b(this.dom,"ln-table:empty",{term:this._searchTerm,total:this._data.length})},h.prototype.destroy=function(){this.dom[l]&&(this._disableVirtualScroll(),this._emptyTbodyObserver&&(this._emptyTbodyObserver.disconnect(),this._emptyTbodyObserver=null),this.dom.removeEventListener("ln-search:change",this._onSearch),this.dom.removeEventListener("ln-table:sort",this._onSort),this.dom.removeEventListener("ln-filter:changed",this._onColumnFilter),this.dom.removeEventListener("click",this._onClear),this._colgroup&&(this._colgroup.remove(),this._colgroup=null),this.table&&(this.table.style.tableLayout=""),this._data=[],this._filteredData=[],delete this.dom[l])},L(o,l,h,"ln-table")})()})();
|
|
1
|
+
(function(){"use strict";function g(o,l,m){o.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:m||{}}))}function C(o,l){if(!document.body){document.addEventListener("DOMContentLoaded",function(){C(o,l)}),console.warn("["+l+'] Script loaded before <body> — add "defer" to your <script> tag');return}o()}function T(o,l,m,v){if(o.nodeType!==1)return;const S=l.indexOf("[")!==-1||l.indexOf(".")!==-1||l.indexOf("#")!==-1?l:"["+l+"]",y=Array.from(o.querySelectorAll(S));o.matches&&o.matches(S)&&y.push(o);for(const h of y)h[m]||(h[m]=new v(h))}function L(o,l,m,v,w={}){const S=w.extraAttributes||[],y=w.onAttributeChange||null,h=w.onInit||null;function e(d){const t=d||document.body;T(t,o,l,m),h&&h(t)}return C(function(){const d=new MutationObserver(function(n){for(let u=0;u<n.length;u++){const i=n[u];if(i.type==="childList"){for(let c=0;c<i.addedNodes.length;c++){const r=i.addedNodes[c];r.nodeType===1&&(T(r,o,l,m),h&&h(r))}for(let c=0;c<i.removedNodes.length;c++){const r=i.removedNodes[c];if(r.nodeType===1){const a=o.indexOf("[")!==-1||o.indexOf(".")!==-1||o.indexOf("#")!==-1?o:"["+o+"]",f=Array.from(r.querySelectorAll(a));r.matches&&r.matches(a)&&f.push(r);for(let _=0;_<f.length;_++){const p=f[_];if(!document.contains(p)){const b=p[l];b&&typeof b.destroy=="function"&&b.destroy()}}}}}else i.type==="attributes"&&(y&&i.target[l]?y(i.target,i.attributeName):(T(i.target,o,l,m),h&&h(i.target)))}});let t=[];if(o.indexOf("[")!==-1){const n=/\[([\w-]+)/g;let u;for(;(u=n.exec(o))!==null;)t.push(u[1])}else t.push(o);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.concat(S)})},v),window[l]=e,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){e(document.body)}):e(document.body),e}const A={};function O(o,l){A[o]=l}function x(o){return A[o]||{ingress:l=>l,egress:l=>l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=O,window.lnCore.getDataMapper=x),(function(){const o="data-ln-table",l="lnTable",m="data-ln-sort",v="data-ln-table-empty";if(window[l]!==void 0)return;const y=typeof Intl<"u"?new Intl.Collator(document.documentElement.lang||void 0,{sensitivity:"base"}):null;function h(e){this.dom=e,this.table=e.querySelector("table"),this.tbody=e.querySelector("tbody"),this.thead=e.querySelector("thead");const d=this.thead?this.thead.querySelector("tr:last-child"):null;this.ths=d?Array.from(d.querySelectorAll("th")):[],this._data=[],this._filteredData=[],this._searchTerm="",this._sortCol=-1,this._sortDir=null,this._sortType=null,this._columnFilters={},this._virtual=!1,this._rowHeight=0,this._vStart=-1,this._vEnd=-1,this._rafId=null,this._scrollHandler=null,this._colgroup=null;const t=this;return this._emptyTbodyObserver=null,this.tbody&&this.tbody.rows.length>0?this._parseRows():this.tbody&&(this._emptyTbodyObserver=new MutationObserver(function(){t.tbody.rows.length>0&&(t._emptyTbodyObserver.disconnect(),t._emptyTbodyObserver=null,t._parseRows())}),this._emptyTbodyObserver.observe(this.tbody,{childList:!0})),this._onSearch=function(n){n.preventDefault(),t._searchTerm=n.detail.term,t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),g(e,"ln-table:filter",{term:t._searchTerm,matched:t._filteredData.length,total:t._data.length})},e.addEventListener("ln-search:change",this._onSearch),this._onSort=function(n){t._sortCol=n.detail.direction===null?-1:n.detail.column,t._sortDir=n.detail.direction,t._sortType=n.detail.sortType,t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),g(e,"ln-table:sorted",{column:n.detail.column,direction:n.detail.direction,matched:t._filteredData.length,total:t._data.length})},e.addEventListener("ln-table:sort",this._onSort),this._onColumnFilter=function(n){const u=n.detail.key;let i=!1;for(let s=0;s<t.ths.length;s++)if(t.ths[s].getAttribute("data-ln-filter-col")===u){i=!0;break}if(!i)return;const c=n.detail.values;if(!c||c.length===0)delete t._columnFilters[u];else{const s=[];for(let a=0;a<c.length;a++)s.push(c[a].toLowerCase());t._columnFilters[u]=s}const r=t.dom.querySelector('th[data-ln-filter-col="'+u+'"]');r&&(c&&c.length>0?r.setAttribute("data-ln-filter-active",""):r.removeAttribute("data-ln-filter-active")),t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),g(e,"ln-table:filter",{term:t._searchTerm,matched:t._filteredData.length,total:t._data.length})},e.addEventListener("ln-filter:changed",this._onColumnFilter),this._onClear=function(n){if(!n.target.closest("[data-ln-table-clear]"))return;t._searchTerm="";const i=document.querySelector('[data-ln-search="'+e.id+'"]');if(i){const r=i.tagName==="INPUT"?i:i.querySelector("input");r&&(r.value="")}t._columnFilters={};for(let r=0;r<t.ths.length;r++)t.ths[r].removeAttribute("data-ln-filter-active");const c=document.querySelectorAll('[data-ln-filter="'+e.id+'"]');for(let r=0;r<c.length;r++){const s=c[r].querySelector("[data-ln-filter-reset]");s&&(s.checked=!0,s.dispatchEvent(new Event("change",{bubbles:!0})))}t._applyFilterAndSort(),t._vStart=-1,t._vEnd=-1,t._render(),g(e,"ln-table:filter",{term:"",matched:t._filteredData.length,total:t._data.length})},e.addEventListener("click",this._onClear),this}h.prototype._parseRows=function(){const e=this.tbody.rows,d=this.ths;this._data=[];const t=[];for(let n=0;n<d.length;n++)t[n]=d[n].getAttribute(m);e.length>0&&(this._rowHeight=e[0].offsetHeight||40),this._lockColumnWidths();for(let n=0;n<e.length;n++){const u=e[n],i=[],c=[],r=[];for(let s=0;s<u.cells.length;s++){const a=u.cells[s],f=a.textContent.trim(),_=a.hasAttribute("data-ln-value")?a.getAttribute("data-ln-value"):f,p=t[s];c[s]=f.toLowerCase(),p==="number"||p==="date"?i[s]=parseFloat(_)||0:p==="string"?i[s]=String(_):i[s]=null,s<u.cells.length-1&&r.push(f.toLowerCase())}this._data.push({sortKeys:i,rawTexts:c,html:u.outerHTML,searchText:r.join(" ")})}this._filteredData=this._data.slice(),this._render(),g(this.dom,"ln-table:ready",{total:this._data.length})},h.prototype._applyFilterAndSort=function(){const e=this._searchTerm,d=this._columnFilters,t=Object.keys(d).length>0,n=this.ths,u={};if(t)for(let a=0;a<n.length;a++){const f=n[a].getAttribute("data-ln-filter-col");f&&(u[f]=a)}if(!e&&!t?this._filteredData=this._data.slice():this._filteredData=this._data.filter(function(a){if(e&&a.searchText.indexOf(e)===-1)return!1;if(t)for(const f in d){const _=u[f];if(_!==void 0&&d[f].indexOf(a.rawTexts[_])===-1)return!1}return!0}),this._sortCol<0||!this._sortDir)return;const i=this._sortCol,c=this._sortDir==="desc"?-1:1,r=this._sortType==="number"||this._sortType==="date",s=y?y.compare:function(a,f){return a<f?-1:a>f?1:0};this._filteredData.sort(function(a,f){const _=a.sortKeys[i],p=f.sortKeys[i];return r?(_-p)*c:s(_,p)*c})},h.prototype._lockColumnWidths=function(){if(!this.table||!this.thead||this._colgroup)return;const e=document.createElement("colgroup");this.ths.forEach(function(d){const t=document.createElement("col");t.style.width=d.offsetWidth+"px",e.appendChild(t)}),this.table.insertBefore(e,this.table.firstChild),this.table.style.tableLayout="fixed",this._colgroup=e},h.prototype._render=function(){if(!this.tbody)return;const e=this._filteredData.length;e===0&&(this._searchTerm||Object.keys(this._columnFilters).length>0)?(this._disableVirtualScroll(),this._showEmptyState()):e>200?(this._enableVirtualScroll(),this._renderVirtual()):(this._disableVirtualScroll(),this._renderAll())},h.prototype._renderAll=function(){const e=[],d=this._filteredData;for(let t=0;t<d.length;t++)e.push(d[t].html);this.tbody.innerHTML=e.join("")},h.prototype._enableVirtualScroll=function(){if(this._virtual)return;this._virtual=!0;const e=this;this._scrollHandler=function(){e._rafId||(e._rafId=requestAnimationFrame(function(){e._rafId=null,e._renderVirtual()}))},window.addEventListener("scroll",this._scrollHandler,{passive:!0}),window.addEventListener("resize",this._scrollHandler,{passive:!0})},h.prototype._disableVirtualScroll=function(){this._virtual&&(this._virtual=!1,this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),window.removeEventListener("resize",this._scrollHandler),this._scrollHandler=null),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._vStart=-1,this._vEnd=-1)},h.prototype._renderVirtual=function(){const e=this._filteredData,d=e.length,t=this._rowHeight;if(!t||!d)return;const u=this.table.getBoundingClientRect().top+window.scrollY,i=this.thead?this.thead.offsetHeight:0,c=u+i,r=window.scrollY-c,s=Math.max(0,Math.floor(r/t)-15),a=Math.min(s+Math.ceil(window.innerHeight/t)+30,d);if(s===this._vStart&&a===this._vEnd)return;this._vStart=s,this._vEnd=a;const f=this.ths.length||1,_=s*t,p=(d-a)*t;let b="";_>0&&(b+='<tr class="ln-table__spacer" aria-hidden="true"><td colspan="'+f+'" style="height:'+_+'px;padding:0;border:none"></td></tr>');for(let E=s;E<a;E++)b+=e[E].html;p>0&&(b+='<tr class="ln-table__spacer" aria-hidden="true"><td colspan="'+f+'" style="height:'+p+'px;padding:0;border:none"></td></tr>'),this.tbody.innerHTML=b},h.prototype._showEmptyState=function(){const e=this.ths.length||1,d=this.dom.querySelector("template["+v+"]"),t=document.createElement("td");t.setAttribute("colspan",String(e)),d&&t.appendChild(document.importNode(d.content,!0));const n=document.createElement("tr");n.className="ln-table__empty",n.appendChild(t),this.tbody.innerHTML="",this.tbody.appendChild(n),g(this.dom,"ln-table:empty",{term:this._searchTerm,total:this._data.length})},h.prototype.destroy=function(){this.dom[l]&&(this._disableVirtualScroll(),this._emptyTbodyObserver&&(this._emptyTbodyObserver.disconnect(),this._emptyTbodyObserver=null),this.dom.removeEventListener("ln-search:change",this._onSearch),this.dom.removeEventListener("ln-table:sort",this._onSort),this.dom.removeEventListener("ln-filter:changed",this._onColumnFilter),this.dom.removeEventListener("click",this._onClear),this._colgroup&&(this._colgroup.remove(),this._colgroup=null),this.table&&(this.table.style.tableLayout=""),this._data=[],this._filteredData=[],delete this.dom[l])},L(o,l,h,"ln-table")})()})();
|
|
@@ -1,168 +1,156 @@
|
|
|
1
|
-
import { guardBody, dispatch } from '../../ln-core';
|
|
2
|
-
import { persistGet, persistSet } from '../../ln-core';
|
|
3
|
-
|
|
4
|
-
(function () {
|
|
5
|
-
const DOM_ATTRIBUTE = 'lnTableSort';
|
|
6
|
-
const SORT_ATTR = 'data-ln-sort';
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
if (window[DOM_ATTRIBUTE] !== undefined) return;
|
|
10
|
-
|
|
11
|
-
// ─── Constructor ───────────────────────────────────────────
|
|
12
|
-
// Auto-initializes any <table> that contains th[data-ln-sort] headers.
|
|
13
|
-
|
|
14
|
-
function constructor(domRoot) {
|
|
15
|
-
findElements(domRoot);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Local findElements — intentional divergence from ln-core helper: tag selector ('table') + two-arg constructor (table, ths).
|
|
19
|
-
function findElements(root) {
|
|
20
|
-
const tables = Array.from(root.querySelectorAll('table'));
|
|
21
|
-
if (root.tagName === 'TABLE') tables.push(root);
|
|
22
|
-
|
|
23
|
-
tables.forEach(function (table) {
|
|
24
|
-
if (table[DOM_ATTRIBUTE]) return;
|
|
25
|
-
const ths = Array.from(table.querySelectorAll('th[' + SORT_ATTR + ']'));
|
|
26
|
-
if (ths.length) table[DOM_ATTRIBUTE] = new _component(table, ths);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ─── Component ─────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} else {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
window[DOM_ATTRIBUTE] = constructor;
|
|
159
|
-
_domObserver();
|
|
160
|
-
|
|
161
|
-
if (document.readyState === 'loading') {
|
|
162
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
163
|
-
constructor(document.body);
|
|
164
|
-
});
|
|
165
|
-
} else {
|
|
166
|
-
constructor(document.body);
|
|
167
|
-
}
|
|
168
|
-
})();
|
|
1
|
+
import { guardBody, dispatch } from '../../ln-core';
|
|
2
|
+
import { persistGet, persistSet } from '../../ln-core';
|
|
3
|
+
|
|
4
|
+
(function () {
|
|
5
|
+
const DOM_ATTRIBUTE = 'lnTableSort';
|
|
6
|
+
const SORT_ATTR = 'data-ln-sort';
|
|
7
|
+
const BUTTON_HOOK = 'data-ln-table-sort';
|
|
8
|
+
|
|
9
|
+
if (window[DOM_ATTRIBUTE] !== undefined) return;
|
|
10
|
+
|
|
11
|
+
// ─── Constructor ───────────────────────────────────────────
|
|
12
|
+
// Auto-initializes any <table> that contains th[data-ln-sort] headers.
|
|
13
|
+
|
|
14
|
+
function constructor(domRoot) {
|
|
15
|
+
findElements(domRoot);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Local findElements — intentional divergence from ln-core helper: tag selector ('table') + two-arg constructor (table, ths).
|
|
19
|
+
function findElements(root) {
|
|
20
|
+
const tables = Array.from(root.querySelectorAll('table'));
|
|
21
|
+
if (root.tagName === 'TABLE') tables.push(root);
|
|
22
|
+
|
|
23
|
+
tables.forEach(function (table) {
|
|
24
|
+
if (table[DOM_ATTRIBUTE]) return;
|
|
25
|
+
const ths = Array.from(table.querySelectorAll('th[' + SORT_ATTR + ']'));
|
|
26
|
+
if (ths.length) table[DOM_ATTRIBUTE] = new _component(table, ths);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ─── Component ─────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
function _component(table, ths) {
|
|
33
|
+
this.table = table;
|
|
34
|
+
this.ths = ths;
|
|
35
|
+
this._col = -1;
|
|
36
|
+
this._dir = null;
|
|
37
|
+
const self = this;
|
|
38
|
+
|
|
39
|
+
ths.forEach(function (th, index) {
|
|
40
|
+
if (th[DOM_ATTRIBUTE + 'Bound']) return;
|
|
41
|
+
th[DOM_ATTRIBUTE + 'Bound'] = true;
|
|
42
|
+
|
|
43
|
+
// D1/Option A: bind click to the sort button, not the whole <th>.
|
|
44
|
+
// Columns without a [data-ln-table-sort] button skip binding.
|
|
45
|
+
const btn = th.querySelector('[' + BUTTON_HOOK + ']');
|
|
46
|
+
if (!btn) return;
|
|
47
|
+
|
|
48
|
+
btn._lnSortClick = function () {
|
|
49
|
+
self._handleClick(index, th);
|
|
50
|
+
};
|
|
51
|
+
btn.addEventListener('click', btn._lnSortClick);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// ─── Restore persisted sort ───────────────────────────────
|
|
55
|
+
const persistRoot = table.closest('[data-ln-table][data-ln-persist]');
|
|
56
|
+
if (persistRoot) {
|
|
57
|
+
const saved = persistGet('table-sort', persistRoot);
|
|
58
|
+
if (saved && saved.dir && saved.col >= 0 && saved.col < ths.length) {
|
|
59
|
+
// Programmatically trigger the saved sort
|
|
60
|
+
this._handleClick(saved.col, ths[saved.col]);
|
|
61
|
+
if (saved.dir === 'desc') {
|
|
62
|
+
this._handleClick(saved.col, ths[saved.col]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_component.prototype._handleClick = function (colIndex, th) {
|
|
71
|
+
let newDir;
|
|
72
|
+
|
|
73
|
+
if (this._col !== colIndex) {
|
|
74
|
+
newDir = 'asc';
|
|
75
|
+
} else if (this._dir === 'asc') {
|
|
76
|
+
newDir = 'desc';
|
|
77
|
+
} else if (this._dir === 'desc') {
|
|
78
|
+
newDir = null;
|
|
79
|
+
} else {
|
|
80
|
+
newDir = 'asc';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// JS-2: use state classes on <th>; CSS owns icon visibility.
|
|
84
|
+
this.ths.forEach(function (t) {
|
|
85
|
+
t.classList.remove('ln-sort-asc', 'ln-sort-desc');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (newDir === null) {
|
|
89
|
+
this._col = -1;
|
|
90
|
+
this._dir = null;
|
|
91
|
+
} else {
|
|
92
|
+
this._col = colIndex;
|
|
93
|
+
this._dir = newDir;
|
|
94
|
+
th.classList.add(newDir === 'asc' ? 'ln-sort-asc' : 'ln-sort-desc');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
dispatch(this.table, 'ln-table:sort', {
|
|
98
|
+
column: colIndex,
|
|
99
|
+
sortType: th.getAttribute(SORT_ATTR),
|
|
100
|
+
direction: newDir
|
|
101
|
+
});
|
|
102
|
+
const persistRoot = this.table.closest('[data-ln-table][data-ln-persist]');
|
|
103
|
+
if (persistRoot) {
|
|
104
|
+
if (newDir === null) {
|
|
105
|
+
persistSet('table-sort', persistRoot, null);
|
|
106
|
+
} else {
|
|
107
|
+
persistSet('table-sort', persistRoot, { col: colIndex, dir: newDir });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
_component.prototype.destroy = function () {
|
|
113
|
+
if (!this.table[DOM_ATTRIBUTE]) return;
|
|
114
|
+
this.ths.forEach(function (th) {
|
|
115
|
+
const btn = th.querySelector('[' + BUTTON_HOOK + ']');
|
|
116
|
+
if (btn && btn._lnSortClick) {
|
|
117
|
+
btn.removeEventListener('click', btn._lnSortClick);
|
|
118
|
+
delete btn._lnSortClick;
|
|
119
|
+
}
|
|
120
|
+
delete th[DOM_ATTRIBUTE + 'Bound'];
|
|
121
|
+
});
|
|
122
|
+
delete this.table[DOM_ATTRIBUTE];
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// ─── DOM Observer ──────────────────────────────────────────
|
|
126
|
+
|
|
127
|
+
function _domObserver() {
|
|
128
|
+
guardBody(function () {
|
|
129
|
+
const observer = new MutationObserver(function (mutations) {
|
|
130
|
+
mutations.forEach(function (mutation) {
|
|
131
|
+
if (mutation.type === 'childList') {
|
|
132
|
+
mutation.addedNodes.forEach(function (node) {
|
|
133
|
+
if (node.nodeType === 1) findElements(node);
|
|
134
|
+
});
|
|
135
|
+
} else if (mutation.type === 'attributes') {
|
|
136
|
+
findElements(mutation.target);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: [SORT_ATTR] });
|
|
141
|
+
}, 'ln-table-sort');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─── Init ──────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
window[DOM_ATTRIBUTE] = constructor;
|
|
147
|
+
_domObserver();
|
|
148
|
+
|
|
149
|
+
if (document.readyState === 'loading') {
|
|
150
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
151
|
+
constructor(document.body);
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
constructor(document.body);
|
|
155
|
+
}
|
|
156
|
+
})();
|
package/js/ln-tabs/ln-tabs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function A(s,n,o){s.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:o||{}}))}function v(s,n){if(!document.body){document.addEventListener("DOMContentLoaded",function(){v(s,n)}),console.warn("["+n+'] Script loaded before <body> — add "defer" to your <script> tag');return}s()}function b(s,n,o,d){if(s.nodeType!==1)return;const p=n.indexOf("[")!==-1||n.indexOf(".")!==-1||n.indexOf("#")!==-1?n:"["+n+"]",e=Array.from(s.querySelectorAll(p));s.matches&&s.matches(p)&&e.push(s);for(const t of e)t[o]||(t[o]=new d(t))}function
|
|
1
|
+
(function(){"use strict";function A(s,n,o){s.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:o||{}}))}function v(s,n){if(!document.body){document.addEventListener("DOMContentLoaded",function(){v(s,n)}),console.warn("["+n+'] Script loaded before <body> — add "defer" to your <script> tag');return}s()}function b(s,n,o,d){if(s.nodeType!==1)return;const p=n.indexOf("[")!==-1||n.indexOf(".")!==-1||n.indexOf("#")!==-1?n:"["+n+"]",e=Array.from(s.querySelectorAll(p));s.matches&&s.matches(p)&&e.push(s);for(const t of e)t[o]||(t[o]=new d(t))}function O(s,n,o,d,m={}){const p=m.extraAttributes||[],e=m.onAttributeChange||null,t=m.onInit||null;function i(a){const r=a||document.body;b(r,s,n,o),t&&t(r)}return v(function(){const a=new MutationObserver(function(f){for(let c=0;c<f.length;c++){const l=f[c];if(l.type==="childList"){for(let h=0;h<l.addedNodes.length;h++){const u=l.addedNodes[h];u.nodeType===1&&(b(u,s,n,o),t&&t(u))}for(let h=0;h<l.removedNodes.length;h++){const u=l.removedNodes[h];if(u.nodeType===1){const E=s.indexOf("[")!==-1||s.indexOf(".")!==-1||s.indexOf("#")!==-1?s:"["+s+"]",y=Array.from(u.querySelectorAll(E));u.matches&&u.matches(E)&&y.push(u);for(let g=0;g<y.length;g++){const L=y[g];if(!document.contains(L)){const w=L[n];w&&typeof w.destroy=="function"&&w.destroy()}}}}}else l.type==="attributes"&&(e&&l.target[n]?e(l.target,l.attributeName):(b(l.target,s,n,o),t&&t(l.target)))}});let r=[];if(s.indexOf("[")!==-1){const f=/\[([\w-]+)/g;let c;for(;(c=f.exec(s))!==null;)r.push(c[1])}else r.push(s);a.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:r.concat(p)})},d),window[n]=i,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){i(document.body)}):i(document.body),i}const C={};function T(s,n){C[s]=n}function _(s){return C[s]||{ingress:n=>n,egress:n=>n}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=T,window.lnCore.getDataMapper=_);const K="ln:";function S(){return location.pathname.replace(/\/+$/,"").toLowerCase()||"/"}function x(s,n){const o=n.getAttribute("data-ln-persist"),d=o!==null&&o!==""?o:n.id;return d?K+s+":"+S()+":"+d:(console.warn('[ln-persist] Element requires id or data-ln-persist="key"',n),null)}function k(s,n){const o=x(s,n);if(!o)return null;try{const d=localStorage.getItem(o);return d!==null?JSON.parse(d):null}catch{return null}}function M(s,n,o){const d=x(s,n);if(d)try{localStorage.setItem(d,JSON.stringify(o))}catch{}}(function(){const s="data-ln-tabs",n="lnTabs";if(window[n]!==void 0&&window[n]!==null)return;function o(){const e=(location.hash||"").replace("#",""),t={};if(!e)return t;for(const i of e.split("&")){const a=i.indexOf(":");a>0&&(t[i.slice(0,a)]=i.slice(a+1))}return t}function d(e,t){const i=(e.getAttribute("data-ln-tab")||"").toLowerCase().trim();if(i)return i;if(e.tagName!=="A")return"";const a=e.getAttribute("href")||"";if(!a.startsWith("#"))return"";const r=a.slice(1);if(!r)return"";const f=r.split("&");if(t)for(const h of f){const u=h.indexOf(":");if(u>0&&h.slice(0,u).toLowerCase().trim()===t)return h.slice(u+1).toLowerCase().trim()}const c=f[f.length-1]||"",l=c.indexOf(":");return(l>0?c.slice(l+1):c).toLowerCase().trim()}function m(e){return this.dom=e,p.call(this),this}function p(){this.tabs=Array.from(this.dom.querySelectorAll("[data-ln-tab]")),this.panels=Array.from(this.dom.querySelectorAll("[data-ln-panel]")),this.nsKey=(this.dom.getAttribute("data-ln-tabs-key")||this.dom.id||"").toLowerCase().trim(),this.hashEnabled=!!this.nsKey,this.mapTabs={},this.mapPanels={};for(const t of this.tabs){const i=d(t,this.nsKey);i?this.mapTabs[i]=t:console.warn('[ln-tabs] Trigger has no resolvable key — needs `data-ln-tab="key"` or `<a href="#…">`.',t)}for(const t of this.panels){const i=(t.getAttribute("data-ln-panel")||"").toLowerCase().trim();i&&(this.mapPanels[i]=t)}this.defaultKey=(this.dom.getAttribute("data-ln-tabs-default")||"").toLowerCase().trim()||Object.keys(this.mapTabs)[0]||"",this.autoFocus=(this.dom.getAttribute("data-ln-tabs-focus")||"true").toLowerCase()!=="false";const e=this;this._clickHandlers=[];for(const t of this.tabs){if(t[n+"Trigger"])continue;const i=function(a){if(a.ctrlKey||a.metaKey||a.button===1)return;const r=d(t,e.nsKey);if(r)if(t.tagName==="A"&&a.preventDefault(),e.hashEnabled){const f=o();f[e.nsKey]=r;const c=Object.keys(f).map(function(l){return l+":"+f[l]}).join("&");location.hash==="#"+c?e.dom.setAttribute("data-ln-tabs-active",r):location.hash=c}else e.dom.setAttribute("data-ln-tabs-active",r)};t.addEventListener("click",i),t[n+"Trigger"]=i,e._clickHandlers.push({el:t,handler:i})}if(this._hashHandler=function(){if(!e.hashEnabled)return;const t=o();e.dom.setAttribute("data-ln-tabs-active",e.nsKey in t?t[e.nsKey]:e.defaultKey)},this.hashEnabled)window.addEventListener("hashchange",this._hashHandler),this._hashHandler();else{let t=this.defaultKey;if(this.dom.hasAttribute("data-ln-persist")&&!this.hashEnabled){const i=k("tabs",this.dom);i!==null&&i in this.mapPanels&&(t=i)}this.dom.setAttribute("data-ln-tabs-active",t)}}m.prototype._applyActive=function(e){var t;(!e||!(e in this.mapPanels))&&(e=this.defaultKey);for(const i in this.mapTabs){const a=this.mapTabs[i];i===e?(a.setAttribute("data-active",""),a.setAttribute("aria-selected","true")):(a.removeAttribute("data-active"),a.setAttribute("aria-selected","false"))}for(const i in this.mapPanels){const a=this.mapPanels[i],r=i===e;a.classList.toggle("hidden",!r),a.setAttribute("aria-hidden",r?"false":"true")}if(this.autoFocus){const i=(t=this.mapPanels[e])==null?void 0:t.querySelector('input,button,select,textarea,[tabindex]:not([tabindex="-1"])');i&&setTimeout(()=>i.focus({preventScroll:!0}),0)}A(this.dom,"ln-tabs:change",{key:e,tab:this.mapTabs[e],panel:this.mapPanels[e]}),this.dom.hasAttribute("data-ln-persist")&&!this.hashEnabled&&M("tabs",this.dom,e)},m.prototype.destroy=function(){if(this.dom[n]){for(const{el:e,handler:t}of this._clickHandlers)e.removeEventListener("click",t),delete e[n+"Trigger"];this.hashEnabled&&window.removeEventListener("hashchange",this._hashHandler),A(this.dom,"ln-tabs:destroyed",{target:this.dom}),delete this.dom[n]}},O(s,n,m,"ln-tabs",{extraAttributes:["data-ln-tabs-active"],onAttributeChange:function(e){const t=e.getAttribute("data-ln-tabs-active");e[n]._applyActive(t)}})})()})();
|
package/js/ln-time/ln-time.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function I(e,n){if(!document.body){document.addEventListener("DOMContentLoaded",function(){I(e,n)}),console.warn("["+n+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function O(e,n,d,v){if(e.nodeType!==1)return;const h=n.indexOf("[")!==-1||n.indexOf(".")!==-1||n.indexOf("#")!==-1?n:"["+n+"]",w=Array.from(e.querySelectorAll(h));e.matches&&e.matches(h)&&w.push(e);for(const
|
|
1
|
+
(function(){"use strict";function I(e,n){if(!document.body){document.addEventListener("DOMContentLoaded",function(){I(e,n)}),console.warn("["+n+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function O(e,n,d,v){if(e.nodeType!==1)return;const h=n.indexOf("[")!==-1||n.indexOf(".")!==-1||n.indexOf("#")!==-1?n:"["+n+"]",w=Array.from(e.querySelectorAll(h));e.matches&&e.matches(h)&&w.push(e);for(const i of w)i[d]||(i[d]=new v(i))}function N(e,n,d,v,A={}){const h=A.extraAttributes||[],w=A.onAttributeChange||null,i=A.onInit||null;function c(x){const l=x||document.body;O(l,e,n,d),i&&i(l)}return I(function(){const x=new MutationObserver(function(M){for(let y=0;y<M.length;y++){const r=M[y];if(r.type==="childList"){for(let g=0;g<r.addedNodes.length;g++){const f=r.addedNodes[g];f.nodeType===1&&(O(f,e,n,d),i&&i(f))}for(let g=0;g<r.removedNodes.length;g++){const f=r.removedNodes[g];if(f.nodeType===1){const p=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",_=Array.from(f.querySelectorAll(p));f.matches&&f.matches(p)&&_.push(f);for(let S=0;S<_.length;S++){const D=_[S];if(!document.contains(D)){const t=D[n];t&&typeof t.destroy=="function"&&t.destroy()}}}}}else r.type==="attributes"&&(w&&r.target[n]?w(r.target,r.attributeName):(O(r.target,e,n,d),i&&i(r.target)))}});let l=[];if(e.indexOf("[")!==-1){const M=/\[([\w-]+)/g;let y;for(;(y=M.exec(e))!==null;)l.push(y[1])}else l.push(e);x.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:l.concat(h)})},v),window[n]=c,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){c(document.body)}):c(document.body),c}const T={};function E(e,n){T[e]=n}function L(e){return T[e]||{ingress:n=>n,egress:n=>n}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=E,window.lnCore.getDataMapper=L),(function(){const e="data-ln-time",n="lnTime";if(window[n]!==void 0)return;const d={},v={};function A(t){return t.getAttribute("data-ln-time-locale")||document.documentElement.lang||void 0}function h(t,o){const s=(t||"")+"|"+JSON.stringify(o);return d[s]||(d[s]=new Intl.DateTimeFormat(t,o)),d[s]}function w(t){const o=t||"";return v[o]||(v[o]=new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"})),v[o]}const i=new Set;let c=null;function x(){c||(c=setInterval(M,6e4))}function l(){c&&(clearInterval(c),c=null)}function M(){for(const t of i){if(!document.body.contains(t.dom)){i.delete(t);continue}p(t)}i.size===0&&l()}function y(t,o){return h(o,{dateStyle:"long",timeStyle:"short"}).format(t)}function r(t,o){const s=new Date,m={month:"short",day:"numeric"};return t.getFullYear()!==s.getFullYear()&&(m.year="numeric"),h(o,m).format(t)}function g(t,o){return h(o,{dateStyle:"medium"}).format(t)}function f(t,o){return h(o,{timeStyle:"short"}).format(t)}function k(t,o){const s=Math.floor(Date.now()/1e3),b=Math.floor(t.getTime()/1e3)-s,a=Math.abs(b);if(a<10)return w(o).format(0,"second");let u,C;if(a<60)u="second",C=b;else if(a<3600)u="minute",C=Math.round(b/60);else if(a<86400)u="hour",C=Math.round(b/3600);else if(a<604800)u="day",C=Math.round(b/86400);else if(a<2592e3)u="week",C=Math.round(b/604800);else return r(t,o);return w(o).format(C,u)}function p(t){const o=t.dom.getAttribute("datetime");if(!o)return;const s=Number(o);if(isNaN(s))return;const m=new Date(s*1e3),b=t.dom.getAttribute(e)||"short",a=A(t.dom);let u;switch(b){case"relative":u=k(m,a);break;case"full":u=y(m,a);break;case"date":u=g(m,a);break;case"time":u=f(m,a);break;default:u=r(m,a);break}t.dom.textContent=u,b!=="full"&&(t.dom.title=y(m,a))}function _(t){return this.dom=t,p(this),t.getAttribute(e)==="relative"&&(i.add(this),x()),this}_.prototype.render=function(){p(this)},_.prototype.destroy=function(){i.delete(this),i.size===0&&l(),delete this.dom[n]};function S(t){const o=t[n];if(!o)return;t.getAttribute(e)==="relative"?(i.add(o),x()):(i.delete(o),i.size===0&&l()),p(o)}function D(t){t.nodeType===1&&t.hasAttribute&&t.hasAttribute(e)&&t[n]&&p(t[n])}N(e,n,_,"ln-time",{extraAttributes:["datetime"],onAttributeChange:S,onInit:D})})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function h(e,t,o){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o||{}}))}function w(e,t,o){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:o||{}});return e.dispatchEvent(i),i}function O(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){O(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function y(e,t,o,i){if(e.nodeType!==1)return;const b=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",n=Array.from(e.querySelectorAll(b));e.matches&&e.matches(b)&&n.push(e);for(const r of n)r[o]||(r[o]=new i(r))}function
|
|
1
|
+
(function(){"use strict";function h(e,t,o){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o||{}}))}function w(e,t,o){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:o||{}});return e.dispatchEvent(i),i}function O(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){O(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function y(e,t,o,i){if(e.nodeType!==1)return;const b=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",n=Array.from(e.querySelectorAll(b));e.matches&&e.matches(b)&&n.push(e);for(const r of n)r[o]||(r[o]=new i(r))}function I(e,t,o,i,g={}){const b=g.extraAttributes||[],n=g.onAttributeChange||null,r=g.onInit||null;function s(d){const f=d||document.body;y(f,e,t,o),r&&r(f)}return O(function(){const d=new MutationObserver(function(p){for(let l=0;l<p.length;l++){const u=p[l];if(u.type==="childList"){for(let a=0;a<u.addedNodes.length;a++){const c=u.addedNodes[a];c.nodeType===1&&(y(c,e,t,o),r&&r(c))}for(let a=0;a<u.removedNodes.length;a++){const c=u.removedNodes[a];if(c.nodeType===1){const L=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",m=Array.from(c.querySelectorAll(L));c.matches&&c.matches(L)&&m.push(c);for(let A=0;A<m.length;A++){const S=m[A];if(!document.contains(S)){const v=S[t];v&&typeof v.destroy=="function"&&v.destroy()}}}}}else u.type==="attributes"&&(n&&u.target[t]?n(u.target,u.attributeName):(y(u.target,e,t,o),r&&r(u.target)))}});let f=[];if(e.indexOf("[")!==-1){const p=/\[([\w-]+)/g;let l;for(;(l=p.exec(e))!==null;)f.push(l[1])}else f.push(e);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:f.concat(b)})},i),window[t]=s,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){s(document.body)}):s(document.body),s}const x={};function M(e,t){x[e]=t}function D(e){return x[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=M,window.lnCore.getDataMapper=D);const _="ln:";function q(){return location.pathname.replace(/\/+$/,"").toLowerCase()||"/"}function C(e,t){const o=t.getAttribute("data-ln-persist"),i=o!==null&&o!==""?o:t.id;return i?_+e+":"+q()+":"+i:(console.warn('[ln-persist] Element requires id or data-ln-persist="key"',t),null)}function N(e,t){const o=C(e,t);if(!o)return null;try{const i=localStorage.getItem(o);return i!==null?JSON.parse(i):null}catch{return null}}function E(e,t,o){const i=C(e,t);if(i)try{localStorage.setItem(i,JSON.stringify(o))}catch{}}(function(){const e="data-ln-toggle",t="lnToggle";if(window[t]!==void 0)return;function o(n){const r=Array.from(n.querySelectorAll("[data-ln-toggle-for]"));n.hasAttribute&&n.hasAttribute("data-ln-toggle-for")&&r.push(n);for(const s of r){if(s[t+"Trigger"])continue;const d=function(l){if(l.ctrlKey||l.metaKey||l.button===1)return;l.preventDefault();const u=s.getAttribute("data-ln-toggle-for"),a=document.getElementById(u);if(!a||!a[t])return;const c=s.getAttribute("data-ln-toggle-action")||"toggle";if(c==="open")a.setAttribute(e,"open");else if(c==="close")a.setAttribute(e,"close");else if(c==="toggle"){const T=a.getAttribute(e);a.setAttribute(e,T==="open"?"close":"open")}};s.addEventListener("click",d),s[t+"Trigger"]=d;const f=s.getAttribute("data-ln-toggle-for"),p=document.getElementById(f);p&&p[t]&&s.setAttribute("aria-expanded",p[t].isOpen?"true":"false")}}function i(n,r){const s=document.querySelectorAll('[data-ln-toggle-for="'+n.id+'"]');for(const d of s)d.setAttribute("aria-expanded",r?"true":"false")}function g(n){if(this.dom=n,n.hasAttribute("data-ln-persist")){const r=N("toggle",n);r!==null&&n.setAttribute(e,r)}return this.isOpen=n.getAttribute(e)==="open",this.isOpen&&n.classList.add("open"),i(n,this.isOpen),this}g.prototype.destroy=function(){if(!this.dom[t])return;h(this.dom,"ln-toggle:destroyed",{target:this.dom});const n=document.querySelectorAll('[data-ln-toggle-for="'+this.dom.id+'"]');for(const r of n)r[t+"Trigger"]&&(r.removeEventListener("click",r[t+"Trigger"]),delete r[t+"Trigger"]);delete this.dom[t]};function b(n){const r=n[t];if(!r)return;const d=n.getAttribute(e)==="open";if(d!==r.isOpen)if(d){if(w(n,"ln-toggle:before-open",{target:n}).defaultPrevented){n.setAttribute(e,"close");return}r.isOpen=!0,n.classList.add("open"),i(n,!0),h(n,"ln-toggle:open",{target:n}),n.hasAttribute("data-ln-persist")&&E("toggle",n,"open")}else{if(w(n,"ln-toggle:before-close",{target:n}).defaultPrevented){n.setAttribute(e,"open");return}r.isOpen=!1,n.classList.remove("open"),i(n,!1),h(n,"ln-toggle:close",{target:n}),n.hasAttribute("data-ln-persist")&&E("toggle",n,"close")}}I(e,t,g,"ln-toggle",{extraAttributes:["data-ln-toggle-for"],onAttributeChange:b,onInit:o})})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function x(e,o,
|
|
1
|
+
(function(){"use strict";function x(e,o,b){e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:b||{}}))}function C(e,o){if(!document.body){document.addEventListener("DOMContentLoaded",function(){C(e,o)}),console.warn("["+o+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function L(e,o,b,c){if(e.nodeType!==1)return;const y=o.indexOf("[")!==-1||o.indexOf(".")!==-1||o.indexOf("#")!==-1?o:"["+o+"]",r=Array.from(e.querySelectorAll(y));e.matches&&e.matches(y)&&r.push(e);for(const i of r)i[b]||(i[b]=new c(i))}function O(e,o,b,c,v={}){const y=v.extraAttributes||[],r=v.onAttributeChange||null,i=v.onInit||null;function s(p){const f=p||document.body;L(f,e,o,b),i&&i(f)}return C(function(){const p=new MutationObserver(function(w){for(let E=0;E<w.length;E++){const d=w[E];if(d.type==="childList"){for(let u=0;u<d.addedNodes.length;u++){const l=d.addedNodes[u];l.nodeType===1&&(L(l,e,o,b),i&&i(l))}for(let u=0;u<d.removedNodes.length;u++){const l=d.removedNodes[u];if(l.nodeType===1){const t=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",m=Array.from(l.querySelectorAll(t));l.matches&&l.matches(t)&&m.push(l);for(let n=0;n<m.length;n++){const a=m[n];if(!document.contains(a)){const h=a[o];h&&typeof h.destroy=="function"&&h.destroy()}}}}}else d.type==="attributes"&&(r&&d.target[o]?r(d.target,d.attributeName):(L(d.target,e,o,b),i&&i(d.target)))}});let f=[];if(e.indexOf("[")!==-1){const w=/\[([\w-]+)/g;let E;for(;(E=w.exec(e))!==null;)f.push(E[1])}else f.push(e);p.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:f.concat(y)})},c),window[o]=s,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){s(document.body)}):s(document.body),s}const T={};function N(e,o){T[e]=o}function M(e){return T[e]||{ingress:o=>o,egress:o=>o}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=N,window.lnCore.getDataMapper=M);function D(e,o,b,c){const v=c,y=window.innerWidth,r=window.innerHeight,i=o.width,s=o.height,p=b.split("-"),f=p[0],w=p[1]==="start"||p[1]==="end"?p[1]:"center",E={top:["top","bottom","right","left"],bottom:["bottom","top","right","left"],left:["left","right","top","bottom"],right:["right","left","top","bottom"]},d=E[f]||E.bottom;function u(n){return n==="top"||n==="bottom"?w==="start"?e.left:w==="end"?e.right-i:e.left+(e.width-i)/2:w==="start"?e.top:w==="end"?e.bottom-s:e.top+(e.height-s)/2}function l(n){let a,h,_=!0;return n==="top"?(a=e.top-v-s,h=u(n),a<0&&(_=!1)):n==="bottom"?(a=e.bottom+v,h=u(n),a+s>r&&(_=!1)):n==="left"?(a=u(n),h=e.left-v-i,h<0&&(_=!1)):(a=u(n),h=e.right+v,h+i>y&&(_=!1)),{top:a,left:h,side:n,fits:_}}let A=null;for(let n=0;n<d.length;n++){const a=l(d[n]);if(a.fits){A=a;break}}A||(A=l(d[0]));let t=A.top,m=A.left;return i>=y?m=0:(m<0&&(m=0),m+i>y&&(m=y-i)),s>=r?t=0:(t<0&&(t=0),t+s>r&&(t=r-s)),{top:t,left:m,placement:A.side}}(function(){const e="data-ln-tooltip-enhance",o="data-ln-tooltip",b="data-ln-tooltip-position",c="lnTooltipEnhance",v="ln-tooltip-portal";if(window[c]!==void 0)return;let y=0,r=null,i=null,s=null,p=null,f=null;function w(){return r&&r.parentNode||(r=document.getElementById(v),r||(r=document.createElement("div"),r.id=v,document.body.appendChild(r))),r}function E(){f||(f=function(t){t.key==="Escape"&&l()},document.addEventListener("keydown",f))}function d(){f&&(document.removeEventListener("keydown",f),f=null)}function u(t){if(s===t)return;l();const m=t.getAttribute(o)||t.getAttribute("title");if(!m)return;w(),t.hasAttribute("title")&&(p=t.getAttribute("title"),t.removeAttribute("title"));const n=document.createElement("div");n.className="ln-tooltip",n.textContent=m,t[c+"Uid"]||(y+=1,t[c+"Uid"]="ln-tooltip-"+y),n.id=t[c+"Uid"],r.appendChild(n);const a=n.offsetWidth,h=n.offsetHeight,_=t.getBoundingClientRect(),I=t.getAttribute(b)||"top",g=D(_,{width:a,height:h},I,6);n.style.top=g.top+"px",n.style.left=g.left+"px",n.setAttribute("data-ln-tooltip-placement",g.placement),t.setAttribute("aria-describedby",n.id),i=n,s=t,E()}function l(){if(!i){d();return}s&&(s.removeAttribute("aria-describedby"),p!==null&&s.setAttribute("title",p)),p=null,i.parentNode&&i.parentNode.removeChild(i),i=null,s=null,d()}function A(t){return this.dom=t,t.hasAttribute("data-ln-tooltip-enhanced")||(t.setAttribute("data-ln-tooltip-enhanced",""),this._addedEnhancedAttr=!0),this._onEnter=function(){u(t)},this._onLeave=function(){s===t&&l()},this._onFocus=function(){u(t)},this._onBlur=function(){s===t&&l()},t.addEventListener("mouseenter",this._onEnter),t.addEventListener("mouseleave",this._onLeave),t.addEventListener("focus",this._onFocus,!0),t.addEventListener("blur",this._onBlur,!0),this}A.prototype.destroy=function(){const t=this.dom;t.removeEventListener("mouseenter",this._onEnter),t.removeEventListener("mouseleave",this._onLeave),t.removeEventListener("focus",this._onFocus,!0),t.removeEventListener("blur",this._onBlur,!0),s===t&&l(),this._addedEnhancedAttr&&t.removeAttribute("data-ln-tooltip-enhanced"),delete t[c],delete t[c+"Uid"],x(t,"ln-tooltip:destroyed",{trigger:t})},O("["+e+"], ["+o+"][title]",c,A,"ln-tooltip")})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const b={};function A(e,a){b[e]||(b[e]=document.querySelector('[data-ln-template="'+e+'"]'));const d=b[e];return d?d.content.cloneNode(!0):(console.warn("["+a+'] Template "'+e+'" not found'),null)}function w(e,a,d){e.dispatchEvent(new CustomEvent(a,{bubbles:!0,detail:d||{}}))}function q(e,a,d){const r=new CustomEvent(a,{bubbles:!0,cancelable:!0,detail:d||{}});return e.dispatchEvent(r),r}function E(e,a){if(!document.body){document.addEventListener("DOMContentLoaded",function(){E(e,a)}),console.warn("["+a+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function m(e,a,d,r){if(e.nodeType!==1)return;const s=a.indexOf("[")!==-1||a.indexOf(".")!==-1||a.indexOf("#")!==-1?a:"["+a+"]",o=Array.from(e.querySelectorAll(s));e.matches&&e.matches(s)&&o.push(e);for(const n of o)n[d]||(n[d]=new r(n))}function
|
|
1
|
+
(function(){"use strict";const b={};function A(e,a){b[e]||(b[e]=document.querySelector('[data-ln-template="'+e+'"]'));const d=b[e];return d?d.content.cloneNode(!0):(console.warn("["+a+'] Template "'+e+'" not found'),null)}function w(e,a,d){e.dispatchEvent(new CustomEvent(a,{bubbles:!0,detail:d||{}}))}function q(e,a,d){const r=new CustomEvent(a,{bubbles:!0,cancelable:!0,detail:d||{}});return e.dispatchEvent(r),r}function E(e,a){if(!document.body){document.addEventListener("DOMContentLoaded",function(){E(e,a)}),console.warn("["+a+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function m(e,a,d,r){if(e.nodeType!==1)return;const s=a.indexOf("[")!==-1||a.indexOf(".")!==-1||a.indexOf("#")!==-1?a:"["+a+"]",o=Array.from(e.querySelectorAll(s));e.matches&&e.matches(s)&&o.push(e);for(const n of o)n[d]||(n[d]=new r(n))}function _(e,a,d,r,t={}){const s=t.extraAttributes||[],o=t.onAttributeChange||null,n=t.onInit||null;function c(u){const l=u||document.body;m(l,e,a,d),n&&n(l)}return E(function(){const u=new MutationObserver(function(p){for(let h=0;h<p.length;h++){const i=p[h];if(i.type==="childList"){for(let g=0;g<i.addedNodes.length;g++){const f=i.addedNodes[g];f.nodeType===1&&(m(f,e,a,d),n&&n(f))}for(let g=0;g<i.removedNodes.length;g++){const f=i.removedNodes[g];if(f.nodeType===1){const C=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",y=Array.from(f.querySelectorAll(C));f.matches&&f.matches(C)&&y.push(f);for(let v=0;v<y.length;v++){const x=y[v];if(!document.contains(x)){const L=x[a];L&&typeof L.destroy=="function"&&L.destroy()}}}}}else i.type==="attributes"&&(o&&i.target[a]?o(i.target,i.attributeName):(m(i.target,e,a,d),n&&n(i.target)))}});let l=[];if(e.indexOf("[")!==-1){const p=/\[([\w-]+)/g;let h;for(;(h=p.exec(e))!==null;)l.push(h[1])}else l.push(e);u.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:l.concat(s)})},r),window[a]=c,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){c(document.body)}):c(document.body),c}const S={};function D(e,a){S[e]=a}function O(e){return S[e]||{ingress:a=>a,egress:a=>a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=D,window.lnCore.getDataMapper=O),(function(){const e="data-ln-translations",a="lnTranslations";if(window[a]!==void 0)return;const d={en:"English",sq:"Shqip",sr:"Srpski"};function r(t){this.dom=t,this.activeLanguages=new Set,this.defaultLang=t.getAttribute(e+"-default")||"",this.badgesEl=t.querySelector("["+e+"-active]"),this.menuEl=t.querySelector("[data-ln-dropdown] > [data-ln-toggle]");const s=t.getAttribute(e+"-locales");if(this.locales=d,s)try{this.locales=JSON.parse(s)}catch{console.warn("[ln-translations] Invalid JSON in data-ln-translations-locales")}this._applyDefaultLang(),this._updateDropdown();const o=this;return this._onRequestAdd=function(n){n.detail&&n.detail.lang&&o.addLanguage(n.detail.lang)},this._onRequestRemove=function(n){n.detail&&n.detail.lang&&o.removeLanguage(n.detail.lang)},t.addEventListener("ln-translations:request-add",this._onRequestAdd),t.addEventListener("ln-translations:request-remove",this._onRequestRemove),this._detectExisting(),this}r.prototype._applyDefaultLang=function(){if(!this.defaultLang)return;const t=this.dom.querySelectorAll("[data-ln-translatable]");for(const s of t){const o=s.querySelectorAll("input:not([data-ln-translatable-lang]), textarea:not([data-ln-translatable-lang]), select:not([data-ln-translatable-lang])");for(const n of o)n.setAttribute("data-ln-translatable-lang",this.defaultLang)}},r.prototype._detectExisting=function(){const t=this.dom.querySelectorAll("[data-ln-translatable-lang]");for(const s of t){const o=s.getAttribute("data-ln-translatable-lang");o&&o!==this.defaultLang&&this.activeLanguages.add(o)}this.activeLanguages.size>0&&(this._updateBadges(),this._updateDropdown())},r.prototype._updateDropdown=function(){if(!this.menuEl)return;this.menuEl.textContent="";const t=this;let s=0;for(const n in this.locales){if(!this.locales.hasOwnProperty(n)||this.activeLanguages.has(n))continue;s++;const c=A("ln-translations-menu-item","ln-translations");if(!c)return;const u=c.querySelector("[data-ln-translations-lang]");u.setAttribute("data-ln-translations-lang",n),u.textContent=this.locales[n],u.addEventListener("click",function(l){l.ctrlKey||l.metaKey||l.button===1||(l.preventDefault(),l.stopPropagation(),t.menuEl.getAttribute("data-ln-toggle")==="open"&&t.menuEl.setAttribute("data-ln-toggle","close"),t.addLanguage(n))}),this.menuEl.appendChild(c)}const o=this.dom.querySelector("["+e+"-add]");o&&(o.style.display=s===0?"none":"")},r.prototype._updateBadges=function(){if(!this.badgesEl)return;this.badgesEl.textContent="";const t=this;this.activeLanguages.forEach(function(s){const o=A("ln-translations-badge","ln-translations");if(!o)return;const n=o.querySelector("[data-ln-translations-lang]");n.setAttribute("data-ln-translations-lang",s);const c=n.querySelector("span");c.textContent=t.locales[s]||s.toUpperCase();const u=n.querySelector("button");u.setAttribute("aria-label","Remove "+(t.locales[s]||s.toUpperCase())),u.addEventListener("click",function(l){l.ctrlKey||l.metaKey||l.button===1||(l.preventDefault(),l.stopPropagation(),t.removeLanguage(s))}),t.badgesEl.appendChild(o)})},r.prototype.addLanguage=function(t,s){if(this.activeLanguages.has(t))return;const o=this.locales[t]||t;if(q(this.dom,"ln-translations:before-add",{target:this.dom,lang:t,langName:o}).defaultPrevented)return;this.activeLanguages.add(t),s=s||{};const c=this.dom.querySelectorAll("[data-ln-translatable]");for(const u of c){const l=u.getAttribute("data-ln-translatable"),p=u.getAttribute("data-ln-translations-prefix")||"",h=u.querySelector(this.defaultLang?'[data-ln-translatable-lang="'+this.defaultLang+'"]':"input:not([data-ln-translatable-lang]), textarea:not([data-ln-translatable-lang]), select:not([data-ln-translatable-lang])");if(!h)continue;const i=h.cloneNode(!1);p?i.name=p+"[trans]["+t+"]["+l+"]":i.name="trans["+t+"]["+l+"]",i.value=s[l]!==void 0?s[l]:"",i.removeAttribute("id"),i.placeholder=o+" translation",i.setAttribute("data-ln-translatable-lang",t);const g=u.querySelectorAll('[data-ln-translatable-lang]:not([data-ln-translatable-lang="'+this.defaultLang+'"])'),f=g.length>0?g[g.length-1]:h;f.parentNode.insertBefore(i,f.nextSibling)}this._updateDropdown(),this._updateBadges(),w(this.dom,"ln-translations:added",{target:this.dom,lang:t,langName:o})},r.prototype.removeLanguage=function(t){if(!this.activeLanguages.has(t)||q(this.dom,"ln-translations:before-remove",{target:this.dom,lang:t}).defaultPrevented)return;const o=this.dom.querySelectorAll('[data-ln-translatable-lang="'+t+'"]');for(const n of o)n.parentNode.removeChild(n);this.activeLanguages.delete(t),this._updateDropdown(),this._updateBadges(),w(this.dom,"ln-translations:removed",{target:this.dom,lang:t})},r.prototype.getActiveLanguages=function(){return new Set(this.activeLanguages)},r.prototype.hasLanguage=function(t){return this.activeLanguages.has(t)},r.prototype.destroy=function(){if(!this.dom[a])return;const t=this.defaultLang,s=this.dom.querySelectorAll("[data-ln-translatable-lang]");for(const o of s)o.getAttribute("data-ln-translatable-lang")!==t&&o.parentNode.removeChild(o);this.dom.removeEventListener("ln-translations:request-add",this._onRequestAdd),this.dom.removeEventListener("ln-translations:request-remove",this._onRequestRemove),delete this.dom[a]},_(e,a,r,"ln-translations")})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function C(t,e,f){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:f||{}}))}function w(t,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){w(t,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function L(t,e,f,h){if(t.nodeType!==1)return;const v=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",p=Array.from(t.querySelectorAll(v));t.matches&&t.matches(v)&&p.push(t);for(const a of p)a[f]||(a[f]=new h(a))}function
|
|
1
|
+
(function(){"use strict";function C(t,e,f){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:f||{}}))}function w(t,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){w(t,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function L(t,e,f,h){if(t.nodeType!==1)return;const v=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",p=Array.from(t.querySelectorAll(v));t.matches&&t.matches(v)&&p.push(t);for(const a of p)a[f]||(a[f]=new h(a))}function O(t,e,f,h,m={}){const v=m.extraAttributes||[],p=m.onAttributeChange||null,a=m.onInit||null;function n(i){const c=i||document.body;L(c,t,e,f),a&&a(c)}return w(function(){const i=new MutationObserver(function(l){for(let u=0;u<l.length;u++){const s=l[u];if(s.type==="childList"){for(let r=0;r<s.addedNodes.length;r++){const o=s.addedNodes[r];o.nodeType===1&&(L(o,t,e,f),a&&a(o))}for(let r=0;r<s.removedNodes.length;r++){const o=s.removedNodes[r];if(o.nodeType===1){const y=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",g=Array.from(o.querySelectorAll(y));o.matches&&o.matches(y)&&g.push(o);for(let _=0;_<g.length;_++){const b=g[_];if(!document.contains(b)){const E=b[e];E&&typeof E.destroy=="function"&&E.destroy()}}}}}else s.type==="attributes"&&(p&&s.target[e]?p(s.target,s.attributeName):(L(s.target,t,e,f),a&&a(s.target)))}});let c=[];if(t.indexOf("[")!==-1){const l=/\[([\w-]+)/g;let u;for(;(u=l.exec(t))!==null;)c.push(u[1])}else c.push(t);i.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:c.concat(v)})},h),window[e]=n,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){n(document.body)}):n(document.body),n}const S={};function A(t,e){S[t]=e}function M(t){return S[t]||{ingress:e=>e,egress:e=>e}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=A,window.lnCore.getDataMapper=M),(function(){const t="data-ln-validate",e="lnValidate",f="data-ln-validate-errors",h="data-ln-validate-error",m="ln-validate-valid",v="ln-validate-invalid",p={required:"valueMissing",typeMismatch:"typeMismatch",tooShort:"tooShort",tooLong:"tooLong",patternMismatch:"patternMismatch",rangeUnderflow:"rangeUnderflow",rangeOverflow:"rangeOverflow"};if(window[e]!==void 0)return;function a(n){this.dom=n,this._touched=!1,this._customErrors=new Set;const i=this,c=n.tagName,l=n.type,u=c==="SELECT"||l==="checkbox"||l==="radio";return this._onInput=function(){i._touched=!0,i.validate()},this._onChange=function(){i._touched=!0,i.validate()},this._onSetCustom=function(s){const r=s.detail&&s.detail.error;if(!r)return;i._customErrors.add(r),i._touched=!0;const o=n.closest(".form-element");if(o){const d=o.querySelector("["+h+'="'+r+'"]');d&&d.classList.remove("hidden")}n.classList.remove(m),n.classList.add(v)},this._onClearCustom=function(s){const r=s.detail&&s.detail.error,o=n.closest(".form-element");if(r){if(i._customErrors.delete(r),o){const d=o.querySelector("["+h+'="'+r+'"]');d&&d.classList.add("hidden")}}else i._customErrors.forEach(function(d){if(o){const y=o.querySelector("["+h+'="'+d+'"]');y&&y.classList.add("hidden")}}),i._customErrors.clear();i._touched&&i.validate()},u||n.addEventListener("input",this._onInput),n.addEventListener("change",this._onChange),n.addEventListener("ln-validate:set-custom",this._onSetCustom),n.addEventListener("ln-validate:clear-custom",this._onClearCustom),this}a.prototype.validate=function(){const n=this.dom,i=n.validity,l=n.checkValidity()&&this._customErrors.size===0,u=n.closest(".form-element");if(u){const r=u.querySelector("["+f+"]");if(r){const o=r.querySelectorAll("["+h+"]");for(let d=0;d<o.length;d++){const y=o[d].getAttribute(h),g=p[y];g&&(i[g]?o[d].classList.remove("hidden"):o[d].classList.add("hidden"))}}}return n.classList.toggle(m,l),n.classList.toggle(v,!l),C(n,l?"ln-validate:valid":"ln-validate:invalid",{target:n,field:n.name}),l},a.prototype.reset=function(){this._touched=!1,this._customErrors.clear(),this.dom.classList.remove(m,v);const n=this.dom.closest(".form-element");if(n){const i=n.querySelectorAll("["+h+"]");for(let c=0;c<i.length;c++)i[c].classList.add("hidden")}},Object.defineProperty(a.prototype,"isValid",{get:function(){return this.dom.checkValidity()&&this._customErrors.size===0}}),a.prototype.destroy=function(){this.dom[e]&&(this.dom.removeEventListener("input",this._onInput),this.dom.removeEventListener("change",this._onChange),this.dom.removeEventListener("ln-validate:set-custom",this._onSetCustom),this.dom.removeEventListener("ln-validate:clear-custom",this._onClearCustom),this.dom.classList.remove(m,v),C(this.dom,"ln-validate:destroyed",{target:this.dom}),delete this.dom[e])},O(t,e,a,"ln-validate")})()})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livenetworks/ashlar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "LiveNetworks unified frontend library - CSS framework and vanilla JS components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Live Networks",
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"dev": "node scripts/build.mjs --watch",
|
|
35
|
-
"build": "node scripts/build.mjs && npm run build:demos",
|
|
35
|
+
"build": "node scripts/build.mjs && npm run build:dev-css && npm run build:demos",
|
|
36
36
|
"build:demos": "npm run build:demo-index && npm run build:demo-admin && npm run build:demo-docuflow",
|
|
37
|
+
"build:dev-css": "sass scss/ln-ashlar-dev.scss demo/dist/ln-ashlar-dev.css --no-source-map --style=compressed",
|
|
37
38
|
"build:demo-index": "sass demo/index.scss demo/index.css --no-source-map --style=compressed",
|
|
38
39
|
"build:demo-admin": "sass demo/admin/src/admin.scss demo/admin/dist/admin.css --no-source-map --style=compressed && cp demo/admin/src/demo.js demo/admin/dist/demo.js && node demo/admin/src/build-pages.mjs",
|
|
39
40
|
"build:demo-docuflow": "sass demo/docuflow/docuflow.scss demo/docuflow/dist/docuflow.css --no-source-map --style=compressed"
|