UNPKG

@square/maker

Version:

Maker Design System by Square

2 lines 6.41 kB
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("../../components/Theme"),require("../../utils/css-validator"));else if("function"==typeof define&&define.amd)define(["../../components/Theme","../../utils/css-validator"],e);else{var r="object"==typeof exports?e(require("../../components/Theme"),require("../../utils/css-validator")):e(t["../../components/Theme"],t["../../utils/css-validator"]);for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(this,(function(t,e){return(()=>{"use strict";var r={219:e=>{e.exports=t},948:t=>{t.exports=e}},o={};function i(t){var e=o[t];if(void 0!==e)return e.exports;var a=o[t]={exports:{}};return r[t](a,a.exports,i),a.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return(()=>{i.r(a),i.d(a,{MStar:()=>s,MStarRating:()=>p});var t=i(948),e=i.n(t);const r={inheritAttrs:!1,props:{fill:{type:String,default:"full",validator:t=>["full","half","empty"].includes(t)},color:{type:String,default:"#ffbf00",validator:e()("color")}}},o={Star:"📚19-10-2GCiyM"};function n(t,e,r,o,i,a,n,s){var l,d="function"==typeof t?t.options:t;if(e&&(d.render=e,d.staticRenderFns=r,d._compiled=!0),o&&(d.functional=!0),a&&(d._scopeId="data-v-"+a),n?(l=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(n)},d._ssrRegister=l):i&&(l=s?function(){i.call(this,(d.functional?this.parent:this).$root.$options.shadowRoot)}:i),l)if(d.functional){d._injectStyles=l;var u=d.render;d.render=function(t,e){return l.call(e),u(t,e)}}else{var c=d.beforeCreate;d.beforeCreate=c?[].concat(c,l):[l]}return{exports:t,options:d}}const s=n(r,(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("svg",t._g(t._b({class:t.$s.Star,attrs:{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"}},"svg",t.$attrs,!1),t.$listeners),["full"===t.fill?r("path",{attrs:{d:"M8.00001 1.5L10.0433 5.00814C10.1846 5.25074 10.4214 5.42277 10.6958 5.48219L14.6636 6.34141L11.9586 9.36878C11.7716 9.57814 11.6811 9.85649 11.7094 10.1358L12.1184 14.175L8.40325 12.5379C8.14634 12.4246 7.85367 12.4246 7.59676 12.5379L3.88166 14.175L4.29062 10.1358C4.3189 9.85649 4.22846 9.57814 4.0414 9.36878L1.33637 6.34141L5.30423 5.48219C5.57862 5.42277 5.8154 5.25074 5.9567 5.00814L8.00001 1.5Z",fill:t.color,stroke:t.color,"stroke-linecap":"round","stroke-linejoin":"round"}}):t._e(),t._v(" "),"empty"===t.fill?r("path",{attrs:{d:"M8.00001 1.5L10.0433 5.00814C10.1846 5.25074 10.4214 5.42277 10.6958 5.48219L14.6636 6.34141L11.9586 9.36878C11.7716 9.57814 11.6811 9.85649 11.7094 10.1358L12.1184 14.175L8.40325 12.5379C8.14634 12.4246 7.85367 12.4246 7.59676 12.5379L3.88166 14.175L4.29062 10.1358C4.3189 9.85649 4.22846 9.57814 4.0414 9.36878L1.33637 6.34141L5.30423 5.48219C5.57862 5.42277 5.8154 5.25074 5.9567 5.00814L8.00001 1.5Z",stroke:t.color,"stroke-linecap":"round","stroke-linejoin":"round"}}):t._e(),t._v(" "),"half"===t.fill?[r("path",{attrs:{d:"M8 1.5L10.0433 5.00814C10.1846 5.25074 10.4214 5.42277 10.6958 5.48219L14.6636 6.34141L11.9586 9.36878C11.7716 9.57814 11.6811 9.85648 11.7094 10.1358L12.1184 14.175L8.40325 12.5379C8.14634 12.4246 7.85367 12.4246 7.59676 12.5379L3.88166 14.175L4.29062 10.1358C4.3189 9.85649 4.22846 9.57814 4.0414 9.36878L1.33637 6.34141L5.30423 5.48219C5.57862 5.42277 5.8154 5.25074 5.9567 5.00814L8 1.5Z",stroke:t.color,"stroke-linecap":"round","stroke-linejoin":"round"}}),t._v(" "),r("path",{attrs:{d:"M4.74068 9.80798L4.44922 13.3867L7.81143 11.9653C7.85659 11.9462 7.90513 11.9364 7.95416 11.9364H7.96093L7.99999 2.91674L8 2.91518V2.5L7.90873 2.51626C7.85536 2.52576 7.80507 2.54799 7.7621 2.58105C7.734 2.60268 7.70948 2.6286 7.68944 2.65786L7.63343 2.73967L7.53284 2.91595L6.14573 5.48649C6.07563 5.6164 5.9517 5.7087 5.80714 5.73864L2.06665 6.51358L4.61907 9.43866C4.70778 9.54031 4.75163 9.67351 4.74068 9.80798Z",fill:t.color}})]:t._e()],2)}),[],!1,(function(t){this.$s=o.locals||o}),null,null).exports;var l=i(219);const d={small:{height:16,spacing:1},medium:{height:24,spacing:2},large:{height:32,spacing:4}},u={components:{MStar:s},inject:{theme:{default:(0,l.defaultTheme)(),from:l.MThemeKey}},inheritAttrs:!1,props:{rating:{type:Number,default:0,validator:t=>t>=0&&t<=5},size:{type:String,default:"medium",validator:t=>["small","medium","large"].includes(t)},color:{type:String,default:void 0,validator:e()("color")},isEditable:{type:Boolean,default:!1},ariaLabel:{type:String,default:"Rating"}},data:()=>({MAX_RATING:5,hoveredRating:0}),computed:{...(0,l.resolveThemeableProps)("starrating",["color"]),displayedRating(){return this.hoveredRating||this.rating},starComputedStyles(){const t=d[this.size];return{"--star-height":"".concat(t.height,"px"),"--star-spacing":"".concat(t.spacing,"px"),"--star-cursor":this.isEditable?"pointer":"default"}}},methods:{fillForStarRating(t){return this.displayedRating>=t?"full":this.displayedRating>=t-.5?"half":"empty"},clickStar(t){this.isEditable&&this.$emit("star-click",t)},hoverStar(t){this.isEditable&&(this.$emit("star-hover",t),this.hoveredRating=t)},unhoverStar(t){this.isEditable&&(this.$emit("star-unhover",t),this.hoveredRating=0)}}},c={Star:"📚19-10-2rKuyo"};const p=n(u,(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",t._g(t._b({style:t.starComputedStyles,attrs:{role:t.isEditable?"slider":"img",tabindex:"0","aria-readonly":"true","aria-valuemin":"0","aria-valuemax":"5","aria-valuenow":t.displayedRating,"aria-label":t.ariaLabel}},"div",t.$attrs,!1),t.$listeners),t._l(t.MAX_RATING,(function(e){return r("m-star",{key:e,class:t.$s.Star,attrs:{fill:t.fillForStarRating(e),color:t.resolvedColor},on:{mouseenter:function(r){return t.hoverStar(e)},mouseleave:function(r){return t.unhoverStar(e)},click:function(r){return t.clickStar(e)}}})})),1)}),[],!1,(function(t){this.$s=c.locals||c}),null,null).exports})(),a})()})); //# sourceMappingURL=script.js.map