UNPKG

quarkd

Version:

Mobile UI Components built on Web Components.

2 lines (1 loc) 5.42 kB
import{_ as t,a as e}from"../typeof.js";import{_ as n,a as o,b as i,c as r,H as a,A as c,d as s,N as l,O as u,B as f}from"../index2.js";import{_ as d}from"../defineProperty.js";import{d as h,a as p,f as v,r as y,w as m,s as g,M as k,h as z}from"../index22.js";var b=function(t){v(i,t);var e,n,o=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,o=h(e);if(n){var i=h(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return p(this,t)});function i(){var t;return y(this,i),(t=o.call(this)).attachShadow({mode:"open"}).innerHTML="\n <style>\n ".concat(m,'\n </style>\n <svg class="icon" id="icon" aria-hidden="true" viewBox="0 0 1024 1024">\n ').concat('<path d="M554.496 127.402667c18.773333 9.429333 34.005333 24.832 43.306667 43.818666l73.6 150.314667 164.053333 24.32c52.352 7.765333 88.533333 57.002667 80.853333 109.909333a97.28 97.28 0 0 1-27.818666 55.210667l-118.570667 117.248 27.818667 165.333333c8.832 52.736-26.24 102.741333-78.378667 111.701334a94.805333 94.805333 0 0 1-60.458667-9.685334L512 817.749333 365.098667 895.573333a95.232 95.232 0 0 1-129.28-40.832 97.834667 97.834667 0 0 1-9.557334-61.184l27.818667-165.333333-118.613333-117.248a97.621333 97.621333 0 0 1-1.536-136.96 95.402667 95.402667 0 0 1 54.613333-28.16l164.053333-24.32 73.6-150.314667a95.274667 95.274667 0 0 1 128.298667-43.818666z" p-id="3914"></path>',"\n </svg>\n "),t.icon=t.shadowRoot.getElementById("icon"),t}return g(i,[{key:"connectedCallback",value:function(){this.upgradeProperty()}},{key:"attributeChangedCallback",value:function(t,e,n){if("color"===t)this.icon.style.color=n;else if("size"===t){var o=this.getFontSize();this.icon.style.fontSize="".concat(o)}}},{key:"upgradeProperty",value:function(){this.size=this.size,this.color=this.color}},{key:"getFontSize",value:function(){return k(this.size)}},{key:"size",get:function(){return this.getAttribute("size")},set:function(t){this.setAttribute("size",t)}},{key:"color",get:function(){return this.getAttribute("color")},set:function(t){this.setAttribute("color",t)}}],[{key:"observedAttributes",get:function(){return["size","color"]}}]),i}(z(HTMLElement));customElements.get("quark-icon-star-fill")||customElements.define("quark-icon-star-fill",b);function R(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,r=n(t);if(e){var a=n(this).constructor;i=Reflect.construct(r,arguments,a)}else i=r.apply(this,arguments);return o(this,i)}}var x=function(n){i(s,a);var o=R(s);function s(){var e;t(this,s);for(var n=arguments.length,i=new Array(n),c=0;c<n;c++)i[c]=arguments[c];return e=o.call.apply(o,[this].concat(i)),d(r(e),"value",""),d(r(e),"name",""),d(r(e),"defaultValue",""),d(r(e),"size","25"),d(r(e),"imgicon",""),d(r(e),"activecolor","#ee0a24"),d(r(e),"disabled",!1),d(r(e),"readonly",!1),d(r(e),"stars",[{id:1},{id:2},{id:3},{id:4},{id:5}]),d(r(e),"activeIndex",-1),d(r(e),"initSelect",(function(t){e.stars=e.stars.map((function(n){return n.id<=t&&(n.color=e.activecolor),n}))})),d(r(e),"renderIcon",(function(t){return e.imgicon?a.h("img",{style:{width:"".concat(e.size,"px"),height:"auto",paddingRight:"4px",filter:t.color&&"inherit"!==t.color?"initial":"grayscale(100%)"},src:e.imgicon,key:t.id,onClick:function(){return e.handleChange(t)},part:"icon"}):a.h("quark-icon-star-fill",{part:"icon",key:t.id,id:t.id,size:e.size,color:t.color||"inherit",onClick:function(){return e.handleChange(t)}})})),e}return e(s,[{key:"componentDidMount",value:function(){this.defaultValue&&this.initSelect(Number(this.defaultValue))}},{key:"shouldComponentUpdate",value:function(t,e,n){return"value"!==t&&"defaultValue"!==t||n&&this.initSelect(Number(n)),!0}},{key:"handleChange",value:function(t){var e=this;if(this.shadowRoot&&!this.disabled){var n=t.id;this.stars=this.stars.map((function(t){return t.color=t.id<=n?e.activecolor:"inherit",t}));var o=this.stars.filter((function(t){return t.color===e.activecolor})).length;this.value="".concat(o),this.$emit("change",{detail:{value:o}})}}},{key:"render",value:function(){var t=this;return a.h(c,null,this.stars.map((function(e){return t.renderIcon(e)})))}}]),s}();s([l()],x.prototype,"value",void 0),s([l()],x.prototype,"name",void 0),s([l()],x.prototype,"defaultValue",void 0),s([l()],x.prototype,"size",void 0),s([l()],x.prototype,"imgicon",void 0),s([l()],x.prototype,"activecolor",void 0),s([l({type:Boolean})],x.prototype,"disabled",void 0),s([l({type:Boolean})],x.prototype,"readonly",void 0),s([u()],x.prototype,"stars",void 0);var w=x=s([f({tag:"quark-rate",style:":host {\n display: flex;\n align-items: center;\n color: #ddd;\n cursor: pointer;\n}\n\n:host([disabled]) {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n:host([readonly]) {\n cursor: not-allowed;\n pointer-events: none;\n}\n\n:host quark-icon-star {\n margin-right: 1.33333vw;\n}\n\n:host quark-icon-star:hover {\n cursor: pointer;\n}\n"})],x);export{w as default};