@haiilo/catalyst 1.3.1 → 2.0.1

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