UNPKG

mom-ui

Version:
17 lines (14 loc) 10.6 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["mom-ui"]={},e.Vue)}(this,(function(e,t){"use strict";var n={props:{type:{type:String,default:"default"},size:{type:String,default:"normal"},disabled:{type:Boolean,default:!1},noBorder:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}}};const o={key:0,class:"icon","aria-hidden":"true"},i=t.createVNode("use",{"xlink:href":"#icon-loading"},null,-1),c=t.createTextVNode("Button");n.render=function(e,n,l,a,r,s){return t.openBlock(),t.createBlock("button",{class:["m-button",{disabled:l.disabled,loading:l.loading,[l.size]:l.size,[l.type]:l.type,noBorder:l.noBorder}]},[l.loading?(t.openBlock(),t.createBlock("svg",o,[i])):t.createCommentVNode("v-if",!0),t.renderSlot(e.$slots,"default",{},(()=>[c]))],2)},n.__file="src/libs/Button.vue";var l={props:{title:{type:String,default:"tab"}}};const a={class:"m-tab"};l.render=function(e,n,o,i,c,l){return t.openBlock(),t.createBlock("div",a,[t.renderSlot(e.$slots,"default")])},l.__file="src/libs/Tab.vue";var r={props:{checked:{type:Boolean,default:!1}},setup:function(e,t){return{toggleBtn:function(){t.emit("update:checked",!e.checked)}}}};const s=t.createVNode("div",{class:"inner"},null,-1);r.render=function(e,n,o,i,c,l){return t.openBlock(),t.createBlock("div",{class:["m-switch",{checked:o.checked}],onClick:n[1]||(n[1]=(...e)=>i.toggleBtn(...e))},[s],2)},r.__file="src/libs/Switch.vue";var d={props:{selectedIndex:{type:Number,default:0}},setup:function(e,n){var o=n.slots.default();o.forEach((function(e){if(e.type!==l)throw Error("Tabs组件中只能包含Tab组件!")}));var i=t.reactive([]),c=t.ref(),a=t.ref();return t.onMounted((function(){t.watchEffect((function(){var t=i[e.selectedIndex].getBoundingClientRect(),n=t.width,o=t.left,l=c.value.getBoundingClientRect().left;a.value.style.width=n+"px",a.value.style.left=o-l+"px"}))})),{slots:o,selected:function(e){n.emit("update:selectedIndex",e)},lis:i,tabs:c,indicator:a}}};const u={class:"m-tabs"},p={class:"m-tabs-tag",ref:"tabs"},f={class:"m-tabs-tag-indicator",ref:"indicator"},v={class:"container"};d.render=function(e,n,o,i,c,l){return t.openBlock(),t.createBlock("div",u,[t.createVNode("ul",p,[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(i.slots,((e,n)=>(t.openBlock(),t.createBlock("li",{key:n,onClick:t.withModifiers((e=>i.selected(n)),["stop"]),class:{selected:n===o.selectedIndex},ref:e=>{e&&(i.lis[n]=e)}},t.toDisplayString(e.props.title),11,["onClick"])))),128)),t.createVNode("li",f,null,512)],512),t.createVNode("section",v,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(i.slots[o.selectedIndex]),{key:o.selectedIndex}))])])},d.__file="src/libs/Tabs.vue";var m={props:{visiable:{type:Boolean,default:!1},title:{type:String,default:"标题"},message:{type:String,default:"提示的内容"},onok:Function,oncancel:Function},components:{Button:n,Teleport:t.Teleport},setup:function(e,t){var n=function(){t.emit("update:visiable",!1)};return{hideModal:n,cancel:function(){!1!==e.oncancel()&&n()},ok:function(){!1!==e.onok()&&n()}}}};const h={key:0,class:"c-modal"},k={class:"action"},y=t.createTextVNode("取消"),b=t.createTextVNode("确认");m.render=function(e,n,o,i,c,l){const a=t.resolveComponent("Button");return t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[o.visiable?(t.openBlock(),t.createBlock("div",h,[t.createVNode("div",{class:"c-mask",onClick:n[1]||(n[1]=t.withModifiers(((...e)=>i.hideModal(...e)),["stop"]))}),t.createVNode("main",null,[t.createVNode("h3",null,t.toDisplayString(o.title),1),t.createVNode("p",null,t.toDisplayString(o.message),1),t.createVNode("section",k,[t.createVNode(a,{size:"small",onClick:t.withModifiers(i.cancel,["stop"])},{default:t.withCtx((()=>[y])),_:1},8,["onClick"]),t.createVNode(a,{size:"small",onClick:t.withModifiers(i.ok,["stop"]),type:"primary"},{default:t.withCtx((()=>[b])),_:1},8,["onClick"])])])])):t.createCommentVNode("v-if",!0)])},m.__file="src/libs/Modal.vue";var g={inheritAttrs:!1,props:{onchange:{type:Function,default:function(){}},size:{type:String,default:"middle"},disabled:{type:Boolean,default:!1}},setup:function(e,n){var o=[],i=t.ref(!1);n.slots.default&&(o=n.slots.default());return{oninput:function(e){n.emit("update:value",e.target.value)},prefix:o[0],suffix:o[1],focused:i,showShadow:function(){i.value=!0},hideShadow:function(){i.value=!1}}}};g.render=function(e,n,o,i,c,l){return t.openBlock(),t.createBlock("div",{class:["m-input",{"m-input-focused":i.focused,["m-input-"+o.size]:o.size,"m-input-disabled":o.disabled}]},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(i.prefix),{class:"m-input-prefix"})),t.createVNode("input",t.mergeProps(e.$attrs,{onChange:n[1]||(n[1]=(...e)=>o.onchange(...e)),onInput:n[2]||(n[2]=(...e)=>i.oninput(...e)),onFocus:n[3]||(n[3]=(...e)=>i.showShadow(...e)),onBlur:n[4]||(n[4]=(...e)=>i.hideShadow(...e)),disabled:o.disabled}),null,16,["disabled"]),(t.openBlock(),t.createBlock(t.resolveDynamicComponent(i.suffix),{class:"m-input-suffix"}))],2)},g.__file="src/libs/Input.vue";var B={props:{name:{type:String,default:""}}};const _={class:"m-icon"},w={class:"icon","aria-hidden":"true"};B.render=function(e,n,o,i,c,l){return t.openBlock(),t.createBlock("div",_,[(t.openBlock(),t.createBlock("svg",w,[t.createVNode("use",{"xlink:href":o.name},null,8,["xlink:href"])]))])},B.__file="src/libs/Icon.vue",function(e){var t,n,o,i,c,l,a='<svg><symbol id="icon-back-top" viewBox="0 0 1024 1024"><path d="M536.797267 281.753035c-4.232394-6.344498-10.273994-11.05887-17.347087-13.536294-3.714602-1.481747-7.735172-2.266623-12.144598-2.266623l-0.183172 0-1.147126-0.12075c-0.575098 0-1.026376 0.090051-1.601474 0.150426-4.229325 0-8.18645 0.7552-11.69332 2.145873-7.312546 2.508123-13.385868 7.312546-17.223267 13.355169l-254.17698 254.752078c-5.952572 5.921873-9.18622 13.990642-9.18622 22.691815 0 9.66922 4.110621 19.24839 11.17962 26.318412 7.010671 6.980995 16.075117 10.850116 25.501814 10.850116 8.702196 0 16.861016-3.325745 23.024389-9.457396 0.242524-0.302899 0.544399-0.544399 0.847298-0.847298 0.63445-0.544399 1.388627-1.24127 1.721201-1.783623l195.588607-195.256032 0.393973 469.799876c-0.151449 1.026376-0.151449 1.962701-0.091074 2.870374l0.060375 1.088798c0 17.675568 15.47239 31.513738 35.233456 31.513738 19.942191 0 36.07666-14.140045 36.07666-31.513738l0.364297-473.759047 195.34506 194.98281c0.632403 0.787946 1.328251 1.452071 2.084475 2.087545l0.846274 0.816598c6.104021 6.131651 14.262842 9.457396 22.961968 9.457396 9.428743 0 18.49319-3.868097 25.504884-10.850116 14.07967-14.048971 14.987343-36.016285 1.991354-49.010227L536.797267 281.753035zM887.66338 129.97933 124.346541 129.97933c-17.706267 0-32.073486 14.382569-32.073486 32.028461 0 17.675568 14.367219 32.05916 32.073486 32.05916l763.317862 0c17.677615 0 32.060183-14.383592 32.060183-32.05916C919.723563 144.361899 905.342018 129.97933 887.66338 129.97933" ></path></symbol></svg>',r=(r=document.getElementsByTagName("script"))[r.length-1].getAttribute("data-injectcss");if(r&&!e.__iconfont__svg__cssinject__){e.__iconfont__svg__cssinject__=!0;try{document.write("<style>.svgfont {display: inline-block;width: 1em;height: 1em;fill: currentColor;vertical-align: -0.1em;font-size:16px;}</style>")}catch(e){console&&console.log(e)}}function s(){c||(c=!0,o())}t=function(){var e,t,n,o;(o=document.createElement("div")).innerHTML=a,a=null,(n=o.getElementsByTagName("svg")[0])&&(n.setAttribute("aria-hidden","true"),n.style.position="absolute",n.style.width=0,n.style.height=0,n.style.overflow="hidden",e=n,(t=document.body).firstChild?(o=e,(n=t.firstChild).parentNode.insertBefore(o,n)):t.appendChild(e))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(n=function(){document.removeEventListener("DOMContentLoaded",n,!1),t()},document.addEventListener("DOMContentLoaded",n,!1)):document.attachEvent&&(o=t,i=e.document,c=!1,(l=function(){try{i.documentElement.doScroll("left")}catch(e){return void setTimeout(l,50)}s()})(),i.onreadystatechange=function(){"complete"==i.readyState&&(i.onreadystatechange=null,s())})}(window);var C={components:{Icon:B},props:{target:{default:function(){return document||window}},visibilityHeight:{default:300},duration:{type:Number,default:250},onclick:{type:Function}},setup:function(e){var n=t.ref(!1),o=t.ref();return t.onMounted((function(){e.target().onscroll=function(t){t.currentTarget.scrollTop>=e.visibilityHeight?n.value=!0:n.value=!1}})),{visibility:n,backTop:o,clickHandler:function(){var t=e.target(),n=t.scrollTop/e.duration,o=setInterval((function(){t.scrollTop-=8*n,t.scrollTop<=0&&(e.onclick&&e.onclick(),clearInterval(o),o=null)}),8)}}}};C.render=function(e,n,o,i,c,l){const a=t.resolveComponent("Icon");return t.withDirectives((t.openBlock(),t.createBlock("div",{class:"m-back-top",ref:"backTop",onClick:n[1]||(n[1]=t.withModifiers(((...e)=>i.clickHandler(...e)),["stop"]))},[t.createVNode(a,{name:"#icon-back-top"})],512)),[[t.vShow,i.visibility]])},C.__file="src/libs/BackTop.vue"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var x=function(){return(x=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};e.BackTop=C,e.Button=n,e.Icon=B,e.Input=g,e.Modal=m,e.Switch=r,e.Tab=l,e.Tabs=d,e.showModal=function(e){var n=document.createElement("div");document.body.appendChild(n);var o=t.createApp({render:function(){return t.h(m,x(x({visiable:!0},e),{"onUpdate:visiable":function(e){e||(o.unmount(n),n.remove())}}))}});o.mount(n)},Object.defineProperty(e,"__esModule",{value:!0})}));