@iamproperty/components 3.7.5 → 3.7.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.
- package/assets/js/components/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
- package/assets/js/components/card/card.component.min.js +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/notification/notification.component.min.js +1 -1
- package/assets/js/components/pagination/pagination.component.min.js +1 -1
- package/assets/js/components/table/table.component.js +12 -9
- package/assets/js/components/table/table.component.min.js +13 -14
- package/assets/js/components/table/table.component.min.js.map +1 -1
- package/assets/js/components/tabs/tabs.component.min.js +1 -1
- package/assets/js/dynamic.min.js +1 -1
- package/assets/js/scripts.bundle.js +25 -26
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +2 -2
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/ts/components/table/table.component.ts +17 -12
- package/dist/components.es.js +56 -58
- package/dist/components.umd.js +18 -19
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function n(r){let a=r.querySelectorAll("details"),e=r.querySelectorAll("summary");if(a.forEach(o=>{o.classList.add("accordion-item")}),e.forEach(o=>{o.classList.add("accordion-header"),o.classList.add("accordion-button"),o.classList.add("h4")}),!r.classList.contains("accordion--keep-open")){const o=r.querySelectorAll(":scope > details");o.forEach(c=>{c.addEventListener("click",()=>{o.forEach(i=>{i!==c&&i.removeAttribute("open")})})})}}window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"accordion"});class t extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const a=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",e=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${a}/css/core.min.css`,o=document.createElement("template");o.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function h(u,m){function f(e,t){let c=!1,r=t.getAttribute("name");r.includes("[]")&&(r=r.replace("[]",`[${t.value}]`));let l=e.querySelector(`[data-name="${r}"]`);l&&t.getAttribute("type")=="checkbox"&&(c=!0);let i=t.getAttribute("data-filter-text");if(l||(l=document.createElement("button"),e.appendChild(l)),l.setAttribute("type","button"),l.classList.add("filter"),l.setAttribute("data-name",r),l.innerHTML=i.replace("$value",t.value),(!t.value||c)&&l.remove(),t.parentNode.closest("[data-filter-text]")){let d=t.parentNode.closest("[data-filter-text]"),p=!0;if(r="",d.querySelectorAll("input").forEach((a,o)=>{let n=a.getAttribute("name");if(r+=`${o!=0?",":""}${n}`,e.querySelector(`[data-name="${n}"]`)&&e.querySelector(`[data-name="${n}"]`).remove(),a.value){let s=document.createElement("button");s.setAttribute("type","button"),s.classList.add("filter"),s.setAttribute("data-name",n),s.innerHTML=i.replace("$value",a.value),e.appendChild(s)}else p=!1}),e.querySelector(`[data-name="${r}"]`)&&e.querySelector(`[data-name="${r}"]`).remove(),p){let a=d.getAttribute("data-filter-text");d.querySelectorAll("input").forEach((n,s)=>{let b=n.getAttribute("name");e.querySelector(`[data-name="${b}"]`)&&e.querySelector(`[data-name="${b}"]`).remove(),a=a.replace(`$${s+1}`,n.value)});let o=document.createElement("button");o.setAttribute("type","button"),o.classList.add("filter"),o.setAttribute("data-name",r),o.innerHTML=a,e.appendChild(o)}}}Array.from(u.querySelectorAll('input[type="checkbox"]:checked')).forEach((e,t)=>{f(m,e)}),u.addEventListener("change",function(e){if(e&&e.target instanceof HTMLElement&&e.target.closest("input[data-filter-text]")){let t=e.target.closest("input[data-filter-text]");f(m,t)}},!1),m.addEventListener("click",function(e){if(e&&e.target instanceof HTMLElement&&e.target.closest(".filter")){let r=e.target.closest(".filter"),l=r.getAttribute("data-name").split(",");for(var t=0;t<l.length;t++){let i=l[t],d=`[name="${i}"]`;i.match(/\[(.*)\]/)&&(i.replace(/\[(.*)\]/,"[]"),d=`[value="${i.replace(/.*\[(.*)\]/,"$1")}"]`);let p=u.querySelectorAll(d);for(var c=0;c<p.length;c++){let a=p[c];if(a.getAttribute("type")!="radio"&&a.getAttribute("type")!="checkbox")a.value="";else{a.checked=!1;var e=new Event("force");a.closest("form").dispatchEvent(e)}}}r.remove()}},!1)}window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"Applied Filters"});class g extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const m=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",f=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${m}/css/core.min.css`;let e=this.classList.toString();const t=document.createElement("template");t.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"Card"});class i extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.querySelector('[class*="fa-"]')&&this.classList.add("card--has-icon");let t=this.classList.toString();const a=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",e=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${a}/css/core.min.css`,r=document.createElement("template");r.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function r(s,t){n(s,t)}function n(s,t){var e;t.addEventListener("keyup",a=>{clearTimeout(e),e=setTimeout(function(){o(s,t.value)},500)}),t.addEventListener("change",a=>{clearTimeout(e),o(s,t.value)})}const o=function(s,t){Array.from(s.querySelectorAll(":scope > li")).forEach((e,a)=>{let i=e.textContent.toLowerCase();e.classList.add("d-none"),i.includes(t.toLowerCase())&&e.classList.remove("d-none")}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"Filtered list",value:t})};window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"filterlist"});class l extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const t=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",e=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${t}/css/core.min.css`,a=document.createElement("template");a.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"header"});class t extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const e=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",r=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${e}/css/core.min.css`,o=document.createElement("template");o.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function r(i){if(i.hasAttribute("data-type")&&i.getAttribute("data-type")=="toast"){let t=document.querySelector(".notification__holder");t||(t=document.createElement("div"),t.classList.add("notification__holder"),t.classList.add("container"),document.querySelector("body").appendChild(t)),i.closest(".notification__holder")||t.appendChild(i)}if(i.setAttribute("role","alert"),i.addEventListener("click",function(t){event&&event.target instanceof HTMLElement&&event.target.closest("[data-dismiss-button]")&&(t.preventDefault(),n(i))},!1),i.hasAttribute("data-timeout")){let t=i.getAttribute("data-timeout");var a=new c(function(){n(i)},t);i.addEventListener("mouseenter",o=>{a.pause()}),i.addEventListener("mouseleave",o=>{a.resume()})}}function c(i,a){var t,o,e=a;this.pause=function(){window.clearTimeout(t),e-=new Date-o},this.resume=function(){o=new Date,window.clearTimeout(t),t=window.setTimeout(i,e)},this.resume()}const n=function(i){i.classList.add("d-none")};window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"Notification"});class d extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const a=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",t=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${a}/css/core.min.css`,o=this.querySelectorAll("a,button");Array.from(o).forEach((s,l)=>{s.setAttribute("slot","btns"),s.classList.add("link")}),(o.length||this.hasAttribute("data-dismiss"))&&this.classList.add("notification--dismissable");const e=document.createElement("template");e.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/const l=function(e,t){if(!e.getAttribute("data-pages"))return!1;e.getAttribute("data-page")||e.setAttribute("data-page",1);let a=e.getAttribute("data-page"),i=e.getAttribute("data-pages"),d=e.getAttribute("data-total"),n=e.getAttribute("data-show"),o=e.getAttribute("data-increment");if(i<=1)return t.innerHTML="",!1;let r="";for(let s=1;s<=i;s++)s==a?r+=`<li class="page-item active" aria-current="page"><span class="page-link">${s}</span></li>`:r+=`<li class="page-item"><a href="?page=${s}" class="page-link" data-page="${s}">${s}</a></li>`;return t.innerHTML=`<ul class="pagination mb-0 d-none d-sm-flex">
|
|
5
5
|
${a==1?'<li class="page-item disabled"><span class="page-link">Previous</span></li>':`<li class="page-item"><a href="?page=${parseInt(a)-1}" class="page-link" data-page="${parseInt(a)-1}">Previous</a></li>`}
|
|
@@ -7,11 +7,6 @@ class iamTable extends HTMLElement {
|
|
|
7
7
|
this.attachShadow({ mode: 'open' });
|
|
8
8
|
const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';
|
|
9
9
|
const coreCSS = document.body.hasAttribute('data-core-css') ? document.body.getAttribute('data-core-css') : `${assetLocation}/css/core.min.css`;
|
|
10
|
-
const isCTA = this.classList.contains('table--cta');
|
|
11
|
-
const isExportable = this.classList.contains('table--export');
|
|
12
|
-
let classList = this.classList.toString();
|
|
13
|
-
classList = classList.replace('table--cta', '');
|
|
14
|
-
classList = classList.replace('table--loading', '');
|
|
15
10
|
const template = document.createElement('template');
|
|
16
11
|
template.innerHTML = `
|
|
17
12
|
<style>
|
|
@@ -29,12 +24,11 @@ class iamTable extends HTMLElement {
|
|
|
29
24
|
|
|
30
25
|
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
31
26
|
</style>
|
|
32
|
-
|
|
33
|
-
<div class="table__wrapper
|
|
27
|
+
<div class="table--cta">
|
|
28
|
+
<div class="table__wrapper">
|
|
34
29
|
<slot></slot>
|
|
35
30
|
</div>
|
|
36
|
-
|
|
37
|
-
${isExportable ? '<button class="link" type="button" data-export>Export table as CSV</button>' : ''}
|
|
31
|
+
</div>
|
|
38
32
|
<div class="table__pagination"></div>
|
|
39
33
|
`;
|
|
40
34
|
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -51,9 +45,18 @@ class iamTable extends HTMLElement {
|
|
|
51
45
|
if (!this.hasAttribute('data-increment'))
|
|
52
46
|
this.setAttribute('data-increment', 15);
|
|
53
47
|
this.setAttribute('data-pages', Math.ceil(this.getAttribute('data-total') / this.getAttribute('data-show')));
|
|
48
|
+
// Update table__wrapper class
|
|
49
|
+
let classList = this.classList.toString();
|
|
50
|
+
classList = classList.replace('table--cta', '');
|
|
51
|
+
classList = classList.replace('table--loading', '');
|
|
52
|
+
this.shadowRoot.querySelector('.table__wrapper').className += ` ${classList}`;
|
|
54
53
|
this.table = this.querySelector('table');
|
|
55
54
|
this.savedTableBody = this.table.querySelector('tbody').cloneNode(true);
|
|
56
55
|
this.pagination = this.shadowRoot.querySelector('.table__pagination');
|
|
56
|
+
// Remove table CTA
|
|
57
|
+
const isCTA = this.classList.contains('table--cta');
|
|
58
|
+
if (!isCTA)
|
|
59
|
+
this.shadowRoot.querySelector('.table--cta').classList.remove('table--cta');
|
|
57
60
|
// Set events on the filter table
|
|
58
61
|
this.form = document.createElement('form');
|
|
59
62
|
if (this.hasAttribute('data-filterby')) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v3.7.
|
|
2
|
+
* iamKey v3.7.6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
|
-
*/const
|
|
5
|
-
${
|
|
4
|
+
*/const F=function(a){return typeof a!="string"?!1:!isNaN(a)&&!isNaN(parseFloat(a))},V=(a,e)=>String(a).padStart(e,"0"),U=a=>a.charAt(0).toUpperCase()+a.slice(1),C=function(a,e){if(!a.getAttribute("data-pages"))return!1;a.getAttribute("data-page")||a.setAttribute("data-page",1);let i=a.getAttribute("data-page"),r=a.getAttribute("data-pages"),o=a.getAttribute("data-total"),n=a.getAttribute("data-show"),s=a.getAttribute("data-increment");if(r<=1)return e.innerHTML="",!1;let d="";for(let c=1;c<=r;c++)c==i?d+=`<li class="page-item active" aria-current="page"><span class="page-link">${c}</span></li>`:d+=`<li class="page-item"><a href="?page=${c}" class="page-link" data-page="${c}">${c}</a></li>`;return e.innerHTML=`<ul class="pagination mb-0 d-none d-sm-flex">
|
|
5
|
+
${i==1?'<li class="page-item disabled"><span class="page-link">Previous</span></li>':`<li class="page-item"><a href="?page=${parseInt(i)-1}" class="page-link" data-page="${parseInt(i)-1}">Previous</a></li>`}
|
|
6
6
|
${d}
|
|
7
|
-
${
|
|
7
|
+
${i==r?'<li class="page-item disabled"><span class="page-link">Next</span></li>':`<li class="page-item"><a href="?page=${parseInt(i)+1}" class="page-link" data-page="${parseInt(i)+1}">Next</a></li>`}
|
|
8
8
|
</ul>`,e.innerHTML+=`<div class="d-sm-none text-center">
|
|
9
|
-
<span class="d-block pb-2">You've viewed ${
|
|
10
|
-
<a href="?show=${parseInt(
|
|
11
|
-
</div>`,!0};var z=function(a,e,o,r){function n(i){return i instanceof o?i:new o(function(s){s(i)})}return new(o||(o=Promise))(function(i,s){function d(h){try{t(r.next(h))}catch(u){s(u)}}function c(h){try{t(r.throw(h))}catch(u){s(u)}}function t(h){h.done?i(h.value):n(h.value).then(d,c)}t((r=r.apply(a,e||[])).next())})};const _=a=>{const e=Array.from(a.querySelectorAll("thead th"));Array.from(a.querySelectorAll("tbody tr")).forEach((r,n)=>{const i=Array.from(r.querySelectorAll("th, td")),s=["0","low","medium","high","unknown","n/a","pending","verified","overdue","incomplete","complete","completed","approval required","requires approval","to do","not started","warning","error"];i.forEach((d,c)=>{const t=e[c];if(typeof t<"u"){let h=document.createElement("div");h.innerHTML=t.innerHTML;let u=h.textContent||h.innerText||"";d.setAttribute("data-label",u),t.hasAttribute("data-td-class")&&d.setAttribute("class",t.getAttribute("data-td-class")),t.hasAttribute("data-format")&&(d.setAttribute("data-format",t.getAttribute("data-format")),d.innerHTML=M(t.getAttribute("data-format"),d.textContent.trim())),s.includes(d.textContent.trim().toLowerCase())&&d.setAttribute("data-content",d.textContent.trim().toLowerCase())}})})},Y=a=>{let e=0;return Array.from(a.querySelectorAll("tbody tr")).forEach((o,r)=>{let n=window.getComputedStyle(document.querySelector("html")),i=o.querySelector(":scope > *:last-child > *:first-child");if(i){i.classList.add("text-nowrap");let s=i.offsetWidth/parseFloat(n.fontSize);s+=1.7,e=e>s?e:s}}),e},J=a=>{if(a.closest(".table--fullwidth")||a.querySelectorAll("thead tr th").length<4)return!1;Array.from(a.querySelectorAll("tbody tr")).forEach((e,o)=>{let r=e.querySelector(":scope > :is(td,th):first-child"),n=r.textContent;if(n!="")r.innerHTML=`<span class="td__content">${n}</span><button type="button" class="d-none">${n}</button>`;else{let i=e.querySelector(":scope > :is(td,th):nth-child(2)"),s=i.textContent;i.innerHTML=`<span class="td__content">${s}</span><button type="button" class="d-none">${s}</button>`}})},Q=a=>{a.addEventListener("click",e=>{if(e&&e.target instanceof HTMLElement&&e.target.closest("tr > :is(td,th):first-child button")){let o=e.target.closest("tr > :is(td,th):first-child button"),r=o.parentNode.closest("tr");r.getAttribute("data-view")=="full"?r.setAttribute("data-view","default"):r.setAttribute("data-view","full"),o.blur()}})},R=(a,e)=>{let o=e.querySelector("[data-search]");if(!o)return!1;const r=o.getAttribute("id"),n=o.getAttribute("data-search").split(",");let i=o.parentNode,s={};n.forEach((d,c)=>{Array.from(a.querySelectorAll('td[data-label="'+d.trim()+'"]')).forEach((t,h)=>{t.querySelector(".td__content")?s[t.querySelector(".td__content").textContent]=t.querySelector(".td__content").textContent:s[t.textContent]=t.textContent})}),o.setAttribute("list",`${r}_list`),o.setAttribute("autocomplete","off"),i.querySelector("datalist")||(i.innerHTML+=`<datalist id="${r}_list"></datalist>`),i.querySelector("datalist").innerHTML=`${Object.keys(s).map(d=>`<option value="${d}"></option>`).join("")}`},X=(a,e,o,r,n)=>{var i;let s=function(t=!1){if(e.hasAttribute("data-ajax")){if(!t){let h=e.querySelector("[data-pagination]");h.value=1,r.setAttribute("data-page",1)}I(a,e,o,r)}else e.hasAttribute("data-submit")?e.submit():(N(a,e,r),C(r,o),H(a,e))};e.addEventListener("keyup",t=>{clearTimeout(i),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&(i=setTimeout(function(){s()},500))}),e.addEventListener("change",t=>{clearTimeout(i),t&&t.target instanceof HTMLElement&&t.target.closest("[data-sort]")&&(e.hasAttribute("data-submit")||j(a,e,n),s()),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&t.target.closest("form .dialog__wrapper > dialog")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&!t.target.closest("form dialog")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-show]")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-mimic]")&&s()}),e.addEventListener("click",t=>{clearTimeout(i),t&&t.target instanceof HTMLElement&&t.target.closest('dialog button:not([type="button"])')&&t.target.closest('dialog button:not([type="button"])').closest("dialog").close(),t&&t.target instanceof HTMLElement&&t.target.closest(".dialog__close")&&(t.preventDefault(),t.stopPropagation()),t&&t.target instanceof HTMLElement&&t.target.closest("[data-clear]")&&(e.reset(),e.hasAttribute("data-submit")||j(a,e,n),s())}),e.addEventListener("submit",t=>{clearTimeout(i),e.hasAttribute("data-submit")||t.preventDefault(),s()}),e.addEventListener("force",t=>{s()}),e.addEventListener("paginate",t=>{s(!0)});let d=[],c=[];Array.from(e.querySelectorAll("[data-mimic]")).forEach((t,h)=>{let u=t.getAttribute("data-mimic");Array.from(document.querySelectorAll(`[name="${u}"]`)).forEach((f,b)=>{let l=f.closest("form");d.includes(l)||d.push(l),c.includes(u)||c.push(u)})}),d.forEach((t,h)=>{const u=function(){let f=[],b=new FormData(t);for(const[l,y]of b)document.querySelector(`[data-mimic="${l}"]`)&&!f.includes(l)?(f.push(l),document.querySelector(`[data-mimic="${l}"]`).value=y):document.querySelector(`[data-mimic="${l}"]`)&&(document.querySelector(`[data-mimic="${l}"]`).value+=","+y);for(const l of f){const y=new Event("force");e.dispatchEvent(y)}for(const l of c)if(!b.has(l)&&t.querySelector(`[name="${l}"]`)){document.querySelector(`[data-mimic="${l}"]`).value="";const y=new Event("force");e.dispatchEvent(y)}};t.addEventListener("force",f=>{u()}),t.addEventListener("change",f=>{u()})})},j=(a,e,o)=>{if(e.getAttribute("data-ajax"))return!1;let r=a.querySelector("tbody"),n=e.querySelector("[data-sort]"),i=n.querySelector(`option:nth-child(${n.selectedIndex+1})`),s=i.getAttribute("data-sort"),d=i.getAttribute("data-order"),c=i.getAttribute("data-format");if(!s)return r.innerHTML=o.innerHTML,_(a),!1;let t=[];["asc","desc","descending"].includes(d)||(t=d.split(","));let h=[];Array.from(r.querySelectorAll("tr")).forEach((f,b)=>{let l=f.querySelector('td[data-label="'+s+'"], th[data-label="'+s+'"]').textContent.trim();t.length&&t.includes(l)&&(l=t.indexOf(l)),B(l)&&(l=F(l,10)),c&&c=="date"&&(l=new Date(l));const y={index:l,row:f};h.push(y)}),h.sort((f,b)=>f.index>b.index?1:-1),(d=="descending"||d=="desc")&&(h=h.reverse());let u="";h.forEach((f,b)=>{u+=f.row.outerHTML}),r.innerHTML=u},N=(a,e,o)=>{a.classList.remove("table--filtered");let r=[],n=[],i=0,s=e.querySelector("[data-pagination]")?parseInt(e.querySelector("[data-pagination]").value):1,d=e.querySelector("[data-show]")?parseInt(e.querySelector("[data-show]").value):15;if(Array.from(a.querySelectorAll("tbody tr")).forEach((t,h)=>{t.classList.remove("filtered"),t.classList.remove("filtered--matched"),t.classList.remove("filtered--show"),t.removeAttribute("data-filtered-by")}),Array.from(e.querySelectorAll("[data-filter]")).forEach((t,h)=>{if(!(t.type=="radio"&&!t.checked)&&!(t.type=="checkbox"&&!t.checked)){if(t.getAttribute("data-filter")=="multi")for(const[u,f]of Object.entries(JSON.parse(t.value)))r[t.getAttribute("data-filter")].push(f);else if(t&&t.value){let u=t.getAttribute("data-filter");r[u]||(r[u]=new Array),r[u].push(t.value)}}}),e.querySelector("[data-search]")){let t=e.querySelector("[data-search]");e.querySelector("[data-search]").getAttribute("data-search").split(",").forEach((u,f)=>{n.push({column:`${u.trim()}`,value:`${t.value}`})})}Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,h)=>{t.innerHTML=""}),r.length&&Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,h)=>{t.innerHTML+=`(${r.length})`}),a.classList.add("table--filtered");for(const[t,h]of Object.entries(r))Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((u,f)=>{let b=!1;h.forEach((l,y)=>{let L=u.querySelector(`[data-label="${t}"]`);if(l&&l=="$today")l=M("date",new Date);else if(l&&l=="$yesterday"){let m=new Date;m.setDate(m.getDate()-1),l=M("date",m)}else if(l&&(l=="$thisWeek"||l=="$lastWeek")){let m=new Date,g=new Date(m.setDate(m.getDate()-(m.getDay()-1))),A=new Date(m.setDate(m.getDate()-m.getDay()+7)),p=new Date(L.textContent.toLowerCase());if(m.setHours(0,0,0,0),g.setHours(0,0,0,0),A.setHours(0,0,0,0),p.setHours(0,0,0,0),l=="$thisWeek")b=p>=g&&p<=A;else{let S=new Date(g.setDate(g.getDate()-7)),x=new Date(A.setDate(A.getDate()-7));S.setHours(0,0,0,0),x.setHours(0,0,0,0),b=p>=S&&p<=x}}else if(l&&l=="$thisMonth"){let m=new Date,g=m.getFullYear(),A=m.getMonth();var q=new Date(g,A,1),v=new Date(g,A+1,0);let p=new Date(L.textContent.toLowerCase());q.setHours(0,0,0,0),v.setHours(0,0,0,0),p.setHours(0,0,0,0),b=p>=q&&p<=v}else if(l&&l=="$lastMonth"){let m=new Date,g=m.getFullYear(),A=m.getMonth();var w=new Date(g,A-1,1),$=new Date(g,A,0);let p=new Date(L.textContent.toLowerCase());w.setHours(0,0,0,0),$.setHours(0,0,0,0),p.setHours(0,0,0,0),b=p>=w&&p<=$}L&&L.textContent.toLowerCase().includes(l.toLowerCase())&&(b=!0)}),b||(u.classList.add("filtered"),u.setAttribute("data-filtered-by",t))});Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((t,h)=>{let u=!(n.length>0&&n[0].value.length>=3);n.forEach((f,b)=>{let l=t.querySelector(`[data-label="${f.column}"]`);l&&f.value.length>=3&&l.textContent.toLowerCase().includes(f.value.toLowerCase())&&(u=!0)}),u||t.classList.add("filtered")}),Array.from(a.querySelectorAll("tbody tr:not(.filtered")).forEach((t,h)=>{i++,t.classList.add("filtered--matched"),Math.ceil(i/d)==parseInt(s)&&t.classList.add("filtered--show")}),o&&(o.setAttribute("data-page",s),o.setAttribute("data-pages",Math.ceil(i/d)),o.setAttribute("data-total",i),o.setAttribute("data-show",d))},H=(a,e,o)=>{Array.from(e.querySelectorAll("[data-query]")).forEach((n,i)=>{let s=n.getAttribute("data-query"),d;if(s=="total")o.hasAttribute("data-total")?d=o.getAttribute("data-total"):d=(a.classList.contains("table--filtered"),a.querySelectorAll("tbody tr").length);else if(!s.includes(" == ")&&s.includes(" & ")){let c=s.split(" & "),t="";c.forEach(h=>{t+=`:not([data-filtered-by="${h}"])`}),d=Array.from(a.querySelectorAll(`tbody tr${t}`)).length}else if(!s.includes(" == "))d=Array.from(a.querySelectorAll(`tbody tr:not([data-filtered-by="${s}"])`)).length;else if(s.includes(" && ")){let c=s.split(" && ");d=Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).filter(function(t){let h=!0;for(const[u,f]of Object.entries(c)){let b=f.split(" == ");(!t.querySelector(`td[data-label="${b[0]}"]`)||t.querySelector(`td[data-label="${b[0]}"]`).textContent!=`${b[1]}`)&&(h=!1)}return h}).length}else{let c=s.split(" == ");d=Array.from(a.querySelectorAll(`tbody tr.filtered--matched td[data-label="${c[0]}"], tbody tr[data-filtered-by="${c[0]}"] td[data-label="${c[0]}"]`)).filter(function(t){return t.textContent===c[1]}).length}n.hasAttribute("data-total")?n.setAttribute("data-total",d):n.innerHTML=d})},G=function(a,e,o,r){o.addEventListener("click",n=>{if(n&&n.target instanceof HTMLElement&&n.target.closest("[data-page]")){n.preventDefault();let i=e.querySelector("[data-pagination]"),s=n.target.closest("[data-page]").getAttribute("data-page");if(i.value=s,r.setAttribute("data-page",s),e.dispatchEvent(new Event("paginate")),a.hasAttribute("data-show-history")){const t=new URL(location);t.searchParams.set("page",s),history.pushState({type:"pagination",form:e.getAttribute("id"),page:s},"",t)}const d=-250,c=a.getBoundingClientRect().top+window.pageYOffset+d;window.scrollTo({top:c,behavior:"smooth"})}if(n&&n.target instanceof HTMLElement&&n.target.closest("[data-show]")){n.preventDefault();let i=e.querySelector("[data-show]"),s=n.target.closest("[data-show]").getAttribute("data-show");i.value=s,r.setAttribute("data-show",s),e.dispatchEvent(new Event("submit"))}})},K=(a,e)=>{if(!a)return!1;a.addEventListener("click",o=>{Z(e)})},Z=function(a){for(var e=[],o=a.getElementsByTagName("tr"),r=0;r<o.length;r++){for(var n=o[r].querySelectorAll("td,th"),i=[],s=0;s<n.length;s++)i.push(`"${n[s].textContent}"`);e.push(i.join(","))}e=e.join(`
|
|
12
|
-
`);let d=new Blob([e],{type:"text/csv"});var c=document.createElement("a");c.download="export.csv";var t=window.URL.createObjectURL(d);c.href=t,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c)},P=function(a,e,
|
|
9
|
+
<span class="d-block pb-2">You've viewed ${n} of ${o} results</span>
|
|
10
|
+
<a href="?show=${parseInt(n)+parseInt(s)}" class="btn btn-primary w-100 m-0" data-show="${parseInt(n)+parseInt(s)}">Load more results</a>
|
|
11
|
+
</div>`,!0};var z=function(a,e,i,r){function o(n){return n instanceof i?n:new i(function(s){s(n)})}return new(i||(i=Promise))(function(n,s){function d(h){try{t(r.next(h))}catch(u){s(u)}}function c(h){try{t(r.throw(h))}catch(u){s(u)}}function t(h){h.done?n(h.value):o(h.value).then(d,c)}t((r=r.apply(a,e||[])).next())})};const _=a=>{const e=Array.from(a.querySelectorAll("thead th"));Array.from(a.querySelectorAll("tbody tr")).forEach((r,o)=>{const n=Array.from(r.querySelectorAll("th, td")),s=["0","low","medium","high","unknown","n/a","pending","verified","overdue","incomplete","complete","completed","approval required","requires approval","to do","not started","warning","error"];n.forEach((d,c)=>{const t=e[c];if(typeof t<"u"){let h=document.createElement("div");h.innerHTML=t.innerHTML;let u=h.textContent||h.innerText||"";d.setAttribute("data-label",u),t.hasAttribute("data-td-class")&&d.setAttribute("class",t.getAttribute("data-td-class")),t.hasAttribute("data-format")&&(d.setAttribute("data-format",t.getAttribute("data-format")),d.innerHTML=M(t.getAttribute("data-format"),d.textContent.trim())),s.includes(d.textContent.trim().toLowerCase())&&d.setAttribute("data-content",d.textContent.trim().toLowerCase())}})})},Y=a=>{let e=0;return Array.from(a.querySelectorAll("tbody tr")).forEach((i,r)=>{let o=window.getComputedStyle(document.querySelector("html")),n=i.querySelector(":scope > *:last-child > *:first-child");if(n){n.classList.add("text-nowrap");let s=n.offsetWidth/parseFloat(o.fontSize);s+=1.7,e=e>s?e:s}}),e},J=a=>{if(a.closest(".table--fullwidth")||a.querySelectorAll("thead tr th").length<4)return!1;Array.from(a.querySelectorAll("tbody tr")).forEach((e,i)=>{let r=e.querySelector(":scope > :is(td,th):first-child"),o=r.textContent;if(o!="")r.innerHTML=`<span class="td__content">${o}</span><button type="button" class="d-none">${o}</button>`;else{let n=e.querySelector(":scope > :is(td,th):nth-child(2)"),s=n.textContent;n.innerHTML=`<span class="td__content">${s}</span><button type="button" class="d-none">${s}</button>`}})},Q=a=>{a.addEventListener("click",e=>{if(e&&e.target instanceof HTMLElement&&e.target.closest("tr > :is(td,th):first-child button")){let i=e.target.closest("tr > :is(td,th):first-child button"),r=i.parentNode.closest("tr");r.getAttribute("data-view")=="full"?r.setAttribute("data-view","default"):r.setAttribute("data-view","full"),i.blur()}})},R=(a,e)=>{let i=e.querySelector("[data-search]");if(!i)return!1;const r=i.getAttribute("id"),o=i.getAttribute("data-search").split(",");let n=i.parentNode,s={};o.forEach((d,c)=>{Array.from(a.querySelectorAll('td[data-label="'+d.trim()+'"]')).forEach((t,h)=>{t.querySelector(".td__content")?s[t.querySelector(".td__content").textContent]=t.querySelector(".td__content").textContent:s[t.textContent]=t.textContent})}),i.setAttribute("list",`${r}_list`),i.setAttribute("autocomplete","off"),n.querySelector("datalist")||(n.innerHTML+=`<datalist id="${r}_list"></datalist>`),n.querySelector("datalist").innerHTML=`${Object.keys(s).map(d=>`<option value="${d}"></option>`).join("")}`},X=(a,e,i,r,o)=>{var n;let s=function(t=!1){if(e.hasAttribute("data-ajax")){if(!t){let h=e.querySelector("[data-pagination]");h.value=1,r.setAttribute("data-page",1)}I(a,e,i,r)}else e.hasAttribute("data-submit")?e.submit():(j(a,e,r),C(r,i),H(a,e))};e.addEventListener("keyup",t=>{clearTimeout(n),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&(n=setTimeout(function(){s()},500))}),e.addEventListener("change",t=>{clearTimeout(n),t&&t.target instanceof HTMLElement&&t.target.closest("[data-sort]")&&(e.hasAttribute("data-submit")||N(a,e,o),s()),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&t.target.closest("form .dialog__wrapper > dialog")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&!t.target.closest("form dialog")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-show]")&&s(),t&&t.target instanceof HTMLElement&&t.target.closest("[data-mimic]")&&s()}),e.addEventListener("click",t=>{clearTimeout(n),t&&t.target instanceof HTMLElement&&t.target.closest('dialog button:not([type="button"])')&&t.target.closest('dialog button:not([type="button"])').closest("dialog").close(),t&&t.target instanceof HTMLElement&&t.target.closest(".dialog__close")&&(t.preventDefault(),t.stopPropagation()),t&&t.target instanceof HTMLElement&&t.target.closest("[data-clear]")&&(e.reset(),e.hasAttribute("data-submit")||N(a,e,o),s())}),e.addEventListener("submit",t=>{clearTimeout(n),e.hasAttribute("data-submit")||t.preventDefault(),s()}),e.addEventListener("force",t=>{s()}),e.addEventListener("paginate",t=>{s(!0)});let d=[],c=[];Array.from(e.querySelectorAll("[data-mimic]")).forEach((t,h)=>{let u=t.getAttribute("data-mimic");Array.from(document.querySelectorAll(`[name="${u}"]`)).forEach((f,b)=>{let l=f.closest("form");d.includes(l)||d.push(l),c.includes(u)||c.push(u)})}),d.forEach((t,h)=>{const u=function(){let f=[],b=new FormData(t);for(const[l,y]of b)document.querySelector(`[data-mimic="${l}"]`)&&!f.includes(l)?(f.push(l),document.querySelector(`[data-mimic="${l}"]`).value=y):document.querySelector(`[data-mimic="${l}"]`)&&(document.querySelector(`[data-mimic="${l}"]`).value+=","+y);for(const l of f){const y=new Event("force");e.dispatchEvent(y)}for(const l of c)if(!b.has(l)&&t.querySelector(`[name="${l}"]`)){document.querySelector(`[data-mimic="${l}"]`).value="";const y=new Event("force");e.dispatchEvent(y)}};t.addEventListener("force",f=>{u()}),t.addEventListener("change",f=>{u()})})},N=(a,e,i)=>{if(e.getAttribute("data-ajax"))return!1;let r=a.querySelector("tbody"),o=e.querySelector("[data-sort]"),n=o.querySelector(`option:nth-child(${o.selectedIndex+1})`),s=n.getAttribute("data-sort"),d=n.getAttribute("data-order"),c=n.getAttribute("data-format");if(!s)return r.innerHTML=i.innerHTML,_(a),!1;let t=[];["asc","desc","descending"].includes(d)||(t=d.split(","));let h=[];Array.from(r.querySelectorAll("tr")).forEach((f,b)=>{let l=f.querySelector('td[data-label="'+s+'"], th[data-label="'+s+'"]').textContent.trim();t.length&&t.includes(l)&&(l=t.indexOf(l)),F(l)&&(l=V(l,10)),c&&c=="date"&&(l=new Date(l));const y={index:l,row:f};h.push(y)}),h.sort((f,b)=>f.index>b.index?1:-1),(d=="descending"||d=="desc")&&(h=h.reverse());let u="";h.forEach((f,b)=>{u+=f.row.outerHTML}),r.innerHTML=u},j=(a,e,i)=>{a.classList.remove("table--filtered");let r=[],o=[],n=0,s=e.querySelector("[data-pagination]")?parseInt(e.querySelector("[data-pagination]").value):1,d=e.querySelector("[data-show]")?parseInt(e.querySelector("[data-show]").value):15;if(Array.from(a.querySelectorAll("tbody tr")).forEach((t,h)=>{t.classList.remove("filtered"),t.classList.remove("filtered--matched"),t.classList.remove("filtered--show"),t.removeAttribute("data-filtered-by")}),Array.from(e.querySelectorAll("[data-filter]")).forEach((t,h)=>{if(!(t.type=="radio"&&!t.checked)&&!(t.type=="checkbox"&&!t.checked)){if(t.getAttribute("data-filter")=="multi")for(const[u,f]of Object.entries(JSON.parse(t.value)))r[t.getAttribute("data-filter")].push(f);else if(t&&t.value){let u=t.getAttribute("data-filter");r[u]||(r[u]=new Array),r[u].push(t.value)}}}),e.querySelector("[data-search]")){let t=e.querySelector("[data-search]");e.querySelector("[data-search]").getAttribute("data-search").split(",").forEach((u,f)=>{o.push({column:`${u.trim()}`,value:`${t.value}`})})}Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,h)=>{t.innerHTML=""}),r.length&&Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,h)=>{t.innerHTML+=`(${r.length})`}),a.classList.add("table--filtered");for(const[t,h]of Object.entries(r))Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((u,f)=>{let b=!1;h.forEach((l,y)=>{let S=u.querySelector(`[data-label="${t}"]`);if(l&&l=="$today")l=M("date",new Date);else if(l&&l=="$yesterday"){let p=new Date;p.setDate(p.getDate()-1),l=M("date",p)}else if(l&&(l=="$thisWeek"||l=="$lastWeek")){let p=new Date,g=new Date(p.setDate(p.getDate()-(p.getDay()-1))),A=new Date(p.setDate(p.getDate()-p.getDay()+7)),m=new Date(S.textContent.toLowerCase());if(p.setHours(0,0,0,0),g.setHours(0,0,0,0),A.setHours(0,0,0,0),m.setHours(0,0,0,0),l=="$thisWeek")b=m>=g&&m<=A;else{let L=new Date(g.setDate(g.getDate()-7)),q=new Date(A.setDate(A.getDate()-7));L.setHours(0,0,0,0),q.setHours(0,0,0,0),b=m>=L&&m<=q}}else if(l&&l=="$thisMonth"){let p=new Date,g=p.getFullYear(),A=p.getMonth();var x=new Date(g,A,1),v=new Date(g,A+1,0);let m=new Date(S.textContent.toLowerCase());x.setHours(0,0,0,0),v.setHours(0,0,0,0),m.setHours(0,0,0,0),b=m>=x&&m<=v}else if(l&&l=="$lastMonth"){let p=new Date,g=p.getFullYear(),A=p.getMonth();var w=new Date(g,A-1,1),T=new Date(g,A,0);let m=new Date(S.textContent.toLowerCase());w.setHours(0,0,0,0),T.setHours(0,0,0,0),m.setHours(0,0,0,0),b=m>=w&&m<=T}S&&S.textContent.toLowerCase().includes(l.toLowerCase())&&(b=!0)}),b||(u.classList.add("filtered"),u.setAttribute("data-filtered-by",t))});Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((t,h)=>{let u=!(o.length>0&&o[0].value.length>=3);o.forEach((f,b)=>{let l=t.querySelector(`[data-label="${f.column}"]`);l&&f.value.length>=3&&l.textContent.toLowerCase().includes(f.value.toLowerCase())&&(u=!0)}),u||t.classList.add("filtered")}),Array.from(a.querySelectorAll("tbody tr:not(.filtered")).forEach((t,h)=>{n++,t.classList.add("filtered--matched"),Math.ceil(n/d)==parseInt(s)&&t.classList.add("filtered--show")}),i&&(i.setAttribute("data-page",s),i.setAttribute("data-pages",Math.ceil(n/d)),i.setAttribute("data-total",n),i.setAttribute("data-show",d))},H=(a,e,i)=>{Array.from(e.querySelectorAll("[data-query]")).forEach((o,n)=>{let s=o.getAttribute("data-query"),d;if(s=="total")i.hasAttribute("data-total")?d=i.getAttribute("data-total"):d=(a.classList.contains("table--filtered"),a.querySelectorAll("tbody tr").length);else if(!s.includes(" == ")&&s.includes(" & ")){let c=s.split(" & "),t="";c.forEach(h=>{t+=`:not([data-filtered-by="${h}"])`}),d=Array.from(a.querySelectorAll(`tbody tr${t}`)).length}else if(!s.includes(" == "))d=Array.from(a.querySelectorAll(`tbody tr:not([data-filtered-by="${s}"])`)).length;else if(s.includes(" && ")){let c=s.split(" && ");d=Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).filter(function(t){let h=!0;for(const[u,f]of Object.entries(c)){let b=f.split(" == ");(!t.querySelector(`td[data-label="${b[0]}"]`)||t.querySelector(`td[data-label="${b[0]}"]`).textContent!=`${b[1]}`)&&(h=!1)}return h}).length}else{let c=s.split(" == ");d=Array.from(a.querySelectorAll(`tbody tr.filtered--matched td[data-label="${c[0]}"], tbody tr[data-filtered-by="${c[0]}"] td[data-label="${c[0]}"]`)).filter(function(t){return t.textContent===c[1]}).length}o.hasAttribute("data-total")?o.setAttribute("data-total",d):o.innerHTML=d})},G=function(a,e,i,r){i.addEventListener("click",o=>{if(o&&o.target instanceof HTMLElement&&o.target.closest("[data-page]")){o.preventDefault();let n=e.querySelector("[data-pagination]"),s=o.target.closest("[data-page]").getAttribute("data-page");if(n.value=s,r.setAttribute("data-page",s),e.dispatchEvent(new Event("paginate")),a.hasAttribute("data-show-history")){const t=new URL(location);t.searchParams.set("page",s),history.pushState({type:"pagination",form:e.getAttribute("id"),page:s},"",t)}const d=-250,c=a.getBoundingClientRect().top+window.pageYOffset+d;window.scrollTo({top:c,behavior:"smooth"})}if(o&&o.target instanceof HTMLElement&&o.target.closest("[data-show]")){o.preventDefault();let n=e.querySelector("[data-show]"),s=o.target.closest("[data-show]").getAttribute("data-show");n.value=s,r.setAttribute("data-show",s),e.dispatchEvent(new Event("submit"))}})},K=(a,e)=>{if(!a)return!1;a.addEventListener("click",i=>{Z(e)})},Z=function(a){for(var e=[],i=a.getElementsByTagName("tr"),r=0;r<i.length;r++){for(var o=i[r].querySelectorAll("td,th"),n=[],s=0;s<o.length;s++)n.push(`"${o[s].textContent}"`);e.push(n.join(","))}e=e.join(`
|
|
12
|
+
`);let d=new Blob([e],{type:"text/csv"});var c=document.createElement("a");c.download="export.csv";var t=window.URL.createObjectURL(d);c.href=t,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c)},P=function(a,e,i,r){if(_(a),J(a),H(a,e,r),r&&r.classList.contains("table--cta")){let o=function(){Array.from(a.querySelectorAll("tr")).forEach((n,s)=>{let d=n.offsetHeight;n.style.setProperty("--row-height",`${d}px`)})};if(!r.hasAttribute("data-cta-width")){const n=Y(a);r.style.setProperty("--cta-width",`${n}rem`),r.setAttribute("data-cta-width",`${n}rem`)}new ResizeObserver(o).observe(a)}},I=function(a,e,i,r){return z(this,void 0,void 0,function*(){const o=(u,f,b)=>f.split(/[\.\[\]\'\"]/).filter(l=>l).reduce((l,y)=>l?l[y]:b,u);let n=new FormData(e),s=new URLSearchParams(n).toString(),d=a.querySelectorAll("thead tr th"),c=a.querySelector("tbody"),t=e.getAttribute("data-ajax");r.classList.add("table--loading"),window.controller||(window.controller=[]),window.controller[t]&&window.controller[t].abort(),window.controller[t]=new AbortController;const{signal:h}=controller[t];try{yield fetch(t+"?"+s,{signal:h,method:"get",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest"})}).then(u=>u.json()).then(u=>{let f=e.hasAttribute("data-schema")?e.getAttribute("data-schema"):"data",b=e.hasAttribute("data-schema-total")?e.getAttribute("data-schema-total"):"meta.total",l=e.hasAttribute("data-schema-page")?e.getAttribute("data-schema-page"):"meta.current_page",y=o(u,b,1),S=o(u,l,1),x=o(u,f),v=r.hasAttribute("data-empty-msg")?r.getAttribute("data-empty-msg"):"No results found";if(x?(c.innerHTML="",x.forEach((w,T)=>{var p=document.createElement("tr");d.forEach((g,A)=>{let m="";var L=document.createElement("td");if(L.setAttribute("data-label",g.innerText),g.getAttribute("data-output")){var q=g.getAttribute("data-output");m=q.replace(new RegExp(/{(.*?)}/,"gm"),function(D){return o(w,D.replace("{","").replace("}",""))})}if(g.hasAttribute("data-output-array")){var q=g.getAttribute("data-output");let W=o(w,q.replace("{","").replace("}",""));m="",W.forEach((k,et)=>{let O=g.getAttribute("data-output-array"),E="";if(g.hasAttribute("data-output-array-property")&&g.hasAttribute("data-output-array-transform")){const $=o(k,g.getAttribute("data-output-array-property")),B=JSON.parse(g.getAttribute("data-output-array-transform"))[$];E=O.replace(`{${g.getAttribute("data-output-array-property")}}`,B)}E=E.replace(new RegExp(/{(.*?)}/,"gm"),function($){return o(k,$.replace("{","").replace("}",""))}),m+=E})}g.hasAttribute("data-transform")&&(m=JSON.parse(g.getAttribute("data-transform"))[m],!m&&g.hasAttribute("data-default")&&(m=g.getAttribute("data-default"))),L.innerHTML=m,p.appendChild(L)}),c.appendChild(p)}),R(a,e),r.setAttribute("data-total",parseInt(y)),r.setAttribute("data-page",parseInt(S)),r.setAttribute("data-pages",Math.ceil(r.getAttribute("data-total")/r.getAttribute("data-show"))),P(a,e,i,r),C(r,i),parseInt(y)==0&&(c.innerHTML=`<tr><td colspan="100%"><span>${v}</span></td></tr>`),r.classList.remove("table--loading"),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"Ajax table loaded",url:t,formData:s})):c.innerHTML='<tr><td colspan="100%"><span>Error loading table</span></td></tr>',e.hasAttribute("data-ajax-post")){const w=new XMLHttpRequest;w.open("GET",`${window.location.href}?ajax=true&${s}`),w.send()}})}catch(u){console.log(u)}})},M=(a,e)=>{switch(a){case"datetime":return new Date(e).toLocaleDateString("en-gb",{weekday:"short",year:"2-digit",month:"long",day:"numeric"})+" "+new Date(e).toLocaleTimeString("en-gb",{hour:"2-digit",minute:"2-digit"});case"date":return new Date(e).toLocaleDateString("en-gb",{year:"2-digit",month:"long",day:"numeric"});case"capitalise":return e=U(e)}};class tt extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const e=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",i=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${e}/css/core.min.css`,r=document.createElement("template");r.innerHTML=`
|
|
13
13
|
<style>
|
|
14
|
-
@import "${
|
|
14
|
+
@import "${i}";
|
|
15
15
|
|
|
16
16
|
:host(.mh-sm){
|
|
17
17
|
max-height: none!important;
|
|
@@ -25,12 +25,11 @@
|
|
|
25
25
|
|
|
26
26
|
${this.hasAttribute("css")?`@import "${this.getAttribute("css")}";`:""}
|
|
27
27
|
</style>
|
|
28
|
-
|
|
29
|
-
<div class="table__wrapper
|
|
28
|
+
<div class="table--cta">
|
|
29
|
+
<div class="table__wrapper">
|
|
30
30
|
<slot></slot>
|
|
31
31
|
</div>
|
|
32
|
-
|
|
33
|
-
${n?'<button class="link" type="button" data-export>Export table as CSV</button>':""}
|
|
32
|
+
</div>
|
|
34
33
|
<div class="table__pagination"></div>
|
|
35
|
-
`,this.shadowRoot.appendChild(
|
|
34
|
+
`,this.shadowRoot.appendChild(r.content.cloneNode(!0))}connectedCallback(){const e=new URLSearchParams(window.location.search);this.hasAttribute("data-total")||this.setAttribute("data-total",this.querySelectorAll("table tbody tr").length),this.hasAttribute("data-page")||this.setAttribute("data-page",e.has("page")?e.get("page"):1),this.hasAttribute("data-show")||this.setAttribute("data-show",15),this.hasAttribute("data-increment")||this.setAttribute("data-increment",15),this.setAttribute("data-pages",Math.ceil(this.getAttribute("data-total")/this.getAttribute("data-show")));let i=this.classList.toString();i=i.replace("table--cta",""),i=i.replace("table--loading",""),this.shadowRoot.querySelector(".table__wrapper").className+=` ${i}`,this.table=this.querySelector("table"),this.savedTableBody=this.table.querySelector("tbody").cloneNode(!0),this.pagination=this.shadowRoot.querySelector(".table__pagination"),this.classList.contains("table--cta")||this.shadowRoot.querySelector(".table--cta").classList.remove("table--cta"),this.form=document.createElement("form"),this.hasAttribute("data-filterby")?this.form=document.querySelector(`#${this.getAttribute("data-filterby")}`):this.table.parentNode.insertBefore(this.form,this.table.nextSibling),this.form.hasAttribute("data-ajax")&&this.table.classList.add("table--ajax"),R(this.table,this.form),this.form.querySelector("[data-page]")||(this.form.innerHTML+=`<input name="page" type="hidden" value="${this.getAttribute("data-page")}" data-pagination="true" />`),this.form.querySelector("[data-show]")||(this.form.innerHTML+=`<input name="show" type="hidden" value="${this.getAttribute("data-show")}" data-show="true" />`),Q(this.table),X(this.table,this.form,this.pagination,this,this.savedTableBody),G(this.table,this.form,this.pagination,this),K(this.shadowRoot.querySelector("[data-export]"),this.table),this.form.getAttribute("data-ajax")?I(this.table,this.form,this.pagination,this):(P(this.table,this.form,this.pagination,this),j(this.table,this.form,this),C(this,this.pagination),H(this.table,this.form)),this.shadowRoot.querySelector(".table__wrapper").addEventListener("scroll",o=>{this.table.querySelector("dialog[open]")&&(this.table.querySelector("dialog[open]").close(),this.table.querySelector(".dialog__wrapper > button.active").classList.remove("active"))})}static get observedAttributes(){return["data-total","data-pages","data-page","data-show"]}attributeChangedCallback(e,i,r){}}export{tt as default};
|
|
36
35
|
//# sourceMappingURL=table.component.min.js.map
|