katoikia-app/web-ui/web-react/node_modules/primereact/messages/messages.esm.min.js

2 lines
6.7 KiB
JavaScript

import e,{Component as t}from"react";import{classNames as n}from"primereact/utils";import{Ripple as r}from"primereact/ripple";import{TransitionGroup as o}from"react-transition-group";import{CSSTransition as s}from"primereact/csstransition";function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e){if(Array.isArray(e))return i(e)}function c(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function l(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e){return a(e)||c(e)||l(e)||u()}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function y(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function d(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&&v(e,t)}function b(e){return b="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},b(e)}function g(e,t){if(t&&("object"===b(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function k(e){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},k(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(){return w=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},w.apply(this,arguments)}function O(){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 E=function(o){d(c,t);var s,i,a=(s=c,i=O(),function(){var e,t=k(s);if(i){var n=k(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function c(e){var t;return f(this,c),(t=a.call(this,e)).onClick=t.onClick.bind(h(t)),t.onClose=t.onClose.bind(h(t)),t}return y(c,[{key:"componentDidMount",value:function(){var e=this;this.props.message.sticky||(this.timeout=setTimeout((function(){e.onClose(null)}),this.props.message.life||3e3))}},{key:"componentWillUnmount",value:function(){this.timeout&&clearTimeout(this.timeout)}},{key:"onClose",value:function(e){this.timeout&&clearTimeout(this.timeout),this.props.onClose&&this.props.onClose(this.props.message),e&&(e.preventDefault(),e.stopPropagation())}},{key:"onClick",value:function(){this.props.onClick&&this.props.onClick(this.props.message)}},{key:"renderCloseIcon",value:function(){return!1!==this.props.message.closable?e.createElement("button",{type:"button",className:"p-message-close p-link",onClick:this.onClose},e.createElement("i",{className:"p-message-close-icon pi pi-times"}),e.createElement(r,null)):null}},{key:"renderMessage",value:function(){if(this.props.message){var t=this.props.message,r=t.severity,o=t.content,s=t.summary,i=t.detail,a=n("p-message-icon pi ",{"pi-info-circle":"info"===r,"pi-check":"success"===r,"pi-exclamation-triangle":"warn"===r,"pi-times-circle":"error"===r});return o||e.createElement(e.Fragment,null,e.createElement("span",{className:a}),e.createElement("span",{className:"p-message-summary"},s),e.createElement("span",{className:"p-message-detail"},i))}return null}},{key:"render",value:function(){var t="p-message p-component p-message-"+this.props.message.severity,n=this.renderCloseIcon(),r=this.renderMessage();return e.createElement("div",{ref:this.props.forwardRef,className:t,onClick:this.onClick},e.createElement("div",{className:"p-message-wrapper"},r,n))}}]),c}();C(E,"defaultProps",{message:null,onClose:null,onClick:null});var R=e.forwardRef((function(t,n){return e.createElement(E,w({forwardRef:n},t))}));function j(){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 S=0,P=function(n){d(c,t);var r,i,a=(r=c,i=j(),function(){var e,t=k(r);if(i){var n=k(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function c(e){var t;return f(this,c),(t=a.call(this,e)).state={messages:[]},t.onClose=t.onClose.bind(h(t)),t}return y(c,[{key:"show",value:function(e){if(e){var t=[];if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n].id=S++,t=[].concat(p(this.state.messages),p(e));else e.id=S++,t=this.state.messages?[].concat(p(this.state.messages),[e]):[e];this.setState({messages:t})}}},{key:"clear",value:function(){this.setState({messages:[]})}},{key:"replace",value:function(e){var t=this;this.setState({messages:[]},(function(){return t.show(e)}))}},{key:"onClose",value:function(e){var t=this.state.messages.filter((function(t){return t.id!==e.id}));this.setState({messages:t}),this.props.onRemove&&this.props.onRemove(e)}},{key:"render",value:function(){var t=this;return e.createElement("div",{id:this.props.id,className:this.props.className,style:this.props.style},e.createElement(o,null,this.state.messages.map((function(n){var r=e.createRef();return e.createElement(s,{nodeRef:r,key:n.id,classNames:"p-message",unmountOnExit:!0,timeout:{enter:300,exit:300},options:t.props.transitionOptions},e.createElement(R,{ref:r,message:n,onClick:t.props.onClick,onClose:t.onClose}))}))))}}]),c}();C(P,"defaultProps",{id:null,className:null,style:null,transitionOptions:null,onRemove:null,onClick:null});export{P as Messages};