1 |
- !function(){function e(e,a){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,t,o=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(n=a.next()).done)&&(o.push(n.value),!r||o.length!==r);l=!0);}catch(u){i=!0,t=u}finally{try{l||null==a.return||a.return()}finally{if(i)throw t}}return o}(e,a)||function(e,a){if(!e)return;if("string"==typeof e)return r(e,a);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 r(e,a)}(e,a)||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 r(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,n=new Array(r);a<r;a++)n[a]=e[a];return n}var a=document.createElement("style");a.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(a),System.register(["./ResizeObserver.es-legacy.8d60aee1.js","./use-refs-legacy.82f31dee.js"],(function(r){"use strict";var a,n,t,o,l,i,u,c,s,d,f,v,y,m,b,h,p;return{setters:[function(e){a=e.E,n=e.G,t=e.a0,o=e.ab,l=e.H,i=e.a_,u=e.d,c=e.ai,s=e.W,d=e.a$,f=e.j,v=e.aq,y=e.a2,m=e.N,b=e.Y,h=e.O},function(e){p=e.u}],execute:function(){var g=e(a("rate"),2),w=g[0],_=g[1];var z={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},x=u({name:w,props:z,emits:["change","update:modelValue"],setup:function(r,a){var n,t=a.emit,o=c(),l=e(p(),2),i=l[0],u=l[1],h=function(){return r.readonly||r.disabled||!r.touchable},g=s((function(){return Array(+r.count).fill("").map((function(e,a){return function(e,r,a,n){if(e>=r)return{status:"full",value:1};if(e+.5>=r&&a&&!n)return{status:"half",value:.5};if(e+1>=r&&a&&n){var t=Math.pow(10,10);return{status:"half",value:Math.round((e-r+1)*t)/t}}return{status:"void",value:0}}(r.modelValue,a+1,r.allowHalf,r.readonly)}))})),w=function(){var e=i.value.map(b);n=[],e.forEach((function(e,a){r.allowHalf?n.push({score:a+.5,left:e.left},{score:a+1,left:e.left+e.width/2}):n.push({score:a+1,left:e.left})}))},z=function(e){for(var a=n.length-1;a>0;a--)if(e>n[a].left)return n[a].score;return r.allowHalf?.5:1},x=function(e){r.disabled||r.readonly||e===r.modelValue||(t("update:modelValue",e),t("change",e))},S=function(e){h()||(o.start(e),w())},H=function(e){if(!h()&&(o.move(e),o.isHorizontal())){var r=e.touches[0].clientX;v(e),x(z(r))}},A=function(e,a){var n,t=r.icon,o=r.size,l=r.color,i=r.count,c=r.gutter,s=r.voidIcon,d=r.disabled,v=r.voidColor,b=r.allowHalf,h=r.iconPrefix,p=r.disabledColor,g=a+1,S="full"===e.status,H="void"===e.status,A=b&&e.value>0&&e.value<1;c&&g!==+i&&(n={paddingRight:y(c)});return f("div",{key:a,ref:u(a),role:"radio",style:n,class:_("item"),tabindex:d?void 0:0,"aria-setsize":i,"aria-posinset":g,"aria-checked":!H,onClick:function(e){w(),x(b?z(e.clientX):g)}},[f(m,{size:o,name:S?t:s,class:_("icon",{disabled:d,full:S}),color:d?p:S?l:v,classPrefix:h},null),A&&f(m,{size:o,style:{width:e.value+"em"},name:H?s:t,class:_("icon",["half",{disabled:d,full:!H}]),color:d?p:H?v:l,classPrefix:h},null)])};return d((function(){return r.modelValue})),function(){return f("div",{role:"radiogroup",class:_({readonly:r.readonly,disabled:r.disabled}),tabindex:r.disabled?void 0:0,"aria-disabled":r.disabled,"aria-readonly":r.readonly,onTouchstart:S,onTouchmove:H},[g.value.map(A)])}}});r("R",h(x))}}}))}();
|