UNPKG

@zoff-tech/zt-bottom-drawer

Version:
23 lines 5.43 kB
import{g as t,a as o,f as n}from"./p-c45d7139.js";import{b as s,d as e,r as c,a as i}from"./p-a75a9102.js";import{a as r,K as a}from"./p-1ae586af.js";import"./p-c8e8aee0.js"; /*! * (C) Ionic http://ionicframework.com - MIT License */const f=new WeakMap;const u=(t,o,n,s=0,e=false)=>{if(f.has(t)===n){return}if(n){d(t,o,s,e)}else{w(t,o)}};const l=t=>t===t.getRootNode().activeElement;const d=(t,o,n,s=false)=>{const e=o.parentNode;const c=o.cloneNode(false);c.classList.add("cloned-input");c.tabIndex=-1;if(s){c.disabled=true}e.appendChild(c);f.set(t,c);const i=t.ownerDocument;const r=i.dir==="rtl"?9999:-9999;t.style.pointerEvents="none";o.style.transform=`translate3d(${r}px,${n}px,0) scale(0)`};const w=(t,o)=>{const n=f.get(t);if(n){f.delete(t);n.remove()}t.style.pointerEvents="";o.style.transform=""};const p=50; /*! * (C) Ionic http://ionicframework.com - MIT License */const m=(t,o,n)=>{if(!n||!o){return()=>{}}const c=n=>{if(l(o)){u(t,o,n)}};const i=()=>u(t,o,false);const r=()=>c(true);const a=()=>c(false);s(n,"ionScrollStart",r);s(n,"ionScrollEnd",a);o.addEventListener("blur",i);return()=>{e(n,"ionScrollStart",r);e(n,"ionScrollEnd",a);o.removeEventListener("blur",i)}}; /*! * (C) Ionic http://ionicframework.com - MIT License */const S="input, textarea, [no-blur], [contenteditable]";const h=()=>{let t=true;let o=false;const n=document;const c=()=>{o=true};const i=()=>{t=true};const r=s=>{if(o){o=false;return}const e=n.activeElement;if(!e){return}if(e.matches(S)){return}const c=s.target;if(c===e){return}if(c.matches(S)||c.closest(S)){return}t=false;setTimeout((()=>{if(!t){e.blur()}}),50)};s(n,"ionScrollStart",c);n.addEventListener("focusin",i,true);n.addEventListener("touchend",r,false);return()=>{e(n,"ionScrollStart",c,true);n.removeEventListener("focusin",i,true);n.removeEventListener("touchend",r,false)}}; /*! * (C) Ionic http://ionicframework.com - MIT License */const y=.3;const b=(t,o,n)=>{var s;const e=(s=t.closest("ion-item,[ion-item]"))!==null&&s!==void 0?s:t;return M(e.getBoundingClientRect(),o.getBoundingClientRect(),n,t.ownerDocument.defaultView.innerHeight)};const M=(t,o,n,s)=>{const e=t.top;const c=t.bottom;const i=o.top;const r=Math.min(o.bottom,s-n);const a=i+15;const f=r-p;const u=f-c;const l=a-e;const d=Math.round(u<0?-u:l>0?-l:0);const w=Math.min(d,e-i);const m=Math.abs(w);const S=m/y;const h=Math.min(400,Math.max(150,S));return{scrollAmount:w,scrollDuration:h,scrollPadding:n,inputSafeY:-(e-a)+4}}; /*! * (C) Ionic http://ionicframework.com - MIT License */const D="$ionPaddingTimer";const x=(t,o,n)=>{const s=t[D];if(s){clearTimeout(s)}if(o>0){t.style.setProperty("--keyboard-offset",`${o}px`)}else{t[D]=setTimeout((()=>{t.style.setProperty("--keyboard-offset","0px");if(n){n()}}),120)}};const k=(t,o,n)=>{const s=()=>{if(o){x(o,0,n)}};t.addEventListener("focusout",s,{once:true})}; /*! * (C) Ionic http://ionicframework.com - MIT License */let K=0;const g="data-ionic-skip-scroll-assist";const T=(t,o,n,s,e,c,i,a=false)=>{const f=c&&(i===undefined||i.mode===r.None);const u=async()=>{if(o.hasAttribute(g)){o.removeAttribute(g);return}P(t,o,n,s,e,f,a)};t.addEventListener("focusin",u,true);return()=>{t.removeEventListener("focusin",u,true)}};const j=t=>{if(document.activeElement===t){return}t.setAttribute(g,"true");t.focus()};const P=async(n,s,e,i,r,a,f=false)=>{if(!e&&!i){return}const l=b(n,e||i,r);if(e&&Math.abs(l.scrollAmount)<4){j(s);if(a&&e!==null){x(e,K);k(s,e,(()=>K=0))}return}u(n,s,true,l.inputSafeY,f);j(s);c((()=>n.click()));if(a&&e){K=l.scrollPadding;x(e,K)}if(typeof window!=="undefined"){let c;const i=async()=>{if(c!==undefined){clearTimeout(c)}window.removeEventListener("ionKeyboardDidShow",r);window.removeEventListener("ionKeyboardDidShow",i);if(e){await o(e,0,l.scrollAmount,l.scrollDuration)}u(n,s,false,l.inputSafeY);j(s);if(a){k(s,e,(()=>K=0))}};const r=()=>{window.removeEventListener("ionKeyboardDidShow",r);window.addEventListener("ionKeyboardDidShow",i)};if(e){const o=await t(e);const n=o.scrollHeight-o.clientHeight;if(l.scrollAmount>n-o.scrollTop){if(s.type==="password"){l.scrollAmount+=p;window.addEventListener("ionKeyboardDidShow",r)}else{window.addEventListener("ionKeyboardDidShow",i)}c=setTimeout(i,1e3);return}}i()}}; /*! * (C) Ionic http://ionicframework.com - MIT License */const $=true;const A=async(t,o)=>{const s=document;const e=o==="ios";const c=o==="android";const r=t.getNumber("keyboardHeight",290);const f=t.getBoolean("scrollAssist",true);const u=t.getBoolean("hideCaretOnScroll",e);const l=t.getBoolean("inputBlurring",e);const d=t.getBoolean("scrollPadding",true);const w=Array.from(s.querySelectorAll("ion-input, ion-textarea"));const p=new WeakMap;const S=new WeakMap;const y=await a.getResizeMode();const b=async t=>{await new Promise((o=>i(t,o)));const o=t.shadowRoot||t;const s=o.querySelector("input")||o.querySelector("textarea");const e=n(t);const a=!e?t.closest("ion-footer"):null;if(!s){return}if(!!e&&u&&!p.has(t)){const o=m(t,s,e);p.set(t,o)}const l=s.type==="date"||s.type==="datetime-local";if(!l&&(!!e||!!a)&&f&&!S.has(t)){const o=T(t,s,e,a,r,d,y,c);S.set(t,o)}};const M=t=>{if(u){const o=p.get(t);if(o){o()}p.delete(t)}if(f){const o=S.get(t);if(o){o()}S.delete(t)}};if(l&&$){h()}for(const t of w){b(t)}s.addEventListener("ionInputDidLoad",(t=>{b(t.detail)}));s.addEventListener("ionInputDidUnload",(t=>{M(t.detail)}))};export{A as startInputShims}; //# sourceMappingURL=p-51ae85b5.js.map