@ionic/core
Version:
Base components for Ionic
4 lines • 2.8 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{r as t,w as o}from"./p-Co7eql8D.js";import{i as n}from"./p-Dojwmvde.js";const e=(n,e,i)=>{let r;const s=()=>void 0!==e()&&void 0===n.label&&null!==i(),d=()=>{const t=e();if(void 0===t)return;if(!s())return void t.style.removeProperty("width");const a=i().scrollWidth;if(0===a&&null===t.offsetParent&&void 0!==o&&"IntersectionObserver"in o){if(void 0!==r)return;const o=r=new IntersectionObserver((t=>{1===t[0].intersectionRatio&&(d(),o.disconnect(),r=void 0)}),{threshold:.01,root:n});o.observe(t)}else t.style.setProperty("width",.75*a+"px")};return{calculateNotchWidth:()=>{s()&&t((()=>{d()}))},destroy:()=>{r&&(r.disconnect(),r=void 0)}}},i="skip-label-transition",r=(o,e,r,s)=>{let d,a,c,v,l,u,f;const h=t=>Math.round(10*t)/10,m=()=>{void 0===v&&(v=t((()=>{v=void 0;const{adjustment:d,startEndWidth:a}=(()=>{const t=e();if(!t||!s())return{adjustment:"",startEndWidth:""};const i=h(t.getBoundingClientRect().width),d=h(r()?.getBoundingClientRect().width??0),a=n(o)?"":"-";return{adjustment:i?`${a}${i}px`:"0px",startEndWidth:`${h(i+d)}px`}})();a!==f&&(o.style.setProperty("--internal-start-end-container-width",a),f=a),d!==u&&(void 0!==l&&cancelAnimationFrame(l),o.classList.add(i),o.style.setProperty("--internal-start-container-adjustment",d),u=d,l=t((()=>{l=void 0,o.classList.remove(i)}))),b()})))},p=()=>{d&&(d.disconnect(),d=void 0,a=void 0,c=void 0)},b=()=>{const t=e(),o=r();t&&s()?"function"!=typeof ResizeObserver||d&&a===t&&c===o||(p(),d=new ResizeObserver((()=>{m()})),a=t,d.observe(t),o&&(c=o,d.observe(o))):p()};return{calculateContainerWidths:()=>{m()},destroy:()=>{p(),void 0!==v&&(cancelAnimationFrame(v),v=void 0),void 0!==l&&(cancelAnimationFrame(l),l=void 0,o.classList.remove(i)),u=void 0,f=void 0}}},s=(t,o)=>{const n=t.target.closest('[slot="start"], [slot="end"]');return null!==n&&n!==o&&o.contains(n)?n:null},d=(o,n)=>{let e=!1;return{handleClickCapture:i=>{if(((t,o)=>null!==s(t,o))(i,o))return e=!0,void t((()=>e=!1));if(void 0===n)return void(e&&(i.stopPropagation(),e=!1));const r=n();void 0!==r&&i.target===r&&(i.stopPropagation(),e||o.click(),e=!1)}}},a=(n,e,i)=>{let r,s;if(void 0!==o&&"MutationObserver"in o){const o=Array.isArray(e)?e:[e];r=new MutationObserver((n=>{for(const e of n)for(const n of e.addedNodes)if(n.nodeType===Node.ELEMENT_NODE&&o.includes(n.slot))return i(),void t((()=>d(n)))})),r.observe(n,{childList:!0,subtree:!0})}const d=t=>{s&&(s.disconnect(),s=void 0),s=new MutationObserver((t=>{i();for(const o of t)for(const t of o.removedNodes)t.nodeType===Node.ELEMENT_NODE&&t.slot===e&&a()})),s.observe(t.parentElement??t,{subtree:!0,childList:!0})},a=()=>{s&&(s.disconnect(),s=void 0)};return{destroy:()=>{r&&(r.disconnect(),r=void 0),a()}}};export{e as a,r as b,a as c,d,s as g}