@everymatrix/nuts-inbox-widget 1.90.37 → 1.91.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.
@@ -1,2 +1,3 @@
1
1
  export declare const MAX_NOTIFICATION_TEXT_LENGTH = 200;
2
2
  export declare const MAX_NOTIFICATION_LINES = 5;
3
+ export declare const BLOCK_ELEMENT_REGEX: RegExp;
package/hydrate/index.js CHANGED
@@ -2183,7 +2183,6 @@ var registerHost = (elm, cmpMeta) => {
2183
2183
  var styles = /* @__PURE__ */ new Map();
2184
2184
 
2185
2185
  const DEFAULT_LANGUAGE = 'en';
2186
- const SUPPORTED_LANGUAGES = ['hu', 'en', 'tr'];
2187
2186
  const TRANSLATIONS = {
2188
2187
  en: {
2189
2188
  notifications: 'Notifications',
@@ -2217,11 +2216,33 @@ const TRANSLATIONS = {
2217
2216
  deleteAllMessages: 'Delete all messages',
2218
2217
  next: 'Következő',
2219
2218
  prev: 'Előző'
2219
+ },
2220
+ az: {
2221
+ notifications: "Bildirişlər",
2222
+ noMessages: "Burada hələ yeni heç nə yoxdur",
2223
+ markAllAsRead: "Hamısını oxunmuş kimi işarələ",
2224
+ markAsRead: "Oxunmuş kimi işarələ",
2225
+ markAsUnread: "Oxunmamış kimi işarələ",
2226
+ removeMessage: "Mesajı sil",
2227
+ deleteAllMessages: "Bütün mesajları sil",
2228
+ next: "Növbəti",
2229
+ prev: "Əvvəlki"
2230
+ },
2231
+ es: {
2232
+ notifications: "Notificaciones",
2233
+ noMessages: "Aún no hay nada nuevo por aquí",
2234
+ markAllAsRead: "Marcar todo como leído",
2235
+ markAsRead: "Marcar como leído",
2236
+ markAsUnread: "Marcar como no leído",
2237
+ removeMessage: "Eliminar el mensaje",
2238
+ deleteAllMessages: "Eliminar todos los mensajes",
2239
+ next: "Siguiente",
2240
+ prev: "Anterior"
2220
2241
  }
2221
2242
  };
2222
2243
  const translate$1 = (key, customLang, values) => {
2223
2244
  const lang = customLang;
2224
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2245
+ let translation = TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
2225
2246
  if (values !== undefined) {
2226
2247
  for (const [key, value] of Object.entries(values.values)) {
2227
2248
  const regex = new RegExp(`{${key}}`, 'g');
@@ -2237,11 +2258,18 @@ const getTranslations = (url) => {
2237
2258
  .then((res) => res.json())
2238
2259
  .then((data) => {
2239
2260
  Object.keys(data).forEach((item) => {
2261
+ if (!TRANSLATIONS[item]) {
2262
+ TRANSLATIONS[item] = {};
2263
+ }
2240
2264
  for (let key in data[item]) {
2241
2265
  TRANSLATIONS[item][key] = data[item][key];
2242
2266
  }
2243
2267
  });
2244
2268
  resolve(true);
2269
+ })
2270
+ .catch((err) => {
2271
+ console.error('Failed to fetch translations:', err);
2272
+ resolve(false);
2245
2273
  });
2246
2274
  });
2247
2275
  };
@@ -44446,9 +44474,10 @@ function renderAbstractNodeToSVGElement(node, options) {
44446
44474
 
44447
44475
  const MAX_NOTIFICATION_TEXT_LENGTH = 200;
44448
44476
  const MAX_NOTIFICATION_LINES = 5;
44477
+ const BLOCK_ELEMENT_REGEX = /<br\s*\/?>|<\/p>|<\/h[1-6]>|<\/?blockquote>/gi;
44449
44478
 
44450
44479
  const truncate = (str, maxChars, maxLines) => {
44451
- var _a, _b, _c;
44480
+ var _a;
44452
44481
  if (!str || maxChars < 0)
44453
44482
  return "";
44454
44483
  const parser = new DOMParser();
@@ -44456,29 +44485,37 @@ const truncate = (str, maxChars, maxLines) => {
44456
44485
  let charCount = 0;
44457
44486
  let lineCount = 0;
44458
44487
  const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
44488
+ const removeAfter = (node) => {
44489
+ let current = node;
44490
+ while (current && current !== doc.body) {
44491
+ const parent = current.parentNode;
44492
+ if (!parent)
44493
+ break;
44494
+ while (current.nextSibling) {
44495
+ parent.removeChild(current.nextSibling);
44496
+ }
44497
+ current = parent;
44498
+ }
44499
+ };
44459
44500
  while (walker.nextNode()) {
44460
44501
  const node = walker.currentNode;
44461
44502
  if (node.nodeType === Node.TEXT_NODE) {
44462
44503
  const text = node.textContent || "";
44463
44504
  if (charCount + text.length > maxChars) {
44464
44505
  node.textContent = text.slice(0, maxChars - charCount) + "...";
44465
- while (node.nextSibling) {
44466
- (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(node.nextSibling);
44467
- }
44506
+ removeAfter(node);
44468
44507
  break;
44469
44508
  }
44470
44509
  charCount += text.length;
44471
44510
  }
44472
44511
  else {
44473
44512
  const tagName = node.nodeName.toLowerCase();
44474
- if (tagName === "br" || /^h[1-6]$/.test(tagName) || tagName === "p") {
44513
+ if (tagName === "br" || /^h[1-6]$/.test(tagName) || tagName === "p" || tagName === "blockquote") {
44475
44514
  lineCount++;
44476
44515
  if (lineCount >= maxLines) {
44477
44516
  const ellipsis = doc.createTextNode("...");
44478
- (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(ellipsis, node.nextSibling);
44479
- while (node.nextSibling) {
44480
- (_c = node.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(node.nextSibling);
44481
- }
44517
+ (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(ellipsis, node);
44518
+ removeAfter(ellipsis);
44482
44519
  break;
44483
44520
  }
44484
44521
  }
@@ -44696,7 +44733,7 @@ class NutsNotification {
44696
44733
  this.messageRead = this.read;
44697
44734
  const fullyStrippedContent = DOMPurify.sanitize(this.content, { ALLOWED_TAGS: [] });
44698
44735
  if ((fullyStrippedContent === null || fullyStrippedContent === void 0 ? void 0 : fullyStrippedContent.length) > this.maxTextLength ||
44699
- (((_a = this.content) === null || _a === void 0 ? void 0 : _a.match(/<br\s*\/?>|<\/p>|<\/h[1-6]>/gi)) || []).length) {
44736
+ (((_a = this.content) === null || _a === void 0 ? void 0 : _a.match(BLOCK_ELEMENT_REGEX)) || []).length) {
44700
44737
  this.displayedContent = truncate(this.content, this.maxTextLength, this.maxLines);
44701
44738
  }
44702
44739
  else {
@@ -44740,11 +44777,11 @@ class NutsNotification {
44740
44777
  'img'
44741
44778
  ]
44742
44779
  });
44743
- return (hAsync("div", { key: 'ac04933f45fbcc0c100615388fe010528c422f6f', class: "Wrapper", onClick: this.markNotificationAsRead }, hAsync("div", { key: 'c85d1cdefb959c390c8db554864f2756809a5341', class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: this.assignRefToStylingContainer, onClick: this.notificationActionHandler }, this.badge ? (hAsync("div", { class: "AvatarContainer" }, hAsync("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ? (hAsync("div", { innerHTML: systemIcons[this.badge].icon })) : (hAsync("img", { class: "AvatarImage", src: this.badge }))))) : (''), hAsync("div", { key: 'f58174fbeb1041f6f94e2032f01802702ecea9af', class: "ContentContainer" }, hAsync("div", { key: '0b35a305a4d7385e324f27463bd9f3f00ccd1ea9', innerHTML: sanitizedNotificationBody, class: "NotificationBody" }), hAsync("p", { key: '11baf24cfea3d48cf3366c97eaed8f7921abd2f3', class: "Date" }, formatDistanceToNow(new Date(this.date), {
44780
+ return (hAsync("div", { key: 'a6e5c8ad297e9c99dc4955ec7aad14b201abf523', class: "Wrapper", onClick: this.markNotificationAsRead }, hAsync("div", { key: '1e92d30f79d7eda3ee3d2592299bc4969cf41ede', class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: this.assignRefToStylingContainer, onClick: this.notificationActionHandler }, this.badge ? (hAsync("div", { class: "AvatarContainer" }, hAsync("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ? (hAsync("div", { innerHTML: systemIcons[this.badge].icon })) : (hAsync("img", { class: "AvatarImage", src: this.badge }))))) : (''), hAsync("div", { key: 'c6df1cc1801ac038933ebc8986c66f2cf81c3833', class: "ContentContainer" }, hAsync("div", { key: 'f15effff484f5f8679e31d05a794ac9ffd6462a8', innerHTML: sanitizedNotificationBody, class: "NotificationBody" }), hAsync("p", { key: '24966927ff1e452a00482dfb9d9527a1d1d85742', class: "Date" }, formatDistanceToNow(new Date(this.date), {
44744
44781
  addSuffix: true,
44745
44782
  locale: dateFnsLocale(this.language)
44746
- }))), hAsync("div", { key: '87670fb6228e11ff3097fdaee66d005d0fb06a6a', class: "RightActionsContainer" }, hAsync("div", { key: 'f858a84bb3dea7486397c80af4aa3e8e0fc7f395', class: "Settings", onClick: this.toggleSettingsModal }, hAsync("svg", { key: '3312814097d3d29d8f299e218b172b130bf2e93a', width: "24", height: "24", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { key: 'e58f7b83f66e95d6866354578a07fefe5a938da3', d: "M20.625 15.5C20.625 16.5547 21.4453 17.375 22.5 17.375C23.5156 17.375 24.375 16.5547 24.375 15.5C24.375 14.4844 23.5156 13.625 22.5 13.625C21.4453 13.625 20.625 14.4844 20.625 15.5ZM9.375 15.5C9.375 14.4844 8.51562 13.625 7.5 13.625C6.44531 13.625 5.625 14.4844 5.625 15.5C5.625 16.5547 6.44531 17.375 7.5 17.375C8.51562 17.375 9.375 16.5547 9.375 15.5ZM16.875 15.5C16.875 14.4844 16.0156 13.625 15 13.625C13.9453 13.625 13.125 14.4844 13.125 15.5C13.125 16.5547 13.9453 17.375 15 17.375C16.0156 17.375 16.875 16.5547 16.875 15.5Z", fill: "currentColor" }))), (((_b = DOMPurify.sanitize(this.content, { ALLOWED_TAGS: [] })) === null || _b === void 0 ? void 0 : _b.length) > this.maxTextLength ||
44747
- (((_c = this.content) === null || _c === void 0 ? void 0 : _c.match(/<br\s*\/?>|<\/p>|<\/h[1-6]>/gi)) || []).length > this.maxLines) && (hAsync("div", { key: '33109a51a711b637f50593731721c98a08ca0157', class: "AccordionArrow", innerHTML: systemIcons.arrowDown.icon, ref: this.assignRefToDropdownArrow, onClick: this.accordionArrowClickHandler })))), this.showSettingsModal ? (hAsync("div", { class: "SettingsDropdown" }, hAsync("button", { onClick: this.toggleNotificationRead }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M14.9434 5.17969C14.2109 4.59375 13.625 4.125 10.1387 1.60547C9.64062 1.25391 8.67383 0.375 8 0.375V0.404297C7.9707 0.404297 7.9707 0.375 7.9707 0.375C7.29688 0.375 6.33008 1.25391 5.83203 1.60547C2.3457 4.125 1.75977 4.59375 1.02734 5.17969C0.675781 5.44336 0.5 5.85352 0.5 6.26367V13.9688C0.5 14.7598 1.11523 15.375 1.90625 15.375H14.0938C14.8555 15.375 15.5 14.7598 15.5 13.9688V6.26367C15.5 5.85352 15.2949 5.44336 14.9434 5.17969ZM9.37695 11.1562C8.9668 11.4785 8.46875 11.6543 8 11.6543C7.50195 11.6543 7.00391 11.4785 6.59375 11.1562L2.375 7.8457V6.49805C2.99023 6 3.72266 5.44336 6.94531 3.12891C7.0332 3.04102 7.15039 2.95312 7.26758 2.86523C7.41406 2.74805 7.73633 2.48438 8 2.33789C8.23438 2.48438 8.55664 2.74805 8.70312 2.86523C8.82031 2.95312 8.9375 3.04102 9.02539 3.12891C12.2188 5.44336 12.9805 6 13.625 6.49805V7.8457L9.37695 11.1562Z", fill: "currentColor" })), translate$1(this.messageRead ? 'markAsUnread' : 'markAsRead', this.language)), hAsync("button", { onClick: this.deleteNotification }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M4.375 15.4375C4.375 16.1758 4.94922 16.75 5.6875 16.75H13.5625C14.2734 16.75 14.875 16.1758 14.875 15.4375V6.25H4.375V15.4375ZM11.8125 8.4375C11.8125 8.21875 12.0039 8 12.25 8C12.4688 8 12.6875 8.21875 12.6875 8.4375V14.5625C12.6875 14.8086 12.4688 15 12.25 15C12.0039 15 11.8125 14.8086 11.8125 14.5625V8.4375ZM9.1875 8.4375C9.1875 8.21875 9.37891 8 9.625 8C9.84375 8 10.0625 8.21875 10.0625 8.4375V14.5625C10.0625 14.8086 9.84375 15 9.625 15C9.37891 15 9.1875 14.8086 9.1875 14.5625V8.4375ZM6.5625 8.4375C6.5625 8.21875 6.75391 8 7 8C7.21875 8 7.4375 8.21875 7.4375 8.4375V14.5625C7.4375 14.8086 7.21875 15 7 15C6.75391 15 6.5625 14.8086 6.5625 14.5625V8.4375ZM15.3125 3.625H12.25L11.9219 2.99609C11.8398 2.85938 11.7031 2.75 11.5391 2.75H7.68359C7.51953 2.75 7.38281 2.85938 7.30078 2.99609L7 3.625H3.9375C3.69141 3.625 3.5 3.84375 3.5 4.0625V4.9375C3.5 5.18359 3.69141 5.375 3.9375 5.375H15.3125C15.5312 5.375 15.75 5.18359 15.75 4.9375V4.0625C15.75 3.84375 15.5312 3.625 15.3125 3.625Z", fill: "currentColor" })), translate$1('removeMessage', this.language)))) : ('')));
44783
+ }))), hAsync("div", { key: '71556828f255616171d3003b9a1b71f8c085d3f4', class: "RightActionsContainer" }, hAsync("div", { key: 'e15d3cd943e119c5d9f221083cb1a7fe20b6995a', class: "Settings", onClick: this.toggleSettingsModal }, hAsync("svg", { key: '1af781321dc8f23582f33ed55061012242236cc0', width: "24", height: "24", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { key: 'e79e7ef95efef24b70a2ba6389e57f385ea6a266', d: "M20.625 15.5C20.625 16.5547 21.4453 17.375 22.5 17.375C23.5156 17.375 24.375 16.5547 24.375 15.5C24.375 14.4844 23.5156 13.625 22.5 13.625C21.4453 13.625 20.625 14.4844 20.625 15.5ZM9.375 15.5C9.375 14.4844 8.51562 13.625 7.5 13.625C6.44531 13.625 5.625 14.4844 5.625 15.5C5.625 16.5547 6.44531 17.375 7.5 17.375C8.51562 17.375 9.375 16.5547 9.375 15.5ZM16.875 15.5C16.875 14.4844 16.0156 13.625 15 13.625C13.9453 13.625 13.125 14.4844 13.125 15.5C13.125 16.5547 13.9453 17.375 15 17.375C16.0156 17.375 16.875 16.5547 16.875 15.5Z", fill: "currentColor" }))), (((_b = DOMPurify.sanitize(this.content, { ALLOWED_TAGS: [] })) === null || _b === void 0 ? void 0 : _b.length) > this.maxTextLength ||
44784
+ (((_c = this.content) === null || _c === void 0 ? void 0 : _c.match(BLOCK_ELEMENT_REGEX)) || []).length > this.maxLines) && (hAsync("div", { key: '56cdc3008e063cd38f1aeea1ce5aee111d97862b', class: "AccordionArrow", innerHTML: systemIcons.arrowDown.icon, ref: this.assignRefToDropdownArrow, onClick: this.accordionArrowClickHandler })))), this.showSettingsModal ? (hAsync("div", { class: "SettingsDropdown" }, hAsync("button", { onClick: this.toggleNotificationRead }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M14.9434 5.17969C14.2109 4.59375 13.625 4.125 10.1387 1.60547C9.64062 1.25391 8.67383 0.375 8 0.375V0.404297C7.9707 0.404297 7.9707 0.375 7.9707 0.375C7.29688 0.375 6.33008 1.25391 5.83203 1.60547C2.3457 4.125 1.75977 4.59375 1.02734 5.17969C0.675781 5.44336 0.5 5.85352 0.5 6.26367V13.9688C0.5 14.7598 1.11523 15.375 1.90625 15.375H14.0938C14.8555 15.375 15.5 14.7598 15.5 13.9688V6.26367C15.5 5.85352 15.2949 5.44336 14.9434 5.17969ZM9.37695 11.1562C8.9668 11.4785 8.46875 11.6543 8 11.6543C7.50195 11.6543 7.00391 11.4785 6.59375 11.1562L2.375 7.8457V6.49805C2.99023 6 3.72266 5.44336 6.94531 3.12891C7.0332 3.04102 7.15039 2.95312 7.26758 2.86523C7.41406 2.74805 7.73633 2.48438 8 2.33789C8.23438 2.48438 8.55664 2.74805 8.70312 2.86523C8.82031 2.95312 8.9375 3.04102 9.02539 3.12891C12.2188 5.44336 12.9805 6 13.625 6.49805V7.8457L9.37695 11.1562Z", fill: "currentColor" })), translate$1(this.messageRead ? 'markAsUnread' : 'markAsRead', this.language)), hAsync("button", { onClick: this.deleteNotification }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M4.375 15.4375C4.375 16.1758 4.94922 16.75 5.6875 16.75H13.5625C14.2734 16.75 14.875 16.1758 14.875 15.4375V6.25H4.375V15.4375ZM11.8125 8.4375C11.8125 8.21875 12.0039 8 12.25 8C12.4688 8 12.6875 8.21875 12.6875 8.4375V14.5625C12.6875 14.8086 12.4688 15 12.25 15C12.0039 15 11.8125 14.8086 11.8125 14.5625V8.4375ZM9.1875 8.4375C9.1875 8.21875 9.37891 8 9.625 8C9.84375 8 10.0625 8.21875 10.0625 8.4375V14.5625C10.0625 14.8086 9.84375 15 9.625 15C9.37891 15 9.1875 14.8086 9.1875 14.5625V8.4375ZM6.5625 8.4375C6.5625 8.21875 6.75391 8 7 8C7.21875 8 7.4375 8.21875 7.4375 8.4375V14.5625C7.4375 14.8086 7.21875 15 7 15C6.75391 15 6.5625 14.8086 6.5625 14.5625V8.4375ZM15.3125 3.625H12.25L11.9219 2.99609C11.8398 2.85938 11.7031 2.75 11.5391 2.75H7.68359C7.51953 2.75 7.38281 2.85938 7.30078 2.99609L7 3.625H3.9375C3.69141 3.625 3.5 3.84375 3.5 4.0625V4.9375C3.5 5.18359 3.69141 5.375 3.9375 5.375H15.3125C15.5312 5.375 15.75 5.18359 15.75 4.9375V4.0625C15.75 3.84375 15.5312 3.625 15.3125 3.625Z", fill: "currentColor" })), translate$1('removeMessage', this.language)))) : ('')));
44748
44785
  }
44749
44786
  get el() { return getElement(this); }
44750
44787
  static get watchers() { return {
package/hydrate/index.mjs CHANGED
@@ -2179,7 +2179,6 @@ var registerHost = (elm, cmpMeta) => {
2179
2179
  var styles = /* @__PURE__ */ new Map();
2180
2180
 
2181
2181
  const DEFAULT_LANGUAGE = 'en';
2182
- const SUPPORTED_LANGUAGES = ['hu', 'en', 'tr'];
2183
2182
  const TRANSLATIONS = {
2184
2183
  en: {
2185
2184
  notifications: 'Notifications',
@@ -2213,11 +2212,33 @@ const TRANSLATIONS = {
2213
2212
  deleteAllMessages: 'Delete all messages',
2214
2213
  next: 'Következő',
2215
2214
  prev: 'Előző'
2215
+ },
2216
+ az: {
2217
+ notifications: "Bildirişlər",
2218
+ noMessages: "Burada hələ yeni heç nə yoxdur",
2219
+ markAllAsRead: "Hamısını oxunmuş kimi işarələ",
2220
+ markAsRead: "Oxunmuş kimi işarələ",
2221
+ markAsUnread: "Oxunmamış kimi işarələ",
2222
+ removeMessage: "Mesajı sil",
2223
+ deleteAllMessages: "Bütün mesajları sil",
2224
+ next: "Növbəti",
2225
+ prev: "Əvvəlki"
2226
+ },
2227
+ es: {
2228
+ notifications: "Notificaciones",
2229
+ noMessages: "Aún no hay nada nuevo por aquí",
2230
+ markAllAsRead: "Marcar todo como leído",
2231
+ markAsRead: "Marcar como leído",
2232
+ markAsUnread: "Marcar como no leído",
2233
+ removeMessage: "Eliminar el mensaje",
2234
+ deleteAllMessages: "Eliminar todos los mensajes",
2235
+ next: "Siguiente",
2236
+ prev: "Anterior"
2216
2237
  }
2217
2238
  };
2218
2239
  const translate$1 = (key, customLang, values) => {
2219
2240
  const lang = customLang;
2220
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2241
+ let translation = TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
2221
2242
  if (values !== undefined) {
2222
2243
  for (const [key, value] of Object.entries(values.values)) {
2223
2244
  const regex = new RegExp(`{${key}}`, 'g');
@@ -2233,11 +2254,18 @@ const getTranslations = (url) => {
2233
2254
  .then((res) => res.json())
2234
2255
  .then((data) => {
2235
2256
  Object.keys(data).forEach((item) => {
2257
+ if (!TRANSLATIONS[item]) {
2258
+ TRANSLATIONS[item] = {};
2259
+ }
2236
2260
  for (let key in data[item]) {
2237
2261
  TRANSLATIONS[item][key] = data[item][key];
2238
2262
  }
2239
2263
  });
2240
2264
  resolve(true);
2265
+ })
2266
+ .catch((err) => {
2267
+ console.error('Failed to fetch translations:', err);
2268
+ resolve(false);
2241
2269
  });
2242
2270
  });
2243
2271
  };
@@ -44442,9 +44470,10 @@ function renderAbstractNodeToSVGElement(node, options) {
44442
44470
 
44443
44471
  const MAX_NOTIFICATION_TEXT_LENGTH = 200;
44444
44472
  const MAX_NOTIFICATION_LINES = 5;
44473
+ const BLOCK_ELEMENT_REGEX = /<br\s*\/?>|<\/p>|<\/h[1-6]>|<\/?blockquote>/gi;
44445
44474
 
44446
44475
  const truncate = (str, maxChars, maxLines) => {
44447
- var _a, _b, _c;
44476
+ var _a;
44448
44477
  if (!str || maxChars < 0)
44449
44478
  return "";
44450
44479
  const parser = new DOMParser();
@@ -44452,29 +44481,37 @@ const truncate = (str, maxChars, maxLines) => {
44452
44481
  let charCount = 0;
44453
44482
  let lineCount = 0;
44454
44483
  const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT);
44484
+ const removeAfter = (node) => {
44485
+ let current = node;
44486
+ while (current && current !== doc.body) {
44487
+ const parent = current.parentNode;
44488
+ if (!parent)
44489
+ break;
44490
+ while (current.nextSibling) {
44491
+ parent.removeChild(current.nextSibling);
44492
+ }
44493
+ current = parent;
44494
+ }
44495
+ };
44455
44496
  while (walker.nextNode()) {
44456
44497
  const node = walker.currentNode;
44457
44498
  if (node.nodeType === Node.TEXT_NODE) {
44458
44499
  const text = node.textContent || "";
44459
44500
  if (charCount + text.length > maxChars) {
44460
44501
  node.textContent = text.slice(0, maxChars - charCount) + "...";
44461
- while (node.nextSibling) {
44462
- (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(node.nextSibling);
44463
- }
44502
+ removeAfter(node);
44464
44503
  break;
44465
44504
  }
44466
44505
  charCount += text.length;
44467
44506
  }
44468
44507
  else {
44469
44508
  const tagName = node.nodeName.toLowerCase();
44470
- if (tagName === "br" || /^h[1-6]$/.test(tagName) || tagName === "p") {
44509
+ if (tagName === "br" || /^h[1-6]$/.test(tagName) || tagName === "p" || tagName === "blockquote") {
44471
44510
  lineCount++;
44472
44511
  if (lineCount >= maxLines) {
44473
44512
  const ellipsis = doc.createTextNode("...");
44474
- (_b = node.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(ellipsis, node.nextSibling);
44475
- while (node.nextSibling) {
44476
- (_c = node.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(node.nextSibling);
44477
- }
44513
+ (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(ellipsis, node);
44514
+ removeAfter(ellipsis);
44478
44515
  break;
44479
44516
  }
44480
44517
  }
@@ -44692,7 +44729,7 @@ class NutsNotification {
44692
44729
  this.messageRead = this.read;
44693
44730
  const fullyStrippedContent = DOMPurify.sanitize(this.content, { ALLOWED_TAGS: [] });
44694
44731
  if ((fullyStrippedContent === null || fullyStrippedContent === void 0 ? void 0 : fullyStrippedContent.length) > this.maxTextLength ||
44695
- (((_a = this.content) === null || _a === void 0 ? void 0 : _a.match(/<br\s*\/?>|<\/p>|<\/h[1-6]>/gi)) || []).length) {
44732
+ (((_a = this.content) === null || _a === void 0 ? void 0 : _a.match(BLOCK_ELEMENT_REGEX)) || []).length) {
44696
44733
  this.displayedContent = truncate(this.content, this.maxTextLength, this.maxLines);
44697
44734
  }
44698
44735
  else {
@@ -44736,11 +44773,11 @@ class NutsNotification {
44736
44773
  'img'
44737
44774
  ]
44738
44775
  });
44739
- return (hAsync("div", { key: 'ac04933f45fbcc0c100615388fe010528c422f6f', class: "Wrapper", onClick: this.markNotificationAsRead }, hAsync("div", { key: 'c85d1cdefb959c390c8db554864f2756809a5341', class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: this.assignRefToStylingContainer, onClick: this.notificationActionHandler }, this.badge ? (hAsync("div", { class: "AvatarContainer" }, hAsync("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ? (hAsync("div", { innerHTML: systemIcons[this.badge].icon })) : (hAsync("img", { class: "AvatarImage", src: this.badge }))))) : (''), hAsync("div", { key: 'f58174fbeb1041f6f94e2032f01802702ecea9af', class: "ContentContainer" }, hAsync("div", { key: '0b35a305a4d7385e324f27463bd9f3f00ccd1ea9', innerHTML: sanitizedNotificationBody, class: "NotificationBody" }), hAsync("p", { key: '11baf24cfea3d48cf3366c97eaed8f7921abd2f3', class: "Date" }, formatDistanceToNow(new Date(this.date), {
44776
+ return (hAsync("div", { key: 'a6e5c8ad297e9c99dc4955ec7aad14b201abf523', class: "Wrapper", onClick: this.markNotificationAsRead }, hAsync("div", { key: '1e92d30f79d7eda3ee3d2592299bc4969cf41ede', class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: this.assignRefToStylingContainer, onClick: this.notificationActionHandler }, this.badge ? (hAsync("div", { class: "AvatarContainer" }, hAsync("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ? (hAsync("div", { innerHTML: systemIcons[this.badge].icon })) : (hAsync("img", { class: "AvatarImage", src: this.badge }))))) : (''), hAsync("div", { key: 'c6df1cc1801ac038933ebc8986c66f2cf81c3833', class: "ContentContainer" }, hAsync("div", { key: 'f15effff484f5f8679e31d05a794ac9ffd6462a8', innerHTML: sanitizedNotificationBody, class: "NotificationBody" }), hAsync("p", { key: '24966927ff1e452a00482dfb9d9527a1d1d85742', class: "Date" }, formatDistanceToNow(new Date(this.date), {
44740
44777
  addSuffix: true,
44741
44778
  locale: dateFnsLocale(this.language)
44742
- }))), hAsync("div", { key: '87670fb6228e11ff3097fdaee66d005d0fb06a6a', class: "RightActionsContainer" }, hAsync("div", { key: 'f858a84bb3dea7486397c80af4aa3e8e0fc7f395', class: "Settings", onClick: this.toggleSettingsModal }, hAsync("svg", { key: '3312814097d3d29d8f299e218b172b130bf2e93a', width: "24", height: "24", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { key: 'e58f7b83f66e95d6866354578a07fefe5a938da3', d: "M20.625 15.5C20.625 16.5547 21.4453 17.375 22.5 17.375C23.5156 17.375 24.375 16.5547 24.375 15.5C24.375 14.4844 23.5156 13.625 22.5 13.625C21.4453 13.625 20.625 14.4844 20.625 15.5ZM9.375 15.5C9.375 14.4844 8.51562 13.625 7.5 13.625C6.44531 13.625 5.625 14.4844 5.625 15.5C5.625 16.5547 6.44531 17.375 7.5 17.375C8.51562 17.375 9.375 16.5547 9.375 15.5ZM16.875 15.5C16.875 14.4844 16.0156 13.625 15 13.625C13.9453 13.625 13.125 14.4844 13.125 15.5C13.125 16.5547 13.9453 17.375 15 17.375C16.0156 17.375 16.875 16.5547 16.875 15.5Z", fill: "currentColor" }))), (((_b = DOMPurify.sanitize(this.content, { ALLOWED_TAGS: [] })) === null || _b === void 0 ? void 0 : _b.length) > this.maxTextLength ||
44743
- (((_c = this.content) === null || _c === void 0 ? void 0 : _c.match(/<br\s*\/?>|<\/p>|<\/h[1-6]>/gi)) || []).length > this.maxLines) && (hAsync("div", { key: '33109a51a711b637f50593731721c98a08ca0157', class: "AccordionArrow", innerHTML: systemIcons.arrowDown.icon, ref: this.assignRefToDropdownArrow, onClick: this.accordionArrowClickHandler })))), this.showSettingsModal ? (hAsync("div", { class: "SettingsDropdown" }, hAsync("button", { onClick: this.toggleNotificationRead }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M14.9434 5.17969C14.2109 4.59375 13.625 4.125 10.1387 1.60547C9.64062 1.25391 8.67383 0.375 8 0.375V0.404297C7.9707 0.404297 7.9707 0.375 7.9707 0.375C7.29688 0.375 6.33008 1.25391 5.83203 1.60547C2.3457 4.125 1.75977 4.59375 1.02734 5.17969C0.675781 5.44336 0.5 5.85352 0.5 6.26367V13.9688C0.5 14.7598 1.11523 15.375 1.90625 15.375H14.0938C14.8555 15.375 15.5 14.7598 15.5 13.9688V6.26367C15.5 5.85352 15.2949 5.44336 14.9434 5.17969ZM9.37695 11.1562C8.9668 11.4785 8.46875 11.6543 8 11.6543C7.50195 11.6543 7.00391 11.4785 6.59375 11.1562L2.375 7.8457V6.49805C2.99023 6 3.72266 5.44336 6.94531 3.12891C7.0332 3.04102 7.15039 2.95312 7.26758 2.86523C7.41406 2.74805 7.73633 2.48438 8 2.33789C8.23438 2.48438 8.55664 2.74805 8.70312 2.86523C8.82031 2.95312 8.9375 3.04102 9.02539 3.12891C12.2188 5.44336 12.9805 6 13.625 6.49805V7.8457L9.37695 11.1562Z", fill: "currentColor" })), translate$1(this.messageRead ? 'markAsUnread' : 'markAsRead', this.language)), hAsync("button", { onClick: this.deleteNotification }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M4.375 15.4375C4.375 16.1758 4.94922 16.75 5.6875 16.75H13.5625C14.2734 16.75 14.875 16.1758 14.875 15.4375V6.25H4.375V15.4375ZM11.8125 8.4375C11.8125 8.21875 12.0039 8 12.25 8C12.4688 8 12.6875 8.21875 12.6875 8.4375V14.5625C12.6875 14.8086 12.4688 15 12.25 15C12.0039 15 11.8125 14.8086 11.8125 14.5625V8.4375ZM9.1875 8.4375C9.1875 8.21875 9.37891 8 9.625 8C9.84375 8 10.0625 8.21875 10.0625 8.4375V14.5625C10.0625 14.8086 9.84375 15 9.625 15C9.37891 15 9.1875 14.8086 9.1875 14.5625V8.4375ZM6.5625 8.4375C6.5625 8.21875 6.75391 8 7 8C7.21875 8 7.4375 8.21875 7.4375 8.4375V14.5625C7.4375 14.8086 7.21875 15 7 15C6.75391 15 6.5625 14.8086 6.5625 14.5625V8.4375ZM15.3125 3.625H12.25L11.9219 2.99609C11.8398 2.85938 11.7031 2.75 11.5391 2.75H7.68359C7.51953 2.75 7.38281 2.85938 7.30078 2.99609L7 3.625H3.9375C3.69141 3.625 3.5 3.84375 3.5 4.0625V4.9375C3.5 5.18359 3.69141 5.375 3.9375 5.375H15.3125C15.5312 5.375 15.75 5.18359 15.75 4.9375V4.0625C15.75 3.84375 15.5312 3.625 15.3125 3.625Z", fill: "currentColor" })), translate$1('removeMessage', this.language)))) : ('')));
44779
+ }))), hAsync("div", { key: '71556828f255616171d3003b9a1b71f8c085d3f4', class: "RightActionsContainer" }, hAsync("div", { key: 'e15d3cd943e119c5d9f221083cb1a7fe20b6995a', class: "Settings", onClick: this.toggleSettingsModal }, hAsync("svg", { key: '1af781321dc8f23582f33ed55061012242236cc0', width: "24", height: "24", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { key: 'e79e7ef95efef24b70a2ba6389e57f385ea6a266', d: "M20.625 15.5C20.625 16.5547 21.4453 17.375 22.5 17.375C23.5156 17.375 24.375 16.5547 24.375 15.5C24.375 14.4844 23.5156 13.625 22.5 13.625C21.4453 13.625 20.625 14.4844 20.625 15.5ZM9.375 15.5C9.375 14.4844 8.51562 13.625 7.5 13.625C6.44531 13.625 5.625 14.4844 5.625 15.5C5.625 16.5547 6.44531 17.375 7.5 17.375C8.51562 17.375 9.375 16.5547 9.375 15.5ZM16.875 15.5C16.875 14.4844 16.0156 13.625 15 13.625C13.9453 13.625 13.125 14.4844 13.125 15.5C13.125 16.5547 13.9453 17.375 15 17.375C16.0156 17.375 16.875 16.5547 16.875 15.5Z", fill: "currentColor" }))), (((_b = DOMPurify.sanitize(this.content, { ALLOWED_TAGS: [] })) === null || _b === void 0 ? void 0 : _b.length) > this.maxTextLength ||
44780
+ (((_c = this.content) === null || _c === void 0 ? void 0 : _c.match(BLOCK_ELEMENT_REGEX)) || []).length > this.maxLines) && (hAsync("div", { key: '56cdc3008e063cd38f1aeea1ce5aee111d97862b', class: "AccordionArrow", innerHTML: systemIcons.arrowDown.icon, ref: this.assignRefToDropdownArrow, onClick: this.accordionArrowClickHandler })))), this.showSettingsModal ? (hAsync("div", { class: "SettingsDropdown" }, hAsync("button", { onClick: this.toggleNotificationRead }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M14.9434 5.17969C14.2109 4.59375 13.625 4.125 10.1387 1.60547C9.64062 1.25391 8.67383 0.375 8 0.375V0.404297C7.9707 0.404297 7.9707 0.375 7.9707 0.375C7.29688 0.375 6.33008 1.25391 5.83203 1.60547C2.3457 4.125 1.75977 4.59375 1.02734 5.17969C0.675781 5.44336 0.5 5.85352 0.5 6.26367V13.9688C0.5 14.7598 1.11523 15.375 1.90625 15.375H14.0938C14.8555 15.375 15.5 14.7598 15.5 13.9688V6.26367C15.5 5.85352 15.2949 5.44336 14.9434 5.17969ZM9.37695 11.1562C8.9668 11.4785 8.46875 11.6543 8 11.6543C7.50195 11.6543 7.00391 11.4785 6.59375 11.1562L2.375 7.8457V6.49805C2.99023 6 3.72266 5.44336 6.94531 3.12891C7.0332 3.04102 7.15039 2.95312 7.26758 2.86523C7.41406 2.74805 7.73633 2.48438 8 2.33789C8.23438 2.48438 8.55664 2.74805 8.70312 2.86523C8.82031 2.95312 8.9375 3.04102 9.02539 3.12891C12.2188 5.44336 12.9805 6 13.625 6.49805V7.8457L9.37695 11.1562Z", fill: "currentColor" })), translate$1(this.messageRead ? 'markAsUnread' : 'markAsRead', this.language)), hAsync("button", { onClick: this.deleteNotification }, hAsync("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, hAsync("path", { d: "M4.375 15.4375C4.375 16.1758 4.94922 16.75 5.6875 16.75H13.5625C14.2734 16.75 14.875 16.1758 14.875 15.4375V6.25H4.375V15.4375ZM11.8125 8.4375C11.8125 8.21875 12.0039 8 12.25 8C12.4688 8 12.6875 8.21875 12.6875 8.4375V14.5625C12.6875 14.8086 12.4688 15 12.25 15C12.0039 15 11.8125 14.8086 11.8125 14.5625V8.4375ZM9.1875 8.4375C9.1875 8.21875 9.37891 8 9.625 8C9.84375 8 10.0625 8.21875 10.0625 8.4375V14.5625C10.0625 14.8086 9.84375 15 9.625 15C9.37891 15 9.1875 14.8086 9.1875 14.5625V8.4375ZM6.5625 8.4375C6.5625 8.21875 6.75391 8 7 8C7.21875 8 7.4375 8.21875 7.4375 8.4375V14.5625C7.4375 14.8086 7.21875 15 7 15C6.75391 15 6.5625 14.8086 6.5625 14.5625V8.4375ZM15.3125 3.625H12.25L11.9219 2.99609C11.8398 2.85938 11.7031 2.75 11.5391 2.75H7.68359C7.51953 2.75 7.38281 2.85938 7.30078 2.99609L7 3.625H3.9375C3.69141 3.625 3.5 3.84375 3.5 4.0625V4.9375C3.5 5.18359 3.69141 5.375 3.9375 5.375H15.3125C15.5312 5.375 15.75 5.18359 15.75 4.9375V4.0625C15.75 3.84375 15.5312 3.625 15.3125 3.625Z", fill: "currentColor" })), translate$1('removeMessage', this.language)))) : ('')));
44744
44781
  }
44745
44782
  get el() { return getElement(this); }
44746
44783
  static get watchers() { return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/nuts-inbox-widget",
3
- "version": "1.90.37",
3
+ "version": "1.91.1",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",