y-design-ssr
Version:
SSR component library of YUI with Vue3
2 lines (1 loc) • 6.9 kB
JavaScript
(function(p,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(p=typeof globalThis<"u"?globalThis:p||self,s(p.tab={},p.Vue))})(this,function(p,s){"use strict";const T=r=>{const n=s.inject(r,null),o=s.getCurrentInstance();if(n&&o){const{children:e,addChild:i,removeChild:c}=n;return i(o),s.onUnmounted(()=>c(o)),{index:s.computed(()=>e.indexOf(o)),parent:n}}return{parent:null,index:s.ref(-1)}},b=(r,n)=>n?typeof n=="string"?` ${r}--${n}`:Array.isArray(n)?n.reduce((o,e)=>o+b(r,e),""):Object.keys(n).reduce((o,e)=>o+(n[e]?b(r,e):""),""):"",I=r=>(n,o)=>{let e=n,i=o;return e&&typeof e!="string"&&(i=e,e=""),e=e?`${r}__${e}`:r,`${e}${b(e,i)}`},N=()=>(r,n)=>n?`${b(`y-${r}`,n)}`:`y-${r}`,X={"pull-refresh":{pulling:"下拉刷新...",loosing:"释放刷新...",loading:"数据加载中...",success:"数据已更新",failed:"数据跟新失败,请稍后再试"},"form-item":{validateMessage:"请输入正确内容"}};s.ref("zh-CN"),s.reactive({"zh-CN":X});const v=r=>{const n=`y-${r}`;return[n,I(n),N()]},[$,A]=v("swipe"),C=$,[j,L]=v("swipe-item"),M=s.defineComponent({name:j,props:{clonenNode:{type:Object,default:null},index:{type:Number,default:-1}},setup(r,{slots:n}){const o=s.getCurrentInstance(),{parent:e}=T(C);!r.clonenNode&&o&&(e==null||e.children.push(o));const i=s.computed(()=>r.clonenNode?r.index:e==null?void 0:e.children.findIndex(f=>f.proxy===(o==null?void 0:o.proxy))),c=s.computed(()=>{const f=`${(e==null?void 0:e.itemDetail.size)||0}px`;let u="auto";const d=`${(e==null?void 0:e.itemDetail.space)||0}px`;return e!=null&&e.props.autoHeight&&(e==null?void 0:e.activeIndex)!==i.value&&(u="0"),e!=null&&e.props.vertical?{height:f,width:u,marginBottom:d}:{width:f,height:u,marginRight:d}});return()=>{var u,d;const f=((u=e==null?void 0:e.itemShowedList)==null?void 0:u.list[i.value||0])||!1;return s.createVNode("div",{class:L(),style:c.value},[f?r.clonenNode||((d=n.default)==null?void 0:d.call(n)):null])}}});var O={},R={get exports(){return O},set exports(r){O=r}};(function(r,n){(function(){function o(){var e=window,i=document;if("scrollBehavior"in i.documentElement.style&&e.__forceSmoothScrollPolyfill__!==!0)return;var c=e.HTMLElement||e.Element,f=468,u={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:c.prototype.scroll||E,scrollIntoView:c.prototype.scrollIntoView},d=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now;function q(t){var l=["MSIE ","Trident/","Edge/"];return new RegExp(l.join("|")).test(t)}var B=q(e.navigator.userAgent)?1:0;function E(t,l){this.scrollLeft=t,this.scrollTop=l}function G(t){return .5*(1-Math.cos(Math.PI*t))}function y(t){if(t===null||typeof t!="object"||t.behavior===void 0||t.behavior==="auto"||t.behavior==="instant")return!0;if(typeof t=="object"&&t.behavior==="smooth")return!1;throw new TypeError("behavior member of ScrollOptions "+t.behavior+" is not a valid value for enumeration ScrollBehavior.")}function Y(t,l){if(l==="Y")return t.clientHeight+B<t.scrollHeight;if(l==="X")return t.clientWidth+B<t.scrollWidth}function _(t,l){var a=e.getComputedStyle(t,null)["overflow"+l];return a==="auto"||a==="scroll"}function K(t){var l=Y(t,"Y")&&_(t,"Y"),a=Y(t,"X")&&_(t,"X");return l||a}function F(t){for(;t!==i.body&&K(t)===!1;)t=t.parentNode||t.host;return t}function x(t){var l=d(),a,g,h,m=(l-t.startTime)/f;m=m>1?1:m,a=G(m),g=t.startX+(t.x-t.startX)*a,h=t.startY+(t.y-t.startY)*a,t.method.call(t.scrollable,g,h),(g!==t.x||h!==t.y)&&e.requestAnimationFrame(x.bind(e,t))}function S(t,l,a){var g,h,m,w,k=d();t===i.body?(g=e,h=e.scrollX||e.pageXOffset,m=e.scrollY||e.pageYOffset,w=u.scroll):(g=t,h=t.scrollLeft,m=t.scrollTop,w=E),x({scrollable:g,method:w,startTime:k,startX:h,startY:m,x:l,y:a})}e.scroll=e.scrollTo=function(){if(arguments[0]!==void 0){if(y(arguments[0])===!0){u.scroll.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:e.scrollY||e.pageYOffset);return}S.call(e,i.body,arguments[0].left!==void 0?~~arguments[0].left:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?~~arguments[0].top:e.scrollY||e.pageYOffset)}},e.scrollBy=function(){if(arguments[0]!==void 0){if(y(arguments[0])){u.scrollBy.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:0,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:0);return}S.call(e,i.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset))}},c.prototype.scroll=c.prototype.scrollTo=function(){if(arguments[0]!==void 0){if(y(arguments[0])===!0){if(typeof arguments[0]=="number"&&arguments[1]===void 0)throw new SyntaxError("Value could not be converted");u.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left:typeof arguments[0]!="object"?~~arguments[0]:this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top:arguments[1]!==void 0?~~arguments[1]:this.scrollTop);return}var t=arguments[0].left,l=arguments[0].top;S.call(this,this,typeof t>"u"?this.scrollLeft:~~t,typeof l>"u"?this.scrollTop:~~l)}},c.prototype.scrollBy=function(){if(arguments[0]!==void 0){if(y(arguments[0])===!0){u.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop);return}this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior})}},c.prototype.scrollIntoView=function(){if(y(arguments[0])===!0){u.scrollIntoView.call(this,arguments[0]===void 0?!0:arguments[0]);return}var t=F(this),l=t.getBoundingClientRect(),a=this.getBoundingClientRect();t!==i.body?(S.call(this,t,t.scrollLeft+a.left-l.left,t.scrollTop+a.top-l.top),e.getComputedStyle(t).position!=="fixed"&&e.scrollBy({left:l.left,top:l.top,behavior:"smooth"})):e.scrollBy({left:a.left,top:a.top,behavior:"smooth"})}}r.exports={polyfill:o}})()})(R);const[V,J]=v("tabs"),P=V;function D(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!s.isVNode(r)}const[H]=v("tab"),z=s.defineComponent({name:H,props:{title:{type:String,default:""},name:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1}},setup(r,{slots:n}){const{parent:o}=T(P),e=s.getCurrentInstance();return e.proxy&&(o==null||o.children.push(e.proxy)),s.onBeforeUnmount(()=>{o&&(o.children=o.children.filter(i=>i!==e.proxy))}),()=>{let i;return n.default?s.createVNode(M,null,D(i=n.default())?i:{default:()=>[i]}):null}}});function U(r){const n=r;return n.install=o=>{const{name:e}=r;e&&o.component(e,r)},n}const W=U(z);p.default=W,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});