2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(e);function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function u(e,t){if(t&&("object"===p(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function f(){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(e){return!1}}var y,m,h,b=function(o){c(v,e.Component);var l,p,y,m,h,b=(l=v,p=f(),function(){var e,t=a(l);if(p){var o=a(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return u(this,e)});function v(e){var t;return n(this,v),(t=b.call(this,e)).state={visible:!0},t.close=t.close.bind(s(t)),t.onKeyDown=t.onKeyDown.bind(s(t)),t}return y=v,(m=[{key:"onKeyDown",value:function(e){13===e.keyCode&&this.close(e)}},{key:"close",value:function(e){var t=this;e.persist(),this.setState({visible:!1},(function(){t.props.onRemove&&t.props.onRemove(e)}))}},{key:"renderContent",value:function(){var e=this,o=[];return this.props.image?o.push(r.default.createElement("img",{key:"image",src:this.props.image,alt:this.props.imageAlt,onError:function(t){e.props.onImageError&&e.props.onImageError(t)}})):this.props.icon&&o.push(t.IconUtils.getJSXIcon(this.props.icon,{key:"icon",className:"p-chip-icon"},{props:this.props})),this.props.label&&o.push(r.default.createElement("span",{key:"label",className:"p-chip-text"},this.props.label)),this.props.removable&&o.push(t.IconUtils.getJSXIcon(this.props.removeIcon,{key:"removeIcon",tabIndex:0,className:"p-chip-remove-icon",onClick:this.close,onKeyDown:this.onKeyDown},{props:this.props})),o}},{key:"renderElement",value:function(){var e=t.classNames("p-chip p-component",{"p-chip-image":null!=this.props.image},this.props.className),o=this.props.template?t.ObjectUtils.getJSXElement(this.props.template,this.props):this.renderContent();return r.default.createElement("div",{className:e,style:this.props.style},o)}},{key:"render",value:function(){return this.state.visible&&this.renderElement()}}])&&i(y.prototype,m),h&&i(y,h),Object.defineProperty(y,"prototype",{writable:!1}),v}();h={label:null,icon:null,image:null,removable:!1,removeIcon:"pi pi-times-circle",className:null,style:null,template:null,imageAlt:"chip",onImageError:null,onRemove:null},(m="defaultProps")in(y=b)?Object.defineProperty(y,m,{value:h,enumerable:!0,configurable:!0,writable:!0}):y[m]=h,exports.Chip=b;
|