@digipair/skill-web-notification 0.8.14
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/index.cjs.d.ts +1 -0
- package/index.cjs.js +405 -0
- package/index.d.ts +1 -0
- package/index.esm.js +400 -0
- package/libs/skill-web-notification/src/index.d.ts +1 -0
- package/libs/skill-web-notification/src/lib/skill-web-notification.d.ts +3 -0
- package/package.json +7 -0
- package/schema.json +53 -0
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
6
|
+
|
|
7
|
+
var toastify$1 = {
|
|
8
|
+
exports: {}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
(function (module) {
|
|
12
|
+
function _instanceof(left, right) {
|
|
13
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
14
|
+
return !!right[Symbol.hasInstance](left);
|
|
15
|
+
} else {
|
|
16
|
+
return left instanceof right;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/*!
|
|
20
|
+
* Toastify js 1.12.0
|
|
21
|
+
* https://github.com/apvarun/toastify-js
|
|
22
|
+
* @license MIT licensed
|
|
23
|
+
*
|
|
24
|
+
* Copyright (C) 2018 Varun A P
|
|
25
|
+
*/ (function(root, factory) {
|
|
26
|
+
if (module.exports) {
|
|
27
|
+
module.exports = factory();
|
|
28
|
+
} else {
|
|
29
|
+
root.Toastify = factory();
|
|
30
|
+
}
|
|
31
|
+
})(commonjsGlobal, function(global) {
|
|
32
|
+
// Object initialization
|
|
33
|
+
var Toastify = function Toastify1(options) {
|
|
34
|
+
// Returning a new init object
|
|
35
|
+
return new Toastify.lib.init(options);
|
|
36
|
+
}, // Library version
|
|
37
|
+
version = "1.12.0";
|
|
38
|
+
// Set the default global options
|
|
39
|
+
Toastify.defaults = {
|
|
40
|
+
oldestFirst: true,
|
|
41
|
+
text: "Toastify is awesome!",
|
|
42
|
+
node: undefined,
|
|
43
|
+
duration: 3000,
|
|
44
|
+
selector: undefined,
|
|
45
|
+
callback: function callback() {},
|
|
46
|
+
destination: undefined,
|
|
47
|
+
newWindow: false,
|
|
48
|
+
close: false,
|
|
49
|
+
gravity: "toastify-top",
|
|
50
|
+
positionLeft: false,
|
|
51
|
+
position: "",
|
|
52
|
+
backgroundColor: "",
|
|
53
|
+
avatar: "",
|
|
54
|
+
className: "",
|
|
55
|
+
stopOnFocus: true,
|
|
56
|
+
onClick: function onClick() {},
|
|
57
|
+
offset: {
|
|
58
|
+
x: 0,
|
|
59
|
+
y: 0
|
|
60
|
+
},
|
|
61
|
+
escapeMarkup: true,
|
|
62
|
+
ariaLive: "polite",
|
|
63
|
+
style: {
|
|
64
|
+
background: ""
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
// Defining the prototype of the object
|
|
68
|
+
Toastify.lib = Toastify.prototype = {
|
|
69
|
+
toastify: version,
|
|
70
|
+
constructor: Toastify,
|
|
71
|
+
// Initializing the object with required parameters
|
|
72
|
+
init: function init(options) {
|
|
73
|
+
// Verifying and validating the input object
|
|
74
|
+
if (!options) {
|
|
75
|
+
options = {};
|
|
76
|
+
}
|
|
77
|
+
// Creating the options object
|
|
78
|
+
this.options = {};
|
|
79
|
+
this.toastElement = null;
|
|
80
|
+
// Validating the options
|
|
81
|
+
this.options.text = options.text || Toastify.defaults.text; // Display message
|
|
82
|
+
this.options.node = options.node || Toastify.defaults.node; // Display content as node
|
|
83
|
+
this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
|
|
84
|
+
this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
|
|
85
|
+
this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
|
|
86
|
+
this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
|
|
87
|
+
this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
|
|
88
|
+
this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
|
|
89
|
+
this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
|
|
90
|
+
this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
|
|
91
|
+
this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
|
|
92
|
+
this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
|
|
93
|
+
this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
|
|
94
|
+
this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
|
|
95
|
+
this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
|
|
96
|
+
this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
|
|
97
|
+
this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
|
|
98
|
+
this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
|
|
99
|
+
this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
|
|
100
|
+
this.options.style = options.style || Toastify.defaults.style;
|
|
101
|
+
if (options.backgroundColor) {
|
|
102
|
+
this.options.style.background = options.backgroundColor;
|
|
103
|
+
}
|
|
104
|
+
// Returning the current object for chaining functions
|
|
105
|
+
return this;
|
|
106
|
+
},
|
|
107
|
+
// Building the DOM element
|
|
108
|
+
buildToast: function buildToast() {
|
|
109
|
+
// Validating if the options are defined
|
|
110
|
+
if (!this.options) {
|
|
111
|
+
throw "Toastify is not initialized";
|
|
112
|
+
}
|
|
113
|
+
// Creating the DOM object
|
|
114
|
+
var divElement = document.createElement("div");
|
|
115
|
+
divElement.className = "toastify on " + this.options.className;
|
|
116
|
+
// Positioning toast to left or right or center
|
|
117
|
+
if (!!this.options.position) {
|
|
118
|
+
divElement.className += " toastify-" + this.options.position;
|
|
119
|
+
} else {
|
|
120
|
+
// To be depreciated in further versions
|
|
121
|
+
if (this.options.positionLeft === true) {
|
|
122
|
+
divElement.className += " toastify-left";
|
|
123
|
+
console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.");
|
|
124
|
+
} else {
|
|
125
|
+
// Default position
|
|
126
|
+
divElement.className += " toastify-right";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Assigning gravity of element
|
|
130
|
+
divElement.className += " " + this.options.gravity;
|
|
131
|
+
if (this.options.backgroundColor) {
|
|
132
|
+
// This is being deprecated in favor of using the style HTML DOM property
|
|
133
|
+
console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
|
|
134
|
+
}
|
|
135
|
+
// Loop through our style object and apply styles to divElement
|
|
136
|
+
for(var property in this.options.style){
|
|
137
|
+
divElement.style[property] = this.options.style[property];
|
|
138
|
+
}
|
|
139
|
+
// Announce the toast to screen readers
|
|
140
|
+
if (this.options.ariaLive) {
|
|
141
|
+
divElement.setAttribute("aria-live", this.options.ariaLive);
|
|
142
|
+
}
|
|
143
|
+
// Adding the toast message/node
|
|
144
|
+
if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
|
|
145
|
+
// If we have a valid node, we insert it
|
|
146
|
+
divElement.appendChild(this.options.node);
|
|
147
|
+
} else {
|
|
148
|
+
if (this.options.escapeMarkup) {
|
|
149
|
+
divElement.innerText = this.options.text;
|
|
150
|
+
} else {
|
|
151
|
+
divElement.innerHTML = this.options.text;
|
|
152
|
+
}
|
|
153
|
+
if (this.options.avatar !== "") {
|
|
154
|
+
var avatarElement = document.createElement("img");
|
|
155
|
+
avatarElement.src = this.options.avatar;
|
|
156
|
+
avatarElement.className = "toastify-avatar";
|
|
157
|
+
if (this.options.position == "left" || this.options.positionLeft === true) {
|
|
158
|
+
// Adding close icon on the left of content
|
|
159
|
+
divElement.appendChild(avatarElement);
|
|
160
|
+
} else {
|
|
161
|
+
// Adding close icon on the right of content
|
|
162
|
+
divElement.insertAdjacentElement("afterbegin", avatarElement);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Adding a close icon to the toast
|
|
167
|
+
if (this.options.close === true) {
|
|
168
|
+
// Create a span for close element
|
|
169
|
+
var closeElement = document.createElement("button");
|
|
170
|
+
closeElement.type = "button";
|
|
171
|
+
closeElement.setAttribute("aria-label", "Close");
|
|
172
|
+
closeElement.className = "toast-close";
|
|
173
|
+
closeElement.innerHTML = "✖";
|
|
174
|
+
// Triggering the removal of toast from DOM on close click
|
|
175
|
+
closeElement.addEventListener("click", (function(event) {
|
|
176
|
+
event.stopPropagation();
|
|
177
|
+
this.removeElement(this.toastElement);
|
|
178
|
+
window.clearTimeout(this.toastElement.timeOutValue);
|
|
179
|
+
}).bind(this));
|
|
180
|
+
//Calculating screen width
|
|
181
|
+
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
182
|
+
// Adding the close icon to the toast element
|
|
183
|
+
// Display on the right if screen width is less than or equal to 360px
|
|
184
|
+
if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
|
|
185
|
+
// Adding close icon on the left of content
|
|
186
|
+
divElement.insertAdjacentElement("afterbegin", closeElement);
|
|
187
|
+
} else {
|
|
188
|
+
// Adding close icon on the right of content
|
|
189
|
+
divElement.appendChild(closeElement);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Clear timeout while toast is focused
|
|
193
|
+
if (this.options.stopOnFocus && this.options.duration > 0) {
|
|
194
|
+
var self = this;
|
|
195
|
+
// stop countdown
|
|
196
|
+
divElement.addEventListener("mouseover", function(event) {
|
|
197
|
+
window.clearTimeout(divElement.timeOutValue);
|
|
198
|
+
});
|
|
199
|
+
// add back the timeout
|
|
200
|
+
divElement.addEventListener("mouseleave", function() {
|
|
201
|
+
divElement.timeOutValue = window.setTimeout(function() {
|
|
202
|
+
// Remove the toast from DOM
|
|
203
|
+
self.removeElement(divElement);
|
|
204
|
+
}, self.options.duration);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Adding an on-click destination path
|
|
208
|
+
if (typeof this.options.destination !== "undefined") {
|
|
209
|
+
divElement.addEventListener("click", (function(event) {
|
|
210
|
+
event.stopPropagation();
|
|
211
|
+
if (this.options.newWindow === true) {
|
|
212
|
+
window.open(this.options.destination, "_blank");
|
|
213
|
+
} else {
|
|
214
|
+
window.location = this.options.destination;
|
|
215
|
+
}
|
|
216
|
+
}).bind(this));
|
|
217
|
+
}
|
|
218
|
+
if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
|
|
219
|
+
divElement.addEventListener("click", (function(event) {
|
|
220
|
+
event.stopPropagation();
|
|
221
|
+
this.options.onClick();
|
|
222
|
+
}).bind(this));
|
|
223
|
+
}
|
|
224
|
+
// Adding offset
|
|
225
|
+
if (typeof this.options.offset === "object") {
|
|
226
|
+
var x = getAxisOffsetAValue("x", this.options);
|
|
227
|
+
var y = getAxisOffsetAValue("y", this.options);
|
|
228
|
+
var xOffset = this.options.position == "left" ? x : "-" + x;
|
|
229
|
+
var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
|
|
230
|
+
divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
|
|
231
|
+
}
|
|
232
|
+
// Returning the generated element
|
|
233
|
+
return divElement;
|
|
234
|
+
},
|
|
235
|
+
// Displaying the toast
|
|
236
|
+
showToast: function showToast() {
|
|
237
|
+
// Creating the DOM object for the toast
|
|
238
|
+
this.toastElement = this.buildToast();
|
|
239
|
+
// Getting the root element to with the toast needs to be added
|
|
240
|
+
var rootElement;
|
|
241
|
+
if (typeof this.options.selector === "string") {
|
|
242
|
+
rootElement = document.getElementById(this.options.selector);
|
|
243
|
+
} else if (_instanceof(this.options.selector, HTMLElement) || typeof ShadowRoot !== "undefined" && _instanceof(this.options.selector, ShadowRoot)) {
|
|
244
|
+
rootElement = this.options.selector;
|
|
245
|
+
} else {
|
|
246
|
+
rootElement = document.body;
|
|
247
|
+
}
|
|
248
|
+
// Validating if root element is present in DOM
|
|
249
|
+
if (!rootElement) {
|
|
250
|
+
throw "Root element is not defined";
|
|
251
|
+
}
|
|
252
|
+
// Adding the DOM element
|
|
253
|
+
var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
|
|
254
|
+
rootElement.insertBefore(this.toastElement, elementToInsert);
|
|
255
|
+
// Repositioning the toasts in case multiple toasts are present
|
|
256
|
+
Toastify.reposition();
|
|
257
|
+
if (this.options.duration > 0) {
|
|
258
|
+
this.toastElement.timeOutValue = window.setTimeout((function() {
|
|
259
|
+
// Remove the toast from DOM
|
|
260
|
+
this.removeElement(this.toastElement);
|
|
261
|
+
}).bind(this), this.options.duration); // Binding `this` for function invocation
|
|
262
|
+
}
|
|
263
|
+
// Supporting function chaining
|
|
264
|
+
return this;
|
|
265
|
+
},
|
|
266
|
+
hideToast: function hideToast() {
|
|
267
|
+
if (this.toastElement.timeOutValue) {
|
|
268
|
+
clearTimeout(this.toastElement.timeOutValue);
|
|
269
|
+
}
|
|
270
|
+
this.removeElement(this.toastElement);
|
|
271
|
+
},
|
|
272
|
+
// Removing the element from the DOM
|
|
273
|
+
removeElement: function removeElement(toastElement) {
|
|
274
|
+
// Hiding the element
|
|
275
|
+
// toastElement.classList.remove("on");
|
|
276
|
+
toastElement.className = toastElement.className.replace(" on", "");
|
|
277
|
+
// Removing the element from DOM after transition end
|
|
278
|
+
window.setTimeout((function() {
|
|
279
|
+
// remove options node if any
|
|
280
|
+
if (this.options.node && this.options.node.parentNode) {
|
|
281
|
+
this.options.node.parentNode.removeChild(this.options.node);
|
|
282
|
+
}
|
|
283
|
+
// Remove the element from the DOM, only when the parent node was not removed before.
|
|
284
|
+
if (toastElement.parentNode) {
|
|
285
|
+
toastElement.parentNode.removeChild(toastElement);
|
|
286
|
+
}
|
|
287
|
+
// Calling the callback function
|
|
288
|
+
this.options.callback.call(toastElement);
|
|
289
|
+
// Repositioning the toasts again
|
|
290
|
+
Toastify.reposition();
|
|
291
|
+
}).bind(this), 400); // Binding `this` for function invocation
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
// Positioning the toasts on the DOM
|
|
295
|
+
Toastify.reposition = function() {
|
|
296
|
+
// Top margins with gravity
|
|
297
|
+
var topLeftOffsetSize = {
|
|
298
|
+
top: 15,
|
|
299
|
+
bottom: 15
|
|
300
|
+
};
|
|
301
|
+
var topRightOffsetSize = {
|
|
302
|
+
top: 15,
|
|
303
|
+
bottom: 15
|
|
304
|
+
};
|
|
305
|
+
var offsetSize = {
|
|
306
|
+
top: 15,
|
|
307
|
+
bottom: 15
|
|
308
|
+
};
|
|
309
|
+
// Get all toast messages on the DOM
|
|
310
|
+
var allToasts = document.getElementsByClassName("toastify");
|
|
311
|
+
var classUsed;
|
|
312
|
+
// Modifying the position of each toast element
|
|
313
|
+
for(var i = 0; i < allToasts.length; i++){
|
|
314
|
+
// Getting the applied gravity
|
|
315
|
+
if (containsClass(allToasts[i], "toastify-top") === true) {
|
|
316
|
+
classUsed = "toastify-top";
|
|
317
|
+
} else {
|
|
318
|
+
classUsed = "toastify-bottom";
|
|
319
|
+
}
|
|
320
|
+
var height = allToasts[i].offsetHeight;
|
|
321
|
+
classUsed = classUsed.substr(9, classUsed.length - 1);
|
|
322
|
+
// Spacing between toasts
|
|
323
|
+
var offset = 15;
|
|
324
|
+
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
325
|
+
// Show toast in center if screen with less than or equal to 360px
|
|
326
|
+
if (width <= 360) {
|
|
327
|
+
// Setting the position
|
|
328
|
+
allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
|
|
329
|
+
offsetSize[classUsed] += height + offset;
|
|
330
|
+
} else {
|
|
331
|
+
if (containsClass(allToasts[i], "toastify-left") === true) {
|
|
332
|
+
// Setting the position
|
|
333
|
+
allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
|
|
334
|
+
topLeftOffsetSize[classUsed] += height + offset;
|
|
335
|
+
} else {
|
|
336
|
+
// Setting the position
|
|
337
|
+
allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
|
|
338
|
+
topRightOffsetSize[classUsed] += height + offset;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Supporting function chaining
|
|
343
|
+
return this;
|
|
344
|
+
};
|
|
345
|
+
// Helper function to get offset.
|
|
346
|
+
function getAxisOffsetAValue(axis, options) {
|
|
347
|
+
if (options.offset[axis]) {
|
|
348
|
+
if (isNaN(options.offset[axis])) {
|
|
349
|
+
return options.offset[axis];
|
|
350
|
+
} else {
|
|
351
|
+
return options.offset[axis] + "px";
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return "0px";
|
|
355
|
+
}
|
|
356
|
+
function containsClass(elem, yourClass) {
|
|
357
|
+
if (!elem || typeof yourClass !== "string") {
|
|
358
|
+
return false;
|
|
359
|
+
} else if (elem.className && elem.className.trim().split(/\s+/gi).indexOf(yourClass) > -1) {
|
|
360
|
+
return true;
|
|
361
|
+
} else {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// Setting up the prototype for the init object
|
|
366
|
+
Toastify.lib.init.prototype = Toastify.lib;
|
|
367
|
+
// Returning the Toastify function to be assigned to the window object/module
|
|
368
|
+
return Toastify;
|
|
369
|
+
});
|
|
370
|
+
}(toastify$1));
|
|
371
|
+
|
|
372
|
+
var toastify = toastify$1.exports;
|
|
373
|
+
|
|
374
|
+
const Toastify = toastify;
|
|
375
|
+
let NotificationService = class NotificationService {
|
|
376
|
+
async information(params, _pinsSettingsList, _context) {
|
|
377
|
+
const { message } = params;
|
|
378
|
+
Toastify({
|
|
379
|
+
text: message,
|
|
380
|
+
position: 'center',
|
|
381
|
+
style: {
|
|
382
|
+
'font-family': '"Poppins", sans-serif',
|
|
383
|
+
background: '#52DFDB'
|
|
384
|
+
},
|
|
385
|
+
duration: 3000
|
|
386
|
+
}).showToast();
|
|
387
|
+
}
|
|
388
|
+
async error(params, _pinsSettingsList, _context) {
|
|
389
|
+
const { message } = params;
|
|
390
|
+
Toastify({
|
|
391
|
+
text: message,
|
|
392
|
+
position: 'center',
|
|
393
|
+
style: {
|
|
394
|
+
'font-family': '"Poppins", sans-serif',
|
|
395
|
+
background: 'linear-gradient(90deg, rgba(121,9,9,1) 0%, rgba(203,62,62,1) 100%)'
|
|
396
|
+
},
|
|
397
|
+
duration: 3000
|
|
398
|
+
}).showToast();
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
const information = (params, pinsSettingsList, context)=>new NotificationService().information(params, pinsSettingsList, context);
|
|
402
|
+
const error = (params, pinsSettingsList, context)=>new NotificationService().error(params, pinsSettingsList, context);
|
|
403
|
+
|
|
404
|
+
exports.error = error;
|
|
405
|
+
exports.information = information;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './libs/skill-web-jsoneditor/src/index';
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2
|
+
|
|
3
|
+
var toastify$1 = {
|
|
4
|
+
exports: {}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
(function (module) {
|
|
8
|
+
function _instanceof(left, right) {
|
|
9
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
10
|
+
return !!right[Symbol.hasInstance](left);
|
|
11
|
+
} else {
|
|
12
|
+
return left instanceof right;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/*!
|
|
16
|
+
* Toastify js 1.12.0
|
|
17
|
+
* https://github.com/apvarun/toastify-js
|
|
18
|
+
* @license MIT licensed
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2018 Varun A P
|
|
21
|
+
*/ (function(root, factory) {
|
|
22
|
+
if (module.exports) {
|
|
23
|
+
module.exports = factory();
|
|
24
|
+
} else {
|
|
25
|
+
root.Toastify = factory();
|
|
26
|
+
}
|
|
27
|
+
})(commonjsGlobal, function(global) {
|
|
28
|
+
// Object initialization
|
|
29
|
+
var Toastify = function Toastify1(options) {
|
|
30
|
+
// Returning a new init object
|
|
31
|
+
return new Toastify.lib.init(options);
|
|
32
|
+
}, // Library version
|
|
33
|
+
version = "1.12.0";
|
|
34
|
+
// Set the default global options
|
|
35
|
+
Toastify.defaults = {
|
|
36
|
+
oldestFirst: true,
|
|
37
|
+
text: "Toastify is awesome!",
|
|
38
|
+
node: undefined,
|
|
39
|
+
duration: 3000,
|
|
40
|
+
selector: undefined,
|
|
41
|
+
callback: function callback() {},
|
|
42
|
+
destination: undefined,
|
|
43
|
+
newWindow: false,
|
|
44
|
+
close: false,
|
|
45
|
+
gravity: "toastify-top",
|
|
46
|
+
positionLeft: false,
|
|
47
|
+
position: "",
|
|
48
|
+
backgroundColor: "",
|
|
49
|
+
avatar: "",
|
|
50
|
+
className: "",
|
|
51
|
+
stopOnFocus: true,
|
|
52
|
+
onClick: function onClick() {},
|
|
53
|
+
offset: {
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0
|
|
56
|
+
},
|
|
57
|
+
escapeMarkup: true,
|
|
58
|
+
ariaLive: "polite",
|
|
59
|
+
style: {
|
|
60
|
+
background: ""
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// Defining the prototype of the object
|
|
64
|
+
Toastify.lib = Toastify.prototype = {
|
|
65
|
+
toastify: version,
|
|
66
|
+
constructor: Toastify,
|
|
67
|
+
// Initializing the object with required parameters
|
|
68
|
+
init: function init(options) {
|
|
69
|
+
// Verifying and validating the input object
|
|
70
|
+
if (!options) {
|
|
71
|
+
options = {};
|
|
72
|
+
}
|
|
73
|
+
// Creating the options object
|
|
74
|
+
this.options = {};
|
|
75
|
+
this.toastElement = null;
|
|
76
|
+
// Validating the options
|
|
77
|
+
this.options.text = options.text || Toastify.defaults.text; // Display message
|
|
78
|
+
this.options.node = options.node || Toastify.defaults.node; // Display content as node
|
|
79
|
+
this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
|
|
80
|
+
this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
|
|
81
|
+
this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
|
|
82
|
+
this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
|
|
83
|
+
this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
|
|
84
|
+
this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
|
|
85
|
+
this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
|
|
86
|
+
this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
|
|
87
|
+
this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
|
|
88
|
+
this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
|
|
89
|
+
this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
|
|
90
|
+
this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
|
|
91
|
+
this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
|
|
92
|
+
this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
|
|
93
|
+
this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
|
|
94
|
+
this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
|
|
95
|
+
this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
|
|
96
|
+
this.options.style = options.style || Toastify.defaults.style;
|
|
97
|
+
if (options.backgroundColor) {
|
|
98
|
+
this.options.style.background = options.backgroundColor;
|
|
99
|
+
}
|
|
100
|
+
// Returning the current object for chaining functions
|
|
101
|
+
return this;
|
|
102
|
+
},
|
|
103
|
+
// Building the DOM element
|
|
104
|
+
buildToast: function buildToast() {
|
|
105
|
+
// Validating if the options are defined
|
|
106
|
+
if (!this.options) {
|
|
107
|
+
throw "Toastify is not initialized";
|
|
108
|
+
}
|
|
109
|
+
// Creating the DOM object
|
|
110
|
+
var divElement = document.createElement("div");
|
|
111
|
+
divElement.className = "toastify on " + this.options.className;
|
|
112
|
+
// Positioning toast to left or right or center
|
|
113
|
+
if (!!this.options.position) {
|
|
114
|
+
divElement.className += " toastify-" + this.options.position;
|
|
115
|
+
} else {
|
|
116
|
+
// To be depreciated in further versions
|
|
117
|
+
if (this.options.positionLeft === true) {
|
|
118
|
+
divElement.className += " toastify-left";
|
|
119
|
+
console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.");
|
|
120
|
+
} else {
|
|
121
|
+
// Default position
|
|
122
|
+
divElement.className += " toastify-right";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Assigning gravity of element
|
|
126
|
+
divElement.className += " " + this.options.gravity;
|
|
127
|
+
if (this.options.backgroundColor) {
|
|
128
|
+
// This is being deprecated in favor of using the style HTML DOM property
|
|
129
|
+
console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
|
|
130
|
+
}
|
|
131
|
+
// Loop through our style object and apply styles to divElement
|
|
132
|
+
for(var property in this.options.style){
|
|
133
|
+
divElement.style[property] = this.options.style[property];
|
|
134
|
+
}
|
|
135
|
+
// Announce the toast to screen readers
|
|
136
|
+
if (this.options.ariaLive) {
|
|
137
|
+
divElement.setAttribute("aria-live", this.options.ariaLive);
|
|
138
|
+
}
|
|
139
|
+
// Adding the toast message/node
|
|
140
|
+
if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
|
|
141
|
+
// If we have a valid node, we insert it
|
|
142
|
+
divElement.appendChild(this.options.node);
|
|
143
|
+
} else {
|
|
144
|
+
if (this.options.escapeMarkup) {
|
|
145
|
+
divElement.innerText = this.options.text;
|
|
146
|
+
} else {
|
|
147
|
+
divElement.innerHTML = this.options.text;
|
|
148
|
+
}
|
|
149
|
+
if (this.options.avatar !== "") {
|
|
150
|
+
var avatarElement = document.createElement("img");
|
|
151
|
+
avatarElement.src = this.options.avatar;
|
|
152
|
+
avatarElement.className = "toastify-avatar";
|
|
153
|
+
if (this.options.position == "left" || this.options.positionLeft === true) {
|
|
154
|
+
// Adding close icon on the left of content
|
|
155
|
+
divElement.appendChild(avatarElement);
|
|
156
|
+
} else {
|
|
157
|
+
// Adding close icon on the right of content
|
|
158
|
+
divElement.insertAdjacentElement("afterbegin", avatarElement);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Adding a close icon to the toast
|
|
163
|
+
if (this.options.close === true) {
|
|
164
|
+
// Create a span for close element
|
|
165
|
+
var closeElement = document.createElement("button");
|
|
166
|
+
closeElement.type = "button";
|
|
167
|
+
closeElement.setAttribute("aria-label", "Close");
|
|
168
|
+
closeElement.className = "toast-close";
|
|
169
|
+
closeElement.innerHTML = "✖";
|
|
170
|
+
// Triggering the removal of toast from DOM on close click
|
|
171
|
+
closeElement.addEventListener("click", (function(event) {
|
|
172
|
+
event.stopPropagation();
|
|
173
|
+
this.removeElement(this.toastElement);
|
|
174
|
+
window.clearTimeout(this.toastElement.timeOutValue);
|
|
175
|
+
}).bind(this));
|
|
176
|
+
//Calculating screen width
|
|
177
|
+
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
178
|
+
// Adding the close icon to the toast element
|
|
179
|
+
// Display on the right if screen width is less than or equal to 360px
|
|
180
|
+
if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
|
|
181
|
+
// Adding close icon on the left of content
|
|
182
|
+
divElement.insertAdjacentElement("afterbegin", closeElement);
|
|
183
|
+
} else {
|
|
184
|
+
// Adding close icon on the right of content
|
|
185
|
+
divElement.appendChild(closeElement);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Clear timeout while toast is focused
|
|
189
|
+
if (this.options.stopOnFocus && this.options.duration > 0) {
|
|
190
|
+
var self = this;
|
|
191
|
+
// stop countdown
|
|
192
|
+
divElement.addEventListener("mouseover", function(event) {
|
|
193
|
+
window.clearTimeout(divElement.timeOutValue);
|
|
194
|
+
});
|
|
195
|
+
// add back the timeout
|
|
196
|
+
divElement.addEventListener("mouseleave", function() {
|
|
197
|
+
divElement.timeOutValue = window.setTimeout(function() {
|
|
198
|
+
// Remove the toast from DOM
|
|
199
|
+
self.removeElement(divElement);
|
|
200
|
+
}, self.options.duration);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
// Adding an on-click destination path
|
|
204
|
+
if (typeof this.options.destination !== "undefined") {
|
|
205
|
+
divElement.addEventListener("click", (function(event) {
|
|
206
|
+
event.stopPropagation();
|
|
207
|
+
if (this.options.newWindow === true) {
|
|
208
|
+
window.open(this.options.destination, "_blank");
|
|
209
|
+
} else {
|
|
210
|
+
window.location = this.options.destination;
|
|
211
|
+
}
|
|
212
|
+
}).bind(this));
|
|
213
|
+
}
|
|
214
|
+
if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
|
|
215
|
+
divElement.addEventListener("click", (function(event) {
|
|
216
|
+
event.stopPropagation();
|
|
217
|
+
this.options.onClick();
|
|
218
|
+
}).bind(this));
|
|
219
|
+
}
|
|
220
|
+
// Adding offset
|
|
221
|
+
if (typeof this.options.offset === "object") {
|
|
222
|
+
var x = getAxisOffsetAValue("x", this.options);
|
|
223
|
+
var y = getAxisOffsetAValue("y", this.options);
|
|
224
|
+
var xOffset = this.options.position == "left" ? x : "-" + x;
|
|
225
|
+
var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
|
|
226
|
+
divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
|
|
227
|
+
}
|
|
228
|
+
// Returning the generated element
|
|
229
|
+
return divElement;
|
|
230
|
+
},
|
|
231
|
+
// Displaying the toast
|
|
232
|
+
showToast: function showToast() {
|
|
233
|
+
// Creating the DOM object for the toast
|
|
234
|
+
this.toastElement = this.buildToast();
|
|
235
|
+
// Getting the root element to with the toast needs to be added
|
|
236
|
+
var rootElement;
|
|
237
|
+
if (typeof this.options.selector === "string") {
|
|
238
|
+
rootElement = document.getElementById(this.options.selector);
|
|
239
|
+
} else if (_instanceof(this.options.selector, HTMLElement) || typeof ShadowRoot !== "undefined" && _instanceof(this.options.selector, ShadowRoot)) {
|
|
240
|
+
rootElement = this.options.selector;
|
|
241
|
+
} else {
|
|
242
|
+
rootElement = document.body;
|
|
243
|
+
}
|
|
244
|
+
// Validating if root element is present in DOM
|
|
245
|
+
if (!rootElement) {
|
|
246
|
+
throw "Root element is not defined";
|
|
247
|
+
}
|
|
248
|
+
// Adding the DOM element
|
|
249
|
+
var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
|
|
250
|
+
rootElement.insertBefore(this.toastElement, elementToInsert);
|
|
251
|
+
// Repositioning the toasts in case multiple toasts are present
|
|
252
|
+
Toastify.reposition();
|
|
253
|
+
if (this.options.duration > 0) {
|
|
254
|
+
this.toastElement.timeOutValue = window.setTimeout((function() {
|
|
255
|
+
// Remove the toast from DOM
|
|
256
|
+
this.removeElement(this.toastElement);
|
|
257
|
+
}).bind(this), this.options.duration); // Binding `this` for function invocation
|
|
258
|
+
}
|
|
259
|
+
// Supporting function chaining
|
|
260
|
+
return this;
|
|
261
|
+
},
|
|
262
|
+
hideToast: function hideToast() {
|
|
263
|
+
if (this.toastElement.timeOutValue) {
|
|
264
|
+
clearTimeout(this.toastElement.timeOutValue);
|
|
265
|
+
}
|
|
266
|
+
this.removeElement(this.toastElement);
|
|
267
|
+
},
|
|
268
|
+
// Removing the element from the DOM
|
|
269
|
+
removeElement: function removeElement(toastElement) {
|
|
270
|
+
// Hiding the element
|
|
271
|
+
// toastElement.classList.remove("on");
|
|
272
|
+
toastElement.className = toastElement.className.replace(" on", "");
|
|
273
|
+
// Removing the element from DOM after transition end
|
|
274
|
+
window.setTimeout((function() {
|
|
275
|
+
// remove options node if any
|
|
276
|
+
if (this.options.node && this.options.node.parentNode) {
|
|
277
|
+
this.options.node.parentNode.removeChild(this.options.node);
|
|
278
|
+
}
|
|
279
|
+
// Remove the element from the DOM, only when the parent node was not removed before.
|
|
280
|
+
if (toastElement.parentNode) {
|
|
281
|
+
toastElement.parentNode.removeChild(toastElement);
|
|
282
|
+
}
|
|
283
|
+
// Calling the callback function
|
|
284
|
+
this.options.callback.call(toastElement);
|
|
285
|
+
// Repositioning the toasts again
|
|
286
|
+
Toastify.reposition();
|
|
287
|
+
}).bind(this), 400); // Binding `this` for function invocation
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
// Positioning the toasts on the DOM
|
|
291
|
+
Toastify.reposition = function() {
|
|
292
|
+
// Top margins with gravity
|
|
293
|
+
var topLeftOffsetSize = {
|
|
294
|
+
top: 15,
|
|
295
|
+
bottom: 15
|
|
296
|
+
};
|
|
297
|
+
var topRightOffsetSize = {
|
|
298
|
+
top: 15,
|
|
299
|
+
bottom: 15
|
|
300
|
+
};
|
|
301
|
+
var offsetSize = {
|
|
302
|
+
top: 15,
|
|
303
|
+
bottom: 15
|
|
304
|
+
};
|
|
305
|
+
// Get all toast messages on the DOM
|
|
306
|
+
var allToasts = document.getElementsByClassName("toastify");
|
|
307
|
+
var classUsed;
|
|
308
|
+
// Modifying the position of each toast element
|
|
309
|
+
for(var i = 0; i < allToasts.length; i++){
|
|
310
|
+
// Getting the applied gravity
|
|
311
|
+
if (containsClass(allToasts[i], "toastify-top") === true) {
|
|
312
|
+
classUsed = "toastify-top";
|
|
313
|
+
} else {
|
|
314
|
+
classUsed = "toastify-bottom";
|
|
315
|
+
}
|
|
316
|
+
var height = allToasts[i].offsetHeight;
|
|
317
|
+
classUsed = classUsed.substr(9, classUsed.length - 1);
|
|
318
|
+
// Spacing between toasts
|
|
319
|
+
var offset = 15;
|
|
320
|
+
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
321
|
+
// Show toast in center if screen with less than or equal to 360px
|
|
322
|
+
if (width <= 360) {
|
|
323
|
+
// Setting the position
|
|
324
|
+
allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
|
|
325
|
+
offsetSize[classUsed] += height + offset;
|
|
326
|
+
} else {
|
|
327
|
+
if (containsClass(allToasts[i], "toastify-left") === true) {
|
|
328
|
+
// Setting the position
|
|
329
|
+
allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
|
|
330
|
+
topLeftOffsetSize[classUsed] += height + offset;
|
|
331
|
+
} else {
|
|
332
|
+
// Setting the position
|
|
333
|
+
allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
|
|
334
|
+
topRightOffsetSize[classUsed] += height + offset;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// Supporting function chaining
|
|
339
|
+
return this;
|
|
340
|
+
};
|
|
341
|
+
// Helper function to get offset.
|
|
342
|
+
function getAxisOffsetAValue(axis, options) {
|
|
343
|
+
if (options.offset[axis]) {
|
|
344
|
+
if (isNaN(options.offset[axis])) {
|
|
345
|
+
return options.offset[axis];
|
|
346
|
+
} else {
|
|
347
|
+
return options.offset[axis] + "px";
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return "0px";
|
|
351
|
+
}
|
|
352
|
+
function containsClass(elem, yourClass) {
|
|
353
|
+
if (!elem || typeof yourClass !== "string") {
|
|
354
|
+
return false;
|
|
355
|
+
} else if (elem.className && elem.className.trim().split(/\s+/gi).indexOf(yourClass) > -1) {
|
|
356
|
+
return true;
|
|
357
|
+
} else {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Setting up the prototype for the init object
|
|
362
|
+
Toastify.lib.init.prototype = Toastify.lib;
|
|
363
|
+
// Returning the Toastify function to be assigned to the window object/module
|
|
364
|
+
return Toastify;
|
|
365
|
+
});
|
|
366
|
+
}(toastify$1));
|
|
367
|
+
|
|
368
|
+
var toastify = toastify$1.exports;
|
|
369
|
+
|
|
370
|
+
const Toastify = toastify;
|
|
371
|
+
let NotificationService = class NotificationService {
|
|
372
|
+
async information(params, _pinsSettingsList, _context) {
|
|
373
|
+
const { message } = params;
|
|
374
|
+
Toastify({
|
|
375
|
+
text: message,
|
|
376
|
+
position: 'center',
|
|
377
|
+
style: {
|
|
378
|
+
'font-family': '"Poppins", sans-serif',
|
|
379
|
+
background: '#52DFDB'
|
|
380
|
+
},
|
|
381
|
+
duration: 3000
|
|
382
|
+
}).showToast();
|
|
383
|
+
}
|
|
384
|
+
async error(params, _pinsSettingsList, _context) {
|
|
385
|
+
const { message } = params;
|
|
386
|
+
Toastify({
|
|
387
|
+
text: message,
|
|
388
|
+
position: 'center',
|
|
389
|
+
style: {
|
|
390
|
+
'font-family': '"Poppins", sans-serif',
|
|
391
|
+
background: 'linear-gradient(90deg, rgba(121,9,9,1) 0%, rgba(203,62,62,1) 100%)'
|
|
392
|
+
},
|
|
393
|
+
duration: 3000
|
|
394
|
+
}).showToast();
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const information = (params, pinsSettingsList, context)=>new NotificationService().information(params, pinsSettingsList, context);
|
|
398
|
+
const error = (params, pinsSettingsList, context)=>new NotificationService().error(params, pinsSettingsList, context);
|
|
399
|
+
|
|
400
|
+
export { error, information };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/skill-web-notification';
|
package/package.json
ADDED
package/schema.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "@digipair/skill-web-notification",
|
|
5
|
+
"summary": "Affichage de notification",
|
|
6
|
+
"description": "Affichage de notifications sur une page web",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"x-icon": "🔔"
|
|
9
|
+
},
|
|
10
|
+
"paths": {
|
|
11
|
+
"/information": {
|
|
12
|
+
"post": {
|
|
13
|
+
"tags": ["web"],
|
|
14
|
+
"summary": "Affiche d'une information",
|
|
15
|
+
"description": "Affiche une notification d'information",
|
|
16
|
+
"parameters": [
|
|
17
|
+
{
|
|
18
|
+
"name": "message",
|
|
19
|
+
"summary": "Message",
|
|
20
|
+
"required": true,
|
|
21
|
+
"description": "Message à afficher",
|
|
22
|
+
"schema": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"x-events": []
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"/error": {
|
|
31
|
+
"post": {
|
|
32
|
+
"tags": ["web"],
|
|
33
|
+
"summary": "Affiche d'une erreur",
|
|
34
|
+
"description": "Affiche une notification d'erreur",
|
|
35
|
+
"parameters": [
|
|
36
|
+
{
|
|
37
|
+
"name": "message",
|
|
38
|
+
"summary": "Message",
|
|
39
|
+
"required": true,
|
|
40
|
+
"description": "Message à afficher",
|
|
41
|
+
"schema": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"x-events": []
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"components": {
|
|
51
|
+
"schemas": {}
|
|
52
|
+
}
|
|
53
|
+
}
|