1 |
- !function(){function e(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,a){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,t,o=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(n=r.next()).done)&&(o.push(n.value),!a||o.length!==a);l=!0);}catch(u){i=!0,t=u}finally{try{l||null==r.return||r.return()}finally{if(i)throw t}}return o}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return a(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,a){(null==a||a>e.length)&&(a=e.length);for(var r=0,n=new Array(a);r<a;r++)n[r]=e[r];return n}var r=document.createElement("style");r.innerHTML=":root{--van-rate-icon-size: .53333rem;--van-rate-icon-gutter: var(--van-padding-base);--van-rate-icon-void-color: var(--van-gray-5);--van-rate-icon-full-color: var(--van-danger-color);--van-rate-icon-disabled-color: var(--van-gray-5)}.van-rate{display:inline-flex;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-wrap:wrap}.van-rate__item{position:relative}.van-rate__item:not(:last-child){padding-right:var(--van-rate-icon-gutter)}.van-rate__icon{display:block;width:1em;color:var(--van-rate-icon-void-color);font-size:var(--van-rate-icon-size)}.van-rate__icon--half{position:absolute;top:0;left:0;overflow:hidden}.van-rate__icon--full{color:var(--van-rate-icon-full-color)}.van-rate__icon--disabled{color:var(--van-rate-icon-disabled-color)}.van-rate--disabled{cursor:not-allowed}.van-rate--readonly{cursor:default}\n",document.head.appendChild(r),System.register(["./index-legacy.fba2875c.js","./use-refs-legacy.2affcb61.js"],(function(a){"use strict";var r,n,t,o,l,i,u,c,s,d,f,v,y,h,m,b,p;return{setters:[function(e){r=e.A,n=e.E,t=e.$,o=e.aa,l=e.G,i=e.aZ,u=e.d,c=e.ah,s=e.V,d=e.a_,f=e.j,v=e.ap,y=e.a1,h=e.M,m=e.X,b=e.N},function(e){p=e.u}],execute:function(){var g=e(r("rate"),2),w=g[0],_=g[1];var x={size:n,icon:t("star"),color:String,count:o(5),gutter:n,readonly:Boolean,disabled:Boolean,voidIcon:t("star-o"),allowHalf:Boolean,voidColor:String,touchable:l,iconPrefix:String,modelValue:i(0),disabledColor:String},z=u({name:w,props:x,emits:["change","update:modelValue"],setup:function(a,r){var n,t=r.emit,o=c(),l=e(p(),2),i=l[0],u=l[1],b=function(){return a.readonly||a.disabled||!a.touchable},g=s((function(){return Array(+a.count).fill("").map((function(e,r){return function(e,a,r,n){if(e>=a)return{status:"full",value:1};if(e+.5>=a&&r&&!n)return{status:"half",value:.5};if(e+1>=a&&r&&n){var t=Math.pow(10,10);return{status:"half",value:Math.round((e-a+1)*t)/t}}return{status:"void",value:0}}(a.modelValue,r+1,a.allowHalf,a.readonly)}))})),w=function(){var e=i.value.map(m);n=[],e.forEach((function(e,r){a.allowHalf?n.push({score:r+.5,left:e.left},{score:r+1,left:e.left+e.width/2}):n.push({score:r+1,left:e.left})}))},x=function(e){for(var r=n.length-1;r>0;r--)if(e>n[r].left)return n[r].score;return a.allowHalf?.5:1},z=function(e){a.disabled||a.readonly||e===a.modelValue||(t("update:modelValue",e),t("change",e))},S=function(e){b()||(o.start(e),w())},A=function(e){if(!b()&&(o.move(e),o.isHorizontal())){var a=e.touches[0].clientX;v(e),z(x(a))}},C=function(e,r){var n,t=a.icon,o=a.size,l=a.color,i=a.count,c=a.gutter,s=a.voidIcon,d=a.disabled,v=a.voidColor,m=a.allowHalf,b=a.iconPrefix,p=a.disabledColor,g=r+1,S="full"===e.status,A="void"===e.status,C=m&&e.value>0&&e.value<1;c&&g!==+i&&(n={paddingRight:y(c)});return f("div",{key:r,ref:u(r),role:"radio",style:n,class:_("item"),tabindex:d?void 0:0,"aria-setsize":i,"aria-posinset":g,"aria-checked":!A,onClick:function(e){w(),z(m?x(e.clientX):g)}},[f(h,{size:o,name:S?t:s,class:_("icon",{disabled:d,full:S}),color:d?p:S?l:v,classPrefix:b},null),C&&f(h,{size:o,style:{width:e.value+"em"},name:A?s:t,class:_("icon",["half",{disabled:d,full:!A}]),color:d?p:A?v:l,classPrefix:b},null)])};return d((function(){return a.modelValue})),function(){return f("div",{role:"radiogroup",class:_({readonly:a.readonly,disabled:a.disabled}),tabindex:a.disabled?void 0:0,"aria-disabled":a.disabled,"aria-readonly":a.readonly,onTouchstart:S,onTouchmove:A},[g.value.map(C)])}}});a("R",b(z))}}}))}();
|