@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.
Files changed (148) hide show
  1. package/dist/catalyst/catalyst.css +1 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.cdn.js +7 -3
  5. package/dist/catalyst/index.esm.js +9 -1
  6. package/dist/catalyst/index.esm.js.map +1 -1
  7. package/dist/catalyst/p-167f01e8.entry.js +2 -0
  8. package/dist/catalyst/p-167f01e8.entry.js.map +1 -0
  9. package/dist/catalyst/p-5865f232.js +2 -0
  10. package/dist/catalyst/p-5865f232.js.map +1 -0
  11. package/dist/catalyst/scss/_variables.scss +1 -1
  12. package/dist/catalyst/scss/core/_form.scss +8 -0
  13. package/dist/catalyst/scss/core/_nav.scss +3 -3
  14. package/dist/catalyst/scss/core/_notification.scss +48 -0
  15. package/dist/catalyst/scss/index.scss +2 -1
  16. package/dist/catalyst/scss/utils/_typography.scss +4 -0
  17. package/dist/cjs/cat-alert_22.cjs.entry.js +351 -290
  18. package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -1
  19. package/dist/cjs/cat-icon-registry-2a54df3d.js +417 -0
  20. package/dist/cjs/cat-icon-registry-2a54df3d.js.map +1 -0
  21. package/dist/cjs/catalyst.cjs.js +1 -1
  22. package/dist/cjs/index.cjs.js +528 -4
  23. package/dist/cjs/index.cjs.js.map +1 -1
  24. package/dist/cjs/loader.cjs.js +1 -1
  25. package/dist/collection/collection-manifest.json +2 -2
  26. package/dist/collection/components/cat-button/cat-button.css +21 -63
  27. package/dist/collection/components/cat-button/cat-button.js +21 -4
  28. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  29. package/dist/collection/components/cat-card/cat-card.css +5 -4
  30. package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -4
  31. package/dist/collection/components/cat-checkbox/cat-checkbox.js +1 -1
  32. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  33. package/dist/collection/components/{cat-menu/cat-menu.css → cat-dropdown/cat-dropdown.css} +20 -0
  34. package/dist/collection/components/{cat-menu/cat-menu.js → cat-dropdown/cat-dropdown.js} +102 -87
  35. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -0
  36. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +13 -38
  37. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  38. package/dist/collection/components/cat-icon/cat-icon-registry.js +1 -0
  39. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
  40. package/dist/collection/components/cat-input/cat-input.css +1 -4
  41. package/dist/collection/components/cat-input/cat-input.js +4 -5
  42. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  43. package/dist/collection/components/cat-notification/cat-notification.js +61 -89
  44. package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
  45. package/dist/collection/components/cat-pagination/cat-pagination.css +106 -0
  46. package/dist/collection/components/cat-pagination/cat-pagination.js +302 -0
  47. package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -0
  48. package/dist/collection/components/cat-radio/cat-radio.css +1 -4
  49. package/dist/collection/components/cat-radio/cat-radio.js +1 -1
  50. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  51. package/dist/collection/components/cat-select/cat-select.css +1 -4
  52. package/dist/collection/components/cat-select/cat-select.js +8 -9
  53. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  54. package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
  55. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
  56. package/dist/collection/components/cat-tabs/cat-tabs.css +2 -2
  57. package/dist/collection/components/cat-tabs/cat-tabs.js +2 -2
  58. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  59. package/dist/collection/components/cat-textarea/cat-textarea.css +1 -4
  60. package/dist/collection/components/cat-textarea/cat-textarea.js +1 -1
  61. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  62. package/dist/collection/components/cat-toggle/cat-toggle.css +1 -4
  63. package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
  64. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  65. package/dist/collection/index.cdn.js +7 -3
  66. package/dist/collection/index.js +3 -3
  67. package/dist/collection/index.js.map +1 -1
  68. package/dist/collection/scss/_variables.scss +1 -1
  69. package/dist/collection/scss/core/_form.scss +8 -0
  70. package/dist/collection/scss/core/_nav.scss +3 -3
  71. package/dist/collection/scss/core/_notification.scss +48 -0
  72. package/dist/collection/scss/index.scss +2 -1
  73. package/dist/collection/scss/utils/_typography.scss +4 -0
  74. package/dist/components/cat-button2.js +6 -5
  75. package/dist/components/cat-button2.js.map +1 -1
  76. package/dist/components/cat-card.js +1 -1
  77. package/dist/components/cat-card.js.map +1 -1
  78. package/dist/components/cat-checkbox2.js +2 -2
  79. package/dist/components/cat-checkbox2.js.map +1 -1
  80. package/dist/components/{cat-menu.d.ts → cat-dropdown.d.ts} +4 -4
  81. package/dist/components/cat-dropdown.js +8 -0
  82. package/dist/components/cat-dropdown.js.map +1 -0
  83. package/dist/components/cat-dropdown2.js +195 -0
  84. package/dist/components/cat-dropdown2.js.map +1 -0
  85. package/dist/components/cat-i18n-registry.js +14 -39
  86. package/dist/components/cat-i18n-registry.js.map +1 -1
  87. package/dist/components/cat-icon2.js +2 -1
  88. package/dist/components/cat-icon2.js.map +1 -1
  89. package/dist/components/cat-input.js +5 -6
  90. package/dist/components/cat-input.js.map +1 -1
  91. package/dist/components/{cat-toast-demo.d.ts → cat-pagination.d.ts} +4 -4
  92. package/dist/components/cat-pagination.js +150 -0
  93. package/dist/components/cat-pagination.js.map +1 -0
  94. package/dist/components/cat-radio.js +2 -2
  95. package/dist/components/cat-radio.js.map +1 -1
  96. package/dist/components/cat-select-demo.js +6 -6
  97. package/dist/components/cat-select-demo.js.map +1 -1
  98. package/dist/components/cat-select2.js +7 -8
  99. package/dist/components/cat-select2.js.map +1 -1
  100. package/dist/components/cat-tabs.js +3 -3
  101. package/dist/components/cat-tabs.js.map +1 -1
  102. package/dist/components/cat-textarea.js +2 -2
  103. package/dist/components/cat-textarea.js.map +1 -1
  104. package/dist/components/cat-toggle.js +2 -2
  105. package/dist/components/cat-toggle.js.map +1 -1
  106. package/dist/components/index.d.ts +2 -2
  107. package/dist/components/index.js +531 -4
  108. package/dist/components/index.js.map +1 -1
  109. package/dist/esm/cat-alert_22.entry.js +348 -287
  110. package/dist/esm/cat-alert_22.entry.js.map +1 -1
  111. package/dist/esm/cat-icon-registry-d537b18b.js +409 -0
  112. package/dist/esm/cat-icon-registry-d537b18b.js.map +1 -0
  113. package/dist/esm/catalyst.js +1 -1
  114. package/dist/esm/index.js +527 -1
  115. package/dist/esm/index.js.map +1 -1
  116. package/dist/esm/loader.js +1 -1
  117. package/dist/types/components/cat-button/cat-button.d.ts +4 -0
  118. package/dist/types/components/{cat-menu/cat-menu.d.ts → cat-dropdown/cat-dropdown.d.ts} +19 -12
  119. package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +4 -6
  120. package/dist/types/components/cat-icon/cat-icon-registry.d.ts +1 -0
  121. package/dist/types/components/cat-input/cat-input.d.ts +0 -1
  122. package/dist/types/components/cat-notification/cat-notification.d.ts +21 -48
  123. package/dist/types/components/cat-pagination/cat-pagination.d.ts +56 -0
  124. package/dist/types/components/cat-select/cat-select.d.ts +0 -1
  125. package/dist/types/components.d.ts +145 -57
  126. package/dist/types/index.d.ts +4 -4
  127. package/package.json +3 -3
  128. package/dist/catalyst/p-10b0d7a2.js +0 -10
  129. package/dist/catalyst/p-10b0d7a2.js.map +0 -1
  130. package/dist/catalyst/p-b561dcd4.entry.js +0 -2
  131. package/dist/catalyst/p-b561dcd4.entry.js.map +0 -1
  132. package/dist/catalyst/scss/core/_toast.scss +0 -87
  133. package/dist/cjs/cat-notification-bcb9fb86.js +0 -990
  134. package/dist/cjs/cat-notification-bcb9fb86.js.map +0 -1
  135. package/dist/collection/components/cat-menu/cat-menu.js.map +0 -1
  136. package/dist/collection/components/cat-toast-demo/cat-toast-demo.css +0 -3
  137. package/dist/collection/components/cat-toast-demo/cat-toast-demo.js +0 -62
  138. package/dist/collection/components/cat-toast-demo/cat-toast-demo.js.map +0 -1
  139. package/dist/collection/scss/core/_toast.scss +0 -87
  140. package/dist/components/cat-menu.js +0 -8
  141. package/dist/components/cat-menu.js.map +0 -1
  142. package/dist/components/cat-menu2.js +0 -176
  143. package/dist/components/cat-menu2.js.map +0 -1
  144. package/dist/components/cat-toast-demo.js +0 -647
  145. package/dist/components/cat-toast-demo.js.map +0 -1
  146. package/dist/esm/cat-notification-8bcf6fa2.js +0 -985
  147. package/dist/esm/cat-notification-8bcf6fa2.js.map +0 -1
  148. package/dist/types/components/cat-toast-demo/cat-toast-demo.d.ts +0 -9
