New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@acpaas-ui/js-notification-store

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acpaas-ui/js-notification-store - npm Package Compare versions

Comparing version 1.0.1-alpha.2 to 1.0.1-alpha.3

2

acpaas-ui-js-notification-store.amd.js

@@ -1,2 +0,2 @@

define(["exports","rxjs/BehaviorSubject","escape-string-regexp"],function(exports,BehaviorSubject,escapeStringRegExp){"use strict";escapeStringRegExp=escapeStringRegExp&&escapeStringRegExp.hasOwnProperty("default")?escapeStringRegExp.default:escapeStringRegExp;var NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,Notification),options=babelHelpers.extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return babelHelpers.createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return babelHelpers.extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return babelHelpers.extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return babelHelpers.createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject.BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return babelHelpers.extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(babelHelpers.toConsumableArray(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return babelHelpers.extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),babelHelpers.createClass(NotificationStore,[{key:"getMessages",value:function(){return babelHelpers.extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(babelHelpers.extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();exports.Notification=Notification,exports.NotificationStore=NotificationStore,Object.defineProperty(exports,"__esModule",{value:!0})});
define(["exports","rxjs/BehaviorSubject","escape-string-regexp"],function(exports,BehaviorSubject,escapeStringRegExp){"use strict";escapeStringRegExp=escapeStringRegExp&&escapeStringRegExp.hasOwnProperty("default")?escapeStringRegExp.default:escapeStringRegExp;var NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")},createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,Notification),options=_extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return _extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return _extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:_extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject.BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=_extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return _extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return _extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=_extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),createClass(NotificationStore,[{key:"getMessages",value:function(){return _extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(_extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();exports.Notification=Notification,exports.NotificationStore=NotificationStore,Object.defineProperty(exports,"__esModule",{value:!0})});
//# sourceMappingURL=acpaas-ui-js-notification-store.amd.js.map

@@ -1,2 +0,2 @@

"use strict";function _interopDefault(ex){return ex&&"object"==typeof ex&&"default"in ex?ex.default:ex}Object.defineProperty(exports,"__esModule",{value:!0});var BehaviorSubject=require("rxjs/BehaviorSubject"),escapeStringRegExp=_interopDefault(require("escape-string-regexp")),NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,Notification),options=babelHelpers.extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return babelHelpers.createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return babelHelpers.extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return babelHelpers.extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return babelHelpers.createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject.BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return babelHelpers.extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(babelHelpers.toConsumableArray(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return babelHelpers.extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),babelHelpers.createClass(NotificationStore,[{key:"getMessages",value:function(){return babelHelpers.extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(babelHelpers.extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();exports.Notification=Notification,exports.NotificationStore=NotificationStore;
"use strict";function _interopDefault(ex){return ex&&"object"==typeof ex&&"default"in ex?ex.default:ex}Object.defineProperty(exports,"__esModule",{value:!0});var BehaviorSubject=require("rxjs/BehaviorSubject"),escapeStringRegExp=_interopDefault(require("escape-string-regexp")),NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")},createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,Notification),options=_extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return _extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return _extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:_extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject.BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=_extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return _extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(toConsumableArray(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return _extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=_extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),createClass(NotificationStore,[{key:"getMessages",value:function(){return _extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(_extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();exports.Notification=Notification,exports.NotificationStore=NotificationStore;
//# sourceMappingURL=acpaas-ui-js-notification-store.cjs.js.map

@@ -1,2 +0,2 @@

import{BehaviorSubject}from"rxjs/BehaviorSubject";import escapeStringRegExp from"escape-string-regexp";var NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,Notification),options=babelHelpers.extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return babelHelpers.createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return babelHelpers.extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return babelHelpers.extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return babelHelpers.createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return babelHelpers.extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(babelHelpers.toConsumableArray(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return babelHelpers.extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),babelHelpers.createClass(NotificationStore,[{key:"getMessages",value:function(){return babelHelpers.extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(babelHelpers.extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();export{Notification,NotificationStore};
import{BehaviorSubject}from"rxjs/BehaviorSubject";import escapeStringRegExp from"escape-string-regexp";var NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")},createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,Notification),options=_extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return _extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return _extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:_extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=_extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return _extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(toConsumableArray(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return _extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=_extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),createClass(NotificationStore,[{key:"getMessages",value:function(){return _extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(_extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();export{Notification,NotificationStore};
//# sourceMappingURL=acpaas-ui-js-notification-store.es.js.map

@@ -1,2 +0,2 @@

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("rxjs/BehaviorSubject"),require("escape-string-regexp")):"function"==typeof define&&define.amd?define(["exports","rxjs/BehaviorSubject","escape-string-regexp"],factory):factory(global["@acpaas-ui/js-notification-store"]=global["@acpaas-ui/js-notification-store"]||{},null,null)}(this,function(exports,BehaviorSubject,escapeStringRegExp){"use strict";escapeStringRegExp=escapeStringRegExp&&escapeStringRegExp.hasOwnProperty("default")?escapeStringRegExp.default:escapeStringRegExp;var NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,Notification),options=babelHelpers.extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return babelHelpers.createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return babelHelpers.extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return babelHelpers.extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};babelHelpers.classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return babelHelpers.createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject.BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return babelHelpers.extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(babelHelpers.toConsumableArray(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return babelHelpers.extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=babelHelpers.extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),babelHelpers.createClass(NotificationStore,[{key:"getMessages",value:function(){return babelHelpers.extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(babelHelpers.extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();exports.Notification=Notification,exports.NotificationStore=NotificationStore,Object.defineProperty(exports,"__esModule",{value:!0})});
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("rxjs/BehaviorSubject"),require("escape-string-regexp")):"function"==typeof define&&define.amd?define(["exports","rxjs/BehaviorSubject","escape-string-regexp"],factory):factory(global["@acpaas-ui/js-notification-store"]=global["@acpaas-ui/js-notification-store"]||{},null,null)}(this,function(exports,BehaviorSubject,escapeStringRegExp){"use strict";escapeStringRegExp=escapeStringRegExp&&escapeStringRegExp.hasOwnProperty("default")?escapeStringRegExp.default:escapeStringRegExp;var NOTIFICATION_STORE_DEFAULTS={allowOverrides:!1,defaultHandle:"system",defaultTarget:"system",defaultMessage:"Something went wrong.",defaultScope:"root",defaultTimer:0},NOTIFICATION_TYPES={INFO:"I",ERROR:"E",WARNING:"W",SUCCESS:"S",NOTIFICATION:"N"},NOTIFICATION_DEFAULTS={handle:NOTIFICATION_STORE_DEFAULTS.defaultHandle,target:NOTIFICATION_STORE_DEFAULTS.defaultTarget,type:NOTIFICATION_TYPES.NOTIFICATION,timer:NOTIFICATION_STORE_DEFAULTS.defaultTimer,scope:NOTIFICATION_STORE_DEFAULTS.defaultScope},classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")},createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},Notification=function(){function Notification(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,Notification),options=_extends({},NOTIFICATION_DEFAULTS,options),this.handle=options.handle,this.target=options.target,this.message=options.message,this.type=options.type,this.timer=options.timer,this.scope=options.scope}return createClass(Notification,null,[{key:"parseOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},result={};for(var prop in NOTIFICATION_DEFAULTS)result[prop]=options[prop]||NOTIFICATION_DEFAULTS[prop];return result}},{key:"defaultOptions",get:function(){return _extends({},NOTIFICATION_DEFAULTS)}},{key:"availableTypes",get:function(){return _extends({},NOTIFICATION_TYPES)}}]),Notification}(),API={options:_extends({},NOTIFICATION_STORE_DEFAULTS),messages:{},notifications:new Map,subjects:new Map},NotificationStore=function(){function NotificationStore(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};classCallCheck(this,NotificationStore),this.loadMessages(newMessages),this.notifications=NotificationStore.subscriber(this)}return createClass(NotificationStore,null,[{key:"subscriber",value:function(store){if(!store)throw Error("No store provided to subscribe to!");return API.subjects.set(store,new BehaviorSubject.BehaviorSubject(NotificationStore.getFlatNotifications())),API.subjects.get(store)}},{key:"getFlatTarget",value:function(targetKey){var notifications=[],target=API.notifications.get(targetKey);return target&&target.forEach(function(notification){notifications.push(notification)}),notifications}},{key:"getFlatNotifications",value:function(target){if(target)return NotificationStore.getFlatTarget(target);var notifications={};return API.notifications.forEach(function(value,t){notifications[t]=NotificationStore.getFlatTarget(t)}),notifications}},{key:"deleteNotification",value:function(notification){if(!(notification&&notification instanceof Notification))throw Error("Invalid notification provided.");var target=API.notifications.get(notification.target);target&&(target.delete(notification),NotificationStore.updateSubjects())}},{key:"updateSubjects",value:function(){var currNotifications=NotificationStore.getFlatNotifications();API.subjects.forEach(function(subject){subject.next(currNotifications)})}},{key:"resetStore",value:function(){API.options=_extends({},NOTIFICATION_STORE_DEFAULTS),API.messages={},API.notifications=new Map,API.subjects=new Map}},{key:"allowOverrides",get:function(){return API.options.allowOverrides},set:function(){var newValue=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return API.options.allowOverrides="boolean"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.allowOverrides,API.options.allowOverrides}},{key:"defaultHandle",get:function(){return API.options.defaultHandle},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultHandle;return API.options.defaultHandle=newValue.toString(),API.options.defaultHandle}},{key:"defaultTarget",get:function(){return API.options.defaultTarget},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTarget;return API.options.defaultTarget=newValue.toString(),API.options.defaultTarget}},{key:"defaultMessage",get:function(){return API.options.defaultMessage},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultMessage;return API.options.defaultMessage=newValue.toString(),API.options.defaultMessage}},{key:"defaultScope",get:function(){return API.options.defaultScope},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultScope;return API.options.defaultScope=newValue.toString(),API.options.defaultScope}},{key:"defaultTimer",get:function(){return API.options.defaultTimer},set:function(){var newValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS.defaultTimer;return API.options.defaultTimer="number"==typeof newValue?newValue:NOTIFICATION_STORE_DEFAULTS.defaultTimer,API.options.defaultTimer}},{key:"messages",get:function(){return _extends({},API.messages)},set:function(){var newMessages=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},messageLoader=[API.messages,newMessages];return API.messages=NotificationStore.allowOverrides?Object.assign.apply(Object,[{}].concat(messageLoader)):Object.assign.apply(Object,[{}].concat(function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}(messageLoader.reverse()))),API.messages}},{key:"options",get:function(){return _extends({},API.options)},set:function(){var newOptions=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NOTIFICATION_STORE_DEFAULTS;return API.options=_extends({},NOTIFICATION_STORE_DEFAULTS,newOptions),API.options}},{key:"subjects",get:function(){return API.subjects}}]),createClass(NotificationStore,[{key:"getMessages",value:function(){return _extends({},API.messages)}},{key:"getMessage",value:function(handle){var replace=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},msg=API.messages.hasOwnProperty(handle)?API.messages[handle]:API.options.defaultMessage,patterns=Object.getOwnPropertyNames(replace).map(function(prop){return escapeStringRegExp(prop)}).join("|"),pattern=new RegExp("<% ("+patterns+") %>","g");return msg.replace(pattern,function(match,prop){return replace[prop]})}},{key:"loadMessages",value:function(newMessages){NotificationStore.messages=newMessages}},{key:"triggerNotification",value:function(){var handle=arguments.length>0&&void 0!==arguments[0]?arguments[0]:NotificationStore.defaultHandle,target=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NotificationStore.defaultTarget,options=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},replace=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},notification=new Notification(_extends({message:options.message||this.getMessage(handle,replace)},Notification.parseOptions(options),{handle:handle,target:target}));this.loadNotification(notification)}},{key:"loadNotification",value:function(notification){if(!notification||!notification.target)throw Error("Invalid notification provided.");API.notifications.has(notification.target)||API.notifications.set(notification.target,new Map),API.notifications.get(notification.target).set(notification,notification),NotificationStore.updateSubjects()}},{key:"getNotifications",value:function(target){return NotificationStore.getFlatNotifications(target)}},{key:"clearNotification",value:function(notification){NotificationStore.deleteNotification(notification)}},{key:"clearTarget",value:function(target){if(!target)throw Error("No target provided.");API.notifications.has(target)&&(API.notifications.delete(target),NotificationStore.updateSubjects())}}]),NotificationStore}();exports.Notification=Notification,exports.NotificationStore=NotificationStore,Object.defineProperty(exports,"__esModule",{value:!0})});
//# sourceMappingURL=acpaas-ui-js-notification-store.umd.js.map
{
"name": "@acpaas-ui/js-notification-store",
"version": "1.0.1-alpha.2",
"version": "1.0.1-alpha.3",
"description": "The Notification Store provides a singleton store to save and easily access notifications throughout your app.",

@@ -5,0 +5,0 @@ "main": "js-notification-store.umd.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc