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

2 lines
8.5 KiB
JavaScript

import e,{Component as t}from"react";import{DomHandler as n,ObjectUtils as r,classNames as o,ZIndexUtils as s}from"primereact/utils";import{Ripple as i}from"primereact/ripple";import{TransitionGroup as a}from"react-transition-group";import{CSSTransition as c}from"primereact/csstransition";import l from"primereact/api";import{Portal as u}from"primereact/portal";function p(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 f(e){if(Array.isArray(e))return p(e)}function m(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function y(e,t){if(e){if("string"==typeof e)return p(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)?p(e,t):void 0}}function h(){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 d(e){return f(e)||m(e)||y(e)||h()}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(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 g(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function O(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e,t){return E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},E(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&&E(e,t)}function k(e){return k="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},k(e)}function w(e,t){if(t&&("object"===k(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return O(e)}function j(e){return j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},j(e)}function P(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(){return S=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},S.apply(this,arguments)}function R(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?R(Object(n),!0).forEach((function(t){P(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function N(){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 T=function(s){C(u,t);var a,c,l=(a=u,c=N(),function(){var e,t=j(a);if(c){var n=j(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return w(this,e)});function u(e){var t;return v(this,u),(t=l.call(this,e)).onClick=t.onClick.bind(O(t)),t.onClose=t.onClose.bind(O(t)),t}return g(u,[{key:"componentWillUnmount",value:function(){this.timeout&&clearTimeout(this.timeout)}},{key:"componentDidMount",value:function(){var e=this;this.props.message.sticky||(this.timeout=setTimeout((function(){e.onClose(null)}),this.props.message.life||3e3))}},{key:"onClose",value:function(){this.timeout&&clearTimeout(this.timeout),this.props.onClose&&this.props.onClose(this.props.message)}},{key:"onClick",value:function(e){!this.props.onClick||n.hasClass(e.target,"p-toast-icon-close")||n.hasClass(e.target,"p-toast-icon-close-icon")||this.props.onClick(this.props.message)}},{key:"renderCloseIcon",value:function(){return!1!==this.props.message.closable?e.createElement("button",{type:"button",className:"p-toast-icon-close p-link",onClick:this.onClose},e.createElement("span",{className:"p-toast-icon-close-icon pi pi-times"}),e.createElement(i,null)):null}},{key:"renderMessage",value:function(){if(this.props.message){var t=this.props.message,n=t.severity,s=t.summary,i=t.detail,a=r.getJSXElement(t.content,x(x({},this.props),{},{onClose:this.onClose})),c=o("p-toast-message-icon pi",{"pi-info-circle":"info"===n,"pi-exclamation-triangle":"warn"===n,"pi-times":"error"===n,"pi-check":"success"===n});return a||e.createElement(e.Fragment,null,e.createElement("span",{className:c}),e.createElement("div",{className:"p-toast-message-text"},e.createElement("span",{className:"p-toast-summary"},s),i&&e.createElement("div",{className:"p-toast-detail"},i)))}return null}},{key:"render",value:function(){var t=this.props.message.severity,n=this.props.message.contentClassName,r=this.props.message.contentStyle,s=this.props.message.style,i=o("p-toast-message",{"p-toast-message-info":"info"===t,"p-toast-message-warn":"warn"===t,"p-toast-message-error":"error"===t,"p-toast-message-success":"success"===t},this.props.message.className),a=this.renderMessage(),c=this.renderCloseIcon();return e.createElement("div",{ref:this.props.forwardRef,className:i,style:s,role:"alert","aria-live":"assertive","aria-atomic":"true",onClick:this.onClick},e.createElement("div",{className:o("p-toast-message-content",n),style:r},a,c))}}]),u}();P(T,"defaultProps",{message:null,onClose:null,onClick:null});var A=e.forwardRef((function(t,n){return e.createElement(T,S({forwardRef:n},t))}));function I(){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 _=0,D=function(n){C(f,t);var r,i,p=(r=f,i=I(),function(){var e,t=j(r);if(i){var n=j(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return w(this,e)});function f(e){var t;return v(this,f),(t=p.call(this,e)).state={messages:[]},t.onClose=t.onClose.bind(O(t)),t.onEntered=t.onEntered.bind(O(t)),t.onExited=t.onExited.bind(O(t)),t}return g(f,[{key:"show",value:function(e){if(e&&e){var t;if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n].id=_++,t=[].concat(d(this.state.messages),d(e));else e.id=_++,t=this.state.messages?[].concat(d(this.state.messages),[e]):[e];0===this.state.messages.length&&s.set("toast",this.container,l.autoZIndex,this.props.baseZIndex||l.zIndex.toast),this.setState({messages:t})}}},{key:"clear",value:function(){s.clear(this.container),this.setState({messages:[]})}},{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:"onEntered",value:function(){this.props.onShow&&this.props.onShow()}},{key:"onExited",value:function(){0===this.state.messages.length&&s.clear(this.container),this.props.onHide&&this.props.onHide()}},{key:"componentWillUnmount",value:function(){s.clear(this.container)}},{key:"renderElement",value:function(){var t=this,n=o("p-toast p-component p-toast-"+this.props.position,this.props.className);return e.createElement("div",{ref:function(e){t.container=e},id:this.props.id,className:n,style:this.props.style},e.createElement(a,null,this.state.messages.map((function(n){var r=e.createRef();return e.createElement(c,{nodeRef:r,key:n.id,classNames:"p-toast-message",unmountOnExit:!0,timeout:{enter:300,exit:300},onEntered:t.onEntered,onExited:t.onExited,options:t.props.transitionOptions},e.createElement(A,{ref:r,message:n,onClick:t.props.onClick,onClose:t.onClose}))}))))}},{key:"render",value:function(){var t=this.renderElement();return e.createElement(u,{element:t,appendTo:this.props.appendTo})}}]),f}();P(D,"defaultProps",{id:null,className:null,style:null,baseZIndex:0,position:"top-right",transitionOptions:null,appendTo:"self",onClick:null,onRemove:null,onShow:null,onHide:null});export{D as Toast};