basecoat-css 0.2.5 → 0.2.8

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.
@@ -1 +1 @@
1
- (()=>{const e=e=>{const t=e.querySelector(":scope > button"),a=t.querySelector(":scope > span"),i=e.querySelector(":scope > [data-popover]"),r=i.querySelector('[role="listbox"]'),n=e.querySelector(':scope > input[type="hidden"]'),s=e.querySelector('header input[type="text"]');if(!(t&&i&&r&&n)){const a=[];return t||a.push("trigger"),i||a.push("popover"),r||a.push("listbox"),n||a.push("input"),void console.error(`Select component initialisation failed. Missing element(s): ${a.join(", ")}`,e)}const o=Array.from(r.querySelectorAll('[role="option"]'));let c=[...o],d=-1;const l=()=>{const e=getComputedStyle(i);return parseFloat(e.transitionDuration)>0||parseFloat(e.transitionDelay)>0},u=e=>{e&&(a.innerHTML=e.dataset.label||e.innerHTML,n.value=e.dataset.value,r.querySelector('[role="option"][aria-selected="true"]')?.removeAttribute("aria-selected"),e.setAttribute("aria-selected","true"))},v=(e=!0)=>{if("true"!==i.getAttribute("aria-hidden")){if(s){const e=()=>{s.value="",c=[...o],o.forEach((e=>e.setAttribute("aria-hidden","false")))};l()?i.addEventListener("transitionend",e,{once:!0}):e()}e&&t.focus(),i.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),t.removeAttribute("aria-activedescendant"),d>-1&&o[d]?.classList.remove("active"),d=-1}},p=t=>{if(!t)return;null!=t.dataset.value&&u(t),v();const a=new CustomEvent("change",{detail:{value:t.dataset.value},bubbles:!0});e.dispatchEvent(a)};if(s){const e=()=>{const e=s.value.trim().toLowerCase();d>-1&&(o[d].classList.remove("active"),t.removeAttribute("aria-activedescendant"),d=-1),c=[],o.forEach((t=>{const a=(t.dataset.label||t.textContent).trim().toLowerCase().includes(e);t.setAttribute("aria-hidden",String(!a)),a&&c.push(t)}))};s.addEventListener("input",e)}let b=o.find((e=>e.dataset.value===n.value));!b&&o.length>0&&(b=o[0]),u(b);const h=e=>{const a="false"===i.getAttribute("aria-hidden");if(!["ArrowDown","ArrowUp","Enter","Home","End","Escape"].includes(e.key))return;if(!a)return void("Enter"!==e.key&&"Escape"!==e.key&&(e.preventDefault(),t.click()));if(e.preventDefault(),"Escape"===e.key)return void v();if("Enter"===e.key)return void(d>-1&&p(o[d]));if(0===c.length)return;const r=d>-1?c.indexOf(o[d]):-1;let n=r;switch(e.key){case"ArrowDown":r<c.length-1&&(n=r+1);break;case"ArrowUp":r>0?n=r-1:-1===r&&(n=0);break;case"Home":n=0;break;case"End":n=c.length-1}if(n!==r){r>-1&&c[r].classList.remove("active");const e=c[n];e.classList.add("active"),d=o.indexOf(e),e.id&&t.setAttribute("aria-activedescendant",e.id),e.scrollIntoView({block:"nearest",behavior:"smooth"})}};t.addEventListener("keydown",h),s&&s.addEventListener("keydown",h);t.addEventListener("click",(()=>{"true"===t.getAttribute("aria-expanded")?v():(()=>{document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:e}})),s&&(l()?i.addEventListener("transitionend",(()=>{s.focus()}),{once:!0}):s.focus()),i.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true");const a=r.querySelector('[role="option"][aria-selected="true"]');a&&(d>-1&&o[d]?.classList.remove("active"),d=o.indexOf(a),a.classList.add("active"),a.id&&t.setAttribute("aria-activedescendant",a.id),a.scrollIntoView({block:"nearest"}))})()})),r.addEventListener("click",(e=>{const t=e.target.closest('[role="option"]');t&&p(t)})),document.addEventListener("click",(t=>{e.contains(t.target)||v(!1)})),document.addEventListener("basecoat:popover",(t=>{t.detail.source!==e&&v(!1)})),i.setAttribute("aria-hidden","true"),e.selectByValue=t=>{const a=o.find((e=>e.dataset.value===t));if(a){u(a);const t=new CustomEvent("change",{detail:{value:a.dataset.value},bubbles:!0});e.dispatchEvent(t)}},e.dataset.selectInitialized=!0,e.dispatchEvent(new CustomEvent("basecoat:initialized"))};document.querySelectorAll("div.select:not([data-select-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("div.select:not([data-select-initialized])")&&e(t),t.querySelectorAll("div.select:not([data-select-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
1
+ (()=>{const e=e=>{const t=e.querySelector(":scope > button"),n=t.querySelector(":scope > span"),r=e.querySelector(":scope > [data-popover]"),a=r.querySelector('[role="listbox"]'),i=e.querySelector(':scope > input[type="hidden"]'),o=e.querySelector('header input[type="text"]');if(!(t&&r&&a&&i)){const n=[];return t||n.push("trigger"),r||n.push("popover"),a||n.push("listbox"),i||n.push("input"),void console.error(`Select component initialisation failed. Missing element(s): ${n.join(", ")}`,e)}const s=Array.from(a.querySelectorAll('[role="option"]'));let d=[...s],c=-1;const l=e=>{if(c>-1&&s[c]&&s[c].classList.remove("active"),c=e,c>-1){const e=s[c];e.classList.add("active"),e.id?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant")}else t.removeAttribute("aria-activedescendant")},u=()=>{const e=getComputedStyle(r);return parseFloat(e.transitionDuration)>0||parseFloat(e.transitionDelay)>0},v=e=>{e&&(n.innerHTML=e.dataset.label||e.innerHTML,i.value=e.dataset.value,a.querySelector('[role="option"][aria-selected="true"]')?.removeAttribute("aria-selected"),e.setAttribute("aria-selected","true"))},p=(e=!0)=>{if("true"!==r.getAttribute("aria-hidden")){if(o){const e=()=>{o.value="",d=[...s],s.forEach((e=>e.setAttribute("aria-hidden","false")))};u()?r.addEventListener("transitionend",e,{once:!0}):e()}e&&t.focus(),r.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),l(-1)}},f=t=>{if(!t)return;const n=i.value,r=t.dataset.value;if(null!=r&&r!==n&&v(t),p(),r!==n){const t=new CustomEvent("change",{detail:{value:r},bubbles:!0});e.dispatchEvent(t)}};if(o){const e=()=>{const e=o.value.trim().toLowerCase();l(-1),d=[],s.forEach((t=>{const n=(t.dataset.label||t.textContent).trim().toLowerCase().includes(e);t.setAttribute("aria-hidden",String(!n)),n&&d.push(t)}))};o.addEventListener("input",e)}let b=s.find((e=>e.dataset.value===i.value));!b&&s.length>0&&(b=s[0]),v(b);const E=e=>{const n="false"===r.getAttribute("aria-hidden");if(!["ArrowDown","ArrowUp","Enter","Home","End","Escape"].includes(e.key))return;if(!n)return void("Enter"!==e.key&&"Escape"!==e.key&&(e.preventDefault(),t.click()));if(e.preventDefault(),"Escape"===e.key)return void p();if("Enter"===e.key)return void(c>-1&&f(s[c]));if(0===d.length)return;const a=c>-1?d.indexOf(s[c]):-1;let i=a;switch(e.key){case"ArrowDown":a<d.length-1&&(i=a+1);break;case"ArrowUp":a>0?i=a-1:-1===a&&(i=0);break;case"Home":i=0;break;case"End":i=d.length-1}if(i!==a){const e=d[i];l(s.indexOf(e)),e.scrollIntoView({block:"nearest",behavior:"smooth"})}};a.addEventListener("mousemove",(e=>{const t=e.target.closest('[role="option"]');if(t&&d.includes(t)){const e=s.indexOf(t);e!==c&&l(e)}})),a.addEventListener("mouseleave",(()=>{const e=a.querySelector('[role="option"][aria-selected="true"]');l(e?s.indexOf(e):-1)})),t.addEventListener("keydown",E),o&&o.addEventListener("keydown",E);t.addEventListener("click",(()=>{"true"===t.getAttribute("aria-expanded")?p():(()=>{document.dispatchEvent(new CustomEvent("basecoat:popover",{detail:{source:e}})),o&&(u()?r.addEventListener("transitionend",(()=>{o.focus()}),{once:!0}):o.focus()),r.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true");const n=a.querySelector('[role="option"][aria-selected="true"]');n&&(l(s.indexOf(n)),n.scrollIntoView({block:"nearest"}))})()})),a.addEventListener("click",(e=>{const t=e.target.closest('[role="option"]');t&&f(t)})),document.addEventListener("click",(t=>{e.contains(t.target)||p(!1)})),document.addEventListener("basecoat:popover",(t=>{t.detail.source!==e&&p(!1)})),r.setAttribute("aria-hidden","true"),e.selectByValue=e=>{const t=s.find((t=>t.dataset.value===e));f(t)},e.dataset.selectInitialized=!0,e.dispatchEvent(new CustomEvent("basecoat:initialized"))};document.querySelectorAll("div.select:not([data-select-initialized])").forEach(e);new MutationObserver((t=>{t.forEach((t=>{t.addedNodes.forEach((t=>{t.nodeType===Node.ELEMENT_NODE&&(t.matches("div.select:not([data-select-initialized])")&&e(t),t.querySelectorAll("div.select:not([data-select-initialized])").forEach(e))}))}))})).observe(document.body,{childList:!0,subtree:!0})})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basecoat-css",
3
- "version": "0.2.5",
3
+ "version": "0.2.8",
4
4
  "description": "Tailwind CSS for Basecoat components",
5
5
  "author": {
6
6
  "name": "hunvreus",