You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
5.8 KiB
2 lines
5.8 KiB
import{b as g,dc as J,d as I,f as Q,di as j,V as R,M as Y,N as Z,da as ee,de as ae,r as ne,e_ as te,q as le,O as re,P as oe,R as ue,T as ie,U as p,be as B,bL as ce,fH as fe}from"./index-f4658ae7.js";import{u as de}from"./useRefs-2f4603d7.js";var se={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3z"}}]},name:"star",theme:"filled"};const ve=se;function M(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},u=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(u=u.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),u.forEach(function(s){be(r,s,t[s])})}return r}function be(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var D=function(e,t){var u=M({},e,t.attrs);return g(J,M({},u,{icon:ve}),null)};D.displayName="StarFilled";D.inheritAttrs=!1;const me=D;function he(r){var e=r.pageXOffset,t="scrollLeft";if(typeof e!="number"){var u=r.document;e=u.documentElement[t],typeof e!="number"&&(e=u.body[t])}return e}function ge(r){var e,t,u=r.ownerDocument,s=u.body,m=u&&u.documentElement,w=r.getBoundingClientRect();return e=w.left,t=w.top,e-=m.clientLeft||s.clientLeft||0,t-=m.clientTop||s.clientTop||0,{left:e,top:t}}function ye(r){var e=ge(r),t=r.ownerDocument,u=t.defaultView||t.parentWindow;return e.left+=he(u),e.left}var Ce={value:Number,index:Number,prefixCls:String,allowHalf:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},character:R.any,characterRender:Function,focused:{type:Boolean,default:void 0},count:Number,onClick:Function,onHover:Function};const we=I({name:"Star",inheritAttrs:!1,props:Ce,emits:["hover","click"],setup:function(e,t){var u=t.slots,s=t.emit,m=function(f){var i=e.index;s("hover",f,i)},w=function(f){var i=e.index;s("click",f,i)},V=function(f){var i=e.index;f.keyCode===13&&s("click",f,i)},x=Q(function(){var o=e.prefixCls,f=e.index,i=e.value,F=e.allowHalf,y=e.focused,C=f+1,h=o;return i===0&&f===0&&y?h+=" ".concat(o,"-focused"):F&&i+.5>=C&&i<C?(h+=" ".concat(o,"-half ").concat(o,"-active"),y&&(h+=" ".concat(o,"-focused"))):(h+=C<=i?" ".concat(o,"-full"):" ".concat(o,"-zero"),C===i&&y&&(h+=" ".concat(o,"-focused"))),h});return function(){var o=e.disabled,f=e.prefixCls,i=e.characterRender,F=e.index,y=e.count,C=e.value,h=j(u,e,"character"),a=g("li",{class:x.value},[g("div",{onClick:o?null:w,onKeydown:o?null:V,onMousemove:o?null:m,role:"radio","aria-checked":C>F?"true":"false","aria-posinset":F+1,"aria-setsize":y,tabindex:o?-1:0},[g("div",{class:"".concat(f,"-first")},[h]),g("div",{class:"".concat(f,"-second")},[h])])]);return i&&(a=i(a,e)),a}}});var xe=function(){return{prefixCls:String,count:Number,value:Number,allowHalf:{type:Boolean,default:void 0},allowClear:{type:Boolean,default:void 0},tooltips:Array,disabled:{type:Boolean,default:void 0},character:R.any,autofocus:{type:Boolean,default:void 0},tabindex:R.oneOfType([R.number,R.string]),direction:String,id:String,onChange:Function,onHoverChange:Function,"onUpdate:value":Function,onFocus:Function,onBlur:Function,onKeydown:Function}},Fe=I({name:"ARate",inheritAttrs:!1,props:Z(xe(),{value:0,count:5,allowHalf:!1,allowClear:!0,tabindex:0,direction:"ltr"}),setup:function(e,t){var u=t.slots,s=t.attrs,m=t.emit,w=t.expose,V=ee("rate",e),x=V.prefixCls,o=V.direction,f=ae(),i=ne(),F=de(),y=te(F,2),C=y[0],h=y[1],a=le({value:e.value,focused:!1,cleanedValue:null,hoverValue:void 0});re(function(){return e.value},function(){a.value=e.value});var A=function(n){return fe(h.value.get(n))},P=function(n,l){var v=o.value==="rtl",c=n+1;if(e.allowHalf){var b=A(n),O=ye(b),k=b.clientWidth;(v&&l-O>k/2||!v&&l-O<k/2)&&(c-=.5)}return c},S=function(n){e.value===void 0&&(a.value=n),m("update:value",n),m("change",n),f.onFieldChange()},_=function(n,l){var v=P(l,n.pageX);v!==a.cleanedValue&&(a.hoverValue=v,a.cleanedValue=null),m("hoverChange",v)},N=function(){a.hoverValue=void 0,a.cleanedValue=null,m("hoverChange",void 0)},K=function(n,l){var v=e.allowClear,c=P(l,n.pageX),b=!1;v&&(b=c===a.value),N(),S(b?0:c),a.cleanedValue=b?c:null},E=function(n){a.focused=!0,m("focus",n)},$=function(n){a.focused=!1,m("blur",n),f.onFieldBlur()},z=function(n){var l=n.keyCode,v=e.count,c=e.allowHalf,b=o.value==="rtl";l===B.RIGHT&&a.value<v&&!b?(c?a.value+=.5:a.value+=1,S(a.value),n.preventDefault()):l===B.LEFT&&a.value>0&&!b||l===B.RIGHT&&a.value>0&&b?(c?a.value-=.5:a.value-=1,S(a.value),n.preventDefault()):l===B.LEFT&&a.value<v&&b&&(c?a.value+=.5:a.value+=1,S(a.value),n.preventDefault()),m("keydown",n)},L=function(){e.disabled||i.value.focus()},X=function(){e.disabled||i.value.blur()};w({focus:L,blur:X}),oe(function(){var d=e.autofocus,n=e.disabled;d&&!n&&L()});var G=function(n,l){var v=l.index,c=e.tooltips;return c?g(ce,{title:c[v]},{default:function(){return[n]}}):n},U=j(u,e,"character")||g(me,null,null);return function(){for(var d=e.count,n=e.allowHalf,l=e.disabled,v=e.tabindex,c=e.id,b=c===void 0?f.id.value:c,O=s.class,k=s.style,T=[],W=l?"".concat(x.value,"-disabled"):"",H=0;H<d;H++)T.push(g(we,{ref:C(H),key:H,index:H,count:d,disabled:l,prefixCls:"".concat(x.value,"-star"),allowHalf:n,value:a.hoverValue===void 0?a.value:a.hoverValue,onClick:K,onHover:_,character:U,characterRender:G,focused:a.focused},null));var q=ue(x.value,W,O,ie({},"".concat(x.value,"-rtl"),o.value==="rtl"));return g("ul",p(p({},s),{},{id:b,class:q,style:k,onMouseleave:l?null:N,tabindex:l?-1:v,onFocus:l?null:E,onBlur:l?null:$,onKeydown:l?null:z,ref:i,role:"radiogroup"}),[T])}}});const Re=Y(Fe);export{Re as R};
|