@spark-ui/rating
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.2.1](https://github.com/adevinta/spark/compare/@spark-ui/rating@0.2.0...@spark-ui/rating@0.2.1) (2023-11-15) | ||
**Note:** Version bump only for package @spark-ui/rating | ||
# [0.2.0](https://github.com/adevinta/spark/compare/@spark-ui/rating@0.1.1...@spark-ui/rating@0.2.0) (2023-11-03) | ||
@@ -8,0 +12,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),at=require("class-variance-authority"),we=require("@spark-ui/icon");var Rt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Je(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Ht={exports:{}};(function(o,_){var g="__lodash_hash_undefined__",v=1,y=2,F=9007199254740991,P="[object Arguments]",ot="[object Array]",pt="[object AsyncFunction]",vt="[object Boolean]",$="[object Date]",q="[object Error]",X="[object Function]",_t="[object GeneratorFunction]",B="[object Map]",Y="[object Number]",Ct="[object Null]",M="[object Object]",m="[object Promise]",w="[object Proxy]",A="[object RegExp]",O="[object Set]",tt="[object String]",it="[object Symbol]",ut="[object Undefined]",z="[object WeakMap]",L="[object ArrayBuffer]",j="[object DataView]",Tt=/^\[object .+?Constructor\]$/,H=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[P]=u[ot]=u[L]=u[vt]=u[j]=u[$]=u[q]=u[X]=u[B]=u[Y]=u[M]=u[A]=u[O]=u[tt]=u[z]=!1;var Wt=typeof Rt=="object"&&Rt&&Rt.Object===Object&&Rt,Ae=typeof self=="object"&&self&&self.Object===Object&&self,N=Wt||Ae||Function("return this")(),Gt=_&&!_.nodeType&&_,Kt=Gt&&o&&!o.nodeType&&o,Jt=Kt&&Kt.exports===Gt,It=Jt&&Wt.process,Qt=function(){try{return It&&It.binding&&It.binding("util")}catch{}}(),Xt=Qt&&Qt.isTypedArray;function ke(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Ee(t){var e=-1,r=Array(t.size);return t.forEach(function(n,l){r[++e]=[l,n]}),r}function Se(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Yt,te,ee,Me=Array.prototype,Ne=Function.prototype,yt=Object.prototype,Ft=N["__core-js_shared__"],re=Ne.toString,E=yt.hasOwnProperty,ne=(Yt=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||""))?"Symbol(src)_1."+Yt:"",ae=yt.toString,Re=RegExp("^"+re.call(E).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=Jt?N.Buffer:void 0,bt=N.Symbol,ie=N.Uint8Array,ue=yt.propertyIsEnumerable,Ce=Me.splice,W=bt?bt.toStringTag:void 0,ce=Object.getOwnPropertySymbols,Te=oe?oe.isBuffer:void 0,Ie=(te=Object.keys,ee=Object,function(t){return te(ee(t))}),Pt=et(N,"DataView"),ct=et(N,"Map"),$t=et(N,"Promise"),Bt=et(N,"Set"),Lt=et(N,"WeakMap"),lt=et(Object,"create"),Fe=J(Pt),Pe=J(ct),$e=J($t),Be=J(Bt),Le=J(Lt),le=bt?bt.prototype:void 0,Ut=le?le.valueOf:void 0;function G(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function R(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function K(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function gt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new K;++e<r;)this.add(t[e])}function U(t){var e=this.__data__=new R(t);this.size=e.size}function Ue(t,e){var r=wt(t),n=!r&&He(t),l=!r&&!n&&Vt(t),a=!r&&!n&&!l&&be(t),f=r||n||l||a,d=f?function(p,S){for(var C=-1,b=Array(p);++C<p;)b[C]=S(C);return b}(t.length,String):[],k=d.length;for(var h in t)!e&&!E.call(t,h)||f&&(h=="length"||l&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||qe(h,k))||d.push(h);return d}function mt(t,e){for(var r=t.length;r--;)if(pe(t[r][0],e))return r;return-1}function st(t){return t==null?t===void 0?ut:Ct:W&&W in Object(t)?function(e){var r=E.call(e,W),n=e[W];try{e[W]=void 0;var l=!0}catch{}var a=ae.call(e);return l&&(r?e[W]=n:delete e[W]),a}(t):function(e){return ae.call(e)}(t)}function se(t){return ft(t)&&st(t)==P}function fe(t,e,r,n,l){return t===e||(t==null||e==null||!ft(t)&&!ft(e)?t!=t&&e!=e:function(a,f,d,k,h,p){var S=wt(a),C=wt(f),b=S?ot:V(a),T=C?ot:V(f),rt=(b=b==P?M:b)==M,Ot=(T=T==P?M:T)==M,nt=b==T;if(nt&&Vt(a)){if(!Vt(f))return!1;S=!0,rt=!1}if(nt&&!rt)return p||(p=new U),S||be(a)?de(a,f,d,k,h,p):function(c,i,zt,D,Dt,x,I){switch(zt){case j:if(c.byteLength!=i.byteLength||c.byteOffset!=i.byteOffset)return!1;c=c.buffer,i=i.buffer;case L:return!(c.byteLength!=i.byteLength||!x(new ie(c),new ie(i)));case vt:case $:case Y:return pe(+c,+i);case q:return c.name==i.name&&c.message==i.message;case A:case tt:return c==i+"";case B:var Z=Ee;case O:var ht=D&v;if(Z||(Z=Se),c.size!=i.size&&!ht)return!1;var xt=I.get(c);if(xt)return xt==i;D|=y,I.set(c,i);var Zt=de(Z(c),Z(i),D,Dt,x,I);return I.delete(c),Zt;case it:if(Ut)return Ut.call(c)==Ut.call(i)}return!1}(a,f,b,d,k,h,p);if(!(d&v)){var dt=rt&&E.call(a,"__wrapped__"),ge=Ot&&E.call(f,"__wrapped__");if(dt||ge){var Ge=dt?a.value():a,Ke=ge?f.value():f;return p||(p=new U),h(Ge,Ke,d,k,p)}}return nt?(p||(p=new U),function(c,i,zt,D,Dt,x){var I=zt&v,Z=he(c),ht=Z.length,xt=he(i),Zt=xt.length;if(ht!=Zt&&!I)return!1;for(var At=ht;At--;){var Q=Z[At];if(!(I?Q in i:E.call(i,Q)))return!1}var me=x.get(c);if(me&&x.get(i))return me==i;var kt=!0;x.set(c,i),x.set(i,c);for(var qt=I;++At<ht;){var Et=c[Q=Z[At]],St=i[Q];if(D)var je=I?D(St,Et,Q,i,c,x):D(Et,St,Q,c,i,x);if(!(je===void 0?Et===St||Dt(Et,St,zt,D,x):je)){kt=!1;break}qt||(qt=Q=="constructor")}if(kt&&!qt){var Mt=c.constructor,Nt=i.constructor;Mt==Nt||!("constructor"in c)||!("constructor"in i)||typeof Mt=="function"&&Mt instanceof Mt&&typeof Nt=="function"&&Nt instanceof Nt||(kt=!1)}return x.delete(c),x.delete(i),kt}(a,f,d,k,h,p)):!1}(t,e,r,n,fe,l))}function Ve(t){return!(!ye(t)||function(e){return!!ne&&ne in e}(t))&&(ve(t)?Re:Tt).test(J(t))}function De(t){if(r=(e=t)&&e.constructor,n=typeof r=="function"&&r.prototype||yt,e!==n)return Ie(t);var e,r,n,l=[];for(var a in Object(t))E.call(t,a)&&a!="constructor"&&l.push(a);return l}function de(t,e,r,n,l,a){var f=r&v,d=t.length,k=e.length;if(d!=k&&!(f&&k>d))return!1;var h=a.get(t);if(h&&a.get(e))return h==e;var p=-1,S=!0,C=r&y?new gt:void 0;for(a.set(t,e),a.set(e,t);++p<d;){var b=t[p],T=e[p];if(n)var rt=f?n(T,b,p,e,t,a):n(b,T,p,t,e,a);if(rt!==void 0){if(rt)continue;S=!1;break}if(C){if(!ke(e,function(Ot,nt){if(dt=nt,!C.has(dt)&&(b===Ot||l(b,Ot,r,n,a)))return C.push(nt);var dt})){S=!1;break}}else if(b!==T&&!l(b,T,r,n,a)){S=!1;break}}return a.delete(t),a.delete(e),S}function he(t){return function(e,r,n){var l=r(e);return wt(e)?l:function(a,f){for(var d=-1,k=f.length,h=a.length;++d<k;)a[h+d]=f[d];return a}(l,n(e))}(t,We,Ze)}function jt(t,e){var r,n,l=t.__data__;return((n=typeof(r=e))=="string"||n=="number"||n=="symbol"||n=="boolean"?r!=="__proto__":r===null)?l[typeof e=="string"?"string":"hash"]:l.map}function et(t,e){var r=function(n,l){return n?.[l]}(t,e);return Ve(r)?r:void 0}G.prototype.clear=function(){this.__data__=lt?lt(null):{},this.size=0},G.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},G.prototype.get=function(t){var e=this.__data__;if(lt){var r=e[t];return r===g?void 0:r}return E.call(e,t)?e[t]:void 0},G.prototype.has=function(t){var e=this.__data__;return lt?e[t]!==void 0:E.call(e,t)},G.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=lt&&e===void 0?g:e,this},R.prototype.clear=function(){this.__data__=[],this.size=0},R.prototype.delete=function(t){var e=this.__data__,r=mt(e,t);return!(r<0)&&(r==e.length-1?e.pop():Ce.call(e,r,1),--this.size,!0)},R.prototype.get=function(t){var e=this.__data__,r=mt(e,t);return r<0?void 0:e[r][1]},R.prototype.has=function(t){return mt(this.__data__,t)>-1},R.prototype.set=function(t,e){var r=this.__data__,n=mt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},K.prototype.clear=function(){this.size=0,this.__data__={hash:new G,map:new(ct||R),string:new G}},K.prototype.delete=function(t){var e=jt(this,t).delete(t);return this.size-=e?1:0,e},K.prototype.get=function(t){return jt(this,t).get(t)},K.prototype.has=function(t){return jt(this,t).has(t)},K.prototype.set=function(t,e){var r=jt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},gt.prototype.add=gt.prototype.push=function(t){return this.__data__.set(t,g),this},gt.prototype.has=function(t){return this.__data__.has(t)},U.prototype.clear=function(){this.__data__=new R,this.size=0},U.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},U.prototype.get=function(t){return this.__data__.get(t)},U.prototype.has=function(t){return this.__data__.has(t)},U.prototype.set=function(t,e){var r=this.__data__;if(r instanceof R){var n=r.__data__;if(!ct||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new K(n)}return r.set(t,e),this.size=r.size,this};var Ze=ce?function(t){return t==null?[]:(t=Object(t),function(e,r){for(var n=-1,l=e==null?0:e.length,a=0,f=[];++n<l;){var d=e[n];r(d,n,e)&&(f[a++]=d)}return f}(ce(t),function(e){return ue.call(t,e)}))}:function(){return[]},V=st;function qe(t,e){return!!(e=e??F)&&(typeof t=="number"||H.test(t))&&t>-1&&t%1==0&&t<e}function J(t){if(t!=null){try{return re.call(t)}catch{}try{return t+""}catch{}}return""}function pe(t,e){return t===e||t!=t&&e!=e}(Pt&&V(new Pt(new ArrayBuffer(1)))!=j||ct&&V(new ct)!=B||$t&&V($t.resolve())!=m||Bt&&V(new Bt)!=O||Lt&&V(new Lt)!=z)&&(V=function(t){var e=st(t),r=e==M?t.constructor:void 0,n=r?J(r):"";if(n)switch(n){case Fe:return j;case Pe:return B;case $e:return m;case Be:return O;case Le:return z}return e});var He=se(function(){return arguments}())?se:function(t){return ft(t)&&E.call(t,"callee")&&!ue.call(t,"callee")},wt=Array.isArray,Vt=Te||function(){return!1};function ve(t){if(!ye(t))return!1;var e=st(t);return e==X||e==_t||e==pt||e==w}function _e(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=F}function ye(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function ft(t){return t!=null&&typeof t=="object"}var be=Xt?function(t){return function(e){return t(e)}}(Xt):function(t){return ft(t)&&_e(t.length)&&!!u[st(t)]};function We(t){return(e=t)!=null&&_e(e.length)&&!ve(e)?Ue(t):De(t);var e}o.exports=function(t,e){return fe(t,e)}})(Ht,Ht.exports);const Qe=Je(Ht.exports),ze=s.forwardRef(({title:o,fill:_="currentColor",stroke:g="none",...v},y)=>s.createElement("svg",{ref:y,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","data-title":"StarFill",...o&&{"data-title":o},fill:_,stroke:g,...v,dangerouslySetInnerHTML:{__html:(o===void 0?"":`<title>${o}</title>`)+'<path d="m11.04,2.25c-.25.17-.5.42-.67.75l-2.08,4.58-4.74.67c-.33,0-.58.17-.91.33-.25.25-.5.5-.58.83-.08.42-.08.75,0,1.08.08.33.25.67.5.92l3.49,3.49-.83,4.99c-.08.33,0,.67.08,1,.08.33.33.58.58.75.25.17.58.33.91.33s.67-.08.91-.17l4.32-2.33,4.32,2.33c.25.17.58.25.91.17.33,0,.67-.17.91-.33.25-.17.5-.5.58-.75.08-.33.17-.67.08-1l-.83-4.99,3.41-3.58c.25-.25.42-.5.5-.83.08-.33.08-.67,0-1-.08-.33-.25-.58-.5-.83-.25-.25-.58-.33-.83-.42l-4.74-.75-2.16-4.49c-.17-.33-.33-.58-.67-.75-.25-.17-.5-.25-.75-.25h-.33c-.42.08-.67.17-.91.25Z"/>'}}));ze.displayName="StarFill";const xe=s.forwardRef(({title:o,fill:_="currentColor",stroke:g="none",...v},y)=>s.createElement("svg",{ref:y,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","data-title":"StarOutline",...o&&{"data-title":o},fill:_,stroke:g,...v,dangerouslySetInnerHTML:{__html:(o===void 0?"":`<title>${o}</title>`)+'<path fill-rule="evenodd" d="m12.02,4.31l-2.01,4.22c-.12.27-.3.5-.53.68-.23.18-.5.29-.79.32l-4.47.69,3.24,3.24c.21.2.36.45.45.73.09.28.11.58.06.87h0s-.78,4.73-.78,4.73l4.03-2.21s.02,0,.03-.01c.25-.13.52-.19.79-.19s.55.07.79.19c0,0,.02,0,.03.01l4.02,2.21-.78-4.66h0c-.05-.29-.03-.59.06-.87.09-.28.24-.52.44-.72l3.21-3.31-4.45-.68c-.28-.04-.56-.15-.79-.32-.23-.18-.41-.41-.53-.68l-2.01-4.22Zm4.91,15.92h0s0,0,0,0ZM11.09,2.28c.28-.18.6-.28.93-.28s.65.1.93.28c.27.18.49.44.63.74l2.16,4.53,4.77.73c.32.05.62.18.87.4.25.22.44.5.54.83.1.32.11.67.03,1-.08.32-.25.62-.48.85l-3.44,3.55.83,4.98c.06.33.02.68-.1.99-.12.31-.33.58-.59.78s-.58.32-.9.34c-.32.02-.65-.05-.94-.21h0s-4.3-2.36-4.3-2.36l-4.3,2.36h0c-.29.16-.61.23-.94.21-.32-.02-.64-.14-.9-.34s-.47-.47-.59-.78c-.12-.31-.16-.65-.1-.99h0s.83-5.04.83-5.04l-3.48-3.49c-.24-.24-.41-.54-.49-.88-.08-.34-.06-.69.05-1.02.11-.33.31-.61.58-.82.25-.2.56-.33.88-.36l4.75-.73,2.16-4.53c.14-.3.36-.56.63-.74Z"/>'}}));xe.displayName="StarOutline";const Xe=at.cx("peer-hover:[&_>_div]:!w-none"),Ye=at.cva(["peer","after:inset-none","group","relative","after:block after:absolute"],{variants:{disabled:{true:"opacity-dim-3",false:""},readOnly:{true:"",false:""},gap:{sm:["after:w-[calc(100%_+_theme(spacing.sm))]","last-of-type:after:content-none"],md:["after:w-[calc(100%_+_theme(spacing.md))]","last-of-type:after:content-none"]}},compoundVariants:[{readOnly:!1,disabled:!1,className:at.cx(Xe,"cursor-pointer")}],defaultVariants:{disabled:!1,readOnly:!1,gap:"sm"}}),Oe=at.cva("",{variants:{size:{sm:"text-caption-link",md:"text-body-1",lg:"text-display-1"},design:{filled:["text-main-variant","group-[[data-part=star][data-hovered]]:text-main-variant-hovered"],outlined:["text-on-surface/dim-3"]}}}),tr=s.forwardRef(({value:o,size:_,disabled:g,readOnly:v,onClick:y,onMouseEnter:F},P)=>s.createElement("div",{ref:P,onMouseEnter:F,className:Ye({gap:_==="lg"?"md":"sm",disabled:g,readOnly:v}),"data-part":"star",onClick:y},s.createElement("div",{className:at.cx("absolute z-raised overflow-hidden","group-[[data-part=star][data-hovered]]:overflow-visible"),style:{width:100*o+"%"}},s.createElement(we.Icon,{className:Oe({size:_,design:"filled"})},s.createElement(ze,null))),s.createElement(we.Icon,{className:Oe({size:_,design:"outlined"})},s.createElement(xe,null))));function er(o){return o===void 0?0:o-Math.floor(o)>.74?Math.ceil(o):Math.floor(o)}function rr({value:o,index:_}){if(o===void 0)return 0;const g=_+1,v=(y=o,.5*Math.round(y/.5));var y;return Math.ceil(v)<g?0:v>=g?1:.5}const nr=s.forwardRef(({defaultValue:o,value:_,onValueChange:g,size:v="md",disabled:y,readOnly:F,name:P,id:ot,...pt},vt)=>{const $=s.useRef(null),q=s.useRef([]),[X,_t]=function(m,w,A){const O=m!==void 0,{current:tt}=s.useRef(O?m:w),[it,ut]=s.useState(w),z=O?m:it,L=s.useCallback((j,Tt=(H,u)=>!Qe(H,u))=>{const H=typeof j!="function"?j:j(z);Tt(z,H)&&!O&&ut(H),A&&A(H)},[O,z,A]);return[z,L,O,tt]}(_,o,g),B=s.useRef(X),Y=!(y||F),Ct=s.useCallback(m=>{m&&q.current.push(m)},[]);function M(){$.current?.removeAttribute("data-clicked")}return s.createElement("div",{className:"relative",ref:vt,"data-spark-component":"rating",...pt,onMouseLeave:function(){q.current.forEach(m=>m.removeAttribute("data-hovered"))}},s.createElement("input",{name:P,id:ot,"aria-label":pt["aria-label"],ref:$,"data-part":"input",className:"peer absolute inset-none opacity-0",type:"range",min:"0",max:"5",step:1,disabled:y,readOnly:F,value:er(X),onChange:m=>Y&&function(w){B.current!==Number(w.target.value)&&(B.current=Number(w.target.value),_t(Number(w.target.value)))}(m),onKeyDown:M,onBlur:M}),s.createElement("div",{className:at.cx(v==="lg"?"gap-x-md":"gap-x-sm","flex","peer-focus-visible:u-ring peer-[[data-part=input][data-clicked]]:shadow-none")},Array.from({length:5}).map((m,w)=>s.createElement(tr,{disabled:y,readOnly:F,size:v,onClick:()=>Y&&function(A){$.current&&(_t(A+1),B.current=A+1,$.current.focus(),$.current.setAttribute("data-clicked",""))}(w),onMouseEnter:A=>Y&&function({currentTarget:O}){const tt=q.current.findIndex(j=>j===O),[it,ut]=(z=q.current,L=tt+1,[z.slice(0,L),z.slice(L)]);var z,L;it.forEach(j=>j.setAttribute("data-hovered","")),ut.forEach(j=>j.removeAttribute("data-hovered"))}(A),ref:Ct,key:w,value:rr({index:w,value:X})}))))});exports.Rating=nr; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),at=require("class-variance-authority"),we=require("@spark-ui/icon");var Rt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Je(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Ht={exports:{}};(function(o,_){var g="__lodash_hash_undefined__",v=1,y=2,F=9007199254740991,P="[object Arguments]",ot="[object Array]",pt="[object AsyncFunction]",vt="[object Boolean]",$="[object Date]",q="[object Error]",X="[object Function]",_t="[object GeneratorFunction]",B="[object Map]",Y="[object Number]",Ct="[object Null]",M="[object Object]",m="[object Promise]",w="[object Proxy]",A="[object RegExp]",O="[object Set]",tt="[object String]",it="[object Symbol]",ut="[object Undefined]",z="[object WeakMap]",L="[object ArrayBuffer]",j="[object DataView]",Tt=/^\[object .+?Constructor\]$/,H=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[P]=u[ot]=u[L]=u[vt]=u[j]=u[$]=u[q]=u[X]=u[B]=u[Y]=u[M]=u[A]=u[O]=u[tt]=u[z]=!1;var Wt=typeof Rt=="object"&&Rt&&Rt.Object===Object&&Rt,Ae=typeof self=="object"&&self&&self.Object===Object&&self,N=Wt||Ae||Function("return this")(),Gt=_&&!_.nodeType&&_,Kt=Gt&&o&&!o.nodeType&&o,Jt=Kt&&Kt.exports===Gt,It=Jt&&Wt.process,Qt=function(){try{return It&&It.binding&&It.binding("util")}catch{}}(),Xt=Qt&&Qt.isTypedArray;function ke(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Ee(t){var e=-1,r=Array(t.size);return t.forEach(function(n,l){r[++e]=[l,n]}),r}function Se(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Yt,te,ee,Me=Array.prototype,Ne=Function.prototype,yt=Object.prototype,Ft=N["__core-js_shared__"],re=Ne.toString,E=yt.hasOwnProperty,ne=(Yt=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||""))?"Symbol(src)_1."+Yt:"",ae=yt.toString,Re=RegExp("^"+re.call(E).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=Jt?N.Buffer:void 0,bt=N.Symbol,ie=N.Uint8Array,ue=yt.propertyIsEnumerable,Ce=Me.splice,W=bt?bt.toStringTag:void 0,ce=Object.getOwnPropertySymbols,Te=oe?oe.isBuffer:void 0,Ie=(te=Object.keys,ee=Object,function(t){return te(ee(t))}),Pt=et(N,"DataView"),ct=et(N,"Map"),$t=et(N,"Promise"),Bt=et(N,"Set"),Lt=et(N,"WeakMap"),lt=et(Object,"create"),Fe=J(Pt),Pe=J(ct),$e=J($t),Be=J(Bt),Le=J(Lt),le=bt?bt.prototype:void 0,Ut=le?le.valueOf:void 0;function G(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function R(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function K(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function gt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new K;++e<r;)this.add(t[e])}function U(t){var e=this.__data__=new R(t);this.size=e.size}function Ue(t,e){var r=wt(t),n=!r&&He(t),l=!r&&!n&&Vt(t),a=!r&&!n&&!l&&be(t),f=r||n||l||a,d=f?function(p,S){for(var C=-1,b=Array(p);++C<p;)b[C]=S(C);return b}(t.length,String):[],k=d.length;for(var h in t)!e&&!E.call(t,h)||f&&(h=="length"||l&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||qe(h,k))||d.push(h);return d}function mt(t,e){for(var r=t.length;r--;)if(pe(t[r][0],e))return r;return-1}function st(t){return t==null?t===void 0?ut:Ct:W&&W in Object(t)?function(e){var r=E.call(e,W),n=e[W];try{e[W]=void 0;var l=!0}catch{}var a=ae.call(e);return l&&(r?e[W]=n:delete e[W]),a}(t):function(e){return ae.call(e)}(t)}function se(t){return ft(t)&&st(t)==P}function fe(t,e,r,n,l){return t===e||(t==null||e==null||!ft(t)&&!ft(e)?t!=t&&e!=e:function(a,f,d,k,h,p){var S=wt(a),C=wt(f),b=S?ot:V(a),T=C?ot:V(f),rt=(b=b==P?M:b)==M,Ot=(T=T==P?M:T)==M,nt=b==T;if(nt&&Vt(a)){if(!Vt(f))return!1;S=!0,rt=!1}if(nt&&!rt)return p||(p=new U),S||be(a)?de(a,f,d,k,h,p):function(c,i,zt,D,Dt,x,I){switch(zt){case j:if(c.byteLength!=i.byteLength||c.byteOffset!=i.byteOffset)return!1;c=c.buffer,i=i.buffer;case L:return!(c.byteLength!=i.byteLength||!x(new ie(c),new ie(i)));case vt:case $:case Y:return pe(+c,+i);case q:return c.name==i.name&&c.message==i.message;case A:case tt:return c==i+"";case B:var Z=Ee;case O:var ht=D&v;if(Z||(Z=Se),c.size!=i.size&&!ht)return!1;var xt=I.get(c);if(xt)return xt==i;D|=y,I.set(c,i);var Zt=de(Z(c),Z(i),D,Dt,x,I);return I.delete(c),Zt;case it:if(Ut)return Ut.call(c)==Ut.call(i)}return!1}(a,f,b,d,k,h,p);if(!(d&v)){var dt=rt&&E.call(a,"__wrapped__"),ge=Ot&&E.call(f,"__wrapped__");if(dt||ge){var Ge=dt?a.value():a,Ke=ge?f.value():f;return p||(p=new U),h(Ge,Ke,d,k,p)}}return nt?(p||(p=new U),function(c,i,zt,D,Dt,x){var I=zt&v,Z=he(c),ht=Z.length,xt=he(i),Zt=xt.length;if(ht!=Zt&&!I)return!1;for(var At=ht;At--;){var Q=Z[At];if(!(I?Q in i:E.call(i,Q)))return!1}var me=x.get(c);if(me&&x.get(i))return me==i;var kt=!0;x.set(c,i),x.set(i,c);for(var qt=I;++At<ht;){var Et=c[Q=Z[At]],St=i[Q];if(D)var je=I?D(St,Et,Q,i,c,x):D(Et,St,Q,c,i,x);if(!(je===void 0?Et===St||Dt(Et,St,zt,D,x):je)){kt=!1;break}qt||(qt=Q=="constructor")}if(kt&&!qt){var Mt=c.constructor,Nt=i.constructor;Mt==Nt||!("constructor"in c)||!("constructor"in i)||typeof Mt=="function"&&Mt instanceof Mt&&typeof Nt=="function"&&Nt instanceof Nt||(kt=!1)}return x.delete(c),x.delete(i),kt}(a,f,d,k,h,p)):!1}(t,e,r,n,fe,l))}function Ve(t){return!(!ye(t)||function(e){return!!ne&&ne in e}(t))&&(ve(t)?Re:Tt).test(J(t))}function De(t){if(r=(e=t)&&e.constructor,n=typeof r=="function"&&r.prototype||yt,e!==n)return Ie(t);var e,r,n,l=[];for(var a in Object(t))E.call(t,a)&&a!="constructor"&&l.push(a);return l}function de(t,e,r,n,l,a){var f=r&v,d=t.length,k=e.length;if(d!=k&&!(f&&k>d))return!1;var h=a.get(t);if(h&&a.get(e))return h==e;var p=-1,S=!0,C=r&y?new gt:void 0;for(a.set(t,e),a.set(e,t);++p<d;){var b=t[p],T=e[p];if(n)var rt=f?n(T,b,p,e,t,a):n(b,T,p,t,e,a);if(rt!==void 0){if(rt)continue;S=!1;break}if(C){if(!ke(e,function(Ot,nt){if(dt=nt,!C.has(dt)&&(b===Ot||l(b,Ot,r,n,a)))return C.push(nt);var dt})){S=!1;break}}else if(b!==T&&!l(b,T,r,n,a)){S=!1;break}}return a.delete(t),a.delete(e),S}function he(t){return function(e,r,n){var l=r(e);return wt(e)?l:function(a,f){for(var d=-1,k=f.length,h=a.length;++d<k;)a[h+d]=f[d];return a}(l,n(e))}(t,We,Ze)}function jt(t,e){var r,n,l=t.__data__;return((n=typeof(r=e))=="string"||n=="number"||n=="symbol"||n=="boolean"?r!=="__proto__":r===null)?l[typeof e=="string"?"string":"hash"]:l.map}function et(t,e){var r=function(n,l){return n?.[l]}(t,e);return Ve(r)?r:void 0}G.prototype.clear=function(){this.__data__=lt?lt(null):{},this.size=0},G.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},G.prototype.get=function(t){var e=this.__data__;if(lt){var r=e[t];return r===g?void 0:r}return E.call(e,t)?e[t]:void 0},G.prototype.has=function(t){var e=this.__data__;return lt?e[t]!==void 0:E.call(e,t)},G.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=lt&&e===void 0?g:e,this},R.prototype.clear=function(){this.__data__=[],this.size=0},R.prototype.delete=function(t){var e=this.__data__,r=mt(e,t);return!(r<0)&&(r==e.length-1?e.pop():Ce.call(e,r,1),--this.size,!0)},R.prototype.get=function(t){var e=this.__data__,r=mt(e,t);return r<0?void 0:e[r][1]},R.prototype.has=function(t){return mt(this.__data__,t)>-1},R.prototype.set=function(t,e){var r=this.__data__,n=mt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},K.prototype.clear=function(){this.size=0,this.__data__={hash:new G,map:new(ct||R),string:new G}},K.prototype.delete=function(t){var e=jt(this,t).delete(t);return this.size-=e?1:0,e},K.prototype.get=function(t){return jt(this,t).get(t)},K.prototype.has=function(t){return jt(this,t).has(t)},K.prototype.set=function(t,e){var r=jt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},gt.prototype.add=gt.prototype.push=function(t){return this.__data__.set(t,g),this},gt.prototype.has=function(t){return this.__data__.has(t)},U.prototype.clear=function(){this.__data__=new R,this.size=0},U.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},U.prototype.get=function(t){return this.__data__.get(t)},U.prototype.has=function(t){return this.__data__.has(t)},U.prototype.set=function(t,e){var r=this.__data__;if(r instanceof R){var n=r.__data__;if(!ct||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new K(n)}return r.set(t,e),this.size=r.size,this};var Ze=ce?function(t){return t==null?[]:(t=Object(t),function(e,r){for(var n=-1,l=e==null?0:e.length,a=0,f=[];++n<l;){var d=e[n];r(d,n,e)&&(f[a++]=d)}return f}(ce(t),function(e){return ue.call(t,e)}))}:function(){return[]},V=st;function qe(t,e){return!!(e=e??F)&&(typeof t=="number"||H.test(t))&&t>-1&&t%1==0&&t<e}function J(t){if(t!=null){try{return re.call(t)}catch{}try{return t+""}catch{}}return""}function pe(t,e){return t===e||t!=t&&e!=e}(Pt&&V(new Pt(new ArrayBuffer(1)))!=j||ct&&V(new ct)!=B||$t&&V($t.resolve())!=m||Bt&&V(new Bt)!=O||Lt&&V(new Lt)!=z)&&(V=function(t){var e=st(t),r=e==M?t.constructor:void 0,n=r?J(r):"";if(n)switch(n){case Fe:return j;case Pe:return B;case $e:return m;case Be:return O;case Le:return z}return e});var He=se(function(){return arguments}())?se:function(t){return ft(t)&&E.call(t,"callee")&&!ue.call(t,"callee")},wt=Array.isArray,Vt=Te||function(){return!1};function ve(t){if(!ye(t))return!1;var e=st(t);return e==X||e==_t||e==pt||e==w}function _e(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=F}function ye(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function ft(t){return t!=null&&typeof t=="object"}var be=Xt?function(t){return function(e){return t(e)}}(Xt):function(t){return ft(t)&&_e(t.length)&&!!u[st(t)]};function We(t){return(e=t)!=null&&_e(e.length)&&!ve(e)?Ue(t):De(t);var e}o.exports=function(t,e){return fe(t,e)}})(Ht,Ht.exports);const Qe=Je(Ht.exports),ze=s.forwardRef(({title:o,fill:_="currentColor",stroke:g="none",...v},y)=>s.createElement("svg",{ref:y,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","data-title":"StarFill",...o&&{"data-title":o},fill:_,stroke:g,...v,dangerouslySetInnerHTML:{__html:(o===void 0?"":`<title>${o}</title>`)+'<path d="m11.04,2.25c-.25.17-.5.42-.67.75l-2.08,4.58-4.74.67c-.33,0-.58.17-.91.33-.25.25-.5.5-.58.83-.08.42-.08.75,0,1.08.08.33.25.67.5.92l3.49,3.49-.83,4.99c-.08.33,0,.67.08,1,.08.33.33.58.58.75.25.17.58.33.91.33s.67-.08.91-.17l4.32-2.33,4.32,2.33c.25.17.58.25.91.17.33,0,.67-.17.91-.33.25-.17.5-.5.58-.75.08-.33.17-.67.08-1l-.83-4.99,3.41-3.58c.25-.25.42-.5.5-.83.08-.33.08-.67,0-1-.08-.33-.25-.58-.5-.83-.25-.25-.58-.33-.83-.42l-4.74-.75-2.16-4.49c-.17-.33-.33-.58-.67-.75-.25-.17-.5-.25-.75-.25h-.33c-.42.08-.67.17-.91.25Z"/>'}}));ze.displayName="StarFill";const xe=s.forwardRef(({title:o,fill:_="currentColor",stroke:g="none",...v},y)=>s.createElement("svg",{ref:y,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","data-title":"StarOutline",...o&&{"data-title":o},fill:_,stroke:g,...v,dangerouslySetInnerHTML:{__html:(o===void 0?"":`<title>${o}</title>`)+'<path fill-rule="evenodd" d="m12.02,4.31l-2.01,4.22c-.12.27-.3.5-.53.68-.23.18-.5.29-.79.32l-4.47.69,3.24,3.24c.21.2.36.45.45.73.09.28.11.58.06.87h0s-.78,4.73-.78,4.73l4.03-2.21s.02,0,.03-.01c.25-.13.52-.19.79-.19s.55.07.79.19c0,0,.02,0,.03.01l4.02,2.21-.78-4.66h0c-.05-.29-.03-.59.06-.87.09-.28.24-.52.44-.72l3.21-3.31-4.45-.68c-.28-.04-.56-.15-.79-.32-.23-.18-.41-.41-.53-.68l-2.01-4.22Zm4.91,15.92h0s0,0,0,0ZM11.09,2.28c.28-.18.6-.28.93-.28s.65.1.93.28c.27.18.49.44.63.74l2.16,4.53,4.77.73c.32.05.62.18.87.4.25.22.44.5.54.83.1.32.11.67.03,1-.08.32-.25.62-.48.85l-3.44,3.55.83,4.98c.06.33.02.68-.1.99-.12.31-.33.58-.59.78s-.58.32-.9.34c-.32.02-.65-.05-.94-.21h0s-4.3-2.36-4.3-2.36l-4.3,2.36h0c-.29.16-.61.23-.94.21-.32-.02-.64-.14-.9-.34s-.47-.47-.59-.78c-.12-.31-.16-.65-.1-.99h0s.83-5.04.83-5.04l-3.48-3.49c-.24-.24-.41-.54-.49-.88-.08-.34-.06-.69.05-1.02.11-.33.31-.61.58-.82.25-.2.56-.33.88-.36l4.75-.73,2.16-4.53c.14-.3.36-.56.63-.74Z"/>'}}));xe.displayName="StarOutline";const Xe=at.cx("peer-hover:[&_>_div]:!w-none"),Ye=at.cva(["peer","after:inset-none","group","relative","after:block after:absolute"],{variants:{disabled:{true:"opacity-dim-3",false:""},readOnly:{true:"",false:""},gap:{sm:["after:w-[calc(100%_+_theme(spacing.sm))]","last-of-type:after:content-none"],md:["after:w-[calc(100%_+_theme(spacing.md))]","last-of-type:after:content-none"]}},compoundVariants:[{readOnly:!1,disabled:!1,className:at.cx(Xe,"cursor-pointer")}],defaultVariants:{disabled:!1,readOnly:!1,gap:"sm"}}),Oe=at.cva("",{variants:{size:{sm:"text-caption-link",md:"text-body-1",lg:"text-display-1"},design:{filled:["text-main-variant","group-[[data-part=star][data-hovered]]:text-main-variant-hovered"],outlined:["text-on-surface/dim-3"]}}}),tr=s.forwardRef(({value:o,size:_,disabled:g,readOnly:v,onClick:y,onMouseEnter:F},P)=>s.createElement("div",{ref:P,onMouseEnter:F,className:Ye({gap:_==="lg"?"md":"sm",disabled:g,readOnly:v}),"data-part":"star",onClick:y},s.createElement("div",{className:at.cx("absolute z-raised overflow-hidden","group-[[data-part=star][data-hovered]]:overflow-visible"),style:{width:100*o+"%"}},s.createElement(we.Icon,{className:Oe({size:_,design:"filled"})},s.createElement(ze,null))),s.createElement(we.Icon,{className:Oe({size:_,design:"outlined"})},s.createElement(xe,null))));function er(o){return o===void 0?0:o-Math.floor(o)>.74?Math.ceil(o):Math.floor(o)}function rr({value:o,index:_}){if(o===void 0)return 0;const g=_+1,v=(y=o,.5*Math.round(y/.5));var y;return Math.ceil(v)<g?0:v>=g?1:.5}const nr=s.forwardRef(({defaultValue:o,value:_,onValueChange:g,size:v="md",disabled:y,readOnly:F,name:P,id:ot,...pt},vt)=>{const $=s.useRef(null),q=s.useRef([]),[X,_t]=function(m,w,A){const O=m!==void 0,{current:tt}=s.useRef(O?m:w),[it,ut]=s.useState(w),z=O?m:it,L=s.useCallback((j,Tt=(H,u)=>!Qe(H,u))=>{const H=typeof j!="function"?j:j(z);Tt(z,H)&&!O&&ut(H),A&&A(H)},[O,z,A]);return[z,L,O,tt]}(_,o,g),B=s.useRef(X),Y=!(y||F),Ct=s.useCallback(m=>{m&&q.current.push(m)},[]);function M(){$.current?.removeAttribute("data-clicked")}return s.createElement("div",{className:"relative inline-flex",ref:vt,"data-spark-component":"rating",...pt,onMouseLeave:function(){q.current.forEach(m=>m.removeAttribute("data-hovered"))}},s.createElement("input",{name:P,id:ot,"aria-label":pt["aria-label"],ref:$,"data-part":"input",className:"peer absolute inset-none opacity-0",type:"range",min:"0",max:"5",step:1,disabled:y,readOnly:F,value:er(X),onChange:m=>Y&&function(w){B.current!==Number(w.target.value)&&(B.current=Number(w.target.value),_t(Number(w.target.value)))}(m),onKeyDown:M,onBlur:M}),s.createElement("div",{className:at.cx(v==="lg"?"gap-x-md":"gap-x-sm","flex","peer-focus-visible:u-ring peer-[[data-part=input][data-clicked]]:shadow-none")},Array.from({length:5}).map((m,w)=>s.createElement(tr,{disabled:y,readOnly:F,size:v,onClick:()=>Y&&function(A){$.current&&(_t(A+1),B.current=A+1,$.current.focus(),$.current.setAttribute("data-clicked",""))}(w),onMouseEnter:A=>Y&&function({currentTarget:O}){const tt=q.current.findIndex(j=>j===O),[it,ut]=(z=q.current,L=tt+1,[z.slice(0,L),z.slice(L)]);var z,L;it.forEach(j=>j.setAttribute("data-hovered","")),ut.forEach(j=>j.removeAttribute("data-hovered"))}(A),ref:Ct,key:w,value:rr({index:w,value:X})}))))});exports.Rating=nr; |
{ | ||
"name": "@spark-ui/rating", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Ratings let users see and/or set a star rating for a product or other item", | ||
@@ -48,3 +48,3 @@ "publishConfig": { | ||
"license": "MIT", | ||
"gitHead": "3d261de26a37cdeaafa5b51db961681cb37a15fe" | ||
"gitHead": "555516f48bee7adee53096ba334b9470456c8ebb" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
59463
2