@iamproperty/components 5.1.0-beta4 → 5.1.0-beta6
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/actionbar/actionbar.component.min.js +1 -1
- package/assets/js/components/address-lookup/address-lookup.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/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/fileupload/fileupload.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/nav/nav.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/search/search.component.js +1 -1
- package/assets/js/components/search/search.component.min.js +6 -6
- package/assets/js/components/search/search.component.min.js.map +1 -1
- package/assets/js/components/table/table.component.min.js +3 -3
- 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/modules/table.js +7 -4
- package/assets/js/scripts.bundle.js +3 -3
- 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/search/search.component.ts +1 -1
- package/assets/ts/modules/table.ts +10 -11
- package/dist/components.es.js +292 -292
- package/dist/components.umd.js +13 -13
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function n(e){let r=e.querySelectorAll("details"),a=e.querySelectorAll("summary");if(r.forEach(o=>{o.classList.add("accordion-item")}),a.forEach(o=>{o.classList.add("accordion-header"),o.classList.add("accordion-button"),o.classList.add("h4")}),!e.classList.contains("accordion--keep-open")){const o=e.querySelectorAll(":scope > details");o.forEach(c=>{c.addEventListener("click",()=>{o.forEach(t=>{t!==c&&t.removeAttribute("open")})})})}}window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"accordion"});class i extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const r=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",a=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${r}/css/core.min.css`,o=document.createElement("template");o.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/const A=function(i){typeof window.player<"u"&&typeof window.player.pauseVideo=="function"&&window.player.pauseVideo();var a=i.getAttribute("data-id"),d=i.getAttribute("id");if(typeof d>"u"||d==null){var n=String.fromCharCode(65+Math.floor(Math.random()*26));d=n+Date.now(),i.setAttribute("id",d)}function o(){window.player=new YT.Player(d,{height:"100%",width:"100%",videoId:a,playerVars:{modestbranding:1,playsinline:1,rel:0,showinfo:0},events:{onReady:u,onStateChange:e}})}o();function u(r){r.target.playVideo()}var t=!1;function e(r){if(r.data==YT.PlayerState.PLAYING&&!t){var s=document.getElementById(d);s.classList.add("player-ready"),t=!0}}},L=i=>(Array.from(i.querySelectorAll("dialog[open]")).forEach((a,d)=>{a.closest(".dialog__wrapper")||(a.removeAttribute("open"),a.showModal(),a.focus(),w(a))}),i.addEventListener("click",a=>{if(a.target.tagName=="IAM-ACTIONBAR")return!1;if(a&&a.target instanceof HTMLElement&&a.target.closest("[data-modal]")){const o=a.target.closest("[data-modal]"),u=o.hasAttribute("data-modal")?o.getAttribute("data-modal"):o.getAttribute("data-filter"),t=document.querySelector(`dialog#${u}`);w(t),t.showModal(),t.focus();let e=t.offsetWidth;t.setAttribute("style",`max-width: ${e}px;`),Array.from(t.querySelectorAll("[data-duplicate]")).forEach((r,s)=>{const b=r.getAttribute("data-duplicate"),c=document.getElementById(b);if(r.checked!=c.checked){r.checked=c.checked;let l=new Event("change");r.dispatchEvent(l)}}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"openModal",id:u})}if(a&&a.target instanceof HTMLElement&&a.target.closest("button.dialog__close")){const o=a.target.closest("dialog[open]");a.preventDefault(),o.close(),Array.from(document.querySelectorAll(".dialog__wrapper > button")).forEach((u,t)=>{u.classList.remove("active")}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"closeModal",id:o.getAttribute("id")})}if(a&&a.target instanceof HTMLElement&&a.target.closest('button[formmethod="dialog"]')){const o=a.target.closest("dialog[open]");Array.from(document.querySelectorAll(".dialog__wrapper > button")).forEach((u,t)=>{u.classList.remove("active")}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"closeModal",id:o.getAttribute("id")})}if(a&&a.target instanceof HTMLElement&&a.target.closest("dialog[open]")){let o=a.target.closest("dialog[open]");var d=window.getComputedStyle(o);if(d.display==="contents"&&(o=o.parentNode.closest("dialog[open]")),!o.querySelector(":scope > .mh-lg > form:last-child > button:last-child, :scope > .mh-lg > button:last-child")||o.classList.contains("dialog--multi")){const u=o.getBoundingClientRect();(a.clientX<u.left||a.clientX>u.right||a.clientY<u.top||a.clientY>u.bottom)&&(a.target.closest('input[type="radio"]')||o.close(),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"closeModal",id:o.getAttribute("id")}))}}if(a&&a.target instanceof HTMLElement&&a.target.closest(".dialog__wrapper > button")){a.stopPropagation();let o=a.target.closest(".dialog__wrapper > button"),u=a.target.closest(".dialog__wrapper > button").parentNode,t="openPopover",e=u.querySelector(":scope > dialog");if(document.querySelector("*:not([data-keep-open]) > dialog[open]")&&document.querySelector("*:not([data-keep-open]) > dialog[open]")!=e&&document.querySelector("*:not([data-keep-open]) > dialog[open]").close(),Array.from(document.querySelectorAll(".dialog__wrapper > button")).forEach((c,l)=>{c.removeAttribute("aria-expanded")}),e.hasAttribute("open"))e.close(),t="closePopover",e.removeAttribute("style"),o.removeAttribute("aria-expanded");else{e.show(),o.setAttribute("aria-expanded",!0);var n=o.getBoundingClientRect();let c=n.top,l=n.left;if(o.closest("iam-table")){let h=o.closest("iam-table").parentNode.getBoundingClientRect();c-=h.top,l-=h.left}e.classList.contains("dialog--fix")&&e.setAttribute("style",`position:fixed;top: ${c}px; left: ${l}px; margin: 3rem 0 0 0;`)}let r=e.getBoundingClientRect(),s=r.bottom-window.scrollY,b=window.innerHeight-window.scrollY;if(s>b){let c=e.hasAttribute("style")?e.getAttribute("style")+" ":"";e.setAttribute("style",c+"transform: translate(0, calc(-100% - 4rem))"),r=e.getBoundingClientRect(),r.top-window.scrollY<100&&e.removeAttribute("style")}window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:t,id:o.textContent})}a&&a.target instanceof HTMLElement&&!a.target.closest("dialog[open]")&&!a.target.closest(".dialog__wrapper > button")&&(document.querySelector(".dialog__wrapper:not([data-keep-open]) > dialog[open]")&&document.querySelector(".dialog__wrapper:not([data-keep-open]) > dialog[open]").close(),Array.from(document.querySelectorAll(".dialog__wrapper:not([data-keep-open]) > button")).forEach((o,u)=>{o.removeAttribute("aria-expanded")}))}),null),w=i=>{i.querySelector(":scope > .mh-lg > form:last-child > button:last-child, :scope > .mh-lg > button:last-child")&&!i.classList.contains("dialog--multi")&&i.addEventListener("cancel",d=>{d.preventDefault()});let a=i.querySelector(".youtube-embed a");if(a&&A(a),i.classList.contains("dialog--multi")&&!i.querySelector(":scope > .steps")&&_(i),!i.querySelector(":scope > .mh-lg")&&!i.classList.contains("dialog--multi")){i.innerHTML=`<div class="mh-lg">${i.innerHTML}</div>`;let d=i.querySelector(".mh-lg"),n=i.querySelector(".mh-lg :is(.h1,.h2,.h3,.h4,.h5,.h6)");if(n){let o=n.previousSibling;d.before(n),o&&n.before(o)}}i.querySelector(":scope > button:first-child")||i.insertAdjacentHTML("afterbegin",'<button class="dialog__close">Close</button>')},_=i=>{let a="",d=Array.from(i.querySelectorAll("fieldset[data-title]")),n=i.querySelector("form");d.forEach((t,e)=>{a+=`<button data-title="${t.getAttribute("data-title")}" type="button" class="${e==0?"active":""}" tabindex="-1">${t.getAttribute("data-title")}</button>`;const r=document.createElement("div");if(r.classList.add("btn--wrapper"),t.appendChild(r),e!=0&&(r.innerHTML+=`<button data-title="${d[e-1].getAttribute("data-title")}" class="btn btn-secondary mb-0" data-previous type="button">Previous</button>`),e!=d.length-1&&(r.innerHTML+=`<button data-title="${d[e+1].getAttribute("data-title")}" class="btn btn-primary mb-0" data-next type="button">Next</button>`),e==d.length-1)if(n&&n.querySelector(':scope > button[type="submit"]')){let s=n.querySelector(':scope > button[type="submit"]');s.classList.add("mb-0"),r.insertAdjacentElement("beforeend",s)}else r.innerHTML+=`<button data-title="${d[e].getAttribute("data-title")}" class="btn btn-primary mb-0" data-next type="submit">Submit</button>`}),i.insertAdjacentHTML("afterbegin",`<div class="steps bg-primary">${a}</div>`);let o=Array.from(i.querySelectorAll("fieldset.was-validated"));for(let t=0;t<o.length;t++){let e=o[t],r=e.getAttribute("data-title");if(e.querySelector(".is-invalid")){Array.from(i.querySelectorAll(`[data-title="${r}"]`)).forEach((s,b)=>{s.classList.add("active")});break}else Array.from(i.querySelectorAll(`[data-title="${r}"]`)).forEach((s,b)=>{s.classList.add("valid")})}i.addEventListener("invalid",function(){return function(t){t.preventDefault()}}(),!0);function u(t){const e=i.querySelector("fieldset.active")?i.querySelector("fieldset.active"):i.querySelector("fieldset[data-title]"),r=e.getAttribute("data-title");let s=!0;if(e.classList.add("was-validated"),Array.from(e.querySelectorAll("input")).forEach((l,h)=>{l.checkValidity()||(s=!1)}),s?Array.from(i.querySelectorAll(`[data-title="${r}"]`)).forEach((l,h)=>{l.classList.add("valid")}):Array.from(i.querySelectorAll(`[data-title="${r}"]`)).forEach((l,h)=>{l.classList.remove("valid")}),s||!t.hasAttribute("data-next")){const l=i.querySelector(`fieldset[data-title="${t.getAttribute("data-title")}"]`),h=i.querySelector(`.steps button[data-title="${t.getAttribute("data-title")}"]`);Array.from(i.querySelectorAll("button")).forEach((g,m)=>{g.classList.remove("active")}),Array.from(i.querySelectorAll("fieldset")).forEach((g,m)=>{g.classList.remove("active")}),h.classList.add("active"),l.classList.add("active")}let b=Array.from(i.querySelectorAll("fieldset")).length,c=Array.from(i.querySelectorAll("fieldset.valid")).length;i.style.setProperty("--progress",`${c/(b-1)*100}%`)}i.addEventListener("keydown",t=>{if(t&&t.target instanceof HTMLElement&&t.target.closest("button")){const e=t.target.closest("button");t.keyCode==13&&e.getAttribute("type")!="submit"&&(t.preventDefault(),u(e))}t&&t.target instanceof HTMLElement&&t.target.closest("input")&&(t.target.closest("input").classList.remove("is-invalid"),t.keyCode==13&&t.preventDefault())}),i.addEventListener("click",t=>{if(t&&t.target instanceof HTMLElement&&t.target.closest('button[type="submit"]'))t.target.closest("form").classList.add("was-validated");else if(t&&t.target instanceof HTMLElement&&t.target.closest("button[data-title]")){const e=t.target.closest("button[data-title]");u(e)}return null})};window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"action bar"});function v(i,a){i&&a=="all"?(i.querySelector("input").indeterminate=!1,i.querySelector("input").checked=!0,i.querySelector("label").textContent="Select all"):i&&a==0?(i.querySelector("input").indeterminate=!1,i.querySelector("input").checked=!1,i.querySelector("label").textContent="Select all"):i&&a?(i.querySelector("input").indeterminate=!0,i.querySelector("input").checked=!1,i.querySelector("label").textContent=`${a} item${a>1?"s":""} selected`):i&&(i.querySelector("input").checked=!1,i.querySelector("input").indeterminate=!1,i.querySelector("label").textContent="Select all")}class S extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const a=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",d=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${a}/css/core.min.css`,n=document.createElement("template");n.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/import k from"js-cookie";var g=function(q,r,o,a){function m(c){return c instanceof o?c:new o(function(u){u(c)})}return new(o||(o=Promise))(function(c,u){function b(n){try{f(a.next(n))}catch(p){u(p)}}function v(n){try{f(a.throw(n))}catch(p){u(p)}}function f(n){n.done?c(n.value):m(n.value).then(b,v)}f((a=a.apply(q,r||[])).next())})};window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"Address Lookup"});class $ extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const r=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",o=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${r}/css/core.min.css`,a=document.createElement("template");a.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function h(d,m){function u(e,t){let l=!1,r=t.getAttribute("name");r.includes("[]")&&(r=r.replace("[]",`[${t.value}]`));let i=e.querySelector(`[data-name="${r}"]`);i&&t.getAttribute("type")=="checkbox"&&(l=!t.checked);let o=t.getAttribute("data-filter-text");if(i||(i=document.createElement("button"),e.appendChild(i)),i.setAttribute("type","button"),i.classList.add("filter"),i.setAttribute("data-name",r),i.innerHTML=o.replace("$value",t.value),(!t.value||l)&&i.remove(),t.parentNode.closest("[data-filter-text]")){let p=t.parentNode.closest("[data-filter-text]"),f=!0;if(r="",p.querySelectorAll("input").forEach((a,n)=>{let s=a.getAttribute("name");if(r+=`${n!=0?",":""}${s}`,e.querySelector(`[data-name="${s}"]`)&&e.querySelector(`[data-name="${s}"]`).remove(),a.value){let c=document.createElement("button");c.setAttribute("type","button"),c.classList.add("filter"),c.setAttribute("data-name",s),c.innerHTML=o.replace("$value",a.value),e.appendChild(c)}else f=!1}),e.querySelector(`[data-name="${r}"]`)&&e.querySelector(`[data-name="${r}"]`).remove(),f){let a=p.getAttribute("data-filter-text");p.querySelectorAll("input").forEach((s,c)=>{let b=s.getAttribute("name");e.querySelector(`[data-name="${b}"]`)&&e.querySelector(`[data-name="${b}"]`).remove(),a=a.replace(`$${c+1}`,s.value)});let n=document.createElement("button");n.setAttribute("type","button"),n.classList.add("filter"),n.setAttribute("data-name",r),n.innerHTML=a,e.appendChild(n)}}}Array.from(d.querySelectorAll('input[type="checkbox"]:checked')).forEach((e,t)=>{u(m,e)}),Array.from(d.querySelectorAll("input[data-filter-text]")).forEach((e,t)=>{e.addEventListener("change",function(l){u(m,e),l.stopPropagation()})}),d.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]");u(m,t)}}),m.addEventListener("click",function(e){if(e&&e.target instanceof HTMLElement&&e.target.closest(".filter")){let r=e.target.closest(".filter"),i=r.getAttribute("data-name").split(",");for(var t=0;t<i.length;t++){let o=i[t],p=`[name="${o}"]`;o.match(/\[(.*)\]/)&&(o.replace(/\[(.*)\]/,"[]"),p=`[value="${o.replace(/.*\[(.*)\]/,"$1")}"]`);let f=d.querySelectorAll(p);for(var l=0;l<f.length;l++){let a=f[l];if(a.getAttribute("type")!="radio"&&a.getAttribute("type")!="checkbox")a.value="";else{a.checked=!1;var e=new Event("force");d.hasAttribute("data-nosubmit")||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",u=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 v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"Card"});class h extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.querySelector('[class*="fa-"]')&&this.classList.add("card--has-icon");let e=this.classList.toString();const a=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"):`${a}/css/core.min.css`,t=document.createElement("template");t.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"collapsible side menu"});class s extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const e=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"):`${e}/css/core.min.css`,n=document.createElement("template");n.innerHTML=`
|
|
5
5
|
<style class="styles">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/function h(c,o){const r=o.querySelector(".files"),l=o.querySelector(".drop-area"),t=c.querySelector("input"),u=c.hasAttribute("data-maxsize")?c.getAttribute("data-maxsize"):0,a=t.cloneNode();l.append(a),o.addEventListener("click",e=>{e&&e.target instanceof HTMLElement&&e.target.closest(".btn-primary")&&(e.target.closest(".btn-primary"),(t.hasAttribute("multiple")?a:t).click())}),o.addEventListener("click",e=>{if(e&&e.target instanceof HTMLElement&&e.target.closest(".files button")){const i=new DataTransfer,{files:d}=t,p=e.target.closest(".files button");for(let n=0;n<d.length;n++){const s=d[n];s.name!=p.getAttribute("data-file")&&i.items.add(s)}t.files=i.files;const m=new Event("change");t.dispatchEvent(m)}}),a.addEventListener("change",e=>{if(t.hasAttribute("multiple")){const d=[...t.files,...a.files];let p=[];const m=new DataTransfer;for(let n=0;n<d.length;n++){const s=d[n],f=s.size/1e3;!p.includes(s.name)&&(u==0||f<u)&&m.items.add(s),p.push(s.name)}t.files=m.files}else t.files=a.files;const i=new Event("change");t.dispatchEvent(i)}),a.addEventListener("dragenter",e=>{a.classList.add("focus")}),a.addEventListener("dragleave",e=>{a.classList.remove("focus")}),a.addEventListener("drop",e=>{a.classList.remove("focus")}),t.addEventListener("change",e=>{r.innerHTML="";for(const i of t.files)r.innerHTML+=`<span class="file">${i.name} <button data-file="${i.name}">Remove</button></span>`})}window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"fileupload"});class b extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const o=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"):`${o}/css/core.min.css`,l=document.createElement("template");l.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
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 v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
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 v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"nav"});class p extends HTMLElement{constructor(){super();const c=this.attachShadow({mode:"open"}),n=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"):`${n}/css/core.min.css`,i=document.createElement("template");i.innerHTML=`
|
|
5
5
|
<style class="styles">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
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(),a(i))},!1),i.hasAttribute("data-timeout")){let t=i.getAttribute("data-timeout");var n=new c(function(){a(i)},t);i.addEventListener("mouseenter",o=>{n.pause()}),i.addEventListener("mouseleave",o=>{n.resume()})}}function c(i,n){var t,o,e=n;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 a=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 n=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"):`${n}/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 v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
4
|
*/class v extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const i=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"):`${i}/css/core.min.css`,e=document.createElement("template");e.innerHTML=`
|
|
5
5
|
<style>
|
|
@@ -44,7 +44,7 @@ class iamSearch extends HTMLElement {
|
|
|
44
44
|
let searched = [];
|
|
45
45
|
// Clone original input field, re-name and use for display purposes
|
|
46
46
|
const displayInputField = inputField.cloneNode();
|
|
47
|
-
|
|
47
|
+
displayInputField.setAttribute('name', `${inputField.getAttribute('name')}Alt`);
|
|
48
48
|
inputField.removeAttribute('data-change-events');
|
|
49
49
|
displayInputField.removeAttribute('id');
|
|
50
50
|
inputField.after(displayInputField);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
|
-
*/import $ from"js-cookie";const C=t=>t.replace(/ /g,"_"),R=function(t){return t=t.toLowerCase(),t=C(t),t=t.replace(/\W/g,""),t},
|
|
4
|
+
*/import $ from"js-cookie";const C=t=>t.replace(/ /g,"_"),R=function(t){return t=t.toLowerCase(),t=C(t),t=t.replace(/\W/g,""),t},m=(t,l,n)=>l.split(/[\.\[\]\'\"]/).filter(o=>o).reduce((o,c)=>o?o[c]:n,t),g=t=>Array.isArray(t)||t!==null&&["function","object"].includes(typeof t);var S=function(t,l,n,o){function c(r){return r instanceof n?r:new n(function(s){s(r)})}return new(n||(n=Promise))(function(r,s){function u(a){try{d(o.next(a))}catch(i){s(i)}}function e(a){try{d(o.throw(a))}catch(i){s(i)}}function d(a){a.done?r(a.value):c(a.value).then(u,e)}d((o=o.apply(t,l||[])).next())})};window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"customElementRegistered",element:"Search"});class j extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const l=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",n=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${l}/css/core.min.css`,o=document.createElement("template");o.innerHTML=`
|
|
5
5
|
<style>
|
|
6
|
-
@import "${
|
|
6
|
+
@import "${n}";
|
|
7
7
|
|
|
8
8
|
</style>
|
|
9
9
|
<link rel="stylesheet" href="https://kit.fontawesome.com/26fdbf0179.css" crossorigin="anonymous" />
|
|
10
10
|
<slot></slot>
|
|
11
|
-
`,this.shadowRoot.appendChild(o.content.cloneNode(!0))}connectedCallback(){return S(this,void 0,void 0,function*(){const l=this,
|
|
12
|
-
`,", ");s.querySelector(`option[data-value="${f}"]`)||(y+=`<option value="${w}" data-value='${f}'></option>`)});else if(typeof p=="object")for(const[
|
|
13
|
-
`,", ");s.querySelector(`option[data-value="${A}"]`)||(y+=`<option value="${
|
|
11
|
+
`,this.shadowRoot.appendChild(o.content.cloneNode(!0))}connectedCallback(){return S(this,void 0,void 0,function*(){const l=this,n=this.querySelector("input"),o=this.hasAttribute("data-value-schema")?this.getAttribute("data-value-schema"):"value",c=this.hasAttribute("data-display-schema")?this.getAttribute("data-display-schema"):"label",r=this.hasAttribute("data-schema")?this.getAttribute("data-schema"):"";let s=this.querySelector("datalist"),u=[];const e=n.cloneNode();if(e.setAttribute("name",`${n.getAttribute("name")}Alt`),n.removeAttribute("data-change-events"),e.removeAttribute("id"),n.after(e),n.setAttribute("type","hidden"),!s){s=document.createElement("datalist");let a=R("list");s.setAttribute("id",a),l.appendChild(s),e.setAttribute("list",a)}e.addEventListener("change",a=>{let i=s.querySelector(`option[value="${e.value}"]`);i&&(n.value=i.getAttribute("data-value"))}),l.hasAttribute("data-url")&&(e.addEventListener("keyup",a=>{e.value.length==3&&!u.includes(e.value)&&(d(e.value),u.push(e.value))}),e.addEventListener("change",a=>{e.value.length>=3&&!u.includes(e.value.substring(0,3))&&(d(e.value.substring(0,3)),u.push(e.value.substring(0,3)))}));const d=a=>S(this,void 0,void 0,function*(){let i=l.getAttribute("data-url");i+=`${encodeURI(a)}`,window.controller||(window.controller=[]),window.controller[i]&&window.controller[i].abort(),window.controller[i]=new AbortController;const{signal:E}=controller[i];try{yield fetch(i,{signal:E,method:"get",credentials:"same-origin",headers:new Headers({"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest","X-XSRF-TOKEN":$.get("XSRF-TOKEN")})}).then(h=>h.json()).then(h=>{let y="",p=m(h,r,"");if(g(p)&&typeof p.forEach=="function")p.forEach((v,b)=>{let f=m(v,o,""),w=m(v,c,"").replace(`
|
|
12
|
+
`,", ");s.querySelector(`option[data-value="${f}"]`)||(y+=`<option value="${w}" data-value='${f}'></option>`)});else if(typeof p=="object")for(const[v,b]of Object.entries(p))g(b)&&typeof b.forEach=="function"&&b.forEach((f,w)=>{let A=m(f,o,""),L=m(f,c,"").replace(`
|
|
13
|
+
`,", ");s.querySelector(`option[data-value="${A}"]`)||(y+=`<option value="${v}: ${L}" data-value='${A}'></option>`)});return s.innerHTML+=y,h})}catch(h){console.log(h)}});l.hasAttribute("data-prevent-submit")&&l.closest("form").addEventListener("submit",i=>{i.preventDefault()})})}}export{j as default};
|
|
14
14
|
//# sourceMappingURL=search.component.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.component.min.js","sources":["../../modules/helpers.js","search.component.js"],"sourcesContent":["// @ts-nocheck\n/**\n * Global helper functions to help maintain and enhance framework elements.\n * @module Helpers\n */\n/**\n * Add global classes used by the CSS and later JavaScript.\n * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.\n */\nexport const addBodyClasses = (body) => {\n body.classList.add(\"js-enabled\");\n if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {\n body.classList.add(\"ie\");\n }\n return null;\n};\n/**\n * Add global events.\n * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.\n */\nexport const addGlobalEvents = (body) => {\n const checkElements = function (hash) {\n const label = document.querySelector(`label[for=\"${hash.replace('#', '')}\"]`);\n const summary = document.querySelector(hash + ' summary');\n const dialog = document.querySelector(`dialog${hash}`);\n if (label instanceof HTMLElement)\n label.click();\n else if (summary instanceof HTMLElement)\n summary.click();\n else if (dialog instanceof HTMLElement)\n dialog.showModal();\n };\n if (location.hash)\n checkElements(location.hash);\n window.addEventListener('hashchange', function () { checkElements(location.hash); }, false);\n addEventListener(\"popstate\", (event) => {\n if (event && event.state && event.state.type && event.state.type == \"pagination\") {\n let form = document.querySelector(`#${event.state.form}`);\n let pageInput = document.querySelector(`#${event.state.form} [data-pagination]`);\n if (pageInput)\n pageInput.value = event.state.page;\n else\n form.innerHTML += `<input name=\"page\" type=\"hidden\" data-pagination=\"true\" value=\"${event.state.page}\" />`;\n form.dispatchEvent(new Event(\"submit\"));\n }\n });\n document.addEventListener(\"submit\", (event) => {\n if (event && event.target instanceof HTMLElement && event.target.matches('form')) {\n let form = event.target;\n if (form.querySelector(':invalid')) {\n form.classList.add('was-validated');\n event.preventDefault();\n }\n }\n });\n return null;\n};\nexport const isNumeric = function (str) {\n if (typeof str != \"string\")\n return false; // we only process strings! \n return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...\n !isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail\n};\nexport const zeroPad = (num, places) => String(num).padStart(places, '0');\nexport const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);\nexport const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ');\nexport const unsnake = (str) => str.replace(/_/g, ' ');\nexport const snake = (str) => str.replace(/ /g, '_');\nexport const safeID = function (str) {\n str = str.toLowerCase();\n str = snake(str);\n str = str.replace(/\\W/g, '');\n return str;\n};\n// Used to get values from nested json objects\nexport const resolvePath = (object, path, defaultValue) => path.split(/[\\.\\[\\]\\'\\\"]/).filter(p => p).reduce((o, p) => o ? o[p] : defaultValue, object);\nexport const isTraversable = o => Array.isArray(o) || o !== null && ['function', 'object'].includes(typeof o);\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n// @ts-nocheck\nimport Cookies from 'js-cookie';\nimport { safeID, resolvePath, isTraversable } from '../../modules/helpers.js';\n// Data layer Web component created\nwindow.dataLayer = window.dataLayer || [];\nwindow.dataLayer.push({\n \"event\": \"customElementRegistered\",\n \"element\": \"Search\"\n});\nclass iamSearch extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';\n const coreCSS = document.body.hasAttribute('data-core-css') ? document.body.getAttribute('data-core-css') : `${assetLocation}/css/core.min.css`;\n const template = document.createElement('template');\n template.innerHTML = `\n <style>\n @import \"${coreCSS}\";\n \n </style>\n <link rel=\"stylesheet\" href=\"https://kit.fontawesome.com/26fdbf0179.css\" crossorigin=\"anonymous\" />\n <slot></slot>\n `;\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n }\n connectedCallback() {\n return __awaiter(this, void 0, void 0, function* () {\n const searchWrapper = this;\n const inputField = this.querySelector('input');\n const valueSchema = this.hasAttribute('data-value-schema') ? this.getAttribute('data-value-schema') : 'value';\n const displaySchema = this.hasAttribute('data-display-schema') ? this.getAttribute('data-display-schema') : 'label';\n const loopSchema = this.hasAttribute('data-schema') ? this.getAttribute('data-schema') : '';\n let datalist = this.querySelector('datalist');\n let searched = [];\n // Clone original input field, re-name and use for display purposes\n const displayInputField = inputField.cloneNode();\n inputField.setAttribute('name', `${inputField.getAttribute}-alt`);\n inputField.removeAttribute('data-change-events');\n displayInputField.removeAttribute('id');\n inputField.after(displayInputField);\n // Hide original input field\n inputField.setAttribute('type', 'hidden');\n // if data list does not exist then create one and append\n if (!datalist) {\n datalist = document.createElement(\"datalist\");\n let listID = safeID('list');\n datalist.setAttribute('id', listID);\n searchWrapper.appendChild(datalist);\n displayInputField.setAttribute('list', listID);\n }\n // on change update oringinal field with the actual value and use displayed input for the nice display text\n displayInputField.addEventListener('change', (event) => {\n let match = datalist.querySelector(`option[value=\"${displayInputField.value}\"]`);\n if (match) {\n inputField.value = match.getAttribute('data-value');\n }\n });\n // Search the endpoint when 3 characters has been added\n if (searchWrapper.hasAttribute('data-url')) {\n displayInputField.addEventListener('keyup', (event) => {\n if (displayInputField.value.length == 3 && !searched.includes(displayInputField.value)) {\n search(displayInputField.value);\n searched.push(displayInputField.value);\n }\n });\n displayInputField.addEventListener('change', (event) => {\n if (displayInputField.value.length >= 3 && !searched.includes(displayInputField.value.substring(0, 3))) {\n search(displayInputField.value.substring(0, 3));\n searched.push(displayInputField.value.substring(0, 3));\n }\n });\n }\n const search = (searchterm) => __awaiter(this, void 0, void 0, function* () {\n let ajaxURL = searchWrapper.getAttribute('data-url');\n ajaxURL += `${encodeURI(searchterm)}`;\n // Setup controller vars if not already set\n if (!window.controller)\n window.controller = [];\n // Abort if controller already present for this url\n if (window.controller[ajaxURL])\n window.controller[ajaxURL].abort();\n // Create a new controller so it can be aborted if new fetch made\n window.controller[ajaxURL] = new AbortController();\n const { signal } = controller[ajaxURL];\n try {\n yield fetch(ajaxURL, {\n signal: signal,\n method: 'get',\n credentials: 'same-origin',\n headers: new Headers({\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'X-Requested-With': 'XMLHttpRequest',\n 'X-XSRF-TOKEN': Cookies.get('XSRF-TOKEN')\n })\n })\n .then((response) => response.json()).then((response) => {\n // populate datalist\n let listString = '';\n let loopValues = resolvePath(response, loopSchema, '');\n if (isTraversable(loopValues) && typeof loopValues.forEach == 'function') {\n loopValues.forEach((item, index) => {\n let actualValue = resolvePath(item, valueSchema, '');\n let displayValue = resolvePath(item, displaySchema, '').replace('\\n', ', ');\n if (!datalist.querySelector(`option[data-value=\"${actualValue}\"]`))\n listString += `<option value=\"${displayValue}\" data-value='${actualValue}'></option>`;\n });\n }\n else if (typeof loopValues == 'object') {\n for (const [key, value] of Object.entries(loopValues)) {\n if (isTraversable(value) && typeof value.forEach == 'function') {\n value.forEach((item, index) => {\n let actualValue = resolvePath(item, valueSchema, '');\n let displayValue = resolvePath(item, displaySchema, '').replace('\\n', ', ');\n if (!datalist.querySelector(`option[data-value=\"${actualValue}\"]`))\n listString += `<option value=\"${key}: ${displayValue}\" data-value='${actualValue}'></option>`;\n });\n }\n }\n }\n datalist.innerHTML += listString;\n return response;\n });\n }\n catch (error) {\n console.log(error);\n }\n });\n if (searchWrapper.hasAttribute('data-prevent-submit')) {\n const form = searchWrapper.closest('form');\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n });\n }\n });\n }\n}\nexport default iamSearch;\n"],"names":["snake","str","safeID","resolvePath","object","path","defaultValue","p","isTraversable","o","__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","reject","fulfilled","step","e","rejected","result","iamSearch","assetLocation","coreCSS","template","searchWrapper","inputField","valueSchema","displaySchema","loopSchema","datalist","searched","displayInputField","listID","event","match","search","searchterm","ajaxURL","signal","Cookies","response","listString","loopValues","item","index","actualValue","displayValue","key","error"],"mappings":";;;6BAmEO,MAAMA,EAASC,GAAQA,EAAI,QAAQ,KAAM,GAAG,EACtCC,EAAS,SAAUD,EAAK,CACjC,OAAAA,EAAMA,EAAI,cACVA,EAAMD,EAAMC,CAAG,EACfA,EAAMA,EAAI,QAAQ,MAAO,EAAE,EACpBA,CACX,EAEaE,EAAc,CAACC,EAAQC,EAAMC,IAAiBD,EAA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c,kBAAkBK,kBAA6BD,eACjG,CAA6B,UAEI,OAAOH,GAAc,SAC1B,SAAW,CAACK,EAAKnC,CAAK,IAAK,OAAO,QAAQ8B,CAAU,EAC5CtC,EAAcQ,CAAK,GAAK,OAAOA,EAAM,SAAW,YAChDA,EAAM,QAAQ,CAAC+B,EAAMC,IAAU,CAC3B,IAAIC,EAAc9C,EAAY4C,EAAMjB,EAAa,EAAE,EAC/CoB,EAAe/C,EAAY4C,EAAMhB,EAAe,EAAE,EAAE,QAAQ;AAAA,EAAM,IAAI,EACrEE,EAAS,cAAc,sBAAsBgB,KAAe,IAC7DJ,GAAc,kBAAkBM,MAAQD,kBAA6BD,eACjH,CAAqC,EAIb,OAAAhB,EAAS,WAAaY,EACfD,CAC/B,CAAqB,CACJ,OACMQ,EAAP,CACI,QAAQ,IAAIA,CAAK,CACpB,CACjB,CAAa,EACGxB,EAAc,aAAa,qBAAqB,GACnCA,EAAc,QAAQ,MAAM,EACpC,iBAAiB,SAAWP,GAAM,CACnCA,EAAE,eAAc,CACpC,CAAiB,CAEjB,CAAS,CACJ,CACL"}
|
|
1
|
+
{"version":3,"file":"search.component.min.js","sources":["../../modules/helpers.js","search.component.js"],"sourcesContent":["// @ts-nocheck\n/**\n * Global helper functions to help maintain and enhance framework elements.\n * @module Helpers\n */\n/**\n * Add global classes used by the CSS and later JavaScript.\n * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.\n */\nexport const addBodyClasses = (body) => {\n body.classList.add(\"js-enabled\");\n if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {\n body.classList.add(\"ie\");\n }\n return null;\n};\n/**\n * Add global events.\n * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.\n */\nexport const addGlobalEvents = (body) => {\n const checkElements = function (hash) {\n const label = document.querySelector(`label[for=\"${hash.replace('#', '')}\"]`);\n const summary = document.querySelector(hash + ' summary');\n const dialog = document.querySelector(`dialog${hash}`);\n if (label instanceof HTMLElement)\n label.click();\n else if (summary instanceof HTMLElement)\n summary.click();\n else if (dialog instanceof HTMLElement)\n dialog.showModal();\n };\n if (location.hash)\n checkElements(location.hash);\n window.addEventListener('hashchange', function () { checkElements(location.hash); }, false);\n addEventListener(\"popstate\", (event) => {\n if (event && event.state && event.state.type && event.state.type == \"pagination\") {\n let form = document.querySelector(`#${event.state.form}`);\n let pageInput = document.querySelector(`#${event.state.form} [data-pagination]`);\n if (pageInput)\n pageInput.value = event.state.page;\n else\n form.innerHTML += `<input name=\"page\" type=\"hidden\" data-pagination=\"true\" value=\"${event.state.page}\" />`;\n form.dispatchEvent(new Event(\"submit\"));\n }\n });\n document.addEventListener(\"submit\", (event) => {\n if (event && event.target instanceof HTMLElement && event.target.matches('form')) {\n let form = event.target;\n if (form.querySelector(':invalid')) {\n form.classList.add('was-validated');\n event.preventDefault();\n }\n }\n });\n return null;\n};\nexport const isNumeric = function (str) {\n if (typeof str != \"string\")\n return false; // we only process strings! \n return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...\n !isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail\n};\nexport const zeroPad = (num, places) => String(num).padStart(places, '0');\nexport const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);\nexport const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ');\nexport const unsnake = (str) => str.replace(/_/g, ' ');\nexport const snake = (str) => str.replace(/ /g, '_');\nexport const safeID = function (str) {\n str = str.toLowerCase();\n str = snake(str);\n str = str.replace(/\\W/g, '');\n return str;\n};\n// Used to get values from nested json objects\nexport const resolvePath = (object, path, defaultValue) => path.split(/[\\.\\[\\]\\'\\\"]/).filter(p => p).reduce((o, p) => o ? o[p] : defaultValue, object);\nexport const isTraversable = o => Array.isArray(o) || o !== null && ['function', 'object'].includes(typeof o);\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n// @ts-nocheck\nimport Cookies from 'js-cookie';\nimport { safeID, resolvePath, isTraversable } from '../../modules/helpers.js';\n// Data layer Web component created\nwindow.dataLayer = window.dataLayer || [];\nwindow.dataLayer.push({\n \"event\": \"customElementRegistered\",\n \"element\": \"Search\"\n});\nclass iamSearch extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';\n const coreCSS = document.body.hasAttribute('data-core-css') ? document.body.getAttribute('data-core-css') : `${assetLocation}/css/core.min.css`;\n const template = document.createElement('template');\n template.innerHTML = `\n <style>\n @import \"${coreCSS}\";\n \n </style>\n <link rel=\"stylesheet\" href=\"https://kit.fontawesome.com/26fdbf0179.css\" crossorigin=\"anonymous\" />\n <slot></slot>\n `;\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n }\n connectedCallback() {\n return __awaiter(this, void 0, void 0, function* () {\n const searchWrapper = this;\n const inputField = this.querySelector('input');\n const valueSchema = this.hasAttribute('data-value-schema') ? this.getAttribute('data-value-schema') : 'value';\n const displaySchema = this.hasAttribute('data-display-schema') ? this.getAttribute('data-display-schema') : 'label';\n const loopSchema = this.hasAttribute('data-schema') ? this.getAttribute('data-schema') : '';\n let datalist = this.querySelector('datalist');\n let searched = [];\n // Clone original input field, re-name and use for display purposes\n const displayInputField = inputField.cloneNode();\n displayInputField.setAttribute('name', `${inputField.getAttribute('name')}Alt`);\n inputField.removeAttribute('data-change-events');\n displayInputField.removeAttribute('id');\n inputField.after(displayInputField);\n // Hide original input field\n inputField.setAttribute('type', 'hidden');\n // if data list does not exist then create one and append\n if (!datalist) {\n datalist = document.createElement(\"datalist\");\n let listID = safeID('list');\n datalist.setAttribute('id', listID);\n searchWrapper.appendChild(datalist);\n displayInputField.setAttribute('list', listID);\n }\n // on change update oringinal field with the actual value and use displayed input for the nice display text\n displayInputField.addEventListener('change', (event) => {\n let match = datalist.querySelector(`option[value=\"${displayInputField.value}\"]`);\n if (match) {\n inputField.value = match.getAttribute('data-value');\n }\n });\n // Search the endpoint when 3 characters has been added\n if (searchWrapper.hasAttribute('data-url')) {\n displayInputField.addEventListener('keyup', (event) => {\n if (displayInputField.value.length == 3 && !searched.includes(displayInputField.value)) {\n search(displayInputField.value);\n searched.push(displayInputField.value);\n }\n });\n displayInputField.addEventListener('change', (event) => {\n if (displayInputField.value.length >= 3 && !searched.includes(displayInputField.value.substring(0, 3))) {\n search(displayInputField.value.substring(0, 3));\n searched.push(displayInputField.value.substring(0, 3));\n }\n });\n }\n const search = (searchterm) => __awaiter(this, void 0, void 0, function* () {\n let ajaxURL = searchWrapper.getAttribute('data-url');\n ajaxURL += `${encodeURI(searchterm)}`;\n // Setup controller vars if not already set\n if (!window.controller)\n window.controller = [];\n // Abort if controller already present for this url\n if (window.controller[ajaxURL])\n window.controller[ajaxURL].abort();\n // Create a new controller so it can be aborted if new fetch made\n window.controller[ajaxURL] = new AbortController();\n const { signal } = controller[ajaxURL];\n try {\n yield fetch(ajaxURL, {\n signal: signal,\n method: 'get',\n credentials: 'same-origin',\n headers: new Headers({\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'X-Requested-With': 'XMLHttpRequest',\n 'X-XSRF-TOKEN': Cookies.get('XSRF-TOKEN')\n })\n })\n .then((response) => response.json()).then((response) => {\n // populate datalist\n let listString = '';\n let loopValues = resolvePath(response, loopSchema, '');\n if (isTraversable(loopValues) && typeof loopValues.forEach == 'function') {\n loopValues.forEach((item, index) => {\n let actualValue = resolvePath(item, valueSchema, '');\n let displayValue = resolvePath(item, displaySchema, '').replace('\\n', ', ');\n if (!datalist.querySelector(`option[data-value=\"${actualValue}\"]`))\n listString += `<option value=\"${displayValue}\" data-value='${actualValue}'></option>`;\n });\n }\n else if (typeof loopValues == 'object') {\n for (const [key, value] of Object.entries(loopValues)) {\n if (isTraversable(value) && typeof value.forEach == 'function') {\n value.forEach((item, index) => {\n let actualValue = resolvePath(item, valueSchema, '');\n let displayValue = resolvePath(item, displaySchema, '').replace('\\n', ', ');\n if (!datalist.querySelector(`option[data-value=\"${actualValue}\"]`))\n listString += `<option value=\"${key}: ${displayValue}\" data-value='${actualValue}'></option>`;\n });\n }\n }\n }\n datalist.innerHTML += listString;\n return response;\n });\n }\n catch (error) {\n console.log(error);\n }\n });\n if (searchWrapper.hasAttribute('data-prevent-submit')) {\n const form = searchWrapper.closest('form');\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n });\n }\n });\n }\n}\nexport default iamSearch;\n"],"names":["snake","str","safeID","resolvePath","object","path","defaultValue","p","isTraversable","o","__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","reject","fulfilled","step","e","rejected","result","iamSearch","assetLocation","coreCSS","template","searchWrapper","inputField","valueSchema","displaySchema","loopSchema","datalist","searched","displayInputField","listID","event","match","search","searchterm","ajaxURL","signal","Cookies","response","listString","loopValues","item","index","actualValue","displayValue","key","error"],"mappings":";;;6BAmEO,MAAMA,EAASC,GAAQA,EAAI,QAAQ,KAAM,GAAG,EACtCC,EAAS,SAAUD,EAAK,CACjC,OAAAA,EAAMA,EAAI,cACVA,EAAMD,EAAMC,CAAG,EACfA,EAAMA,EAAI,QAAQ,MAAO,EAAE,EACpBA,CACX,EAEaE,EAAc,CAACC,EAAQC,EAAMC,IAAiBD,EAAK,MAAM,cAAc,EAAE,OAAOE,GAAKA,CAAC,EAAE,OAAO,CAAC,EAAGA,IAAM,EAAI,EAAEA,CAAC,EAAID,EAAcF,CAAM,EACxII,EAAgBC,GAAK,MAAM,QAAQA,CAAC,GAAKA,IAAM,MAAQ,CAAC,WAAY,QAAQ,E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AAQ,CAAC+B,EAAMC,IAAU,CAC3B,IAAIC,EAAc9C,EAAY4C,EAAMjB,EAAa,EAAE,EAC/CoB,EAAe/C,EAAY4C,EAAMhB,EAAe,EAAE,EAAE,QAAQ;AAAA,EAAM,IAAI,EACrEE,EAAS,cAAc,sBAAsBgB,KAAe,IAC7DJ,GAAc,kBAAkBM,MAAQD,kBAA6BD,eACjH,CAAqC,EAIb,OAAAhB,EAAS,WAAaY,EACfD,CAC/B,CAAqB,CACJ,OACMQ,EAAP,CACI,QAAQ,IAAIA,CAAK,CACpB,CACjB,CAAa,EACGxB,EAAc,aAAa,qBAAqB,GACnCA,EAAc,QAAQ,MAAM,EACpC,iBAAiB,SAAWP,GAAM,CACnCA,EAAE,eAAc,CACpC,CAAiB,CAEjB,CAAS,CACJ,CACL"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iamKey v5.1.0-
|
|
2
|
+
* iamKey v5.1.0-beta6
|
|
3
3
|
* Copyright 2022-2023 iamproperty
|
|
4
|
-
*/const B=function(a){return typeof a!="string"?!1:!isNaN(a)&&!isNaN(parseFloat(a))},Q=(a,e)=>String(a).padStart(e,"0"),X=a=>a.charAt(0).toUpperCase()+a.slice(1),k=(a,e,o)=>e.split(/[\.\[\]\'\"]/).filter(i=>i).reduce((i,b)=>i?i[b]:o,a);var Y=function(a,e,o,i){function b(d){return d instanceof o?d:new o(function(r){r(d)})}return new(o||(o=Promise))(function(d,r){function n(c){try{t(i.next(c))}catch(h){r(h)}}function l(c){try{t(i.throw(c))}catch(h){r(h)}}function t(c){c.done?d(c.value):b(c.value).then(n,l)}t((i=i.apply(a,e||[])).next())})};const R=a=>{const e=Array.from(a.querySelectorAll("thead th"));Array.from(a.querySelectorAll("tbody tr")).forEach((i,b)=>{const d=Array.from(i.querySelectorAll("th, td")),r=["0","low","medium","high","unknown","n/a","pending","verified","due","overdue","incomplete","complete","completed","approval required","upcoming","requires approval","to do","on track","not started","warning","error"];d.forEach((n,l)=>{const t=e[l];if(typeof t<"u"){let c=document.createElement("div");c.innerHTML=t.innerHTML;let h=c.textContent||c.innerText||"";n.setAttribute("data-label",h),t.hasAttribute("data-td-class")&&n.setAttribute("class",t.getAttribute("data-td-class")),t.hasAttribute("data-format")&&(n.setAttribute("data-format",t.getAttribute("data-format")),n.innerHTML=M(t.getAttribute("data-format"),n.textContent.trim())),r.includes(n.textContent.trim().toLowerCase())&&n.setAttribute("data-content",n.textContent.trim().toLowerCase())}})})},J=a=>{let e=0;return Array.from(a.querySelectorAll("tbody tr")).forEach((o,i)=>{let b=window.getComputedStyle(document.querySelector("html")),d=o.querySelector(":scope > *:last-child > *:first-child");if(d){d.classList.add("text-nowrap");let r=d.offsetWidth/parseFloat(b.fontSize);r+=1.7,e=e>r?e:r}}),e},G=(a,e)=>{if(e.classList.contains(".table--fullwidth")&&!e.hasAttribute("data-expandable")||a.querySelectorAll("thead tr th").length<4&&!e.hasAttribute("data-expandable"))return!1;Array.from(a.querySelectorAll("thead tr")).forEach((o,i)=>{o.insertAdjacentHTML("afterbegin",'<th class="th--fixed expand-button-heading"></th>')}),Array.from(a.querySelectorAll("tbody tr")).forEach((o,i)=>{const b=o.getAttribute("data-view")==="full"?"aria-expanded":"";o.insertAdjacentHTML("afterbegin",`<td class="td--fixed td--expand"><button class="btn btn-compact btn-secondary" data-expand-button ${b}>Expand</button></td>`)})},K=a=>{a.addEventListener("click",e=>{if(e&&e.target instanceof HTMLElement&&e.target.closest("[data-expand-button]")){let o=e.target.closest("[data-expand-button]"),i=o.closest("tr");o.toggleAttribute("aria-expanded"),i.getAttribute("data-view")=="full"?i.setAttribute("data-view","default"):i.setAttribute("data-view","full"),o.blur()}})},N=(a,e)=>{let o=e.querySelector("[data-search]");if(!o)return!1;const i=o.getAttribute("id"),b=o.getAttribute("data-search").split(",");let d=o.parentNode,r={};b.forEach((n,l)=>{Array.from(a.querySelectorAll('td[data-label="'+n.trim()+'"]')).forEach((t,c)=>{t.querySelector(".td__content")?r[t.querySelector(".td__content").textContent]=t.querySelector(".td__content").textContent:r[t.textContent]=t.textContent})}),o.setAttribute("list",`${i}_list`),o.setAttribute("autocomplete","off"),d.querySelector("datalist")||(d.innerHTML+=`<datalist id="${i}_list"></datalist>`),d.querySelector("datalist").innerHTML=`${Object.keys(r).map(n=>`<option value="${n}"></option>`).join("")}`},V=(a,e,o,i,b)=>{var d;let r=function(t,c=!1){if(e.classList.contains("processing"))return!1;if(t.type=="submit"&&(e.classList.add("processing"),Array.from(e.querySelectorAll("[data-duplicate]")).forEach((h,u)=>{const m=h.getAttribute("data-duplicate"),s=document.getElementById(m),g=document.querySelector(`[for="${m}"] iam-card`);if(s.checked!=h.checked)if(g){let x=new Event("click");g.dispatchEvent(x)}else s.checked=h.checked}),e.classList.remove("processing")),e.hasAttribute("data-ajax")){if(!c){let h=e.querySelector("[data-pagination]");h.value=1,i.setAttribute("data-page",1)}z(a,e,o,i)}else e.hasAttribute("data-submit")?e.submit():(C(a,e,i),_(a,e));if(e.hasAttribute("data-ajax-post")){let h=new FormData(e),u=new URLSearchParams(h).toString();const m=new XMLHttpRequest;m.open("GET",`${window.location.href}?ajax=true&${u}`),m.send()}};e.addEventListener("keyup",t=>{clearTimeout(d),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&(d=setTimeout(function(){r(t)},500))}),e.addEventListener("change",t=>{clearTimeout(d),t&&t.target instanceof HTMLElement&&t.target.closest("[data-sort]")&&(e.hasAttribute("data-submit")||O(a,e,b),r(t)),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&r(t),t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter][data-no-ajax]")?(C(a,e,i),_(a,e)):(t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&t.target.closest("form .dialog__wrapper > dialog")||t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&!t.target.closest("form dialog"))&&r(t),t&&t.target instanceof HTMLElement&&t.target.closest("[data-show]")&&r(t),t&&t.target instanceof HTMLElement&&t.target.closest("[data-mimic]")&&r(t)}),e.addEventListener("click",t=>{if(clearTimeout(d),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.classList.add("processing"),Array.from(e.querySelectorAll(".applied-filters")).forEach((h,u)=>{h.innerHTML=""});let c=e.elements;for(let h=0;h<c.length;h++)switch(c[h].type.toLowerCase()?c[h].type.toLowerCase():"text"){case"text":case"password":case"textarea":c[h].value="";break;case"radio":case"checkbox":if(c[h].checked){let m=c[h],s=m.getAttribute("id"),g=document.querySelector(`[for="${s}"`);if(g.querySelector("iam-card")){let x=g.querySelector("iam-card"),S=new Event("click");x.dispatchEvent(S)}m.checked=!1}break;case"select-one":case"select-multi":c[h].selectedIndex=-1;break}e.classList.remove("processing"),e.hasAttribute("data-submit")||O(a,e,b),r(t)}}),e.addEventListener("submit",t=>{clearTimeout(d),e.hasAttribute("data-submit")||t.preventDefault(),r(t)}),e.addEventListener("force",t=>{r(t)}),e.addEventListener("paginate",t=>{r(t,!0)});let n=[],l=[];Array.from(e.querySelectorAll("[data-mimic]")).forEach((t,c)=>{let h=t.getAttribute("data-mimic");Array.from(document.querySelectorAll(`[name="${h}"]`)).forEach((u,m)=>{let s=u.closest("form");n.includes(s)||n.push(s),l.includes(h)||l.push(h)})}),n.forEach((t,c)=>{const h=function(){let u=[],m=new FormData(t);for(const[s,g]of m)document.querySelector(`[data-mimic="${s}"]`)&&!u.includes(s)?(u.push(s),document.querySelector(`[data-mimic="${s}"]`).value=g):document.querySelector(`[data-mimic="${s}"]`)&&(document.querySelector(`[data-mimic="${s}"]`).value+=","+g);for(const s of u){const g=new Event("force");e.dispatchEvent(g)}for(const s of l)if(!m.has(s)&&t.querySelector(`[name="${s}"]`)){document.querySelector(`[data-mimic="${s}"]`).value="";const g=new Event("force");e.dispatchEvent(g)}};t.addEventListener("force",u=>{h()}),t.addEventListener("change",u=>{h()})})},O=(a,e,o)=>{if(e.getAttribute("data-ajax"))return!1;let i=a.querySelector("tbody"),b=e.querySelector("[data-sort]"),d=b.querySelector(`option:nth-child(${b.selectedIndex+1})`),r=d.getAttribute("data-sort"),n=d.getAttribute("data-order"),l=d.getAttribute("data-format");if(!r)return i.innerHTML=o.innerHTML,R(a),!1;let t=[];["asc","desc","descending"].includes(n)||(t=n.split(","));let c=[];Array.from(i.querySelectorAll("tr")).forEach((u,m)=>{let s=u.querySelector('td[data-label="'+r+'"], th[data-label="'+r+'"]').textContent.trim();u.querySelector('[data-label="'+r+'"] .td__content')&&(s=u.querySelector('[data-label="'+r+'"] .td__content').textContent.trim()),t.length&&t.includes(s)&&(s=t.indexOf(s)),B(s)&&(s=Q(s,10)),l&&l=="date"&&(s=new Date(s));const g={index:s,row:u};c.push(g)}),c.sort((u,m)=>u.index>m.index?1:-1),(n=="descending"||n=="desc")&&(c=c.reverse());let h="";c.forEach((u,m)=>{h+=u.row.outerHTML}),i.innerHTML=h},C=(a,e,o)=>{a.classList.remove("table--filtered");let i=P(e),b=[],d=0,r=e.querySelector("[data-pagination]")?parseInt(e.querySelector("[data-pagination]").value):1,n=e.querySelector("[data-show]")?parseInt(e.querySelector("[data-show]").value):15;if(Array.from(a.querySelectorAll("tbody tr")).forEach((t,c)=>{t.classList.remove("filtered"),t.classList.remove("filtered--matched"),t.classList.remove("filtered--show"),t.removeAttribute("data-filtered-by")}),e.querySelector("[data-search]")){let t=e.querySelector("[data-search]");e.querySelector("[data-search]").getAttribute("data-search").split(",").forEach((h,u)=>{b.push({column:`${h.trim()}`,value:`${t.value}`})})}Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,c)=>{t.innerHTML="",t.parentNode.classList.remove("hover")});let l=0;Object.values(i).forEach((t,c)=>{typeof t=="object"&&Object.values(t).length?l+=Object.values(t).length:l++}),l&&Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,c)=>{t.innerHTML+=`(${l})`,t.parentNode.classList.add("hover")}),a.classList.add("table--filtered");for(const[t,c]of Object.entries(i))Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((h,u)=>{let m=!1;c.forEach((s,g)=>{let x=h.querySelector(`[data-label="${t}"]`);if(s&&s=="$today")s=M("date",new Date);else if(s&&s=="$yesterday"){let f=new Date;f.setDate(f.getDate()-1),s=M("date",f)}else if(s&&(s=="$thisWeek"||s=="$lastWeek")){let f=new Date,y=new Date(f.setDate(f.getDate()-(f.getDay()-1))),p=new Date(f.setDate(f.getDate()-f.getDay()+7)),w=new Date(x.textContent.toLowerCase());if(f.setHours(0,0,0,0),y.setHours(0,0,0,0),p.setHours(0,0,0,0),w.setHours(0,0,0,0),s=="$thisWeek")m=w>=y&&w<=p;else{let A=new Date(y.setDate(y.getDate()-7)),L=new Date(p.setDate(p.getDate()-7));A.setHours(0,0,0,0),L.setHours(0,0,0,0),m=w>=A&&w<=L}}else if(s&&s=="$thisMonth"){let f=new Date,y=f.getFullYear(),p=f.getMonth();var S=new Date(y,p,1),q=new Date(y,p+1,0);let w=new Date(x.textContent.toLowerCase());S.setHours(0,0,0,0),q.setHours(0,0,0,0),w.setHours(0,0,0,0),m=w>=S&&w<=q}else if(s&&s=="$lastMonth"){let f=new Date,y=f.getFullYear(),p=f.getMonth();var E=new Date(y,p-1,1),v=new Date(y,p,0);let w=new Date(x.textContent.toLowerCase());E.setHours(0,0,0,0),v.setHours(0,0,0,0),w.setHours(0,0,0,0),m=w>=E&&w<=v}x&&x.textContent.toLowerCase().includes(s.toLowerCase())&&(m=!0)}),m||(h.classList.add("filtered"),h.setAttribute("data-filtered-by",t))});Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((t,c)=>{let h=!(b.length>0&&b[0].value.length>=3);b.forEach((u,m)=>{let s=t.querySelector(`[data-label="${u.column}"]`);s&&u.value.length>=3&&s.textContent.toLowerCase().includes(u.value.toLowerCase())&&(h=!0)}),h||t.classList.add("filtered")}),Array.from(a.querySelectorAll("tbody tr:not(.filtered")).forEach((t,c)=>{d++,t.classList.add("filtered--matched"),Math.ceil(d/n)==parseInt(r)&&t.classList.add("filtered--show")}),o&&(o.setAttribute("data-total",d),o.setAttribute("data-show",n),o.setAttribute("data-page",r))},_=(a,e,o)=>{Array.from(e.querySelectorAll("[data-query]")).forEach((b,d)=>{let r=b.getAttribute("data-query"),n;if(r=="total")o.hasAttribute("data-total")?n=o.getAttribute("data-total"):n=(a.classList.contains("table--filtered"),a.querySelectorAll("tbody tr").length);else if(!r.includes(" == ")&&r.includes(" & ")){let l=r.split(" & "),t="";l.forEach(c=>{t+=`:not([data-filtered-by="${c}"])`}),n=Array.from(a.querySelectorAll(`tbody tr${t}`)).length}else if(!r.includes(" == "))n=Array.from(a.querySelectorAll(`tbody tr:not([data-filtered-by="${r}"])`)).length;else if(r.includes(" && ")){let l=r.split(" && ");n=Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).filter(function(t){let c=!0;for(const[h,u]of Object.entries(l)){let m=u.split(" == ");(!t.querySelector(`td[data-label="${m[0]}"]`)||t.querySelector(`td[data-label="${m[0]}"]`).textContent!=`${m[1]}`)&&(c=!1)}return c}).length}else{let l=r.split(" == ");n=Array.from(a.querySelectorAll(`tbody tr.filtered--matched td[data-label="${l[0]}"], tbody tr[data-filtered-by="${l[0]}"] td[data-label="${l[0]}"]`)).filter(function(t){return t.textContent===l[1]}).length}b.hasAttribute("data-total")?b.setAttribute("data-total",n):b.innerHTML=n})},Z=function(a,e,o,i){o.addEventListener("update-page",b=>{let d=e.querySelector("[data-pagination]"),r=b.detail.page;if(d.value=r,e.dispatchEvent(new Event("paginate")),i.setAttribute("data-page",r),a.hasAttribute("data-show-history")){const n=new URL(location);n.searchParams.set("page",r),history.pushState({type:"pagination",form:e.getAttribute("id"),page:r},"",n)}if(!i.hasAttribute("data-no-scroll")){const l=a.getBoundingClientRect().top+window.pageYOffset+-250;window.scrollTo({top:l,behavior:"smooth"})}}),o.addEventListener("update-show",b=>{let d=e.querySelector("[data-show]"),r=b.detail.show;d.value=r,i.setAttribute("data-show",r),e.dispatchEvent(new Event("submit"))})},tt=(a,e)=>{if(!a)return!1;a.addEventListener("click",o=>{et(e)})},et=function(a){for(var e=[],o=a.getElementsByTagName("tr"),i=0;i<o.length;i++){for(var b=o[i].querySelectorAll("td,th"),d=[],r=0;r<b.length;r++)d.push(`"${b[r].textContent}"`);e.push(d.join(","))}e=e.join(`
|
|
5
|
-
`);let n=new Blob([e],{type:"text/csv"});var l=document.createElement("a");l.download="export.csv";var t=window.URL.createObjectURL(n);l.href=t,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l)},I=function(a,e,o,i){if(R(a),G(a,i),_(a,e,i),i&&i.classList.contains("table--cta")){let d=function(){Array.from(a.querySelectorAll("tr")).forEach((r,n)=>{let l=r.offsetHeight;r.style.setProperty("--row-height",`${l}px`)})};const b=J(a);i.style.setProperty("--cta-width",`${b}rem`),new ResizeObserver(d).observe(a)}},P=function(a){let e=new Object;return Array.from(a.querySelectorAll("[data-filter]")).forEach((i,b)=>{if(!(i.type=="radio"&&!i.checked)&&!(i.type=="checkbox"&&!i.checked)&&i&&i.value){let d=i.getAttribute("data-filter");e[d]||(e[d]=new Array),e[d].push(i.value)}}),e},z=function(a,e,o,i){return Y(this,void 0,void 0,function*(){let b=new FormData(e),d=new URLSearchParams(b).toString(),r=a.querySelectorAll("thead tr th"),n=a.querySelector("tbody"),l=e.getAttribute("data-ajax");i.classList.add("table--loading");let t=P(e);Array.from(e.querySelectorAll("[data-filter-count]")).forEach((u,m)=>{u.innerHTML="",u.parentNode.classList.remove("hover")});let c=0;Object.values(t).forEach((u,m)=>{typeof u=="object"&&Object.values(u).length?c+=Object.values(u).length:c++}),c&&Array.from(e.querySelectorAll("[data-filter-count]")).forEach((u,m)=>{u.innerHTML+=`(${c})`,u.parentNode.classList.add("hover")}),window.controller||(window.controller=[]),window.controller[l]&&window.controller[l].abort(),window.controller[l]=new AbortController;const{signal:h}=controller[l];o.setAttribute("data-loading","true"),e.classList.add("processing");try{yield fetch(l+"?"+d,{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 m=e.hasAttribute("data-schema")?e.getAttribute("data-schema"):"data",s=e.hasAttribute("data-schema-total")?e.getAttribute("data-schema-total"):"meta.total",g=e.hasAttribute("data-schema-page")?e.getAttribute("data-schema-page"):"meta.current_page",x=k(u,s,15),S=k(u,g,1),q=k(u,m),E=i.hasAttribute("data-empty-msg")?i.getAttribute("data-empty-msg"):"No results found";q?(n.innerHTML="",q.forEach((v,f)=>{var y=document.createElement("tr");r.forEach((p,w)=>{let A="";var L=document.createElement("td");if(L.setAttribute("data-label",p.innerText),p.getAttribute("data-output")){var $=p.getAttribute("data-output");A=$.replace(new RegExp(/{(.*?)}/,"gm"),function(D){return k(v,D.replace("{","").replace("}",""))})}if(p.hasAttribute("data-output-array")){var $=p.getAttribute("data-output");let F=k(v,$.replace("{","").replace("}",""));A="",F.forEach((j,it)=>{let W=p.getAttribute("data-output-array"),T="";if(p.hasAttribute("data-output-array-property")&&p.hasAttribute("data-output-array-transform")){const H=k(j,p.getAttribute("data-output-array-property")),U=JSON.parse(p.getAttribute("data-output-array-transform"))[H];T=W.replace(`{${p.getAttribute("data-output-array-property")}}`,U)}T=T.replace(new RegExp(/{(.*?)}/,"gm"),function(H){return k(j,H.replace("{","").replace("}",""))}),A+=T})}p.hasAttribute("data-transform")&&(A=JSON.parse(p.getAttribute("data-transform"))[A],!A&&p.hasAttribute("data-default")&&(A=p.getAttribute("data-default"))),L.innerHTML=A,y.appendChild(L)}),n.appendChild(y)}),N(a,e),i.setAttribute("data-total",parseInt(x)),i.setAttribute("data-page",parseInt(S)),I(a,e,o,i),Array.from(e.querySelectorAll("[data-ajax-query]")).forEach((v,f)=>{let y=k(u,v.getAttribute("data-ajax-query"),"");v.hasAttribute("data-total")?v.setAttribute("data-total",y):v.innerHTML=y}),parseInt(x)==0&&(n.innerHTML=`<tr><td colspan="100%"><span>${E}</span></td></tr>`),i.classList.remove("table--loading"),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"Ajax table loaded",url:l,formData:d})):n.innerHTML='<tr><td colspan="100%"><span>Error loading table</span></td></tr>',o.removeAttribute("data-loading"),e.classList.remove("processing")})}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=X(e)}};class at extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const e=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",o=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${e}/css/core.min.css`,i=document.createElement("template");i.innerHTML=`
|
|
4
|
+
*/const B=function(a){return typeof a!="string"?!1:!isNaN(a)&&!isNaN(parseFloat(a))},Q=(a,e)=>String(a).padStart(e,"0"),X=a=>a.charAt(0).toUpperCase()+a.slice(1),k=(a,e,o)=>e.split(/[\.\[\]\'\"]/).filter(i=>i).reduce((i,b)=>i?i[b]:o,a);var Y=function(a,e,o,i){function b(d){return d instanceof o?d:new o(function(r){r(d)})}return new(o||(o=Promise))(function(d,r){function n(c){try{t(i.next(c))}catch(h){r(h)}}function l(c){try{t(i.throw(c))}catch(h){r(h)}}function t(c){c.done?d(c.value):b(c.value).then(n,l)}t((i=i.apply(a,e||[])).next())})};const R=a=>{const e=Array.from(a.querySelectorAll("thead th"));Array.from(a.querySelectorAll("tbody tr")).forEach((i,b)=>{const d=Array.from(i.querySelectorAll("th, td")),r=["0","low","medium","high","unknown","n/a","pending","verified","due","overdue","incomplete","complete","completed","approval required","upcoming","requires approval","to do","on track","not started","warning","error"];d.forEach((n,l)=>{const t=e[l];if(typeof t<"u"){let c=document.createElement("div");c.innerHTML=t.innerHTML;let h=c.textContent||c.innerText||"";n.setAttribute("data-label",h),t.hasAttribute("data-td-class")&&n.setAttribute("class",t.getAttribute("data-td-class")),t.hasAttribute("data-format")&&(n.setAttribute("data-format",t.getAttribute("data-format")),n.innerHTML=M(t.getAttribute("data-format"),n.textContent.trim())),r.includes(n.textContent.trim().toLowerCase())&&n.setAttribute("data-content",n.textContent.trim().toLowerCase())}})})},J=a=>{let e=0;return Array.from(a.querySelectorAll("tbody tr")).forEach((o,i)=>{let b=window.getComputedStyle(document.querySelector("html")),d=o.querySelector(":scope > *:last-child > *:first-child");if(d){d.classList.add("text-nowrap");let r=d.offsetWidth/parseFloat(b.fontSize);r+=1.7,e=e>r?e:r}}),e},G=(a,e)=>{if(e.classList.contains("table--fullwidth")&&!e.hasAttribute("data-expandable")||a.querySelectorAll("thead tr th").length<4&&!e.hasAttribute("data-expandable"))return!1;Array.from(a.querySelectorAll("thead tr")).forEach((o,i)=>{a.querySelectorAll("thead tr th.expand-button-heading").length||o.insertAdjacentHTML("afterbegin",'<th class="th--fixed expand-button-heading"></th>')}),Array.from(a.querySelectorAll("tbody tr")).forEach((o,i)=>{const b=o.getAttribute("data-view")==="full"?"aria-expanded":"";o.insertAdjacentHTML("afterbegin",`<td class="td--fixed td--expand"><button class="btn btn-compact btn-secondary" data-expand-button ${b}>Expand</button></td>`)})},K=a=>{a.addEventListener("click",e=>{if(e&&e.target instanceof HTMLElement&&e.target.closest("[data-expand-button]")){let o=e.target.closest("[data-expand-button]"),i=o.closest("tr");o.toggleAttribute("aria-expanded"),i.getAttribute("data-view")=="full"?i.setAttribute("data-view","default"):i.setAttribute("data-view","full"),o.blur()}})},N=(a,e)=>{let o=e.querySelector("[data-search]");if(!o)return!1;const i=o.getAttribute("id"),b=o.getAttribute("data-search").split(",");let d=o.parentNode,r={};b.forEach((n,l)=>{Array.from(a.querySelectorAll('td[data-label="'+n.trim()+'"]')).forEach((t,c)=>{t.querySelector(".td__content")?r[t.querySelector(".td__content").textContent]=t.querySelector(".td__content").textContent:r[t.textContent]=t.textContent})}),o.setAttribute("list",`${i}_list`),o.setAttribute("autocomplete","off"),d.querySelector("datalist")||(d.innerHTML+=`<datalist id="${i}_list"></datalist>`),d.querySelector("datalist").innerHTML=`${Object.keys(r).map(n=>`<option value="${n}"></option>`).join("")}`},V=(a,e,o,i,b)=>{var d;let r=function(t,c=!1){if(e.classList.contains("processing"))return!1;if(t.type=="submit"&&(e.classList.add("processing"),Array.from(e.querySelectorAll("[data-duplicate]")).forEach((h,u)=>{const m=h.getAttribute("data-duplicate"),s=document.getElementById(m),g=document.querySelector(`[for="${m}"] iam-card`);if(s.checked!=h.checked)if(g){let x=new Event("click");g.dispatchEvent(x)}else s.checked=h.checked}),e.classList.remove("processing")),e.hasAttribute("data-ajax")){if(!c){let h=e.querySelector("[data-pagination]");h.value=1,i.setAttribute("data-page",1)}z(a,e,o,i)}else e.hasAttribute("data-submit")?e.submit():(C(a,e,i),_(a,e));if(e.hasAttribute("data-ajax-post")){let h=new FormData(e),u=new URLSearchParams(h).toString();const m=new XMLHttpRequest;m.open("GET",`${window.location.href}?ajax=true&${u}`),m.send()}};e.addEventListener("keyup",t=>{clearTimeout(d),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&(d=setTimeout(function(){r(t)},500))}),e.addEventListener("change",t=>{clearTimeout(d),t&&t.target instanceof HTMLElement&&t.target.closest("[data-sort]")&&(e.hasAttribute("data-submit")||O(a,e,b),r(t)),t&&t.target instanceof HTMLElement&&t.target.closest("[data-search]")&&r(t),t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter][data-no-ajax]")?(C(a,e,i),_(a,e)):(t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&t.target.closest("form .dialog__wrapper > dialog")||t&&t.target instanceof HTMLElement&&t.target.closest("[data-filter]")&&!t.target.closest("form dialog"))&&r(t),t&&t.target instanceof HTMLElement&&t.target.closest("[data-show]")&&r(t),t&&t.target instanceof HTMLElement&&t.target.closest("[data-mimic]")&&r(t)}),e.addEventListener("click",t=>{if(clearTimeout(d),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.classList.add("processing"),Array.from(e.querySelectorAll(".applied-filters")).forEach((h,u)=>{h.innerHTML=""});let c=e.elements;for(let h=0;h<c.length;h++)switch(c[h].type.toLowerCase()?c[h].type.toLowerCase():"text"){case"text":case"password":case"textarea":c[h].value="";break;case"radio":case"checkbox":if(c[h].checked){let m=c[h],s=m.getAttribute("id"),g=document.querySelector(`[for="${s}"`);if(g.querySelector("iam-card")){let x=g.querySelector("iam-card"),S=new Event("click");x.dispatchEvent(S)}m.checked=!1}break;case"select-one":case"select-multi":c[h].selectedIndex=-1;break}e.classList.remove("processing"),e.hasAttribute("data-submit")||O(a,e,b),r(t)}}),e.addEventListener("submit",t=>{clearTimeout(d),e.hasAttribute("data-submit")||t.preventDefault(),r(t)}),e.addEventListener("force",t=>{r(t)}),e.addEventListener("paginate",t=>{r(t,!0)});let n=[],l=[];Array.from(e.querySelectorAll("[data-mimic]")).forEach((t,c)=>{let h=t.getAttribute("data-mimic");Array.from(document.querySelectorAll(`[name="${h}"]`)).forEach((u,m)=>{let s=u.closest("form");n.includes(s)||n.push(s),l.includes(h)||l.push(h)})}),n.forEach((t,c)=>{const h=function(){let u=[],m=new FormData(t);for(const[s,g]of m)document.querySelector(`[data-mimic="${s}"]`)&&!u.includes(s)?(u.push(s),document.querySelector(`[data-mimic="${s}"]`).value=g):document.querySelector(`[data-mimic="${s}"]`)&&(document.querySelector(`[data-mimic="${s}"]`).value+=","+g);for(const s of u){const g=new Event("force");e.dispatchEvent(g)}for(const s of l)if(!m.has(s)&&t.querySelector(`[name="${s}"]`)){document.querySelector(`[data-mimic="${s}"]`).value="";const g=new Event("force");e.dispatchEvent(g)}};t.addEventListener("force",u=>{h()}),t.addEventListener("change",u=>{h()})})},O=(a,e,o)=>{if(e.getAttribute("data-ajax"))return!1;let i=a.querySelector("tbody"),b=e.querySelector("[data-sort]"),d=b.querySelector(`option:nth-child(${b.selectedIndex+1})`),r=d.getAttribute("data-sort"),n=d.getAttribute("data-order"),l=d.getAttribute("data-format");if(!r)return i.innerHTML=o.innerHTML,R(a),!1;let t=[];["asc","desc","descending"].includes(n)||(t=n.split(","));let c=[];Array.from(i.querySelectorAll("tr")).forEach((u,m)=>{let s=u.querySelector('td[data-label="'+r+'"], th[data-label="'+r+'"]').textContent.trim();u.querySelector('[data-label="'+r+'"] .td__content')&&(s=u.querySelector('[data-label="'+r+'"] .td__content').textContent.trim()),t.length&&t.includes(s)&&(s=t.indexOf(s)),B(s)&&(s=Q(s,10)),l&&l=="date"&&(s=new Date(s));const g={index:s,row:u};c.push(g)}),c.sort((u,m)=>u.index>m.index?1:-1),(n=="descending"||n=="desc")&&(c=c.reverse());let h="";c.forEach((u,m)=>{h+=u.row.outerHTML}),i.innerHTML=h},C=(a,e,o)=>{a.classList.remove("table--filtered");let i=P(e),b=[],d=0,r=e.querySelector("[data-pagination]")?parseInt(e.querySelector("[data-pagination]").value):1,n=e.querySelector("[data-show]")?parseInt(e.querySelector("[data-show]").value):15;if(Array.from(a.querySelectorAll("tbody tr")).forEach((t,c)=>{t.classList.remove("filtered"),t.classList.remove("filtered--matched"),t.classList.remove("filtered--show"),t.removeAttribute("data-filtered-by")}),e.querySelector("[data-search]")){let t=e.querySelector("[data-search]");e.querySelector("[data-search]").getAttribute("data-search").split(",").forEach((h,u)=>{b.push({column:`${h.trim()}`,value:`${t.value}`})})}Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,c)=>{t.innerHTML="",t.parentNode.classList.remove("hover")});let l=0;Object.values(i).forEach((t,c)=>{typeof t=="object"&&Object.values(t).length?l+=Object.values(t).length:l++}),l&&Array.from(e.querySelectorAll("[data-filter-count]")).forEach((t,c)=>{t.innerHTML+=`(${l})`,t.parentNode.classList.add("hover")}),a.classList.add("table--filtered");for(const[t,c]of Object.entries(i))Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((h,u)=>{let m=!1;c.forEach((s,g)=>{let x=h.querySelector(`[data-label="${t}"]`);if(s&&s=="$today")s=M("date",new Date);else if(s&&s=="$yesterday"){let f=new Date;f.setDate(f.getDate()-1),s=M("date",f)}else if(s&&(s=="$thisWeek"||s=="$lastWeek")){let f=new Date,y=new Date(f.setDate(f.getDate()-(f.getDay()-1))),p=new Date(f.setDate(f.getDate()-f.getDay()+7)),w=new Date(x.textContent.toLowerCase());if(f.setHours(0,0,0,0),y.setHours(0,0,0,0),p.setHours(0,0,0,0),w.setHours(0,0,0,0),s=="$thisWeek")m=w>=y&&w<=p;else{let A=new Date(y.setDate(y.getDate()-7)),L=new Date(p.setDate(p.getDate()-7));A.setHours(0,0,0,0),L.setHours(0,0,0,0),m=w>=A&&w<=L}}else if(s&&s=="$thisMonth"){let f=new Date,y=f.getFullYear(),p=f.getMonth();var S=new Date(y,p,1),q=new Date(y,p+1,0);let w=new Date(x.textContent.toLowerCase());S.setHours(0,0,0,0),q.setHours(0,0,0,0),w.setHours(0,0,0,0),m=w>=S&&w<=q}else if(s&&s=="$lastMonth"){let f=new Date,y=f.getFullYear(),p=f.getMonth();var E=new Date(y,p-1,1),v=new Date(y,p,0);let w=new Date(x.textContent.toLowerCase());E.setHours(0,0,0,0),v.setHours(0,0,0,0),w.setHours(0,0,0,0),m=w>=E&&w<=v}x&&x.textContent.toLowerCase().includes(s.toLowerCase())&&(m=!0)}),m||(h.classList.add("filtered"),h.setAttribute("data-filtered-by",t))});Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).forEach((t,c)=>{let h=!(b.length>0&&b[0].value.length>=3);b.forEach((u,m)=>{let s=t.querySelector(`[data-label="${u.column}"]`);s&&u.value.length>=3&&s.textContent.toLowerCase().includes(u.value.toLowerCase())&&(h=!0)}),h||t.classList.add("filtered")}),Array.from(a.querySelectorAll("tbody tr:not(.filtered")).forEach((t,c)=>{d++,t.classList.add("filtered--matched"),Math.ceil(d/n)==parseInt(r)&&t.classList.add("filtered--show")}),o&&(o.setAttribute("data-total",d),o.setAttribute("data-show",n),o.setAttribute("data-page",r))},_=(a,e,o)=>{Array.from(e.querySelectorAll("[data-query]")).forEach((b,d)=>{let r=b.getAttribute("data-query"),n=0;if(r=="total")o.hasAttribute("data-total")?n=o.getAttribute("data-total"):n=(a.classList.contains("table--filtered"),a.querySelectorAll("tbody tr").length);else if(!r.includes(" == ")&&r.includes(" & ")){let l=r.split(" & "),t="";l.forEach(c=>{t+=`:not([data-filtered-by="${c}"])`}),n=Array.from(a.querySelectorAll(`tbody tr${t}`)).length}else if(!r.includes(" == "))n=Array.from(a.querySelectorAll(`tbody tr:not([data-filtered-by="${r}"])`)).length;else if(r.includes(" && ")){let l=r.split(" && ");n=Array.from(a.querySelectorAll("tbody tr:not(.filtered)")).filter(function(t){let c=!0;for(const[h,u]of Object.entries(l)){let m=u.split(" == ");(!t.querySelector(`td[data-label="${m[0]}"]`)||t.querySelector(`td[data-label="${m[0]}"]`).textContent!=`${m[1]}`)&&(c=!1)}return c}).length}else{let l=r.split(" == ");n=Array.from(a.querySelectorAll(`tbody tr.filtered--matched td[data-label="${l[0]}"], tbody tr[data-filtered-by="${l[0]}"] td[data-label="${l[0]}"]`)).filter(function(t){return t.textContent===l[1]}).length}b.hasAttribute("data-total")?b.setAttribute("data-total",n):b.innerHTML=n})},Z=function(a,e,o,i){o.addEventListener("update-page",b=>{let d=e.querySelector("[data-pagination]"),r=b.detail.page;if(d.value=r,e.dispatchEvent(new Event("paginate")),i.setAttribute("data-page",r),a.hasAttribute("data-show-history")){const n=new URL(location);n.searchParams.set("page",r),history.pushState({type:"pagination",form:e.getAttribute("id"),page:r},"",n)}if(!i.hasAttribute("data-no-scroll")){const l=a.getBoundingClientRect().top+window.pageYOffset+-250;window.scrollTo({top:l,behavior:"smooth"})}}),o.addEventListener("update-show",b=>{let d=e.querySelector("[data-show]"),r=b.detail.show;d.value=r,i.setAttribute("data-show",r),e.dispatchEvent(new Event("submit"))})},tt=(a,e)=>{if(!a)return!1;a.addEventListener("click",o=>{et(e)})},et=function(a){for(var e=[],o=a.getElementsByTagName("tr"),i=0;i<o.length;i++){for(var b=o[i].querySelectorAll("td,th"),d=[],r=0;r<b.length;r++)d.push(`"${b[r].textContent}"`);e.push(d.join(","))}e=e.join(`
|
|
5
|
+
`);let n=new Blob([e],{type:"text/csv"});var l=document.createElement("a");l.download="export.csv";var t=window.URL.createObjectURL(n);l.href=t,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l)},I=function(a,e,o,i){if(R(a),G(a,i),_(a,e,i),i&&i.classList.contains("table--cta")){let d=function(){Array.from(a.querySelectorAll("tr")).forEach((r,n)=>{let l=r.offsetHeight;r.style.setProperty("--row-height",`${l}px`)})};const b=J(a);i.style.setProperty("--cta-width",`${b}rem`),new ResizeObserver(d).observe(a)}},P=function(a){let e=new Object;return Array.from(a.querySelectorAll("[data-filter]")).forEach((i,b)=>{if(!(i.type=="radio"&&!i.checked)&&!(i.type=="checkbox"&&!i.checked)&&i&&i.value){let d=i.getAttribute("data-filter");e[d]||(e[d]=new Array),e[d].push(i.value)}}),e},z=function(a,e,o,i){return Y(this,void 0,void 0,function*(){let b=new FormData(e),d=new URLSearchParams(b).toString(),r=a.querySelectorAll("thead tr th:not(.expand-button-heading)"),n=a.querySelector("tbody"),l=e.getAttribute("data-ajax");i.classList.add("table--loading");let t=P(e);Array.from(e.querySelectorAll("[data-filter-count]")).forEach((u,m)=>{u.innerHTML="",u.parentNode.classList.remove("hover")});let c=0;Object.values(t).forEach((u,m)=>{typeof u=="object"&&Object.values(u).length?c+=Object.values(u).length:c++}),c&&Array.from(e.querySelectorAll("[data-filter-count]")).forEach((u,m)=>{u.innerHTML+=`(${c})`,u.parentNode.classList.add("hover")}),window.controller||(window.controller=[]),window.controller[l]&&window.controller[l].abort(),window.controller[l]=new AbortController;const{signal:h}=controller[l];o.setAttribute("data-loading","true"),e.classList.add("processing");try{yield fetch(l+"?"+d,{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 m=e.hasAttribute("data-schema")?e.getAttribute("data-schema"):"data",s=e.hasAttribute("data-schema-total")?e.getAttribute("data-schema-total"):"meta.total",g=e.hasAttribute("data-schema-page")?e.getAttribute("data-schema-page"):"meta.current_page",x=k(u,s,15),S=k(u,g,1),q=k(u,m),E=i.hasAttribute("data-empty-msg")?i.getAttribute("data-empty-msg"):"No results found";q?(n.innerHTML="",q.forEach((v,f)=>{var y=document.createElement("tr");r.forEach((p,w)=>{let A="";var L=document.createElement("td");if(L.setAttribute("data-label",p.innerText),p.getAttribute("data-output")){var $=p.getAttribute("data-output");A=$.replace(new RegExp(/{(.*?)}/,"gm"),function(D){return k(v,D.replace("{","").replace("}",""))})}if(p.hasAttribute("data-output-array")){var $=p.getAttribute("data-output");let F=k(v,$.replace("{","").replace("}",""));A="",F.forEach((j,it)=>{let W=p.getAttribute("data-output-array"),T="";if(p.hasAttribute("data-output-array-property")&&p.hasAttribute("data-output-array-transform")){const H=k(j,p.getAttribute("data-output-array-property")),U=JSON.parse(p.getAttribute("data-output-array-transform"))[H];T=W.replace(`{${p.getAttribute("data-output-array-property")}}`,U)}T=T.replace(new RegExp(/{(.*?)}/,"gm"),function(H){return k(j,H.replace("{","").replace("}",""))}),A+=T})}p.hasAttribute("data-transform")&&(A=JSON.parse(p.getAttribute("data-transform"))[A],!A&&p.hasAttribute("data-default")&&(A=p.getAttribute("data-default"))),L.innerHTML=A,y.appendChild(L)}),n.appendChild(y)}),N(a,e),i.setAttribute("data-total",parseInt(x)),i.setAttribute("data-page",parseInt(S)),I(a,e,o,i),Array.from(e.querySelectorAll("[data-ajax-query]")).forEach((v,f)=>{let y=k(u,v.getAttribute("data-ajax-query"),"");v.hasAttribute("data-total")?v.setAttribute("data-total",y):v.innerHTML=y}),parseInt(x)==0&&(n.innerHTML=`<tr><td colspan="100%"><span>${E}</span></td></tr>`),i.classList.remove("table--loading"),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"Ajax table loaded",url:l,formData:d})):n.innerHTML='<tr><td colspan="100%"><span>Error loading table</span></td></tr>',o.removeAttribute("data-loading"),e.classList.remove("processing")})}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=X(e)}};class at extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});const e=document.body.hasAttribute("data-assets-location")?document.body.getAttribute("data-assets-location"):"/assets",o=document.body.hasAttribute("data-core-css")?document.body.getAttribute("data-core-css"):`${e}/css/core.min.css`,i=document.createElement("template");i.innerHTML=`
|
|
6
6
|
<style>
|
|
7
7
|
@import "${o}";
|
|
8
8
|
:host{--wrapper-padding: 2rem;--bg-colour: #ffffff;display:block;background:#fff;padding:var(--wrapper-padding);box-shadow:0px 6px 12px rgba(0,0,0,.11);border-radius:0.625rem;margin-bottom:2rem;overflow:hidden}:host:before{display:none !important}@media screen and (prefers-color-scheme: dark){:host{background:var(--colour-canvas-2)}}@media(forced-colors: active){:host{--wrapper-padding: 0;background:var(--colour-canvas-2)}}::slotted(table){margin-bottom:0 !important}.table__wrapper{display:block;width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar}@container (width < 23.4375em){:host(:not(.table--fullwidth)){margin-left:-1.5rem;margin-right:-1.5rem;margin-bottom:0;background:var(--colour-canvas-2);border-radius:0;background:none;padding:0;box-shadow:none;overflow:visible}:host(:not(.table--fullwidth)) .table__wrapper:not(.table--fullwidth){overflow:hidden;max-height:none !important}:host(:not(.table--fullwidth)) ::slotted(table){overflow:visible !important;margin-inline:1.5rem;margin-bottom:1.5rem !important;width:calc(100% - 3rem) !important;display:block}:host(:not(.table--fullwidth)) .table--cta{border-bottom:0}:host(:not(.table--fullwidth)) .table--cta:after{content:none;display:none !important}}@container (width > 23.4375em){:host{--cta-width: 8rem}:host(.table--loading){--cta-width: 1.5rem!important}.table--cta{position:relative}.table--cta .table__wrapper{overflow-y:hidden;margin-bottom:0}}.table__wrapper:is(.mh-sm,.mh-md,.mh-lg){position:relative}.table__wrapper:is(.mh-sm,.mh-md,.mh-lg)::before{top:calc(100% - 1.2rem);bottom:2px;height:1.2rem;border-bottom:2px solid var(--colour-border);margin-bottom:-1.2rem}.table--cta>.table__wrapper:is(.mh-sm,.mh-md,.mh-lg){max-height:none;position:static}.table--cta>.table__wrapper:is(.mh-sm,.mh-md,.mh-lg)::before{display:none}@container (width < 23.4375em){.table__wrapper.has-actionbar{margin-top:calc(-100vh + 6.75rem) !important}}:host(.table--loading){pointer-events:none;position:relative}:host(.table--loading) ::slotted(table){min-height:20rem;opacity:.5}:host(.table--loading)::after{content:"Loading...";position:absolute;top:6.25rem;left:50%;transform:translate(-50%, 0);font-weight:bold;color:var(--colour-heading);font-size:1.5rem;text-shadow:0px 0px 10px var(--colour-canvas-2);padding-inline:2rem;text-shadow:0px 0px 10px var(--colour-canvas-2);background:radial-gradient(var(--colour-canvas-2), transparent)}@container (width < 23.4375em){.pagination--table{margin-inline:1.5rem;width:auto}:host(.table--fullwidth) .pagination--table{margin-inline:0}}/*# sourceMappingURL=assets/css/components/table.css.map */
|