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

2 lines
8.9 KiB
JavaScript

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