@haiilo/catalyst 1.3.1 → 2.0.0
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/dist/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.cdn.js +7 -3
- package/dist/catalyst/index.esm.js +9 -1
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-167f01e8.entry.js +2 -0
- package/dist/catalyst/p-167f01e8.entry.js.map +1 -0
- package/dist/catalyst/p-5865f232.js +2 -0
- package/dist/catalyst/p-5865f232.js.map +1 -0
- package/dist/catalyst/scss/_variables.scss +1 -1
- package/dist/catalyst/scss/core/_form.scss +8 -0
- package/dist/catalyst/scss/core/_nav.scss +3 -3
- package/dist/catalyst/scss/core/_notification.scss +48 -0
- package/dist/catalyst/scss/index.scss +2 -1
- package/dist/catalyst/scss/utils/_typography.scss +4 -0
- package/dist/cjs/cat-alert_22.cjs.entry.js +351 -290
- package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -1
- package/dist/cjs/cat-icon-registry-2a54df3d.js +417 -0
- package/dist/cjs/cat-icon-registry-2a54df3d.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +528 -4
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/cat-button/cat-button.css +21 -63
- package/dist/collection/components/cat-button/cat-button.js +21 -4
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-card/cat-card.css +5 -4
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -4
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/{cat-menu/cat-menu.css → cat-dropdown/cat-dropdown.css} +20 -0
- package/dist/collection/components/{cat-menu/cat-menu.js → cat-dropdown/cat-dropdown.js} +102 -87
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -0
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +13 -38
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js +1 -0
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +1 -4
- package/dist/collection/components/cat-input/cat-input.js +4 -5
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js +61 -89
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.css +106 -0
- package/dist/collection/components/cat-pagination/cat-pagination.js +302 -0
- package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -0
- package/dist/collection/components/cat-radio/cat-radio.css +1 -4
- package/dist/collection/components/cat-radio/cat-radio.js +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.css +1 -4
- package/dist/collection/components/cat-select/cat-select.js +8 -9
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.css +2 -2
- package/dist/collection/components/cat-tabs/cat-tabs.js +2 -2
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +1 -4
- package/dist/collection/components/cat-textarea/cat-textarea.js +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +1 -4
- package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/index.cdn.js +7 -3
- package/dist/collection/index.js +3 -3
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/scss/_variables.scss +1 -1
- package/dist/collection/scss/core/_form.scss +8 -0
- package/dist/collection/scss/core/_nav.scss +3 -3
- package/dist/collection/scss/core/_notification.scss +48 -0
- package/dist/collection/scss/index.scss +2 -1
- package/dist/collection/scss/utils/_typography.scss +4 -0
- package/dist/components/cat-button2.js +6 -5
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-card.js +1 -1
- package/dist/components/cat-card.js.map +1 -1
- package/dist/components/cat-checkbox2.js +2 -2
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/{cat-menu.d.ts → cat-dropdown.d.ts} +4 -4
- package/dist/components/cat-dropdown.js +8 -0
- package/dist/components/cat-dropdown.js.map +1 -0
- package/dist/components/cat-dropdown2.js +195 -0
- package/dist/components/cat-dropdown2.js.map +1 -0
- package/dist/components/cat-i18n-registry.js +14 -39
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-icon2.js +2 -1
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +5 -6
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/{cat-toast-demo.d.ts → cat-pagination.d.ts} +4 -4
- package/dist/components/cat-pagination.js +150 -0
- package/dist/components/cat-pagination.js.map +1 -0
- package/dist/components/cat-radio.js +2 -2
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-select-demo.js +6 -6
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +7 -8
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-tabs.js +3 -3
- package/dist/components/cat-tabs.js.map +1 -1
- package/dist/components/cat-textarea.js +2 -2
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +2 -2
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +531 -4
- package/dist/components/index.js.map +1 -1
- package/dist/esm/cat-alert_22.entry.js +348 -287
- package/dist/esm/cat-alert_22.entry.js.map +1 -1
- package/dist/esm/cat-icon-registry-d537b18b.js +409 -0
- package/dist/esm/cat-icon-registry-d537b18b.js.map +1 -0
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +527 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/cat-button/cat-button.d.ts +4 -0
- package/dist/types/components/{cat-menu/cat-menu.d.ts → cat-dropdown/cat-dropdown.d.ts} +19 -12
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +4 -6
- package/dist/types/components/cat-icon/cat-icon-registry.d.ts +1 -0
- package/dist/types/components/cat-input/cat-input.d.ts +0 -1
- package/dist/types/components/cat-notification/cat-notification.d.ts +21 -48
- package/dist/types/components/cat-pagination/cat-pagination.d.ts +56 -0
- package/dist/types/components/cat-select/cat-select.d.ts +0 -1
- package/dist/types/components.d.ts +145 -57
- package/dist/types/index.d.ts +4 -4
- package/package.json +3 -3
- package/dist/catalyst/p-10b0d7a2.js +0 -10
- package/dist/catalyst/p-10b0d7a2.js.map +0 -1
- package/dist/catalyst/p-b561dcd4.entry.js +0 -2
- package/dist/catalyst/p-b561dcd4.entry.js.map +0 -1
- package/dist/catalyst/scss/core/_toast.scss +0 -87
- package/dist/cjs/cat-notification-bcb9fb86.js +0 -990
- package/dist/cjs/cat-notification-bcb9fb86.js.map +0 -1
- package/dist/collection/components/cat-menu/cat-menu.js.map +0 -1
- package/dist/collection/components/cat-toast-demo/cat-toast-demo.css +0 -3
- package/dist/collection/components/cat-toast-demo/cat-toast-demo.js +0 -62
- package/dist/collection/components/cat-toast-demo/cat-toast-demo.js.map +0 -1
- package/dist/collection/scss/core/_toast.scss +0 -87
- package/dist/components/cat-menu.js +0 -8
- package/dist/components/cat-menu.js.map +0 -1
- package/dist/components/cat-menu2.js +0 -176
- package/dist/components/cat-menu2.js.map +0 -1
- package/dist/components/cat-toast-demo.js +0 -647
- package/dist/components/cat-toast-demo.js.map +0 -1
- package/dist/esm/cat-notification-8bcf6fa2.js +0 -985
- package/dist/esm/cat-notification-8bcf6fa2.js.map +0 -1
- package/dist/types/components/cat-toast-demo/cat-toast-demo.d.ts +0 -9
|
@@ -1,647 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement as HTMLElement$1, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { c as createCommonjsModule, a as commonjsGlobal } from './loglevel.js';
|
|
3
|
-
import { d as defineCustomElement$4 } from './cat-button2.js';
|
|
4
|
-
import { d as defineCustomElement$3 } from './cat-icon2.js';
|
|
5
|
-
import { d as defineCustomElement$2 } from './cat-spinner2.js';
|
|
6
|
-
|
|
7
|
-
var toastify = createCommonjsModule(function (module) {
|
|
8
|
-
/*!
|
|
9
|
-
* Toastify js 1.12.0
|
|
10
|
-
* https://github.com/apvarun/toastify-js
|
|
11
|
-
* @license MIT licensed
|
|
12
|
-
*
|
|
13
|
-
* Copyright (C) 2018 Varun A P
|
|
14
|
-
*/
|
|
15
|
-
(function(root, factory) {
|
|
16
|
-
if (module.exports) {
|
|
17
|
-
module.exports = factory();
|
|
18
|
-
} else {
|
|
19
|
-
root.Toastify = factory();
|
|
20
|
-
}
|
|
21
|
-
})(commonjsGlobal, function(global) {
|
|
22
|
-
// Object initialization
|
|
23
|
-
var Toastify = function(options) {
|
|
24
|
-
// Returning a new init object
|
|
25
|
-
return new Toastify.lib.init(options);
|
|
26
|
-
},
|
|
27
|
-
// Library version
|
|
28
|
-
version = "1.12.0";
|
|
29
|
-
|
|
30
|
-
// Set the default global options
|
|
31
|
-
Toastify.defaults = {
|
|
32
|
-
oldestFirst: true,
|
|
33
|
-
text: "Toastify is awesome!",
|
|
34
|
-
node: undefined,
|
|
35
|
-
duration: 3000,
|
|
36
|
-
selector: undefined,
|
|
37
|
-
callback: function () {
|
|
38
|
-
},
|
|
39
|
-
destination: undefined,
|
|
40
|
-
newWindow: false,
|
|
41
|
-
close: false,
|
|
42
|
-
gravity: "toastify-top",
|
|
43
|
-
positionLeft: false,
|
|
44
|
-
position: '',
|
|
45
|
-
backgroundColor: '',
|
|
46
|
-
avatar: "",
|
|
47
|
-
className: "",
|
|
48
|
-
stopOnFocus: true,
|
|
49
|
-
onClick: function () {
|
|
50
|
-
},
|
|
51
|
-
offset: {x: 0, y: 0},
|
|
52
|
-
escapeMarkup: true,
|
|
53
|
-
ariaLive: 'polite',
|
|
54
|
-
style: {background: ''}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// Defining the prototype of the object
|
|
58
|
-
Toastify.lib = Toastify.prototype = {
|
|
59
|
-
toastify: version,
|
|
60
|
-
|
|
61
|
-
constructor: Toastify,
|
|
62
|
-
|
|
63
|
-
// Initializing the object with required parameters
|
|
64
|
-
init: function(options) {
|
|
65
|
-
// Verifying and validating the input object
|
|
66
|
-
if (!options) {
|
|
67
|
-
options = {};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Creating the options object
|
|
71
|
-
this.options = {};
|
|
72
|
-
|
|
73
|
-
this.toastElement = null;
|
|
74
|
-
|
|
75
|
-
// Validating the options
|
|
76
|
-
this.options.text = options.text || Toastify.defaults.text; // Display message
|
|
77
|
-
this.options.node = options.node || Toastify.defaults.node; // Display content as node
|
|
78
|
-
this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
|
|
79
|
-
this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
|
|
80
|
-
this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
|
|
81
|
-
this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
|
|
82
|
-
this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
|
|
83
|
-
this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
|
|
84
|
-
this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
|
|
85
|
-
this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
|
|
86
|
-
this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
|
|
87
|
-
this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
|
|
88
|
-
this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
|
|
89
|
-
this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
|
|
90
|
-
this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
|
|
91
|
-
this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
|
|
92
|
-
this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
|
|
93
|
-
this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
|
|
94
|
-
this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
|
|
95
|
-
this.options.style = options.style || Toastify.defaults.style;
|
|
96
|
-
if(options.backgroundColor) {
|
|
97
|
-
this.options.style.background = options.backgroundColor;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Returning the current object for chaining functions
|
|
101
|
-
return this;
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
// Building the DOM element
|
|
105
|
-
buildToast: function() {
|
|
106
|
-
// Validating if the options are defined
|
|
107
|
-
if (!this.options) {
|
|
108
|
-
throw "Toastify is not initialized";
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Creating the DOM object
|
|
112
|
-
var divElement = document.createElement("div");
|
|
113
|
-
divElement.className = "toastify on " + this.options.className;
|
|
114
|
-
|
|
115
|
-
// Positioning toast to left or right or center
|
|
116
|
-
if (!!this.options.position) {
|
|
117
|
-
divElement.className += " toastify-" + this.options.position;
|
|
118
|
-
} else {
|
|
119
|
-
// To be depreciated in further versions
|
|
120
|
-
if (this.options.positionLeft === true) {
|
|
121
|
-
divElement.className += " toastify-left";
|
|
122
|
-
console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.');
|
|
123
|
-
} else {
|
|
124
|
-
// Default position
|
|
125
|
-
divElement.className += " toastify-right";
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Assigning gravity of element
|
|
130
|
-
divElement.className += " " + this.options.gravity;
|
|
131
|
-
|
|
132
|
-
if (this.options.backgroundColor) {
|
|
133
|
-
// This is being deprecated in favor of using the style HTML DOM property
|
|
134
|
-
console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Loop through our style object and apply styles to divElement
|
|
138
|
-
for (var property in this.options.style) {
|
|
139
|
-
divElement.style[property] = this.options.style[property];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Announce the toast to screen readers
|
|
143
|
-
if (this.options.ariaLive) {
|
|
144
|
-
divElement.setAttribute('aria-live', this.options.ariaLive);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Adding the toast message/node
|
|
148
|
-
if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
|
|
149
|
-
// If we have a valid node, we insert it
|
|
150
|
-
divElement.appendChild(this.options.node);
|
|
151
|
-
} else {
|
|
152
|
-
if (this.options.escapeMarkup) {
|
|
153
|
-
divElement.innerText = this.options.text;
|
|
154
|
-
} else {
|
|
155
|
-
divElement.innerHTML = this.options.text;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (this.options.avatar !== "") {
|
|
159
|
-
var avatarElement = document.createElement("img");
|
|
160
|
-
avatarElement.src = this.options.avatar;
|
|
161
|
-
|
|
162
|
-
avatarElement.className = "toastify-avatar";
|
|
163
|
-
|
|
164
|
-
if (this.options.position == "left" || this.options.positionLeft === true) {
|
|
165
|
-
// Adding close icon on the left of content
|
|
166
|
-
divElement.appendChild(avatarElement);
|
|
167
|
-
} else {
|
|
168
|
-
// Adding close icon on the right of content
|
|
169
|
-
divElement.insertAdjacentElement("afterbegin", avatarElement);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Adding a close icon to the toast
|
|
175
|
-
if (this.options.close === true) {
|
|
176
|
-
// Create a span for close element
|
|
177
|
-
var closeElement = document.createElement("button");
|
|
178
|
-
closeElement.type = "button";
|
|
179
|
-
closeElement.setAttribute("aria-label", "Close");
|
|
180
|
-
closeElement.className = "toast-close";
|
|
181
|
-
closeElement.innerHTML = "✖";
|
|
182
|
-
|
|
183
|
-
// Triggering the removal of toast from DOM on close click
|
|
184
|
-
closeElement.addEventListener(
|
|
185
|
-
"click",
|
|
186
|
-
function(event) {
|
|
187
|
-
event.stopPropagation();
|
|
188
|
-
this.removeElement(this.toastElement);
|
|
189
|
-
window.clearTimeout(this.toastElement.timeOutValue);
|
|
190
|
-
}.bind(this)
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
//Calculating screen width
|
|
194
|
-
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
195
|
-
|
|
196
|
-
// Adding the close icon to the toast element
|
|
197
|
-
// Display on the right if screen width is less than or equal to 360px
|
|
198
|
-
if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
|
|
199
|
-
// Adding close icon on the left of content
|
|
200
|
-
divElement.insertAdjacentElement("afterbegin", closeElement);
|
|
201
|
-
} else {
|
|
202
|
-
// Adding close icon on the right of content
|
|
203
|
-
divElement.appendChild(closeElement);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Clear timeout while toast is focused
|
|
208
|
-
if (this.options.stopOnFocus && this.options.duration > 0) {
|
|
209
|
-
var self = this;
|
|
210
|
-
// stop countdown
|
|
211
|
-
divElement.addEventListener(
|
|
212
|
-
"mouseover",
|
|
213
|
-
function(event) {
|
|
214
|
-
window.clearTimeout(divElement.timeOutValue);
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
// add back the timeout
|
|
218
|
-
divElement.addEventListener(
|
|
219
|
-
"mouseleave",
|
|
220
|
-
function() {
|
|
221
|
-
divElement.timeOutValue = window.setTimeout(
|
|
222
|
-
function() {
|
|
223
|
-
// Remove the toast from DOM
|
|
224
|
-
self.removeElement(divElement);
|
|
225
|
-
},
|
|
226
|
-
self.options.duration
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Adding an on-click destination path
|
|
233
|
-
if (typeof this.options.destination !== "undefined") {
|
|
234
|
-
divElement.addEventListener(
|
|
235
|
-
"click",
|
|
236
|
-
function(event) {
|
|
237
|
-
event.stopPropagation();
|
|
238
|
-
if (this.options.newWindow === true) {
|
|
239
|
-
window.open(this.options.destination, "_blank");
|
|
240
|
-
} else {
|
|
241
|
-
window.location = this.options.destination;
|
|
242
|
-
}
|
|
243
|
-
}.bind(this)
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
|
|
248
|
-
divElement.addEventListener(
|
|
249
|
-
"click",
|
|
250
|
-
function(event) {
|
|
251
|
-
event.stopPropagation();
|
|
252
|
-
this.options.onClick();
|
|
253
|
-
}.bind(this)
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Adding offset
|
|
258
|
-
if(typeof this.options.offset === "object") {
|
|
259
|
-
|
|
260
|
-
var x = getAxisOffsetAValue("x", this.options);
|
|
261
|
-
var y = getAxisOffsetAValue("y", this.options);
|
|
262
|
-
|
|
263
|
-
var xOffset = this.options.position == "left" ? x : "-" + x;
|
|
264
|
-
var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
|
|
265
|
-
|
|
266
|
-
divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// Returning the generated element
|
|
271
|
-
return divElement;
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
// Displaying the toast
|
|
275
|
-
showToast: function() {
|
|
276
|
-
// Creating the DOM object for the toast
|
|
277
|
-
this.toastElement = this.buildToast();
|
|
278
|
-
|
|
279
|
-
// Getting the root element to with the toast needs to be added
|
|
280
|
-
var rootElement;
|
|
281
|
-
if (typeof this.options.selector === "string") {
|
|
282
|
-
rootElement = document.getElementById(this.options.selector);
|
|
283
|
-
} else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
|
|
284
|
-
rootElement = this.options.selector;
|
|
285
|
-
} else {
|
|
286
|
-
rootElement = document.body;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Validating if root element is present in DOM
|
|
290
|
-
if (!rootElement) {
|
|
291
|
-
throw "Root element is not defined";
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Adding the DOM element
|
|
295
|
-
var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
|
|
296
|
-
rootElement.insertBefore(this.toastElement, elementToInsert);
|
|
297
|
-
|
|
298
|
-
// Repositioning the toasts in case multiple toasts are present
|
|
299
|
-
Toastify.reposition();
|
|
300
|
-
|
|
301
|
-
if (this.options.duration > 0) {
|
|
302
|
-
this.toastElement.timeOutValue = window.setTimeout(
|
|
303
|
-
function() {
|
|
304
|
-
// Remove the toast from DOM
|
|
305
|
-
this.removeElement(this.toastElement);
|
|
306
|
-
}.bind(this),
|
|
307
|
-
this.options.duration
|
|
308
|
-
); // Binding `this` for function invocation
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Supporting function chaining
|
|
312
|
-
return this;
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
hideToast: function() {
|
|
316
|
-
if (this.toastElement.timeOutValue) {
|
|
317
|
-
clearTimeout(this.toastElement.timeOutValue);
|
|
318
|
-
}
|
|
319
|
-
this.removeElement(this.toastElement);
|
|
320
|
-
},
|
|
321
|
-
|
|
322
|
-
// Removing the element from the DOM
|
|
323
|
-
removeElement: function(toastElement) {
|
|
324
|
-
// Hiding the element
|
|
325
|
-
// toastElement.classList.remove("on");
|
|
326
|
-
toastElement.className = toastElement.className.replace(" on", "");
|
|
327
|
-
|
|
328
|
-
// Removing the element from DOM after transition end
|
|
329
|
-
window.setTimeout(
|
|
330
|
-
function() {
|
|
331
|
-
// remove options node if any
|
|
332
|
-
if (this.options.node && this.options.node.parentNode) {
|
|
333
|
-
this.options.node.parentNode.removeChild(this.options.node);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Remove the element from the DOM, only when the parent node was not removed before.
|
|
337
|
-
if (toastElement.parentNode) {
|
|
338
|
-
toastElement.parentNode.removeChild(toastElement);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Calling the callback function
|
|
342
|
-
this.options.callback.call(toastElement);
|
|
343
|
-
|
|
344
|
-
// Repositioning the toasts again
|
|
345
|
-
Toastify.reposition();
|
|
346
|
-
}.bind(this),
|
|
347
|
-
400
|
|
348
|
-
); // Binding `this` for function invocation
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
// Positioning the toasts on the DOM
|
|
353
|
-
Toastify.reposition = function() {
|
|
354
|
-
|
|
355
|
-
// Top margins with gravity
|
|
356
|
-
var topLeftOffsetSize = {
|
|
357
|
-
top: 15,
|
|
358
|
-
bottom: 15,
|
|
359
|
-
};
|
|
360
|
-
var topRightOffsetSize = {
|
|
361
|
-
top: 15,
|
|
362
|
-
bottom: 15,
|
|
363
|
-
};
|
|
364
|
-
var offsetSize = {
|
|
365
|
-
top: 15,
|
|
366
|
-
bottom: 15,
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
// Get all toast messages on the DOM
|
|
370
|
-
var allToasts = document.getElementsByClassName("toastify");
|
|
371
|
-
|
|
372
|
-
var classUsed;
|
|
373
|
-
|
|
374
|
-
// Modifying the position of each toast element
|
|
375
|
-
for (var i = 0; i < allToasts.length; i++) {
|
|
376
|
-
// Getting the applied gravity
|
|
377
|
-
if (containsClass(allToasts[i], "toastify-top") === true) {
|
|
378
|
-
classUsed = "toastify-top";
|
|
379
|
-
} else {
|
|
380
|
-
classUsed = "toastify-bottom";
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
var height = allToasts[i].offsetHeight;
|
|
384
|
-
classUsed = classUsed.substr(9, classUsed.length-1);
|
|
385
|
-
// Spacing between toasts
|
|
386
|
-
var offset = 15;
|
|
387
|
-
|
|
388
|
-
var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
389
|
-
|
|
390
|
-
// Show toast in center if screen with less than or equal to 360px
|
|
391
|
-
if (width <= 360) {
|
|
392
|
-
// Setting the position
|
|
393
|
-
allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
|
|
394
|
-
|
|
395
|
-
offsetSize[classUsed] += height + offset;
|
|
396
|
-
} else {
|
|
397
|
-
if (containsClass(allToasts[i], "toastify-left") === true) {
|
|
398
|
-
// Setting the position
|
|
399
|
-
allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
|
|
400
|
-
|
|
401
|
-
topLeftOffsetSize[classUsed] += height + offset;
|
|
402
|
-
} else {
|
|
403
|
-
// Setting the position
|
|
404
|
-
allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
|
|
405
|
-
|
|
406
|
-
topRightOffsetSize[classUsed] += height + offset;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Supporting function chaining
|
|
412
|
-
return this;
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
// Helper function to get offset.
|
|
416
|
-
function getAxisOffsetAValue(axis, options) {
|
|
417
|
-
|
|
418
|
-
if(options.offset[axis]) {
|
|
419
|
-
if(isNaN(options.offset[axis])) {
|
|
420
|
-
return options.offset[axis];
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
return options.offset[axis] + 'px';
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
return '0px';
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
function containsClass(elem, yourClass) {
|
|
432
|
-
if (!elem || typeof yourClass !== "string") {
|
|
433
|
-
return false;
|
|
434
|
-
} else if (
|
|
435
|
-
elem.className &&
|
|
436
|
-
elem.className
|
|
437
|
-
.trim()
|
|
438
|
-
.split(/\s+/gi)
|
|
439
|
-
.indexOf(yourClass) > -1
|
|
440
|
-
) {
|
|
441
|
-
return true;
|
|
442
|
-
} else {
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// Setting up the prototype for the init object
|
|
448
|
-
Toastify.lib.init.prototype = Toastify.lib;
|
|
449
|
-
|
|
450
|
-
// Returning the Toastify function to be assigned to the window object/module
|
|
451
|
-
return Toastify;
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
var TypeIcons;
|
|
456
|
-
(function (TypeIcons) {
|
|
457
|
-
TypeIcons["success"] = "check-circle-filled";
|
|
458
|
-
TypeIcons["error"] = "cross-circle-filled";
|
|
459
|
-
TypeIcons["info"] = "danger-filled";
|
|
460
|
-
TypeIcons["primary"] = "star-circle-filled";
|
|
461
|
-
TypeIcons["secondary"] = "info-circle-filled";
|
|
462
|
-
})(TypeIcons || (TypeIcons = {}));
|
|
463
|
-
const ToastPositions = {
|
|
464
|
-
'top-left': {
|
|
465
|
-
gravity: 'top',
|
|
466
|
-
position: 'left'
|
|
467
|
-
},
|
|
468
|
-
'top-center': {
|
|
469
|
-
gravity: 'top',
|
|
470
|
-
position: 'center'
|
|
471
|
-
},
|
|
472
|
-
'top-right': {
|
|
473
|
-
gravity: 'top',
|
|
474
|
-
position: 'right'
|
|
475
|
-
},
|
|
476
|
-
'bottom-left': {
|
|
477
|
-
gravity: 'bottom',
|
|
478
|
-
position: 'left'
|
|
479
|
-
},
|
|
480
|
-
'bottom-center': {
|
|
481
|
-
gravity: 'bottom',
|
|
482
|
-
position: 'center'
|
|
483
|
-
},
|
|
484
|
-
'bottom-right': {
|
|
485
|
-
gravity: 'bottom',
|
|
486
|
-
position: 'right'
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
class CatNotificationService {
|
|
490
|
-
error(title, message = ' ', options) {
|
|
491
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
492
|
-
toastify(toastOptions).showToast();
|
|
493
|
-
}
|
|
494
|
-
success(title, message = ' ', options) {
|
|
495
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
496
|
-
toastify(toastOptions).showToast();
|
|
497
|
-
}
|
|
498
|
-
info(title, message = ' ', options) {
|
|
499
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
500
|
-
toastify(toastOptions).showToast();
|
|
501
|
-
}
|
|
502
|
-
primary(title, message = ' ', options) {
|
|
503
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
504
|
-
toastify(toastOptions).showToast();
|
|
505
|
-
}
|
|
506
|
-
secondary(title, message = ' ', options) {
|
|
507
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
508
|
-
toastify(toastOptions).showToast();
|
|
509
|
-
}
|
|
510
|
-
toastHTMLTemplate(title, message = ' ', options) {
|
|
511
|
-
var _a;
|
|
512
|
-
const template = document.createElement('template');
|
|
513
|
-
const typeIcon = (options === null || options === void 0 ? void 0 : options.type) ? TypeIcons[options.type] : TypeIcons.secondary;
|
|
514
|
-
title = title.trim();
|
|
515
|
-
message = message.trim();
|
|
516
|
-
const hasMessage = message && message !== '';
|
|
517
|
-
const hasMessageClass = hasMessage ? 'has-message' : '';
|
|
518
|
-
template.innerHTML = `<div class="cat-toastify-wrapper">
|
|
519
|
-
<div class="cat-toastify-icon-wrapper ${(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'secondary'}">
|
|
520
|
-
<cat-icon icon="${typeIcon}"></cat-icon>
|
|
521
|
-
</div>
|
|
522
|
-
<div class="cat-toastify-title-wrapper ${hasMessageClass}">
|
|
523
|
-
<div class="cat-toastify-title">${title}</div></div>
|
|
524
|
-
${hasMessage ? `<div class="cat-toastify-message">${message}</div>` : ''}
|
|
525
|
-
</div>`;
|
|
526
|
-
return template.content.firstChild;
|
|
527
|
-
}
|
|
528
|
-
getPosition(options) {
|
|
529
|
-
const position = {
|
|
530
|
-
gravity: 'bottom',
|
|
531
|
-
position: 'left'
|
|
532
|
-
};
|
|
533
|
-
if ((options === null || options === void 0 ? void 0 : options.position) && ToastPositions[options.position]) {
|
|
534
|
-
position.position = ToastPositions[options.position].position;
|
|
535
|
-
position.gravity = ToastPositions[options.position].gravity;
|
|
536
|
-
}
|
|
537
|
-
return position;
|
|
538
|
-
}
|
|
539
|
-
extractOptions(title, message = ' ', options) {
|
|
540
|
-
const position = this.getPosition(options);
|
|
541
|
-
return {
|
|
542
|
-
node: (options === null || options === void 0 ? void 0 : options.content) ? options.content : this.toastHTMLTemplate(title, message, options),
|
|
543
|
-
duration: CatNotificationService.DURATION,
|
|
544
|
-
close: true,
|
|
545
|
-
className: 'cat-toastify',
|
|
546
|
-
gravity: position.gravity,
|
|
547
|
-
position: position.position,
|
|
548
|
-
stopOnFocus: true,
|
|
549
|
-
offset: {
|
|
550
|
-
x: '1.5rem',
|
|
551
|
-
y: '1.5rem'
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
CatNotificationService.DURATION = 80000;
|
|
557
|
-
const NotificationsService = new CatNotificationService();
|
|
558
|
-
|
|
559
|
-
const catToastDemoCss = ":host{display:block}";
|
|
560
|
-
|
|
561
|
-
const CatToastDemo$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
562
|
-
constructor() {
|
|
563
|
-
super();
|
|
564
|
-
this.__registerHost();
|
|
565
|
-
}
|
|
566
|
-
render() {
|
|
567
|
-
return h("cat-button", { onClick: this.onClick.bind(this) }, "Show Notifications");
|
|
568
|
-
}
|
|
569
|
-
onClick() {
|
|
570
|
-
const infoOptions = {
|
|
571
|
-
position: 'top-left',
|
|
572
|
-
type: 'info'
|
|
573
|
-
};
|
|
574
|
-
const errorOptions = {
|
|
575
|
-
position: 'top-center',
|
|
576
|
-
type: 'error'
|
|
577
|
-
};
|
|
578
|
-
const errorOptions2 = {
|
|
579
|
-
position: 'bottom-left',
|
|
580
|
-
type: 'error'
|
|
581
|
-
};
|
|
582
|
-
const successOptions3 = {
|
|
583
|
-
position: 'bottom-right',
|
|
584
|
-
type: 'success'
|
|
585
|
-
};
|
|
586
|
-
const template = document.createElement('template');
|
|
587
|
-
template.innerHTML = `<div style="padding: 7px 30px 7px 10px">Custom HTML Node Content</div>`;
|
|
588
|
-
const successOptions4 = {
|
|
589
|
-
position: 'bottom-right',
|
|
590
|
-
type: 'success',
|
|
591
|
-
content: template.content.firstChild
|
|
592
|
-
};
|
|
593
|
-
const primaryOptions = {
|
|
594
|
-
position: 'bottom-right',
|
|
595
|
-
type: 'primary'
|
|
596
|
-
};
|
|
597
|
-
const secondaryOptions = {
|
|
598
|
-
position: 'bottom-right',
|
|
599
|
-
type: 'secondary'
|
|
600
|
-
};
|
|
601
|
-
NotificationsService.secondary('Secondary Click', 'secondary info', secondaryOptions);
|
|
602
|
-
NotificationsService.primary('primary Click', 'secondary info', primaryOptions);
|
|
603
|
-
NotificationsService.error('Default Click');
|
|
604
|
-
NotificationsService.error('Long default title, long default title, long default title, long default title');
|
|
605
|
-
NotificationsService.info('Info Click', 'Info message', infoOptions);
|
|
606
|
-
NotificationsService.success('', ' ', successOptions4);
|
|
607
|
-
NotificationsService.error('Error Title', ' ', errorOptions);
|
|
608
|
-
NotificationsService.error('Error 2 Title', 'Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message,Very long message, Very long message, Very long message, Very long message, Very long message, ', errorOptions2);
|
|
609
|
-
NotificationsService.success('Success Title - very long title without message', ' ', successOptions3);
|
|
610
|
-
}
|
|
611
|
-
static get style() { return catToastDemoCss; }
|
|
612
|
-
}, [0, "cat-toast-demo"]);
|
|
613
|
-
function defineCustomElement$1() {
|
|
614
|
-
if (typeof customElements === "undefined") {
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
const components = ["cat-toast-demo", "cat-button", "cat-icon", "cat-spinner"];
|
|
618
|
-
components.forEach(tagName => { switch (tagName) {
|
|
619
|
-
case "cat-toast-demo":
|
|
620
|
-
if (!customElements.get(tagName)) {
|
|
621
|
-
customElements.define(tagName, CatToastDemo$1);
|
|
622
|
-
}
|
|
623
|
-
break;
|
|
624
|
-
case "cat-button":
|
|
625
|
-
if (!customElements.get(tagName)) {
|
|
626
|
-
defineCustomElement$4();
|
|
627
|
-
}
|
|
628
|
-
break;
|
|
629
|
-
case "cat-icon":
|
|
630
|
-
if (!customElements.get(tagName)) {
|
|
631
|
-
defineCustomElement$3();
|
|
632
|
-
}
|
|
633
|
-
break;
|
|
634
|
-
case "cat-spinner":
|
|
635
|
-
if (!customElements.get(tagName)) {
|
|
636
|
-
defineCustomElement$2();
|
|
637
|
-
}
|
|
638
|
-
break;
|
|
639
|
-
} });
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
const CatToastDemo = CatToastDemo$1;
|
|
643
|
-
const defineCustomElement = defineCustomElement$1;
|
|
644
|
-
|
|
645
|
-
export { CatToastDemo, NotificationsService as N, defineCustomElement };
|
|
646
|
-
|
|
647
|
-
//# sourceMappingURL=cat-toast-demo.js.map
|