@everymatrix/nuts-inbox-widget 0.0.9 → 1.44.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 (35) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/nuts-inbox-widget.cjs.js +1 -1
  3. package/dist/cjs/nuts-inbox-widget_3.cjs.entry.js +476 -449
  4. package/dist/collection/api/methods/index.js +135 -0
  5. package/dist/collection/api/methods/types.js +1 -0
  6. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.css +5 -0
  7. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.js +100 -123
  8. package/dist/collection/components/nuts-notification/constants.js +1 -0
  9. package/dist/collection/components/nuts-notification/nuts-notification.css +26 -11
  10. package/dist/collection/components/nuts-notification/nuts-notification.js +158 -100
  11. package/dist/collection/components/nuts-popover/nuts-popover.css +43 -0
  12. package/dist/collection/components/nuts-popover/nuts-popover.js +122 -61
  13. package/dist/collection/types/nuts-inbox-widget.types.js +0 -8
  14. package/dist/collection/utils/locale.utils.js +12 -4
  15. package/dist/collection/utils/utils.js +16 -0
  16. package/dist/components/nuts-inbox-widget.js +55 -235
  17. package/dist/components/nuts-notification2.js +278 -84
  18. package/dist/components/nuts-popover2.js +61 -45
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/nuts-inbox-widget.js +1 -1
  21. package/dist/esm/nuts-inbox-widget_3.entry.js +477 -450
  22. package/dist/nuts-inbox-widget/nuts-inbox-widget.esm.js +1 -1
  23. package/dist/nuts-inbox-widget/p-d0db9d2d.entry.js +1 -0
  24. package/dist/types/api/methods/index.d.ts +7 -0
  25. package/dist/types/api/methods/types.d.ts +65 -0
  26. package/dist/types/components/nuts-inbox-widget/nuts-inbox-widget.d.ts +20 -11
  27. package/dist/types/components/nuts-notification/constants.d.ts +1 -0
  28. package/dist/types/components/nuts-notification/nuts-notification.d.ts +18 -6
  29. package/dist/types/components/nuts-popover/nuts-popover.d.ts +17 -2
  30. package/dist/types/components.d.ts +50 -2
  31. package/dist/types/types/nuts-inbox-widget.types.d.ts +4 -7
  32. package/dist/types/utils/utils.d.ts +2 -0
  33. package/package.json +4 -1
  34. package/dist/nuts-inbox-widget/p-4788b3e5.entry.js +0 -1
  35. /package/dist/types/Users/{raul.vasile/workspace/everymatrix → adrian.pripon/Documents/Work}/widgets-stencil/packages/nuts-inbox-widget/.stencil/packages/nuts-inbox-widget/stencil.config.d.ts +0 -0
@@ -8,19 +8,27 @@ const TRANSLATIONS = {
8
8
  noMessages: 'Nothing new to see here yet',
9
9
  markAllAsRead: 'Mark all as read',
10
10
  markAsRead: 'Mark as read',
11
- removeMessage: 'Remove the message'
11
+ markAsUnread: 'Mark as unread',
12
+ removeMessage: 'Remove the message',
13
+ next: 'Next',
14
+ prev: 'Previous',
12
15
  },
13
16
  hu: {
14
17
  notifications: 'értesítéseket',
15
18
  noMessages: 'Itt még semmi újat nem látni',
16
19
  markAllAsRead: 'összes megjelölése olvasottként',
17
20
  markAsRead: 'Jelöld olvasottként',
18
- removeMessage: 'Távolítsa el az üzenetet'
19
- }
21
+ markAsUnread: 'Megjelölés olvasatlanként',
22
+ removeMessage: 'Távolítsa el az üzenetet',
23
+ next: 'Következő',
24
+ prev: 'Előző',
25
+ },
20
26
  };
