2 lines
3.1 KiB
JavaScript
2 lines
3.1 KiB
JavaScript
import t,{Component as e}from"react";import{IconUtils as r,classNames as o,ObjectUtils as n}from"primereact/utils";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function p(t,e){return p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},p(t,e)}function l(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&&p(t,e)}function s(t){return s="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},s(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t,e){if(e&&("object"===s(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function y(){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 m,h,b,v=function(p){l(g,e);var s,c,m,h,b,v=(s=g,c=y(),function(){var t,e=f(s);if(c){var r=f(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return u(this,t)});function g(){return i(this,g),v.apply(this,arguments)}return m=g,(h=[{key:"renderContent",value:function(){var e=this;return this.props.label?t.createElement("span",{className:"p-avatar-text"},this.props.label):this.props.icon?r.getJSXIcon(this.props.icon,{className:"p-avatar-icon"},{props:this.props}):this.props.image?t.createElement("img",{src:this.props.image,alt:this.props.imageAlt,onError:function(t){e.props.onImageError&&e.props.onImageError(t)}}):null}},{key:"render",value:function(){var e=o("p-avatar p-component",{"p-avatar-image":null!=this.props.image,"p-avatar-circle":"circle"===this.props.shape,"p-avatar-lg":"large"===this.props.size,"p-avatar-xl":"xlarge"===this.props.size,"p-avatar-clickable":!!this.props.onClick},this.props.className),r=this.props.template?n.getJSXElement(this.props.template,this.props):this.renderContent();return t.createElement("div",{className:e,style:this.props.style,onClick:this.props.onClick},r,this.props.children)}}])&&a(m.prototype,h),b&&a(m,b),Object.defineProperty(m,"prototype",{writable:!1}),g}();b={label:null,icon:null,image:null,size:"normal",shape:"square",style:null,className:null,template:null,imageAlt:"avatar",onImageError:null,onClick:null},(h="defaultProps")in(m=v)?Object.defineProperty(m,h,{value:b,enumerable:!0,configurable:!0,writable:!0}):m[h]=b;export{v as Avatar};
|