@topvisor/ui
Version:
Topvisor UI-kit Vue
3 lines (2 loc) • 6.2 kB
JavaScript
define(["require","exports","vue","./forms-DHThMe8-.amd","../popup/worker.amd","./dialogs.vue_vue_type_script_setup_true_lang-YGicBjlC.amd","../utils/dom.amd"],(function(r,L,_,i,l,U,$){"use strict";if(typeof _>"u")var _=window.Vue;class V{static isInited=!1;static init(){this.isInited||(this.isInited=!0,document.addEventListener("mouseover",e=>{var o;!(e.target instanceof HTMLElement)||!((o=e.target.dataset)!=null&&o.topPopupOpenByHover)||e.target.click()}),document.addEventListener("scroll",()=>{i.Core.state.isMobile||i.Core.state.isMobileUA||l.TopPopupWorker.getAll().forEach(e=>l.TopPopupWorker.close(e))}),i.Events.addOnReize(e=>{i.Core.state.isMobile&&e.topEvent.widthDiff&&l.TopPopupWorker.getAll().forEach(o=>l.TopPopupWorker.close(o))}),document.addEventListener("click",this.onclick,{capture:!0}))}static async onclick(e){var n,s,c,a,D;if(!(e.target instanceof HTMLElement)||e.target.dataset.topPopupDisabled)return;let o;switch(!0){case!!((n=e.target.dataset)!=null&&n.topPopup):o=e.target;break;case!!((s=e.target.parentElement)!=null&&s.dataset.topPopup):o=e.target.parentElement;break;case!!((a=(c=e.target.parentElement)==null?void 0:c.parentElement)!=null&&a.dataset.topPopup):o=(D=e.target.parentElement)==null?void 0:D.parentElement;break}o&&(o.dataset.topPopupDisabled||o.dataset.topPopupOpened||(e.preventDefault(),await l.TopPopupWorker.openByOpener(o)))}}let g;const I={mounted:async(t,e)=>{g||(g=(await new Promise((c,a)=>r(["../utils/dom.amd"],c,a))).storage);const o=e.arg,n=e.value;g(t,o,n)}};let h,d=[],T;const M=async()=>{const{isVisible:t}=await new Promise((o,n)=>r(["../utils/dom.amd"],o,n));if(d=d.filter(t),!d.length)return;d[0].focus(),d=[]},S=async t=>{h||(h=await new Promise((e,o)=>r(["../utils/lodash.amd"],e,o))),T||(T=h.debounce(M,30)),d.push(t),T()},R={mounted:function(t,e){t.__TOP_V_FOCUS_VALUE=e.value??!0,(e.value??!0)&&S(t)},updated:function(t,e){e.modifiers.onupdate&&t.__TOP_V_FOCUS_VALUE!==(e.value??!0)&&(t.__TOP_V_FOCUS_VALUE=e.value??!0,(e.value??!0)&&S(t))}};let f,b;const C=t=>(typeof t=="boolean"||(t?t={...t}:t={},t.behavior??="smooth",t.block??="nearest",t.inline??="nearest"),t);let v,E;const H=async()=>{if(!v)return;const t=await P(v);t.isVisible&&v.scrollIntoView(t.scrollIntoViewOptions)},O=async t=>{b||(b=await new Promise((e,o)=>r(["../utils/lodash.amd"],e,o))),E||(E=b.debounce(H,30)),v=t,E()},P=async(t,e)=>{f||(f=await new Promise((n,s)=>r(["../utils/dom.amd"],n,s)));let o=f.storage(t,"v-top-scrollIntoView");return o||(o={isVisible:$.isVisible(t),scrollIntoViewOptions:C(e)},f.storage(t,"v-top-scrollIntoView",o)),o},W={async mounted(t,e){await P(t,e.value),e.modifiers.immediate&&O(t)},async updated(t,e){const o=await P(t,e.value);o.scrollIntoViewOptions=C(e.value);const n=$.isVisible(t);n&&o.isVisible!==n&&O(t),o.isVisible=n}};let u;const x={async mounted(t){u||(u=await new Promise((e,o)=>r(["../utils/scroll.amd"],e,o))),u.connectScrollShadow(t)},async unmounted(t){u||(u=await new Promise((e,o)=>r(["../utils/scroll.amd"],e,o))),u.unconnectScrollShadow(t)}};let p;const N={mounted(t,e,o){const n=e.value||"top-sticky";p=new IntersectionObserver(s=>{let c=s[0].intersectionRatio<1;c&&e.modifiers.bottom&&s[0].intersectionRect.y===0&&(c=!1),t.classList.toggle(n,c)},{threshold:[1]}),p.observe(t)},unmounted(t,e,o){p==null||p.disconnect()}};let k=!1,m;const w=new Map,F=(t,e)=>{const{distance:o,percent:n}=t.directiveSwipUpOptions,s=t.getBoundingClientRect().top,c=e*n/100/o,a=(e-s)/c;a<=o?t.style.transform=`translateY(${o-a}px)`:t.style.transform="translateY(0px)"},B=t=>{let e=window.innerHeight;window.addEventListener("scroll",()=>{w.forEach(o=>F(o,e))},{passive:!0}),m=new IntersectionObserver(o=>{e=window.innerHeight,o.forEach(n=>{const s=n.target;if(n.intersectionRatio<.1?w.delete(s):w.set(s,s),n.intersectionRatio===0){const{distance:c}=s.directiveSwipUpOptions;s.style.transform=`translateY(${c}px)`}})},{threshold:.1})},Y={mounted(t,e,o){var n,s;i.Core.state.isMobileUA||(t.directiveSwipUpOptions={distance:((n=e.value)==null?void 0:n.distance)??100,percent:((s=e.value)==null?void 0:s.percent)??30},k||(B(),k=!0),m.observe(t))},unmounted(t,e,o){w.delete(t),m==null||m.unobserve(t)}},y=t=>{var e,o;if(!((o=(e=i.Core.$)==null?void 0:e.ui)!=null&&o.tooltip)){console.info("Для работы v-top-tooltip требуется глобальная загрузка jQuery UI Tooltip");return}return i.Core.$(t)},A=(t,e)=>{var n;const o=t.value??{};return o.content??=(n=e.props)==null?void 0:n.title,o.content=String(o.content).replace(/([^<>])\r?\n([^<>])/g,"$1<br>$2"),o.position??={my:"bottom-18px",at:"top center"},o},j={mounted(t,e,o){var n;(n=y(t))==null||n.tooltip(A(e,o))},updated(t,e,o,n){var a;const s=A(e,o),c=(a=y(t))==null?void 0:a.tooltip("instance");c&&(c.options={...c.options,...s})},unmounted(t,e,o){var n;(n=y(t))==null||n.tooltip("destroy")}},z=_.defineAsyncComponent(()=>new Promise((t,e)=>r(["./notice-Bj_A6EZr.amd"],t,e)));window.vd=console.log;const G={install:(t,e)=>{t.config.globalProperties.$core=i.Core,t.config.globalProperties.$vd=console.log;for(const o in e)i.Core.state[o]=e[o];e.widthForMobile&&(i.Core.widthForMobile=e.widthForMobile),e.themeName&&(i.Core.themeName=e.themeName),i.Core._setState(),e.topPopupOptions&&(l.TopPopupWorker.options=e.topPopupOptions),V.init(),U.TopDialogWorker.init(e.topDialogOptions),t.directive("top-data",I),t.directive("top-focus",R),t.directive("top-scroll-into-view",W),t.directive("top-scroll-shadow",x),t.directive("top-sticky",N),t.directive("top-swim-up",Y),t.directive("top-tooltip",j),t.component("TopAvatar",i._sfc_main$3),t.component("TopButton",i._sfc_main$1),t.component("TopCheckbox",i._sfc_main$4),t.component("TopControlLabel",i._sfc_main$5),t.component("TopHint",i._sfc_main$2),t.component("TopInput",i._sfc_main),t.component("TopInputDate",i._sfc_main$6),t.component("TopInputRange",i._sfc_main$7),t.component("TopLoadbar",i.TopLoadbar),t.component("TopRadio",i._sfc_main$8),t.component("TopSelect",i._sfc_main$9),t.component("TopSwitcher",i._sfc_main$10),t.component("TopTextarea",i._sfc_main$11),t.component("TopNotice",z),t.component("TopDialogs",U._sfc_main)}};L.core=G}));
//# sourceMappingURL=core-D4Sv-IKP.amd.js.map