katoikia-app/web-ui/web-react/node_modules/primereact/rating/rating.cjs.min.js

2 lines
5.5 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("primereact/utils"),n=require("primereact/tooltip");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=o(t);function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function p(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function a(t,e){return a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},a(t,e)}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function c(t,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return p(t)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?d(Object(n),!0).forEach((function(e){y(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function b(){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}}var v=function(o){s(m,t.Component);var a,u,y,d,v,O=(a=m,u=b(),function(){var t,e=f(a);if(u){var n=f(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return c(this,t)});function m(t){var e;return i(this,m),(e=O.call(this,t)).clear=e.clear.bind(p(e)),e.onStarKeyDown=e.onStarKeyDown.bind(p(e)),e.onCancelKeyDown=e.onCancelKeyDown.bind(p(e)),e}return y=m,(d=[{key:"rate",value:function(t,e){this.props.readOnly||this.props.disabled||!this.props.onChange||this.props.onChange({originalEvent:t,value:e,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:e}}),t.preventDefault()}},{key:"clear",value:function(t){this.props.readOnly||this.props.disabled||!this.props.onChange||this.props.onChange({originalEvent:t,value:null,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:null}}),t.preventDefault()}},{key:"shouldComponentUpdate",value:function(t,e){return t.value!==this.props.value||t.disabled!==this.props.disabled}},{key:"onStarKeyDown",value:function(t,e){"Enter"===t.key&&this.rate(t,e)}},{key:"onCancelKeyDown",value:function(t){"Enter"===t.key&&this.clear(t)}},{key:"getFocusIndex",value:function(){return this.props.disabled||this.props.readOnly?null:0}},{key:"componentDidMount",value:function(){this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(t){t.tooltip===this.props.tooltip&&t.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(h({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=n.tip({target:this.element,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderStars",value:function(){for(var t=this,n=[],o=0;o<this.props.stars;o++)n[o]=o+1;return n.map((function(n){var o=e.classNames("p-rating-icon",{"pi pi-star":!t.props.value||n>t.props.value,"pi pi-star-fill":n<=t.props.value});return r.default.createElement("span",{className:o,onClick:function(e){return t.rate(e,n)},key:n,tabIndex:t.getFocusIndex(),onKeyDown:function(e){return t.onStarKeyDown(e,n)}})}))}},{key:"renderCancelIcon",value:function(){return this.props.cancel?r.default.createElement("span",{className:"p-rating-icon p-rating-cancel pi pi-ban",onClick:this.clear,tabIndex:this.getFocusIndex(),onKeyDown:this.onCancelKeyDown}):null}},{key:"render",value:function(){var t=this,n=e.classNames("p-rating",{"p-disabled":this.props.disabled,"p-rating-readonly":this.props.readOnly},this.props.className),o=this.renderCancelIcon(),i=this.renderStars();return r.default.createElement("div",{ref:function(e){return t.element=e},id:this.props.id,className:n,style:this.props.style},o,i)}}])&&l(y.prototype,d),v&&l(y,v),Object.defineProperty(y,"prototype",{writable:!1}),m}();y(v,"defaultProps",{id:null,value:null,disabled:!1,readOnly:!1,stars:5,cancel:!0,style:null,className:null,tooltip:null,tooltipOptions:null,onChange:null}),exports.Rating=v;