21
27
  const translate$1 = (key, customLang, values) => {
22
28
  const lang = customLang;
23
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
29
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang)
30
+ ? lang
31
+ : DEFAULT_LANGUAGE][key];
24
32
  if (values !== undefined) {
25
33
  for (const [key, value] of Object.entries(values.values)) {
26
34
  const regex = new RegExp(`{${key}}`, 'g');
@@ -45,6 +53,159 @@ const getTranslations = (url) => {
45
53
  });
46
54
  };
47
55
 
56
+ const initializeSession = async ({ baseUrl, body, headers, }) => {
57
+ var _a;
58
+ const url = new URL(`${baseUrl}/widgets/session/initialize`);
59
+ const localHeaders = new Headers(headers);
60
+ localHeaders.append('Content-Type', 'application/json');
61
+ const options = {
62
+ method: 'POST',
63
+ body: JSON.stringify(body),
64
+ headers: localHeaders,
65
+ };
66
+ try {
67
+ const res = await fetch(url.href, options);
68
+ const data = await res.json();
69
+ const newToken = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.token;
70
+ headers.append('Widget-Authorization', `Bearer ${newToken}`);
71
+ const unseenCounter = await getUnseenCount({
72
+ baseUrl,
73
+ headers,
74
+ });
75
+ return {
76
+ token: newToken,
77
+ unseenCounter,
78
+ };
79
+ }
80
+ catch (error) {
81
+ console.log(error);
82
+ return {
83
+ token: null,
84
+ unseenCounter: 0,
85
+ };
86
+ }
87
+ };
88
+ const getUnseenCount = async ({ baseUrl, headers, }) => {
89
+ var _a;
90
+ const url = new URL(`${baseUrl}/widgets/notifications/unseen?limit=100`);
91
+ const options = {
92
+ method: 'GET',
93
+ headers,
94
+ };
95
+ try {
96
+ const res = await fetch(url.href, options);
97
+ const data = await res.json();
98
+ const unseenCount = ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.count) || 0;
99
+ return unseenCount;
100
+ }
101
+ catch (error) {
102
+ console.log(error);
103
+ return 0;
104
+ }
105
+ };
106
+ const deleteMessage = async ({ baseUrl, headers, messageId, }) => {
107
+ const url = new URL(`${baseUrl}/widgets/messages/${messageId}`);
108
+ const options = {
109
+ method: 'DELETE',
110
+ headers,
111
+ };
112
+ try {
113
+ await fetch(url.href, options);
114
+ return false;
115
+ }
116
+ catch (error) {
117
+ console.log(error);
118
+ return true;
119
+ }
120
+ };
121
+ const markAsRead = async ({ baseUrl, body, headers, unread, }) => {
122
+ const url = new URL(`${baseUrl}/widgets/messages/markAs`);
123
+ const localHeaders = new Headers(headers);
124
+ localHeaders.append('Content-Type', 'application/json');
125
+ const options = {
126
+ method: 'POST',
127
+ headers: localHeaders,
128
+ body: JSON.stringify(body),
129
+ };
130
+ try {
131
+ const res = await fetch(url.href, options);
132
+ const data = await res.json();
133
+ return {
134
+ messageSeen: data.data[0].seen,
135
+ messageRead: data.data[0].read,
136
+ showSettingsModal: false,
137
+ };
138
+ }
139
+ catch (err) {
140
+ console.error('err', err);
141
+ return {
142
+ messageSeen: unread,
143
+ messageRead: unread,
144
+ showSettingsModal: true,
145
+ };
146
+ }
147
+ };
148
+ const getNotifications = async ({ baseUrl, headers, page, }) => {
149
+ const url = new URL(`${baseUrl}/widgets/notifications/feed`);
150
+ url.searchParams.append('page', page.toString());
151
+ const options = {
152
+ method: 'GET',
153
+ headers,
154
+ };
155
+ try {
156
+ const res = await fetch(url.href, options);
157
+ const data = await res.json();
158
+ return {
159
+ isLoading: false,
160
+ numberOfNotifications: data.totalCount,
161
+ notifications: data.data,
162
+ };
163
+ }
164
+ catch (error) {
165
+ console.log(error);
166
+ return {
167
+ isLoading: false,
168
+ numberOfNotifications: 0,
169
+ notifications: [],
170
+ };
171
+ }
172
+ };
173
+ const markAllAsRead = async ({ baseUrl, headers, }) => {
174
+ const url = new URL(`${baseUrl}/widgets/messages/read`);
175
+ const localHeaders = new Headers(headers);
176
+ localHeaders.append('Content-Type', 'application/json');
177
+ const options = {
178
+ method: 'POST',
179
+ body: JSON.stringify({}),
180
+ headers: localHeaders,
181
+ };
182
+ try {
183
+ await fetch(url.href, options);
184
+ return true;
185
+ }
186
+ catch (error) {
187
+ console.log(error);
188
+ return false;
189
+ }
190
+ };
191
+
192
+ const createAuthHeaders = (token, sessionId, admin) => {
193
+ const headers = new Headers();
194
+ if (token) {
195
+ headers.append('Widget-Authorization', `Bearer ${token}`);
196
+ }
197
+ if (admin) {
198
+ headers.append('Authorization', sessionId);
199
+ }
200
+ return headers;
201
+ };
202
+ const truncate = (str, n) => {
203
+ if (!str || n < 0) {
204
+ return;
205
+ }
206
+ return str.length > n ? str.slice(0, n - 1) + '...' : str;
207
+ };
208
+
48
209
  function _typeof(o) {
49
210
  "@babel/helpers - typeof";
50
211
 
@@ -35671,6 +35832,9 @@ var CheckCircleFilled = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 8
35671
35832
  // This icon file is generated automatically.
35672
35833
  var CloseCircleFilled = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z" } }] }, "name": "close-circle", "theme": "filled" };
35673
35834
 
35835
+ // This icon file is generated automatically.
35836
+ var DownOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" } }] }, "name": "down", "theme": "outlined" };
35837
+
35674
35838
  // This icon file is generated automatically.
35675
35839
  var InfoCircleFilled = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" } }] }, "name": "info-circle", "theme": "filled" };
35676
35840
 
@@ -35728,26 +35892,45 @@ function renderAbstractNodeToSVGElement(node, options) {
35728
35892
  return "<".concat(node.tag).concat(attrsToken, " />");
35729
35893
  }
35730
35894
 
35731
- const nutsNotificationCss = ":host{display:block}p{display:block;margin-block-start:0em;margin-block-end:0em;margin-inline-start:0px;margin-inline-end:0px}.NotificationContainer{animation:show 600ms 100ms cubic-bezier(0.38, 0.97, 0.56, 0.76) forwards;opacity:0;transform-origin:top center;padding:15px;position:relative;display:flex;line-height:20px;justify-content:flex-start;align-items:center;border-radius:7px;margin:10px 15px;color:var(--emfe-w-color-white, white);background:var(--emfe-w-color-gray-400, #23232b);font-weight:400;font-size:14px}@keyframes show{100%{opacity:1;transform:none}}.NotificationContainer .AvatarContainer{margin-right:10px;width:40px;min-width:40px;height:40px;border-radius:50%;display:flex;justify-content:center;align-items:center;font-size:40px;border:1px solid var(--emfe-w-color-gray-200, #525266);overflow:hidden}.NotificationContainer .AvatarContainer .Avatar{box-sizing:border-box;position:relative;display:flex;user-select:none;overflow:hidden;width:38px;min-width:38px;height:38px;border-radius:32px;text-decoration:none;border:0px;background-color:transparent;padding:0px;justify-content:center;align-items:center}.NotificationContainer .AvatarContainer .Avatar .AvatarImage{object-fit:cover;width:100%;height:100%;display:block}.NotificationContainer .AvatarContainer .Avatar svg{object-fit:cover;display:block}.NotificationContainer .ContentContainer{display:flex;flex-direction:column}.NotificationContainer .Date{min-width:55px;font-size:12px;font-weight:400;opacity:0.5;line-height:14.4px;color:var(--emfe-w-color-gray-200, #525266)}.NotificationContainer .Settings{opacity:0;margin-left:auto;cursor:pointer}.NotificationContainer:hover .Settings{opacity:0.5}.Unseen::before{content:\"\";position:absolute;inset:0px;width:5px;border-radius:7px 0px 0px 7px;background:linear-gradient(0deg, var(--emfe-w-color-secondary-20, #ff512f) 0%, var(--emfe-w-color-secondary, #dd2476) 100%)}.Unseen:hover .UnseenButton{opacity:0;width:0px}.SettingsDropdown{z-index:999;position:absolute;background:var(--emfe-w-color-gray-400, #292933);box-shadow:var(--emfe-w-color-gray-20, rgba(0, 0, 0, 0.2)) 0px 5px 20px;border-radius:7px;padding:4px;border:none;transition-property:opacity;transition-duration:150ms;transition-timing-function:ease;opacity:1;width:max-content;display:flex;flex-direction:column;margin-left:195px;margin-top:-30px}.SettingsDropdown svg{margin-right:10px}.SettingsDropdown button{font-family:inherit;border:0px;background-color:transparent;outline:0px;width:100%;text-align:left;text-decoration:none;box-sizing:border-box;padding:10px 12px;cursor:pointer;border-radius:7px;display:flex;align-items:center;color:var(--emfe-w-color-white, white);font-weight:400;font-size:14px}.SettingsDropdown button:hover{background:var(--emfe-w-color-gray-300, #3d3d4d);transition:300ms}";
35895
+ const MAX_NOTIFICATION_TEXT_LENGTH = 150;
35896
+
35897
+ const nutsNotificationCss = ":host{display:block}p{display:block;margin-block-start:0em;margin-block-end:0em;margin-inline-start:0px;margin-inline-end:0px}.NotificationContainer{animation:show 600ms 100ms cubic-bezier(0.38, 0.97, 0.56, 0.76) forwards;opacity:0;transform-origin:top center;padding:15px;position:relative;display:flex;line-height:20px;justify-content:space-between;align-items:flex-start;border-radius:7px;margin:10px 15px;color:var(--emfe-w-color-white, white);background:var(--emfe-w-color-gray-400, #23232b);font-weight:400;font-size:14px;gap:8px;cursor:pointer}@keyframes show{100%{opacity:1;transform:none}}.NotificationContainer .AvatarContainer{margin-right:10px;width:40px;min-width:40px;height:40px;border-radius:50%;display:flex;justify-content:center;align-items:center;font-size:40px;border:1px solid var(--emfe-w-color-gray-200, #525266);overflow:hidden}.NotificationContainer .AvatarContainer .Avatar{box-sizing:border-box;position:relative;display:flex;user-select:none;overflow:hidden;width:38px;min-width:38px;height:38px;border-radius:32px;text-decoration:none;border:0px;background-color:transparent;padding:0px;justify-content:center;align-items:center}.NotificationContainer .AvatarContainer .Avatar .AvatarImage{object-fit:cover;width:100%;height:100%;display:block}.NotificationContainer .AvatarContainer .Avatar svg{object-fit:cover;display:block}.NotificationContainer .ContentContainer{display:flex;flex-direction:column;word-break:break-all}.NotificationContainer .RightActionsContainer{display:flex;flex-direction:column}.NotificationContainer .FlipX{transform:rotateX(180deg) translate(0, 4px)}.NotificationContainer .AccordionArrow{margin-left:4px;transition-duration:0.2s;transition-property:transform}.NotificationContainer .Date{min-width:55px;font-size:12px;font-weight:400;opacity:0.5;line-height:14.4px;color:var(--emfe-w-color-gray-200, #525266)}.NotificationContainer .Settings{opacity:0.5;display:inline;cursor:pointer}.Unseen::before{content:\"\";position:absolute;inset:0px;width:5px;border-radius:7px 0px 0px 7px;background:linear-gradient(0deg, var(--emfe-w-color-secondary-20, #ff512f) 0%, var(--emfe-w-color-secondary, #dd2476) 100%)}.Unseen:hover .UnseenButton{display:none}.SettingsDropdown{z-index:999;position:absolute;background:var(--emfe-w-color-gray-400, #292933);box-shadow:var(--emfe-w-color-gray-20, rgba(0, 0, 0, 0.2)) 0px 5px 20px;border-radius:7px;padding:4px;border:none;transition-property:opacity;transition-duration:150ms;transition-timing-function:ease;opacity:1;width:max-content;display:flex;flex-direction:column;right:50px;top:50px}.SettingsDropdown svg{margin-right:10px}.SettingsDropdown button{font-family:inherit;border:0px;background-color:transparent;outline:0px;width:100%;text-align:left;text-decoration:none;box-sizing:border-box;padding:10px 12px;cursor:pointer;border-radius:7px;display:flex;align-items:center;color:var(--emfe-w-color-white, white);font-weight:400;font-size:14px}.SettingsDropdown button:hover{background:var(--emfe-w-color-gray-300, #3d3d4d);transition:300ms}.Wrapper{position:relative}";
35732
35898
 
35733
35899
  const systemIcons = {
35734
35900
  warning: {
35735
- icon: renderIconDefinitionToSVGElement(WarningFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#FFF000' } }),
35901
+ icon: renderIconDefinitionToSVGElement(WarningFilled, {
35902
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#FFF000' },
35903
+ }),
35736
35904
  },
35737
35905
  info: {
35738
- icon: renderIconDefinitionToSVGElement(InfoCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#0000FF' } }),
35906
+ icon: renderIconDefinitionToSVGElement(InfoCircleFilled, {
35907
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#0000FF' },
35908
+ }),
35739
35909
  },
35740
35910
  up: {
35741
- icon: renderIconDefinitionToSVGElement(UpCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' } }),
35911
+ icon: renderIconDefinitionToSVGElement(UpCircleFilled, {
35912
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' },
35913
+ }),
35742
35914
  },
35743
35915
  question: {
35744
- icon: renderIconDefinitionToSVGElement(QuestionCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' } }),
35916
+ icon: renderIconDefinitionToSVGElement(QuestionCircleFilled, {
35917
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' },
35918
+ }),
35745
35919
  },
35746
35920
  success: {
35747
- icon: renderIconDefinitionToSVGElement(CheckCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#4D9980' } }),
35921
+ icon: renderIconDefinitionToSVGElement(CheckCircleFilled, {
35922
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#4D9980' },
35923
+ }),
35748
35924
  },
35749
35925
  error: {
35750
- icon: renderIconDefinitionToSVGElement(CloseCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#E54545' } }),
35926
+ icon: renderIconDefinitionToSVGElement(CloseCircleFilled, {
35927
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#E54545' },
35928
+ }),
35929
+ },
35930
+ arrowDown: {
35931
+ icon: renderIconDefinitionToSVGElement(DownOutlined, {
35932
+ extraSVGAttrs: { width: '16px', height: '16px', fill: '#A1A1B2' },
35933
+ }),
35751
35934
  },
35752
35935
  };
35753
35936
  const dateFnsLocale = (lang) => {
@@ -35770,6 +35953,68 @@ const NutsNotification = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
35770
35953
  this.showSettingsModal = false;
35771
35954
  this.messageSeen = false;
35772
35955
  this.messageRead = false;
35956
+ this.toggleSettingsModal = (e) => {
35957
+ e.stopImmediatePropagation();
35958
+ this.showSettingsModal = !this.showSettingsModal;
35959
+ this.settingsOpened.emit(this.messageId);
35960
+ };
35961
+ this.toggleNotificationRead = async (event) => {
35962
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
35963
+ const unread = this.messageRead;
35964
+ const markAsReadBody = {
35965
+ messageId: `${this.messageId}`,
35966
+ mark: {
35967
+ seen: !unread,
35968
+ read: !unread,
35969
+ },
35970
+ };
35971
+ const notificationData = await markAsRead({
35972
+ baseUrl: this.baseUrl,
35973
+ body: markAsReadBody,
35974
+ headers: this.defaultHeaders,
35975
+ unread,
35976
+ });
35977
+ this.messageRead = notificationData.messageRead;
35978
+ this.messageSeen = notificationData.messageSeen;
35979
+ this.showSettingsModal = notificationData.showSettingsModal;
35980
+ };
35981
+ this.deleteNotification = async () => {
35982
+ const deleteMessageResponse = await deleteMessage({
35983
+ baseUrl: this.baseUrl,
35984
+ headers: this.defaultHeaders,
35985
+ messageId: this.messageId,
35986
+ });
35987
+ this.showSettingsModal = deleteMessageResponse;
35988
+ if (deleteMessageResponse) {
35989
+ return;
35990
+ }
35991
+ this.messageDeteled.emit(this.messageId);
35992
+ };
35993
+ this.notificationActionHandler = () => {
35994
+ var _a, _b, _c;
35995
+ if (this.notificationAction == 'default' || !this.notificationAction) {
35996
+ if (this.redirectUrl.length > 0) {
35997
+ window.location.href = this.redirectUrl;
35998
+ }
35999
+ }
36000
+ if (this.notificationAction == 'postMessage') {
36001
+ window.postMessage({ type: 'NotificationRedirect', url: this.redirectUrl }, window.location.href);
36002
+ }
36003
+ if (!this.messageRead) {
36004
+ this.toggleNotificationRead();
36005
+ }
36006
+ if (((_a = this.content) === null || _a === void 0 ? void 0 : _a.length) <= MAX_NOTIFICATION_TEXT_LENGTH) {
36007
+ return;
36008
+ }
36009
+ if (((_b = this.displayedContent) === null || _b === void 0 ? void 0 : _b.length) !== ((_c = this.content) === null || _c === void 0 ? void 0 : _c.length) &&
36010
+ this.displayedContent !== this.content) {
36011
+ this.displayedContent = this.content;
36012
+ this.dropdownArrowRef.classList.add('FlipX');
36013
+ return;
36014
+ }
36015
+ this.displayedContent = truncate(this.content, MAX_NOTIFICATION_TEXT_LENGTH);
36016
+ this.dropdownArrowRef.classList.remove('FlipX');
36017
+ };
35773
36018
  this.setClientStyling = () => {
35774
36019
  let sheet = document.createElement('style');
35775
36020
  sheet.innerHTML = this.clientStyling;
@@ -35782,12 +36027,20 @@ const NutsNotification = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
35782
36027
  .then((res) => res.text())
35783
36028
  .then((data) => {
35784
36029
  cssFile.innerHTML = data;
35785
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
36030
+ setTimeout(() => {
36031
+ this.stylingContainer.prepend(cssFile);
36032
+ }, 1);
35786
36033
  })
35787
36034
  .catch((err) => {
35788
36035
  console.log('error ', err);
35789
36036
  });
35790
36037
  };
36038
+ this.assignRefToStylingContainer = (ref) => {
36039
+ this.stylingContainer = ref;
36040
+ };
36041
+ this.assignRefToDropdownArrow = (ref) => {
36042
+ this.dropdownArrowRef = ref;
36043
+ };
35791
36044
  }
35792
36045
  allNotificationsReadHandler() {
35793
36046
  this.messageSeen = true;
@@ -35809,78 +36062,16 @@ const NutsNotification = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
35809
36062
  connectedCallback() {
35810
36063
  this.messageSeen = this.seen;
35811
36064
  this.messageRead = this.read;
35812
- }
35813
- deleteMessage(messageId) {
35814
- let url = new URL(`${this.backendUrl}/v1/widgets/messages/${messageId}`);
35815
- const headers = new Headers();
35816
- headers.append('Authorization', `Bearer ${this.token || ''}`);
35817
- const options = {
35818
- method: 'DELETE',
35819
- headers,
35820
- };
35821
- fetch(url.href, options)
35822
- .then((res) => res.json())
35823
- .then(() => {
35824
- this.showSettingsModal = false;
35825
- this.messageDeteled.emit(messageId);
35826
- })
35827
- .catch((err) => {
35828
- console.error('err', err);
35829
- });
35830
- }
35831
- markAsRead(messageId) {
35832
- let url = new URL(`${this.backendUrl}/v1/widgets/messages/markAs`);
35833
- const headers = new Headers();
35834
- headers.append('Authorization', `Bearer ${this.token || ''}`);
35835
- headers.append('Content-Type', 'application/json');
35836
- const body = {
35837
- messageId: `${messageId}`,
35838
- mark: {
35839
- seen: true,
35840
- read: true
35841
- }
35842
- };
35843
- const options = {
35844
- method: 'POST',
35845
- headers,
35846
- body: JSON.stringify(body)
35847
- };
35848
- fetch(url.href, options)
35849
- .then((res) => res.json())
35850
- .then((response) => {
35851
- this.messageSeen = response.data[0].seen;
35852
- this.messageRead = response.data[0].read;
35853
- this.showSettingsModal = false;
35854
- })
35855
- .catch((err) => {
35856
- console.error('err', err);
35857
- });
35858
- }
35859
- toggleSettingsModal(e) {
35860
- e.stopImmediatePropagation();
35861
- this.showSettingsModal = !this.showSettingsModal;
35862
- if (this.showSettingsModal) {
35863
- let rect = this.settingsButtonRef.getBoundingClientRect();
35864
- this.settingsModalRef.style.left = `${rect.left}px`;
35865
- this.settingsModalRef.style.top = `${rect.top}px`;
35866
- this.settingsOpened.emit(this.messageId);
35867
- }
35868
- }
35869
- notificationActionHandler() {
35870
- if (this.notificationAction == 'default' || !this.notificationAction) {
35871
- if (this.redirectUrl.length > 0) {
35872
- window.location.href = this.redirectUrl;
35873
- }
35874
- }
35875
- if (this.notificationAction == 'postMessage') {
35876
- window.postMessage({ type: 'NotificationRedirect', url: this.redirectUrl }, window.location.href);
35877
- }
36065
+ this.displayedContent = truncate(this.content, MAX_NOTIFICATION_TEXT_LENGTH);
36066
+ this.defaultHeaders = createAuthHeaders(this.token, this.sessionId, this.admin);
36067
+ this.baseUrl = `${this.backendUrl}/v1/${this.operatorId}`;
35878
36068
  }
35879
36069
  render() {
35880
- var _a;
35881
- return (h("div", null, h("div", { class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: el => this.stylingContainer = el, onClick: () => this.notificationActionHandler() }, this.badge ? h("div", { class: "AvatarContainer" }, h("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ?
35882
- h("div", { innerHTML: systemIcons[this.badge].icon }) :
35883
- h("img", { class: "AvatarImage", src: this.badge }))) : '', h("div", { class: "ContentContainer" }, h("p", null, this.content), h("p", { class: "Date" }, formatDistanceToNow(new Date(this.date), { addSuffix: true, locale: dateFnsLocale(this.language) }))), h("div", { class: "Settings", onClick: (e) => this.toggleSettingsModal(e), ref: el => this.settingsButtonRef = el }, h("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { 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" }))), this.messageSeen ? '' : h("div", { class: "UnseenButton" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "10px", height: "10px", viewBox: "0 0 16 16", fill: "none" }, h("rect", { x: "1.5", y: "1.5", width: "13", height: "13", rx: "6.5", fill: "url(#paint0_linear_1722_2699)", stroke: "#1E1E26", "stroke-width": "3" }), h("defs", null, h("linearGradient", { id: "paint0_linear_1722_2699", x1: "8", y1: "13", x2: "8", y2: "3", gradientUnits: "userSpaceOnUse" }, h("stop", { "stop-color": "#FF512F" }), h("stop", { offset: "1", "stop-color": "#DD2476" })))))), this.showSettingsModal ? h("div", { class: "SettingsDropdown", ref: el => this.settingsModalRef = el }, h("button", { onClick: () => this.markAsRead(this.messageId) }, h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("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('markAsRead', this.language)), h("button", { onClick: () => this.deleteMessage(this.messageId) }, h("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("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))) : ''));
36070
+ var _a, _b;
36071
+ return (h("div", { class: "Wrapper" }, h("div", { class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: this.assignRefToStylingContainer, onClick: this.notificationActionHandler }, this.badge ? (h("div", { class: "AvatarContainer" }, h("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ? (h("div", { innerHTML: systemIcons[this.badge].icon })) : (h("img", { class: "AvatarImage", src: this.badge }))))) : (''), h("div", { class: "ContentContainer" }, h("p", null, this.displayedContent), h("p", { class: "Date" }, formatDistanceToNow(new Date(this.date), {
36072
+ addSuffix: true,
36073
+ locale: dateFnsLocale(this.language),
36074
+ }))), h("div", { class: "RightActionsContainer" }, h("div", { class: "Settings", onClick: this.toggleSettingsModal }, h("svg", { width: "24", height: "24", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { 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 = this.content) === null || _b === void 0 ? void 0 : _b.length) > MAX_NOTIFICATION_TEXT_LENGTH && (h("div", { class: "AccordionArrow", innerHTML: systemIcons.arrowDown.icon, ref: this.assignRefToDropdownArrow })))), this.showSettingsModal ? (h("div", { class: "SettingsDropdown" }, h("button", { onClick: this.toggleNotificationRead }, h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("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)), h("button", { onClick: this.deleteNotification }, h("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("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)))) : ('')));
35884
36075
  }
35885
36076
  static get watchers() { return {
35886
36077
  "translationUrl": ["handleNewTranslations"]
@@ -35894,6 +36085,8 @@ const NutsNotification = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
35894
36085
  "read": [516],
35895
36086
  "seen": [516],
35896
36087
  "language": [513],
36088
+ "sessionId": [513, "session-id"],
36089
+ "admin": [516],
35897
36090
  "userId": [513, "user-id"],
35898
36091
  "messageId": [513, "message-id"],
35899
36092
  "operatorId": [513, "operator-id"],
@@ -35906,7 +36099,8 @@ const NutsNotification = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
35906
36099
  "clientStyling": [1537, "client-styling"],
35907
36100
  "showSettingsModal": [32],
35908
36101
  "messageSeen": [32],
35909
- "messageRead": [32]
36102
+ "messageRead": [32],
36103
+ "displayedContent": [32]
35910
36104
  }, [[8, "allNotificationsRead", "allNotificationsReadHandler"], [8, "settingsOpened", "settingsOpenedHandler"]]]);
35911
36105
  function defineCustomElement() {
35912
36106
  if (typeof customElements === "undefined") {
@@ -35922,4 +36116,4 @@ function defineCustomElement() {
35922
36116
  } });
35923
36117
  }
35924
36118
 
35925
- export { NutsNotification as N, defineCustomElement as d, getTranslations as g, translate$1 as t };
36119
+ export { NutsNotification as N, getNotifications as a, createAuthHeaders as c, defineCustomElement as d, getTranslations as g, initializeSession as i, markAllAsRead as m, translate$1 as t };