@energycap/components 0.27.8 → 0.27.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/energycap-components.umd.js +130 -110
- package/bundles/energycap-components.umd.js.map +1 -1
- package/bundles/energycap-components.umd.min.js +2 -2
- package/bundles/energycap-components.umd.min.js.map +1 -1
- package/energycap-components.metadata.json +1 -1
- package/esm2015/lib/controls/banner/banner.component.js +24 -3
- package/fesm2015/energycap-components.js +125 -105
- package/fesm2015/energycap-components.js.map +1 -1
- package/lib/controls/banner/banner.component.d.ts +9 -0
- package/package.json +1 -1
|
@@ -9,8 +9,117 @@
|
|
|
9
9
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
10
10
|
var Popper__default = /*#__PURE__*/_interopDefaultLegacy(Popper);
|
|
11
11
|
|
|
12
|
+
var CacheService = /** @class */ (function () {
|
|
13
|
+
function CacheService() {
|
|
14
|
+
this.localStorageAvailable = false;
|
|
15
|
+
this.sessionStorageAvailable = false;
|
|
16
|
+
var cacheError = null;
|
|
17
|
+
try {
|
|
18
|
+
var dateStr = 'roundtrip-test-' + new Date().getTime();
|
|
19
|
+
var value = 'val-' + dateStr;
|
|
20
|
+
localStorage.setItem(dateStr, value);
|
|
21
|
+
sessionStorage.setItem(dateStr, value);
|
|
22
|
+
this.localStorageAvailable = localStorage.getItem(dateStr) == value;
|
|
23
|
+
this.sessionStorageAvailable = sessionStorage.getItem(dateStr) == value;
|
|
24
|
+
localStorage.removeItem(dateStr);
|
|
25
|
+
sessionStorage.removeItem(dateStr);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
cacheError = error;
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
if (!this.localStorageAvailable || !this.sessionStorageAvailable) {
|
|
32
|
+
console.warn('storage unavailable for caching purposes. Some features will not be fully supported. ', {
|
|
33
|
+
local: this.localStorageAvailable,
|
|
34
|
+
session: this.sessionStorageAvailable,
|
|
35
|
+
error: cacheError
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**Return true if the requested cache allows the user to round-trip data in the current environment.
|
|
41
|
+
* Security settings can prevent it and the app may need to know if "not found" means "never set" or "not supported"
|
|
42
|
+
*/
|
|
43
|
+
CacheService.prototype.isCacheAvailable = function (sessionOnly) {
|
|
44
|
+
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
45
|
+
return sessionOnly ? this.sessionStorageAvailable : this.localStorageAvailable;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve an item from cache
|
|
49
|
+
*/
|
|
50
|
+
CacheService.prototype.getItem = function (key, sessionOnly) {
|
|
51
|
+
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
52
|
+
var storage = this.getStorage(sessionOnly);
|
|
53
|
+
if (storage) {
|
|
54
|
+
var result = storage.getItem(key);
|
|
55
|
+
if (result) {
|
|
56
|
+
return JSON.parse(result);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves all keys from cache
|
|
63
|
+
*/
|
|
64
|
+
CacheService.prototype.keys = function (sessionOnly) {
|
|
65
|
+
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
66
|
+
var result = new Array();
|
|
67
|
+
var storage = this.getStorage(sessionOnly);
|
|
68
|
+
if (storage) {
|
|
69
|
+
for (var i = 0, len = storage.length; i < len; ++i) {
|
|
70
|
+
result.push(storage.key(i));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Removes an item from the cache
|
|
77
|
+
*/
|
|
78
|
+
CacheService.prototype.removeItem = function (key, sessionOnly) {
|
|
79
|
+
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
80
|
+
var storage = this.getStorage(sessionOnly);
|
|
81
|
+
if (storage) {
|
|
82
|
+
storage.removeItem(key);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Persists an item to cache
|
|
87
|
+
*/
|
|
88
|
+
CacheService.prototype.setItem = function (key, value, sessionOnly) {
|
|
89
|
+
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
90
|
+
var storage = this.getStorage(sessionOnly);
|
|
91
|
+
if (storage) {
|
|
92
|
+
storage.setItem(key, JSON.stringify(value));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**Returns the local or session storage to use for backing the given cache request.
|
|
96
|
+
* If the browser does not support the requested storage the result will be null.
|
|
97
|
+
* This can happen if the user is in Firefox for example with the setting dom.storage.enabled = false
|
|
98
|
+
*/
|
|
99
|
+
CacheService.prototype.getStorage = function (sessionOnly) {
|
|
100
|
+
if (sessionOnly && this.sessionStorageAvailable) {
|
|
101
|
+
return window.sessionStorage;
|
|
102
|
+
}
|
|
103
|
+
else if (this.localStorageAvailable) {
|
|
104
|
+
return window.localStorage;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return CacheService;
|
|
111
|
+
}());
|
|
112
|
+
CacheService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CacheService_Factory() { return new CacheService(); }, token: CacheService, providedIn: "root" });
|
|
113
|
+
CacheService.decorators = [
|
|
114
|
+
{ type: i0.Injectable, args: [{
|
|
115
|
+
providedIn: 'root'
|
|
116
|
+
},] }
|
|
117
|
+
];
|
|
118
|
+
CacheService.ctorParameters = function () { return []; };
|
|
119
|
+
|
|
12
120
|
var BannerComponent = /** @class */ (function () {
|
|
13
|
-
function BannerComponent() {
|
|
121
|
+
function BannerComponent(cacheService) {
|
|
122
|
+
this.cacheService = cacheService;
|
|
14
123
|
/** hidden hides the banner */
|
|
15
124
|
this.hidden = false;
|
|
16
125
|
/**The ID of the component, rendered into the HTML to make it more accessible to automation */
|
|
@@ -22,6 +131,8 @@
|
|
|
22
131
|
this.showCloseBtn = false;
|
|
23
132
|
/** When true, the banner will hide itself when the close button is clicked */
|
|
24
133
|
this.autoHideOnClose = true;
|
|
134
|
+
/** When true, the banner will automatically hide itself based on the state found in local storage */
|
|
135
|
+
this.rememberClosed = false;
|
|
25
136
|
/**Event to hide the banner */
|
|
26
137
|
this.closed = new i0.EventEmitter();
|
|
27
138
|
/**
|
|
@@ -29,6 +140,7 @@
|
|
|
29
140
|
* If no value for overrideIcon is provided, will be automatically selected based on the type input.
|
|
30
141
|
*/
|
|
31
142
|
this.icon = '';
|
|
143
|
+
this.cacheKeyPrefix = 'dismissableBanner-';
|
|
32
144
|
}
|
|
33
145
|
BannerComponent.prototype.ngOnChanges = function () {
|
|
34
146
|
if (this.customIcon) {
|
|
@@ -37,12 +149,24 @@
|
|
|
37
149
|
else {
|
|
38
150
|
this.getIconByBannerType();
|
|
39
151
|
}
|
|
152
|
+
if (this.rememberClosed) {
|
|
153
|
+
var cacheValue = this.cacheService.getItem("" + this.cacheKeyPrefix + this.id);
|
|
154
|
+
if (cacheValue) {
|
|
155
|
+
this.hidden = cacheValue.hidden;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this.hidden = false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
40
161
|
};
|
|
41
162
|
/** On close, explicitly hide the banner one time. If the input changes afterward then it can reappear*/
|
|
42
163
|
BannerComponent.prototype.close = function () {
|
|
43
164
|
if (this.autoHideOnClose) {
|
|
44
165
|
this.hidden = true;
|
|
45
166
|
}
|
|
167
|
+
if (this.rememberClosed) {
|
|
168
|
+
this.cacheService.setItem("" + this.cacheKeyPrefix + this.id, { hidden: true });
|
|
169
|
+
}
|
|
46
170
|
this.closed.emit();
|
|
47
171
|
};
|
|
48
172
|
BannerComponent.prototype.getIconByBannerType = function () {
|
|
@@ -64,10 +188,13 @@
|
|
|
64
188
|
BannerComponent.decorators = [
|
|
65
189
|
{ type: i0.Component, args: [{
|
|
66
190
|
selector: 'ec-banner',
|
|
67
|
-
template: "<div class=\"banner {{type}} {{bannerStyle}}\">\r\n <ec-button id=\"banner{{id}}_close\"\r\n *ngIf=\"showCloseBtn\"\r\n type=\"icon\"\r\n icon=\"ec-icon-sm icon-cancel\"\r\n (clicked)=\"close()\">\r\n </ec-button>\r\n <div class=\"banner-content d-flex text-body-1 font-color-secondary\">\r\n <i class=\"ec-icon {{icon}}\"></i>\r\n <div class=\"ml-2\">\r\n <p class=\"title mb-0\" *ngIf=\"title\">\r\n {{title}}\r\n </p>\r\n <p class=\"text mb-0\" *ngIf=\"text\">{{text}}</p>\r\n \r\n <ul class=\"list mb-0\" *ngIf=\"list?.length\">\r\n <li *ngFor=\"let item of list\">{{item}}</li>\r\n </ul>\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n",
|
|
191
|
+
template: "<div id=\"banner_{{id}}\" class=\"banner {{type}} {{bannerStyle}}\">\r\n <ec-button id=\"banner{{id}}_close\"\r\n *ngIf=\"showCloseBtn\"\r\n type=\"icon\"\r\n icon=\"ec-icon-sm icon-cancel\"\r\n (clicked)=\"close()\">\r\n </ec-button>\r\n <div class=\"banner-content d-flex text-body-1 font-color-secondary\">\r\n <i class=\"ec-icon {{icon}}\"></i>\r\n <div class=\"ml-2\">\r\n <p class=\"title mb-0\" *ngIf=\"title\">\r\n {{title}}\r\n </p>\r\n <p class=\"text mb-0\" *ngIf=\"text\">{{text}}</p>\r\n \r\n <ul class=\"list mb-0\" *ngIf=\"list?.length\">\r\n <li *ngFor=\"let item of list\">{{item}}</li>\r\n </ul>\r\n <ng-content></ng-content>\r\n </div>\r\n </div>\r\n\r\n</div>\r\n",
|
|
68
192
|
styles: ["@-webkit-keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}:host{display:flex}:host(.border-bottom-0) .banner{border-bottom:0}.banner{display:flex;flex:1 1;flex-direction:column;min-height:2.5rem;overflow-y:auto;position:relative}.banner-content{flex:none;margin:auto 0;padding:.5rem 1rem}.banner-content ::ng-deep p{line-height:inherit}.ec-icon{font-size:1.125rem}ec-button{position:absolute;right:.25rem;top:.25rem}ec-button+.banner-content{padding-right:2.75rem}.title{font-weight:700}.list{margin:0;padding-left:2em}.text+.list{margin-top:1em}.info{background-color:#dae4e9}.info .banner-content>.ec-icon{color:#2d9ab8}.warning{background-color:#fff8cc}.warning .banner-content>.ec-icon{color:#fa7b2e}.success{background-color:#dff0d8}.success .banner-content>.ec-icon{color:#3c763d}.error{background-color:#ecc4c5}.error .banner-content>.ec-icon{color:#cd1d20}.pinned{border-bottom:1px solid rgba(26,26,35,.08)}.toast{border:1px solid rgba(26,26,35,.08);box-shadow:0 .125rem .625rem 0 rgba(26,26,35,.18)}.toast ec-button{right:.1875rem;top:.1875rem}"]
|
|
69
193
|
},] }
|
|
70
194
|
];
|
|
195
|
+
BannerComponent.ctorParameters = function () { return [
|
|
196
|
+
{ type: CacheService }
|
|
197
|
+
]; };
|
|
71
198
|
BannerComponent.propDecorators = {
|
|
72
199
|
hidden: [{ type: i0.HostBinding, args: ['hidden',] }, { type: i0.Input }],
|
|
73
200
|
id: [{ type: i0.Input }],
|
|
@@ -79,6 +206,7 @@
|
|
|
79
206
|
showCloseBtn: [{ type: i0.Input }],
|
|
80
207
|
autoHideOnClose: [{ type: i0.Input }],
|
|
81
208
|
customIcon: [{ type: i0.Input }],
|
|
209
|
+
rememberClosed: [{ type: i0.Input }],
|
|
82
210
|
closed: [{ type: i0.Output }]
|
|
83
211
|
};
|
|
84
212
|
|
|
@@ -5864,114 +5992,6 @@
|
|
|
5864
5992
|
maxLength: [{ type: i0.Input }]
|
|
5865
5993
|
};
|
|
5866
5994
|
|
|
5867
|
-
var CacheService = /** @class */ (function () {
|
|
5868
|
-
function CacheService() {
|
|
5869
|
-
this.localStorageAvailable = false;
|
|
5870
|
-
this.sessionStorageAvailable = false;
|
|
5871
|
-
var cacheError = null;
|
|
5872
|
-
try {
|
|
5873
|
-
var dateStr = 'roundtrip-test-' + new Date().getTime();
|
|
5874
|
-
var value = 'val-' + dateStr;
|
|
5875
|
-
localStorage.setItem(dateStr, value);
|
|
5876
|
-
sessionStorage.setItem(dateStr, value);
|
|
5877
|
-
this.localStorageAvailable = localStorage.getItem(dateStr) == value;
|
|
5878
|
-
this.sessionStorageAvailable = sessionStorage.getItem(dateStr) == value;
|
|
5879
|
-
localStorage.removeItem(dateStr);
|
|
5880
|
-
sessionStorage.removeItem(dateStr);
|
|
5881
|
-
}
|
|
5882
|
-
catch (error) {
|
|
5883
|
-
cacheError = error;
|
|
5884
|
-
}
|
|
5885
|
-
finally {
|
|
5886
|
-
if (!this.localStorageAvailable || !this.sessionStorageAvailable) {
|
|
5887
|
-
console.warn('storage unavailable for caching purposes. Some features will not be fully supported. ', {
|
|
5888
|
-
local: this.localStorageAvailable,
|
|
5889
|
-
session: this.sessionStorageAvailable,
|
|
5890
|
-
error: cacheError
|
|
5891
|
-
});
|
|
5892
|
-
}
|
|
5893
|
-
}
|
|
5894
|
-
}
|
|
5895
|
-
/**Return true if the requested cache allows the user to round-trip data in the current environment.
|
|
5896
|
-
* Security settings can prevent it and the app may need to know if "not found" means "never set" or "not supported"
|
|
5897
|
-
*/
|
|
5898
|
-
CacheService.prototype.isCacheAvailable = function (sessionOnly) {
|
|
5899
|
-
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
5900
|
-
return sessionOnly ? this.sessionStorageAvailable : this.localStorageAvailable;
|
|
5901
|
-
};
|
|
5902
|
-
/**
|
|
5903
|
-
* Retrieve an item from cache
|
|
5904
|
-
*/
|
|
5905
|
-
CacheService.prototype.getItem = function (key, sessionOnly) {
|
|
5906
|
-
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
5907
|
-
var storage = this.getStorage(sessionOnly);
|
|
5908
|
-
if (storage) {
|
|
5909
|
-
var result = storage.getItem(key);
|
|
5910
|
-
if (result) {
|
|
5911
|
-
return JSON.parse(result);
|
|
5912
|
-
}
|
|
5913
|
-
}
|
|
5914
|
-
return null;
|
|
5915
|
-
};
|
|
5916
|
-
/**
|
|
5917
|
-
* Retrieves all keys from cache
|
|
5918
|
-
*/
|
|
5919
|
-
CacheService.prototype.keys = function (sessionOnly) {
|
|
5920
|
-
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
5921
|
-
var result = new Array();
|
|
5922
|
-
var storage = this.getStorage(sessionOnly);
|
|
5923
|
-
if (storage) {
|
|
5924
|
-
for (var i = 0, len = storage.length; i < len; ++i) {
|
|
5925
|
-
result.push(storage.key(i));
|
|
5926
|
-
}
|
|
5927
|
-
}
|
|
5928
|
-
return result;
|
|
5929
|
-
};
|
|
5930
|
-
/**
|
|
5931
|
-
* Removes an item from the cache
|
|
5932
|
-
*/
|
|
5933
|
-
CacheService.prototype.removeItem = function (key, sessionOnly) {
|
|
5934
|
-
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
5935
|
-
var storage = this.getStorage(sessionOnly);
|
|
5936
|
-
if (storage) {
|
|
5937
|
-
storage.removeItem(key);
|
|
5938
|
-
}
|
|
5939
|
-
};
|
|
5940
|
-
/**
|
|
5941
|
-
* Persists an item to cache
|
|
5942
|
-
*/
|
|
5943
|
-
CacheService.prototype.setItem = function (key, value, sessionOnly) {
|
|
5944
|
-
if (sessionOnly === void 0) { sessionOnly = false; }
|
|
5945
|
-
var storage = this.getStorage(sessionOnly);
|
|
5946
|
-
if (storage) {
|
|
5947
|
-
storage.setItem(key, JSON.stringify(value));
|
|
5948
|
-
}
|
|
5949
|
-
};
|
|
5950
|
-
/**Returns the local or session storage to use for backing the given cache request.
|
|
5951
|
-
* If the browser does not support the requested storage the result will be null.
|
|
5952
|
-
* This can happen if the user is in Firefox for example with the setting dom.storage.enabled = false
|
|
5953
|
-
*/
|
|
5954
|
-
CacheService.prototype.getStorage = function (sessionOnly) {
|
|
5955
|
-
if (sessionOnly && this.sessionStorageAvailable) {
|
|
5956
|
-
return window.sessionStorage;
|
|
5957
|
-
}
|
|
5958
|
-
else if (this.localStorageAvailable) {
|
|
5959
|
-
return window.localStorage;
|
|
5960
|
-
}
|
|
5961
|
-
else {
|
|
5962
|
-
return null;
|
|
5963
|
-
}
|
|
5964
|
-
};
|
|
5965
|
-
return CacheService;
|
|
5966
|
-
}());
|
|
5967
|
-
CacheService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CacheService_Factory() { return new CacheService(); }, token: CacheService, providedIn: "root" });
|
|
5968
|
-
CacheService.decorators = [
|
|
5969
|
-
{ type: i0.Injectable, args: [{
|
|
5970
|
-
providedIn: 'root'
|
|
5971
|
-
},] }
|
|
5972
|
-
];
|
|
5973
|
-
CacheService.ctorParameters = function () { return []; };
|
|
5974
|
-
|
|
5975
5995
|
/**
|
|
5976
5996
|
* Base class for handling click and drag resizing of elements with a mouse.
|
|
5977
5997
|
* Derived classes must provide the element to be resized and implement the setWidth function.
|