react-notify-bootstrap
Version:
Simple Boostrap notification for React app
2 lines (1 loc) • 17.7 kB
JavaScript
function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=require("react"),React__default=_interopDefault(React),Toast=_interopDefault(require("react-bootstrap/Toast"));function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}require("bootstrap/dist/css/bootstrap.min.css");var b="function"==typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;function z(o){if("object"==typeof o&&null!==o){var a=o.$$typeof;switch(a){case c:switch(o=o.type){case l:case m:case e:case g:case f:case p:return o;default:switch(o=o&&o.$$typeof){case k:case n:case t:case r:case h:return o;default:return a}}case d:return a}}}function A(e){return z(e)===m}var AsyncMode=l,ConcurrentMode=m,ContextConsumer=k,ContextProvider=h,Element=c,ForwardRef=n,Fragment=e,Lazy=t,Memo=r,Portal=d,Profiler=g,StrictMode=f,Suspense=p,isAsyncMode=function(e){return A(e)||z(e)===l},isConcurrentMode=A,isContextConsumer=function(e){return z(e)===k},isContextProvider=function(e){return z(e)===h},isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===c},isForwardRef=function(e){return z(e)===n},isFragment=function(t){return z(t)===e},isLazy=function(e){return z(e)===t},isMemo=function(e){return z(e)===r},isPortal=function(e){return z(e)===d},isProfiler=function(e){return z(e)===g},isStrictMode=function(e){return z(e)===f},isSuspense=function(e){return z(e)===p},isValidElementType=function(o){return"string"==typeof o||"function"==typeof o||o===e||o===m||o===g||o===f||o===p||o===q||"object"==typeof o&&null!==o&&(o.$$typeof===t||o.$$typeof===r||o.$$typeof===h||o.$$typeof===k||o.$$typeof===n||o.$$typeof===w||o.$$typeof===x||o.$$typeof===y||o.$$typeof===v)},typeOf=z,reactIs_production_min={AsyncMode:AsyncMode,ConcurrentMode:ConcurrentMode,ContextConsumer:ContextConsumer,ContextProvider:ContextProvider,Element:Element,ForwardRef:ForwardRef,Fragment:Fragment,Lazy:Lazy,Memo:Memo,Portal:Portal,Profiler:Profiler,StrictMode:StrictMode,Suspense:Suspense,isAsyncMode:isAsyncMode,isConcurrentMode:isConcurrentMode,isContextConsumer:isContextConsumer,isContextProvider:isContextProvider,isElement:isElement,isForwardRef:isForwardRef,isFragment:isFragment,isLazy:isLazy,isMemo:isMemo,isPortal:isPortal,isProfiler:isProfiler,isStrictMode:isStrictMode,isSuspense:isSuspense,isValidElementType:isValidElementType,typeOf:typeOf},reactIs_development=createCommonjsModule(function(e,t){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,a=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,f=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,y=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,b=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,h=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:var y=e.type;switch(y){case u:case f:case o:case i:case a:case l:return y;default:var b=y&&y.$$typeof;switch(b){case s:case p:case m:case d:case c:return b;default:return t}}case n:return t}}}var w=u,T=f,O=s,P=c,_=r,E=p,x=o,C=m,$=d,R=n,j=i,N=a,k=l,M=!1;function I(e){return S(e)===f}t.AsyncMode=w,t.ConcurrentMode=T,t.ContextConsumer=O,t.ContextProvider=P,t.Element=_,t.ForwardRef=E,t.Fragment=x,t.Lazy=C,t.Memo=$,t.Portal=R,t.Profiler=j,t.StrictMode=N,t.Suspense=k,t.isAsyncMode=function(e){return M||(M=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),I(e)||S(e)===u},t.isConcurrentMode=I,t.isContextConsumer=function(e){return S(e)===s},t.isContextProvider=function(e){return S(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return S(e)===p},t.isFragment=function(e){return S(e)===o},t.isLazy=function(e){return S(e)===m},t.isMemo=function(e){return S(e)===d},t.isPortal=function(e){return S(e)===n},t.isProfiler=function(e){return S(e)===i},t.isStrictMode=function(e){return S(e)===a},t.isSuspense=function(e){return S(e)===l},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===f||e===i||e===a||e===l||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===c||e.$$typeof===s||e.$$typeof===p||e.$$typeof===v||e.$$typeof===h||e.$$typeof===g||e.$$typeof===b)},t.typeOf=S}()}),reactIs=createCommonjsModule(function(e){"production"===process.env.NODE_ENV?e.exports=reactIs_production_min:e.exports=reactIs_development}),getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function shouldUseNative(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}var objectAssign=shouldUseNative()?Object.assign:function(e,t){for(var r,n,o=toObject(e),a=1;a<arguments.length;a++){for(var i in r=Object(arguments[a]))hasOwnProperty.call(r,i)&&(o[i]=r[i]);if(getOwnPropertySymbols){n=getOwnPropertySymbols(r);for(var c=0;c<n.length;c++)propIsEnumerable.call(r,n[c])&&(o[n[c]]=r[n[c]])}}return o},ReactPropTypesSecret="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ReactPropTypesSecret_1=ReactPropTypesSecret,printWarning=function(){};if("production"!==process.env.NODE_ENV){var ReactPropTypesSecret$1=ReactPropTypesSecret_1,loggedTypeFailures={},has=Function.call.bind(Object.prototype.hasOwnProperty);printWarning=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function checkPropTypes(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var a in e)if(has(e,a)){var i;try{if("function"!=typeof e[a]){var c=Error((n||"React class")+": "+r+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[a]+"`.");throw c.name="Invariant Violation",c}i=e[a](t,a,n,r,null,ReactPropTypesSecret$1)}catch(e){i=e}if(!i||i instanceof Error||printWarning((n||"React class")+": type specification of "+r+" `"+a+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof i+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),i instanceof Error&&!(i.message in loggedTypeFailures)){loggedTypeFailures[i.message]=!0;var s=o?o():"";printWarning("Failed "+r+" type: "+i.message+(null!=s?s:""))}}}checkPropTypes.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(loggedTypeFailures={})};var checkPropTypes_1=checkPropTypes,has$1=Function.call.bind(Object.prototype.hasOwnProperty),printWarning$1=function(){};function emptyFunctionThatReturnsNull(){return null}"production"!==process.env.NODE_ENV&&(printWarning$1=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}});var factoryWithTypeCheckers=function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n="@@iterator";var o="<<anonymous>>",a={array:u("array"),bool:u("boolean"),func:u("function"),number:u("number"),object:u("object"),string:u("string"),symbol:u("symbol"),any:s(emptyFunctionThatReturnsNull),arrayOf:function(e){return s(function(t,r,n,o,a){if("function"!=typeof e)return new c("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var i=t[r];if(!Array.isArray(i)){var s=p(i);return new c("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+n+"`, expected an array.")}for(var u=0;u<i.length;u++){var f=e(i,u,n,o,a+"["+u+"]",ReactPropTypesSecret_1);if(f instanceof Error)return f}return null})},element:function(){return s(function(t,r,n,o,a){var i=t[r];if(!e(i)){var s=p(i);return new c("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+n+"`, expected a single ReactElement.")}return null})}(),elementType:function(){return s(function(e,t,r,n,o){var a=e[t];if(!reactIs.isValidElementType(a)){var i=p(a);return new c("Invalid "+n+" `"+o+"` of type `"+i+"` supplied to `"+r+"`, expected a single ReactElement type.")}return null})}(),instanceOf:function(e){return s(function(t,r,n,a,i){if(!(t[r]instanceof e)){var s=e.name||o,u=function(e){if(!e.constructor||!e.constructor.name)return o;return e.constructor.name}(t[r]);return new c("Invalid "+a+" `"+i+"` of type `"+u+"` supplied to `"+n+"`, expected instance of `"+s+"`.")}return null})},node:function(){return s(function(e,t,r,n,o){if(!f(e[t]))return new c("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.");return null})}(),objectOf:function(e){return s(function(t,r,n,o,a){if("function"!=typeof e)return new c("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var i=t[r],s=p(i);if("object"!==s)return new c("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+n+"`, expected an object.");for(var u in i)if(has$1(i,u)){var f=e(i,u,n,o,a+"."+u,ReactPropTypesSecret_1);if(f instanceof Error)return f}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&(arguments.length>1?printWarning$1("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):printWarning$1("Invalid argument supplied to oneOf, expected an array.")),emptyFunctionThatReturnsNull;return s(function(t,r,n,o,a){for(var s=t[r],u=0;u<e.length;u++)if(i(s,e[u]))return null;var f=JSON.stringify(e,function(e,t){var r=l(t);return"symbol"===r?String(t):t});return new c("Invalid "+o+" `"+a+"` of value `"+String(s)+"` supplied to `"+n+"`, expected one of "+f+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&printWarning$1("Invalid argument supplied to oneOfType, expected an instance of array."),emptyFunctionThatReturnsNull;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return printWarning$1("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+y(r)+" at index "+t+"."),emptyFunctionThatReturnsNull}return s(function(t,r,n,o,a){for(var i=0;i<e.length;i++){var s=e[i];if(null==s(t,r,n,o,a,ReactPropTypesSecret_1))return null}return new c("Invalid "+o+" `"+a+"` supplied to `"+n+"`.")})},shape:function(e){return s(function(t,r,n,o,a){var i=t[r],s=p(i);if("object"!==s)return new c("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+n+"`, expected `object`.");for(var u in e){var f=e[u];if(f){var l=f(i,u,n,o,a+"."+u,ReactPropTypesSecret_1);if(l)return l}}return null})},exact:function(e){return s(function(t,r,n,o,a){var i=t[r],s=p(i);if("object"!==s)return new c("Invalid "+o+" `"+a+"` of type `"+s+"` supplied to `"+n+"`, expected `object`.");var u=objectAssign({},t[r],e);for(var f in u){var l=e[f];if(!l)return new c("Invalid "+o+" `"+a+"` key `"+f+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=l(i,f,n,o,a+"."+f,ReactPropTypesSecret_1);if(y)return y}return null})}};function i(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function c(e){this.message=e,this.stack=""}function s(e){if("production"!==process.env.NODE_ENV)var r={},n=0;function a(a,i,s,u,f,p,l){if(u=u||o,p=p||s,l!==ReactPropTypesSecret_1){if(t){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var d=u+":"+s;!r[d]&&n<3&&(printWarning$1("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+u+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),r[d]=!0,n++)}}return null==i[s]?a?null===i[s]?new c("The "+f+" `"+p+"` is marked as required in `"+u+"`, but its value is `null`."):new c("The "+f+" `"+p+"` is marked as required in `"+u+"`, but its value is `undefined`."):null:e(i,s,u,f,p)}var i=a.bind(null,!1);return i.isRequired=a.bind(null,!0),i}function u(e){return s(function(t,r,n,o,a,i){var s=t[r];return p(s)!==e?new c("Invalid "+o+" `"+a+"` of type `"+l(s)+"` supplied to `"+n+"`, expected `"+e+"`."):null})}function f(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(f);if(null===t||e(t))return!0;var o=function(e){var t=e&&(r&&e[r]||e[n]);if("function"==typeof t)return t}(t);if(!o)return!1;var a,i=o.call(t);if(o!==t.entries){for(;!(a=i.next()).done;)if(!f(a.value))return!1}else for(;!(a=i.next()).done;){var c=a.value;if(c&&!f(c[1]))return!1}return!0;default:return!1}}function p(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function l(e){if(null==e)return""+e;var t=p(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function y(e){var t=l(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return c.prototype=Error.prototype,a.checkPropTypes=checkPropTypes_1,a.resetWarningCache=checkPropTypes_1.resetWarningCache,a.PropTypes=a,a};function emptyFunction(){}function emptyFunctionWithReset(){}emptyFunctionWithReset.resetWarningCache=emptyFunction;var openNotification,factoryWithThrowingShims=function(){function e(e,t,r,n,o,a){if(a!==ReactPropTypesSecret_1){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:emptyFunctionWithReset,resetWarningCache:emptyFunction};return r.PropTypes=r,r},propTypes=createCommonjsModule(function(e){if("production"!==process.env.NODE_ENV){var t=reactIs;e.exports=factoryWithTypeCheckers(t.isElement,!0)}else e.exports=factoryWithThrowingShims()}),variants={white:"#fff",primary:"#007bff",secondary:"#6c757d",success:"#28a745",info:"#17a2b8",warning:"#ffc107",danger:"#dc3545",light:"#f8f9fa",dark:"#343a40"},notify=function(e){var t=e.text,r=void 0===t?"":t,n=e.variant,o=void 0===n?"primary":n,a=e.onClose;if(!openNotification)throw new Error("Can't use notify before declaration");openNotification(r,o,a)},Notification=function(e){function t(){var t;return(t=e.call(this)||this).state={show:!1,variant:variants.primary,text:"",onClose:null},t.open=function(e,r,n){void 0===e&&(e=""),void 0===r&&(r="primary"),t.setState({show:!0,text:e,variant:variants[r],onClose:n})},t.onClose=function(){t.setState({show:!1}),t.state.onClose&&t.state.onClose()},openNotification=t.open,t}return _inheritsLoose(t,e),t.prototype.render=function(){var e,t=this.props.options,r=this.state,n=r.show,o=r.variant,a=r.text,i=!1,c=4e3,s=!0,u="bottom";return t&&(i=t.animation||!1,c=t.delay||4e3,s=t.autohide||!0,u=t.position||"bottom"),React__default.createElement("div",{className:"d-flex justify-content-center"},React__default.createElement(Toast,{style:(e={background:o,position:"fixed"},e[u]=20,e.zIndex=9999,e),onClose:this.onClose,show:n,animation:i,delay:c,autohide:s},React__default.createElement(Toast.Header,null,React__default.createElement("strong",{className:"mr-auto"},a))))},t}(React.Component);Notification.propTypes={options:propTypes.shape({animation:propTypes.bool,delay:propTypes.number,autohide:propTypes.bool})},exports.default=Notification,exports.notify=notify;