@@ -1,990 +0,0 @@
1
- 'use strict';
2
-
3
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
-
5
- function createCommonjsModule(fn, basedir, module) {
6
- return module = {
7
- path: basedir,
8
- exports: {},
9
- require: function (path, base) {
10
- return commonjsRequire();
11
- }
12
- }, fn(module, module.exports), module.exports;
13
- }
14
-
15
- function commonjsRequire () {
16
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
17
- }
18
-
19
- var loglevel = createCommonjsModule(function (module) {
20
- /*
21
- * loglevel - https://github.com/pimterry/loglevel
22
- *
23
- * Copyright (c) 2013 Tim Perry
24
- * Licensed under the MIT license.
25
- */
26
- (function (root, definition) {
27
- if (module.exports) {
28
- module.exports = definition();
29
- } else {
30
- root.log = definition();
31
- }
32
- }(commonjsGlobal, function () {
33
-
34
- // Slightly dubious tricks to cut down minimized file size
35
- var noop = function() {};
36
- var undefinedType = "undefined";
37
- var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
38
- /Trident\/|MSIE /.test(window.navigator.userAgent)
39
- );
40
-
41
- var logMethods = [
42
- "trace",
43
- "debug",
44
- "info",
45
- "warn",
46
- "error"
47
- ];
48
-
49
- // Cross-browser bind equivalent that works at least back to IE6
50
- function bindMethod(obj, methodName) {
51
- var method = obj[methodName];
52
- if (typeof method.bind === 'function') {
53
- return method.bind(obj);
54
- } else {
55
- try {
56
- return Function.prototype.bind.call(method, obj);
57
- } catch (e) {
58
- // Missing bind shim or IE8 + Modernizr, fallback to wrapping
59
- return function() {
60
- return Function.prototype.apply.apply(method, [obj, arguments]);
61
- };
62
- }
63
- }
64
- }
65
-
66
- // Trace() doesn't print the message in IE, so for that case we need to wrap it
67
- function traceForIE() {
68
- if (console.log) {
69
- if (console.log.apply) {
70
- console.log.apply(console, arguments);
71
- } else {
72
- // In old IE, native console methods themselves don't have apply().
73
- Function.prototype.apply.apply(console.log, [console, arguments]);
74
- }
75
- }
76
- if (console.trace) console.trace();
77
- }
78
-
79
- // Build the best logging method possible for this env
80
- // Wherever possible we want to bind, not wrap, to preserve stack traces
81
- function realMethod(methodName) {
82
- if (methodName === 'debug') {
83
- methodName = 'log';
84
- }
85
-
86
- if (typeof console === undefinedType) {
87
- return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
88
- } else if (methodName === 'trace' && isIE) {
89
- return traceForIE;
90
- } else if (console[methodName] !== undefined) {
91
- return bindMethod(console, methodName);
92
- } else if (console.log !== undefined) {
93
- return bindMethod(console, 'log');
94
- } else {
95
- return noop;
96
- }
97
- }
98
-
99
- // These private functions always need `this` to be set properly
100
-
101
- function replaceLoggingMethods(level, loggerName) {
102
- /*jshint validthis:true */
103
- for (var i = 0; i < logMethods.length; i++) {
104
- var methodName = logMethods[i];
105
- this[methodName] = (i < level) ?
106
- noop :
107
- this.methodFactory(methodName, level, loggerName);
108
- }
109
-
110
- // Define log.log as an alias for log.debug
111
- this.log = this.debug;
112
- }
113
-
114
- // In old IE versions, the console isn't present until you first open it.
115
- // We build realMethod() replacements here that regenerate logging methods
116
- function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
117
- return function () {
118
- if (typeof console !== undefinedType) {
119
- replaceLoggingMethods.call(this, level, loggerName);
120
- this[methodName].apply(this, arguments);
121
- }
122
- };
123
- }
124
-
125
- // By default, we use closely bound real methods wherever possible, and
126
- // otherwise we wait for a console to appear, and then try again.
127
- function defaultMethodFactory(methodName, level, loggerName) {
128
- /*jshint validthis:true */
129
- return realMethod(methodName) ||
130
- enableLoggingWhenConsoleArrives.apply(this, arguments);
131
- }
132
-
133
- function Logger(name, defaultLevel, factory) {
134
- var self = this;
135
- var currentLevel;
136
- defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
137
-
138
- var storageKey = "loglevel";
139
- if (typeof name === "string") {
140
- storageKey += ":" + name;
141
- } else if (typeof name === "symbol") {
142
- storageKey = undefined;
143
- }
144
-
145
- function persistLevelIfPossible(levelNum) {
146
- var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
147
-
148
- if (typeof window === undefinedType || !storageKey) return;
149
-
150
- // Use localStorage if available
151
- try {
152
- window.localStorage[storageKey] = levelName;
153
- return;
154
- } catch (ignore) {}
155
-
156
- // Use session cookie as fallback
157
- try {
158
- window.document.cookie =
159
- encodeURIComponent(storageKey) + "=" + levelName + ";";
160
- } catch (ignore) {}
161
- }
162
-
163
- function getPersistedLevel() {
164
- var storedLevel;
165
-
166
- if (typeof window === undefinedType || !storageKey) return;
167
-
168
- try {
169
- storedLevel = window.localStorage[storageKey];
170
- } catch (ignore) {}
171
-
172
- // Fallback to cookies if local storage gives us nothing
173
- if (typeof storedLevel === undefinedType) {
174
- try {
175
- var cookie = window.document.cookie;
176
- var location = cookie.indexOf(
177
- encodeURIComponent(storageKey) + "=");
178
- if (location !== -1) {
179
- storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
180
- }
181
- } catch (ignore) {}
182
- }
183
-
184
- // If the stored level is not valid, treat it as if nothing was stored.
185
- if (self.levels[storedLevel] === undefined) {
186
- storedLevel = undefined;
187
- }
188
-
189
- return storedLevel;
190
- }
191
-
192
- function clearPersistedLevel() {
193
- if (typeof window === undefinedType || !storageKey) return;
194
-
195
- // Use localStorage if available
196
- try {
197
- window.localStorage.removeItem(storageKey);
198
- return;
199
- } catch (ignore) {}
200
-
201
- // Use session cookie as fallback
202
- try {
203
- window.document.cookie =
204
- encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
205
- } catch (ignore) {}
206
- }
207
-
208
- /*
209
- *
210
- * Public logger API - see https://github.com/pimterry/loglevel for details
211
- *
212
- */
213
-
214
- self.name = name;
215
-
216
- self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
217
- "ERROR": 4, "SILENT": 5};
218
-
219
- self.methodFactory = factory || defaultMethodFactory;
220
-
221
- self.getLevel = function () {
222
- return currentLevel;
223
- };
224
-
225
- self.setLevel = function (level, persist) {
226
- if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
227
- level = self.levels[level.toUpperCase()];
228
- }
229
- if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
230
- currentLevel = level;
231
- if (persist !== false) { // defaults to true
232
- persistLevelIfPossible(level);
233
- }
234
- replaceLoggingMethods.call(self, level, name);
235
- if (typeof console === undefinedType && level < self.levels.SILENT) {
236
- return "No console available for logging";
237
- }
238
- } else {
239
- throw "log.setLevel() called with invalid level: " + level;
240
- }
241
- };
242
-
243
- self.setDefaultLevel = function (level) {
244
- defaultLevel = level;
245
- if (!getPersistedLevel()) {
246
- self.setLevel(level, false);
247
- }
248
- };
249
-
250
- self.resetLevel = function () {
251
- self.setLevel(defaultLevel, false);
252
- clearPersistedLevel();
253
- };
254
-
255
- self.enableAll = function(persist) {
256
- self.setLevel(self.levels.TRACE, persist);
257
- };
258
-
259
- self.disableAll = function(persist) {
260
- self.setLevel(self.levels.SILENT, persist);
261
- };
262
-
263
- // Initialize with the right level
264
- var initialLevel = getPersistedLevel();
265
- if (initialLevel == null) {
266
- initialLevel = defaultLevel;
267
- }
268
- self.setLevel(initialLevel, false);
269
- }
270
-
271
- /*
272
- *
273
- * Top-level API
274
- *
275
- */
276
-
277
- var defaultLogger = new Logger();
278
-
279
- var _loggersByName = {};
280
- defaultLogger.getLogger = function getLogger(name) {
281
- if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
282
- throw new TypeError("You must supply a name when creating a logger.");
283
- }
284
-
285
- var logger = _loggersByName[name];
286
- if (!logger) {
287
- logger = _loggersByName[name] = new Logger(
288
- name, defaultLogger.getLevel(), defaultLogger.methodFactory);
289
- }
290
- return logger;
291
- };
292
-
293
- // Grab the current global log variable in case of overwrite
294
- var _log = (typeof window !== undefinedType) ? window.log : undefined;
295
- defaultLogger.noConflict = function() {
296
- if (typeof window !== undefinedType &&
297
- window.log === defaultLogger) {
298
- window.log = _log;
299
- }
300
-
301
- return defaultLogger;
302
- };
303
-
304
- defaultLogger.getLoggers = function getLoggers() {
305
- return _loggersByName;
306
- };
307
-
308
- // ES6 default export, for compatibility
309
- defaultLogger['default'] = defaultLogger;
310
-
311
- return defaultLogger;
312
- }));
313
- });
314
-
315
- class CatI18nRegistry {
316
- constructor() {
317
- this._locale = 'en';
318
- this._dicts = new Map();
319
- // hide constructor
320
- }
321
- static getInstance() {
322
- if (!CatI18nRegistry.instance) {
323
- CatI18nRegistry.instance = new CatI18nRegistry();
324
- }
325
- return CatI18nRegistry.instance;
326
- }
327
- locale(locale) {
328
- if (locale) {
329
- this._locale = locale;
330
- loglevel.info(`[CatI18nRegistry] Locale set to ${locale}`);
331
- window.dispatchEvent(this.buildEvent('cat-i18n-locale', { locale }));
332
- }
333
- return this._locale;
334
- }
335
- register(locale, i18n) {
336
- const dict = this.getDict(locale);
337
- Object.entries(i18n).forEach(([key, message]) => dict.set(key, message));
338
- loglevel.info(`[CatI18nRegistry] Registered messages for ${locale}`, i18n);
339
- window.dispatchEvent(this.buildEvent('cat-i18n-register', { i18n }));
340
- }
341
- clear(locale) {
342
- if (locale) {
343
- this.getDict(locale).clear();
344
- loglevel.info(`[CatI18nRegistry] Cleared messages for ${locale}`);
345
- window.dispatchEvent(this.buildEvent('cat-i18n-clear', { locale }));
346
- }
347
- else {
348
- this._dicts.clear();
349
- loglevel.info(`[CatI18nRegistry] Cleared messages`);
350
- window.dispatchEvent(this.buildEvent('cat-i18n-clear'));
351
- }
352
- }
353
- t(key, params) {
354
- var _a;
355
- const message = (_a = this._dicts.get(this._locale)) === null || _a === void 0 ? void 0 : _a.get(key);
356
- if (message === undefined) {
357
- loglevel.error(`[CatI18nRegistry] Unknown message for ${this._locale}: ${key}`);
358
- return '';
359
- }
360
- return message.replace(/{{\s*([-a-zA-Z._]+)\s*}}/g, (_match, key) => { var _a; return `${(_a = params === null || params === void 0 ? void 0 : params[key]) !== null && _a !== void 0 ? _a : ''}`; });
361
- }
362
- buildEvent(name, detail) {
363
- return new CustomEvent(name, {
364
- bubbles: true,
365
- composed: true,
366
- detail
367
- });
368
- }
369
- getDict(lang) {
370
- let dict = this._dicts.get(lang);
371
- if (!dict) {
372
- dict = new Map();
373
- this._dicts.set(lang, dict);
374
- }
375
- return dict;
376
- }
377
- }
378
-
379
- class CatIconRegistry {
380
- constructor() {
381
- this.icons = new Map();
382
- // hide constructor
383
- }
384
- static getInstance() {
385
- if (!CatIconRegistry.instance) {
386
- CatIconRegistry.instance = new CatIconRegistry();
387
- }
388
- return CatIconRegistry.instance;
389
- }
390
- getIcon(name, setName) {
391
- const icon = this.icons.get(this.buildName(name, setName));
392
- if (!icon) {
393
- loglevel.error(`[CatIconRegistry] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);
394
- }
395
- return icon;
396
- }
397
- addIcon(name, data, setName) {
398
- this.icons.set(this.buildName(name, setName), data);
399
- loglevel.info(`[CatIconRegistry] Added icon${setName ? ` to set ${setName}` : ''}: ${name}`);
400
- window.dispatchEvent(this.buildEvent('cat-icon-added', { name, setName }));
401
- return this;
402
- }
403
- addIcons(icons, setName) {
404
- Object.entries(icons).forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));
405
- loglevel.info(`[CatIconRegistry] Added icons${setName ? ` to set ${setName}` : ''}: ${Object.keys(icons).concat(', ')}`);
406
- window.dispatchEvent(this.buildEvent('cat-icons-added', { names: Object.keys(icons), setName }));
407
- return this;
408
- }
409
- removeIcon(name, setName) {
410
- this.icons.delete(this.buildName(name, setName));
411
- loglevel.info(`[CatIconRegistry] Removed icon${setName ? ` from set ${setName}` : ''}: ${name}`);
412
- window.dispatchEvent(this.buildEvent('cat-icon-removed', { name, setName }));
413
- return this;
414
- }
415
- removeIcons(names, setName) {
416
- names.forEach(name => this.icons.delete(this.buildName(name, setName)));
417
- loglevel.info(`[CatIconRegistry] Removed icons${setName ? ` from set ${setName}` : ''}: ${names.concat(', ')}`);
418
- window.dispatchEvent(this.buildEvent('cat-icons-removed', { names, setName }));
419
- return this;
420
- }
421
- buildName(name, setName) {
422
- return setName ? `${setName}:name` : name;
423
- }
424
- buildEvent(name, detail) {
425
- return new CustomEvent(name, {
426
- bubbles: true,
427
- composed: true,
428
- detail
429
- });
430
- }
431
- }
432
-
433
- var toastify = createCommonjsModule(function (module) {
434
- /*!
435
- * Toastify js 1.12.0
436
- * https://github.com/apvarun/toastify-js
437
- * @license MIT licensed
438
- *
439
- * Copyright (C) 2018 Varun A P
440
- */
441
- (function(root, factory) {
442
- if (module.exports) {
443
- module.exports = factory();
444
- } else {
445
- root.Toastify = factory();
446
- }
447
- })(commonjsGlobal, function(global) {
448
- // Object initialization
449
- var Toastify = function(options) {
450
- // Returning a new init object
451
- return new Toastify.lib.init(options);
452
- },
453
- // Library version
454
- version = "1.12.0";
455
-
456
- // Set the default global options
457
- Toastify.defaults = {
458
- oldestFirst: true,
459
- text: "Toastify is awesome!",
460
- node: undefined,
461
- duration: 3000,
462
- selector: undefined,
463
- callback: function () {
464
- },
465
- destination: undefined,
466
- newWindow: false,
467
- close: false,
468
- gravity: "toastify-top",
469
- positionLeft: false,
470
- position: '',
471
- backgroundColor: '',
472
- avatar: "",
473
- className: "",
474
- stopOnFocus: true,
475
- onClick: function () {
476
- },
477
- offset: {x: 0, y: 0},
478
- escapeMarkup: true,
479
- ariaLive: 'polite',
480
- style: {background: ''}
481
- };
482
-
483
- // Defining the prototype of the object
484
- Toastify.lib = Toastify.prototype = {
485
- toastify: version,
486
-
487
- constructor: Toastify,
488
-
489
- // Initializing the object with required parameters
490
- init: function(options) {
491
- // Verifying and validating the input object
492
- if (!options) {
493
- options = {};
494
- }
495
-
496
- // Creating the options object
497
- this.options = {};
498
-
499
- this.toastElement = null;
500
-
501
- // Validating the options
502
- this.options.text = options.text || Toastify.defaults.text; // Display message
503
- this.options.node = options.node || Toastify.defaults.node; // Display content as node
504
- this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
505
- this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
506
- this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
507
- this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
508
- this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
509
- this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
510
- this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
511
- this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
512
- this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
513
- this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
514
- this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
515
- this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
516
- this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
517
- this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
518
- this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
519
- this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
520
- this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
521
- this.options.style = options.style || Toastify.defaults.style;
522
- if(options.backgroundColor) {
523
- this.options.style.background = options.backgroundColor;
524
- }
525
-
526
- // Returning the current object for chaining functions
527
- return this;
528
- },
529
-
530
- // Building the DOM element
531
- buildToast: function() {
532
- // Validating if the options are defined
533
- if (!this.options) {
534
- throw "Toastify is not initialized";
535
- }
536
-
537
- // Creating the DOM object
538
- var divElement = document.createElement("div");
539
- divElement.className = "toastify on " + this.options.className;
540
-
541
- // Positioning toast to left or right or center
542
- if (!!this.options.position) {
543
- divElement.className += " toastify-" + this.options.position;
544
- } else {
545
- // To be depreciated in further versions
546
- if (this.options.positionLeft === true) {
547
- divElement.className += " toastify-left";
548
- console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.');
549
- } else {
550
- // Default position
551
- divElement.className += " toastify-right";
552
- }
553
- }
554
-
555
- // Assigning gravity of element
556
- divElement.className += " " + this.options.gravity;
557
-
558
- if (this.options.backgroundColor) {
559
- // This is being deprecated in favor of using the style HTML DOM property
560
- console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
561
- }
562
-
563
- // Loop through our style object and apply styles to divElement
564
- for (var property in this.options.style) {
565
- divElement.style[property] = this.options.style[property];
566
- }
567
-
568
- // Announce the toast to screen readers
569
- if (this.options.ariaLive) {
570
- divElement.setAttribute('aria-live', this.options.ariaLive);
571
- }
572
-
573
- // Adding the toast message/node
574
- if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
575
- // If we have a valid node, we insert it
576
- divElement.appendChild(this.options.node);
577
- } else {
578
- if (this.options.escapeMarkup) {
579
- divElement.innerText = this.options.text;
580
- } else {
581
- divElement.innerHTML = this.options.text;
582
- }
583
-
584
- if (this.options.avatar !== "") {
585
- var avatarElement = document.createElement("img");
586
- avatarElement.src = this.options.avatar;
587
-
588
- avatarElement.className = "toastify-avatar";
589
-
590
- if (this.options.position == "left" || this.options.positionLeft === true) {
591
- // Adding close icon on the left of content
592
- divElement.appendChild(avatarElement);
593
- } else {
594
- // Adding close icon on the right of content
595
- divElement.insertAdjacentElement("afterbegin", avatarElement);
596
- }
597
- }
598
- }
599
-
600
- // Adding a close icon to the toast
601
- if (this.options.close === true) {
602
- // Create a span for close element
603
- var closeElement = document.createElement("button");
604
- closeElement.type = "button";
605
- closeElement.setAttribute("aria-label", "Close");
606
- closeElement.className = "toast-close";
607
- closeElement.innerHTML = "&#10006;";
608
-
609
- // Triggering the removal of toast from DOM on close click
610
- closeElement.addEventListener(
611
- "click",
612
- function(event) {
613
- event.stopPropagation();
614
- this.removeElement(this.toastElement);
615
- window.clearTimeout(this.toastElement.timeOutValue);
616
- }.bind(this)
617
- );
618
-
619
- //Calculating screen width
620
- var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
621
-
622
- // Adding the close icon to the toast element
623
- // Display on the right if screen width is less than or equal to 360px
624
- if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
625
- // Adding close icon on the left of content
626
- divElement.insertAdjacentElement("afterbegin", closeElement);
627
- } else {
628
- // Adding close icon on the right of content
629
- divElement.appendChild(closeElement);
630
- }
631
- }
632
-
633
- // Clear timeout while toast is focused
634
- if (this.options.stopOnFocus && this.options.duration > 0) {
635
- var self = this;
636
- // stop countdown
637
- divElement.addEventListener(
638
- "mouseover",
639
- function(event) {
640
- window.clearTimeout(divElement.timeOutValue);
641
- }
642
- );
643
- // add back the timeout
644
- divElement.addEventListener(
645
- "mouseleave",
646
- function() {
647
- divElement.timeOutValue = window.setTimeout(
648
- function() {
649
- // Remove the toast from DOM
650
- self.removeElement(divElement);
651
- },
652
- self.options.duration
653
- );
654
- }
655
- );
656
- }
657
-
658
- // Adding an on-click destination path
659
- if (typeof this.options.destination !== "undefined") {
660
- divElement.addEventListener(
661
- "click",
662
- function(event) {
663
- event.stopPropagation();
664
- if (this.options.newWindow === true) {
665
- window.open(this.options.destination, "_blank");
666
- } else {
667
- window.location = this.options.destination;
668
- }
669
- }.bind(this)
670
- );
671
- }
672
-
673
- if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
674
- divElement.addEventListener(
675
- "click",
676
- function(event) {
677
- event.stopPropagation();
678
- this.options.onClick();
679
- }.bind(this)
680
- );
681
- }
682
-
683
- // Adding offset
684
- if(typeof this.options.offset === "object") {
685
-
686
- var x = getAxisOffsetAValue("x", this.options);
687
- var y = getAxisOffsetAValue("y", this.options);
688
-
689
- var xOffset = this.options.position == "left" ? x : "-" + x;
690
- var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
691
-
692
- divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
693
-
694
- }
695
-
696
- // Returning the generated element
697
- return divElement;
698
- },
699
-
700
- // Displaying the toast
701
- showToast: function() {
702
- // Creating the DOM object for the toast
703
- this.toastElement = this.buildToast();
704
-
705
- // Getting the root element to with the toast needs to be added
706
- var rootElement;
707
- if (typeof this.options.selector === "string") {
708
- rootElement = document.getElementById(this.options.selector);
709
- } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
710
- rootElement = this.options.selector;
711
- } else {
712
- rootElement = document.body;
713
- }
714
-
715
- // Validating if root element is present in DOM
716
- if (!rootElement) {
717
- throw "Root element is not defined";
718
- }
719
-
720
- // Adding the DOM element
721
- var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
722
- rootElement.insertBefore(this.toastElement, elementToInsert);
723
-
724
- // Repositioning the toasts in case multiple toasts are present
725
- Toastify.reposition();
726
-
727
- if (this.options.duration > 0) {
728
- this.toastElement.timeOutValue = window.setTimeout(
729
- function() {
730
- // Remove the toast from DOM
731
- this.removeElement(this.toastElement);
732
- }.bind(this),
733
- this.options.duration
734
- ); // Binding `this` for function invocation
735
- }
736
-
737
- // Supporting function chaining
738
- return this;
739
- },
740
-
741
- hideToast: function() {
742
- if (this.toastElement.timeOutValue) {
743
- clearTimeout(this.toastElement.timeOutValue);
744
- }
745
- this.removeElement(this.toastElement);
746
- },
747
-
748
- // Removing the element from the DOM
749
- removeElement: function(toastElement) {
750
- // Hiding the element
751
- // toastElement.classList.remove("on");
752
- toastElement.className = toastElement.className.replace(" on", "");
753
-
754
- // Removing the element from DOM after transition end
755
- window.setTimeout(
756
- function() {
757
- // remove options node if any
758
- if (this.options.node && this.options.node.parentNode) {
759
- this.options.node.parentNode.removeChild(this.options.node);
760
- }
761
-
762
- // Remove the element from the DOM, only when the parent node was not removed before.
763
- if (toastElement.parentNode) {
764
- toastElement.parentNode.removeChild(toastElement);
765
- }
766
-
767
- // Calling the callback function
768
- this.options.callback.call(toastElement);
769
-
770
- // Repositioning the toasts again
771
- Toastify.reposition();
772
- }.bind(this),
773
- 400
774
- ); // Binding `this` for function invocation
775
- },
776
- };
777
-
778
- // Positioning the toasts on the DOM
779
- Toastify.reposition = function() {
780
-
781
- // Top margins with gravity
782
- var topLeftOffsetSize = {
783
- top: 15,
784
- bottom: 15,
785
- };
786
- var topRightOffsetSize = {
787
- top: 15,
788
- bottom: 15,
789
- };
790
- var offsetSize = {
791
- top: 15,
792
- bottom: 15,
793
- };
794
-
795
- // Get all toast messages on the DOM
796
- var allToasts = document.getElementsByClassName("toastify");
797
-
798
- var classUsed;
799
-
800
- // Modifying the position of each toast element
801
- for (var i = 0; i < allToasts.length; i++) {
802
- // Getting the applied gravity
803
- if (containsClass(allToasts[i], "toastify-top") === true) {
804
- classUsed = "toastify-top";
805
- } else {
806
- classUsed = "toastify-bottom";
807
- }
808
-
809
- var height = allToasts[i].offsetHeight;
810
- classUsed = classUsed.substr(9, classUsed.length-1);
811
- // Spacing between toasts
812
- var offset = 15;
813
-
814
- var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
815
-
816
- // Show toast in center if screen with less than or equal to 360px
817
- if (width <= 360) {
818
- // Setting the position
819
- allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
820
-
821
- offsetSize[classUsed] += height + offset;
822
- } else {
823
- if (containsClass(allToasts[i], "toastify-left") === true) {
824
- // Setting the position
825
- allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
826
-
827
- topLeftOffsetSize[classUsed] += height + offset;
828
- } else {
829
- // Setting the position
830
- allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
831
-
832
- topRightOffsetSize[classUsed] += height + offset;
833
- }
834
- }
835
- }
836
-
837
- // Supporting function chaining
838
- return this;
839
- };
840
-
841
- // Helper function to get offset.
842
- function getAxisOffsetAValue(axis, options) {
843
-
844
- if(options.offset[axis]) {
845
- if(isNaN(options.offset[axis])) {
846
- return options.offset[axis];
847
- }
848
- else {
849
- return options.offset[axis] + 'px';
850
- }
851
- }
852
-
853
- return '0px';
854
-
855
- }
856
-
857
- function containsClass(elem, yourClass) {
858
- if (!elem || typeof yourClass !== "string") {
859
- return false;
860
- } else if (
861
- elem.className &&
862
- elem.className
863
- .trim()
864
- .split(/\s+/gi)
865
- .indexOf(yourClass) > -1
866
- ) {
867
- return true;
868
- } else {
869
- return false;
870
- }
871
- }
872
-
873
- // Setting up the prototype for the init object
874
- Toastify.lib.init.prototype = Toastify.lib;
875
-
876
- // Returning the Toastify function to be assigned to the window object/module
877
- return Toastify;
878
- });
879
- });
880
-
881
- var TypeIcons;
882
- (function (TypeIcons) {
883
- TypeIcons["success"] = "check-circle-filled";
884
- TypeIcons["error"] = "cross-circle-filled";
885
- TypeIcons["info"] = "danger-filled";
886
- TypeIcons["primary"] = "star-circle-filled";
887
- TypeIcons["secondary"] = "info-circle-filled";
888
- })(TypeIcons || (TypeIcons = {}));
889
- const ToastPositions = {
890
- 'top-left': {
891
- gravity: 'top',
892
- position: 'left'
893
- },
894
- 'top-center': {
895
- gravity: 'top',
896
- position: 'center'
897
- },
898
- 'top-right': {
899
- gravity: 'top',
900
- position: 'right'
901
- },
902
- 'bottom-left': {
903
- gravity: 'bottom',
904
- position: 'left'
905
- },
906
- 'bottom-center': {
907
- gravity: 'bottom',
908
- position: 'center'
909
- },
910
- 'bottom-right': {
911
- gravity: 'bottom',
912
- position: 'right'
913
- }
914
- };
915
- class CatNotificationService {
916
- error(title, message = ' ', options) {
917
- const toastOptions = this.extractOptions(title, message, options);
918
- toastify(toastOptions).showToast();
919
- }
920
- success(title, message = ' ', options) {
921
- const toastOptions = this.extractOptions(title, message, options);
922
- toastify(toastOptions).showToast();
923
- }
924
- info(title, message = ' ', options) {
925
- const toastOptions = this.extractOptions(title, message, options);
926
- toastify(toastOptions).showToast();
927
- }
928
- primary(title, message = ' ', options) {
929
- const toastOptions = this.extractOptions(title, message, options);
930
- toastify(toastOptions).showToast();
931
- }
932
- secondary(title, message = ' ', options) {
933
- const toastOptions = this.extractOptions(title, message, options);
934
- toastify(toastOptions).showToast();
935
- }
936
- toastHTMLTemplate(title, message = ' ', options) {
937
- var _a;
938
- const template = document.createElement('template');
939
- const typeIcon = (options === null || options === void 0 ? void 0 : options.type) ? TypeIcons[options.type] : TypeIcons.secondary;
940
- title = title.trim();
941
- message = message.trim();
942
- const hasMessage = message && message !== '';
943
- const hasMessageClass = hasMessage ? 'has-message' : '';
944
- template.innerHTML = `<div class="cat-toastify-wrapper">
945
- <div class="cat-toastify-icon-wrapper ${(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'secondary'}">
946
- <cat-icon icon="${typeIcon}"></cat-icon>
947
- </div>
948
- <div class="cat-toastify-title-wrapper ${hasMessageClass}">
949
- <div class="cat-toastify-title">${title}</div></div>
950
- ${hasMessage ? `<div class="cat-toastify-message">${message}</div>` : ''}
951
- </div>`;
952
- return template.content.firstChild;
953
- }
954
- getPosition(options) {
955
- const position = {
956
- gravity: 'bottom',
957
- position: 'left'
958
- };
959
- if ((options === null || options === void 0 ? void 0 : options.position) && ToastPositions[options.position]) {
960
- position.position = ToastPositions[options.position].position;
961
- position.gravity = ToastPositions[options.position].gravity;
962
- }
963
- return position;
964
- }
965
- extractOptions(title, message = ' ', options) {
966
- const position = this.getPosition(options);
967
- return {
968
- node: (options === null || options === void 0 ? void 0 : options.content) ? options.content : this.toastHTMLTemplate(title, message, options),
969
- duration: CatNotificationService.DURATION,
970
- close: true,
971
- className: 'cat-toastify',
972
- gravity: position.gravity,
973
- position: position.position,
974
- stopOnFocus: true,
975
- offset: {
976
- x: '1.5rem',
977
- y: '1.5rem'
978
- }
979
- };
980
- }
981
- }
982
- CatNotificationService.DURATION = 80000;
983
- const NotificationsService = new CatNotificationService();
984
-
985
- exports.CatI18nRegistry = CatI18nRegistry;
986
- exports.CatIconRegistry = CatIconRegistry;
987
- exports.NotificationsService = NotificationsService;
988
- exports.loglevel = loglevel;
989
-
990
- //# sourceMappingURL=cat-notification-bcb9fb86.js.map