@everymatrix/nuts-inbox-widget 0.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 (59) hide show
  1. package/dist/cjs/index-305bcf58.js +1349 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/nuts-inbox-widget.cjs.js +19 -0
  5. package/dist/cjs/nuts-inbox-widget_3.cjs.entry.js +39985 -0
  6. package/dist/collection/collection-manifest.json +14 -0
  7. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.css +15 -0
  8. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.js +450 -0
  9. package/dist/collection/components/nuts-notification/nuts-notification.css +147 -0
  10. package/dist/collection/components/nuts-notification/nuts-notification.js +426 -0
  11. package/dist/collection/components/nuts-popover/nuts-popover.css +75 -0
  12. package/dist/collection/components/nuts-popover/nuts-popover.js +265 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/types/nuts-inbox-widget.types.js +47 -0
  15. package/dist/collection/utils/utils.js +0 -0
  16. package/dist/components/index.d.ts +26 -0
  17. package/dist/components/index.js +1 -0
  18. package/dist/components/nuts-inbox-widget.d.ts +11 -0
  19. package/dist/components/nuts-inbox-widget.js +4216 -0
  20. package/dist/components/nuts-notification.d.ts +11 -0
  21. package/dist/components/nuts-notification.js +6 -0
  22. package/dist/components/nuts-notification2.js +35762 -0
  23. package/dist/components/nuts-popover.d.ts +11 -0
  24. package/dist/components/nuts-popover.js +6 -0
  25. package/dist/components/nuts-popover2.js +119 -0
  26. package/dist/esm/index-4e49d940.js +1322 -0
  27. package/dist/esm/index.js +1 -0
  28. package/dist/esm/loader.js +17 -0
  29. package/dist/esm/nuts-inbox-widget.js +17 -0
  30. package/dist/esm/nuts-inbox-widget_3.entry.js +39979 -0
  31. package/dist/esm/polyfills/core-js.js +11 -0
  32. package/dist/esm/polyfills/css-shim.js +1 -0
  33. package/dist/esm/polyfills/dom.js +79 -0
  34. package/dist/esm/polyfills/es5-html-element.js +1 -0
  35. package/dist/esm/polyfills/index.js +34 -0
  36. package/dist/esm/polyfills/system.js +6 -0
  37. package/dist/index.cjs.js +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/nuts-inbox-widget/index.esm.js +0 -0
  40. package/dist/nuts-inbox-widget/nuts-inbox-widget.esm.js +1 -0
  41. package/dist/nuts-inbox-widget/p-2f19681b.entry.js +1 -0
  42. package/dist/nuts-inbox-widget/p-d5a07a94.js +1 -0
  43. package/dist/stencil.config.js +22 -0
  44. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-stencil/packages/nuts-inbox-widget/.stencil/packages/nuts-inbox-widget/stencil.config.d.ts +2 -0
  45. package/dist/types/components/nuts-inbox-widget/nuts-inbox-widget.d.ts +70 -0
  46. package/dist/types/components/nuts-notification/nuts-notification.d.ts +38 -0
  47. package/dist/types/components/nuts-popover/nuts-popover.d.ts +29 -0
  48. package/dist/types/components.d.ts +225 -0
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  51. package/dist/types/types/nuts-inbox-widget.types.d.ts +98 -0
  52. package/dist/types/utils/utils.d.ts +0 -0
  53. package/loader/cdn.js +3 -0
  54. package/loader/index.cjs.js +3 -0
  55. package/loader/index.d.ts +12 -0
  56. package/loader/index.es2017.js +3 -0
  57. package/loader/index.js +4 -0
  58. package/loader/package.json +10 -0
  59. package/package.json +19 -0
@@ -0,0 +1,426 @@
1
+ import { Component, h, Prop, State, Event, Listen } from '@stencil/core';
2
+ import { formatDistanceToNow } from 'date-fns';
3
+ import * as dateFnsLocales from 'date-fns/locale';
4
+ const dateFnsLocale = (lang) => {
5
+ return lang in dateFnsLocales ? dateFnsLocales[lang] : dateFnsLocales.enUS;
6
+ };
7
+ export class NutsNotification {
8
+ constructor() {
9
+ /**
10
+ * Client custom styling via inline styles
11
+ */
12
+ this.clientStyling = '';
13
+ this.showSettingsModal = false;
14
+ this.messageSeen = false;
15
+ this.messageRead = false;
16
+ this.setClientStyling = () => {
17
+ let sheet = document.createElement('style');
18
+ sheet.innerHTML = this.clientStyling;
19
+ this.stylingContainer.prepend(sheet);
20
+ };
21
+ this.setClientStylingURL = () => {
22
+ let url = new URL(this.clientStylingUrl);
23
+ let cssFile = document.createElement('style');
24
+ fetch(url.href)
25
+ .then((res) => res.text())
26
+ .then((data) => {
27
+ cssFile.innerHTML = data;
28
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
29
+ })
30
+ .catch((err) => {
31
+ console.log('error ', err);
32
+ });
33
+ };
34
+ }
35
+ allNotificationsReadHandler() {
36
+ this.messageSeen = true;
37
+ this.messageRead = true;
38
+ }
39
+ settingsOpenedHandler(event) {
40
+ if (event.detail != this.messageId) {
41
+ this.showSettingsModal = false;
42
+ }
43
+ }
44
+ connectedCallback() {
45
+ this.messageSeen = this.seen;
46
+ this.messageRead = this.read;
47
+ }
48
+ deleteMessage(messageId) {
49
+ let url = new URL(`${this.backendUrl}/v1/widgets/messages/${messageId}`);
50
+ const headers = new Headers();
51
+ headers.append('Authorization', `Bearer ${this.token || ''}`);
52
+ const options = {
53
+ method: 'DELETE',
54
+ headers,
55
+ };
56
+ fetch(url.href, options)
57
+ .then((res) => res.json())
58
+ .then(() => {
59
+ this.showSettingsModal = false;
60
+ this.messageDeteled.emit(messageId);
61
+ })
62
+ .catch((err) => {
63
+ console.error('err', err);
64
+ });
65
+ }
66
+ markAsRead(messageId) {
67
+ let url = new URL(`${this.backendUrl}/v1/widgets/messages/markAs`);
68
+ const headers = new Headers();
69
+ headers.append('Authorization', `Bearer ${this.token || ''}`);
70
+ headers.append('Content-Type', 'application/json');
71
+ const body = {
72
+ messageId: `${messageId}`,
73
+ mark: {
74
+ seen: true,
75
+ read: true
76
+ }
77
+ };
78
+ const options = {
79
+ method: 'POST',
80
+ headers,
81
+ body: JSON.stringify(body)
82
+ };
83
+ fetch(url.href, options)
84
+ .then((res) => res.json())
85
+ .then((response) => {
86
+ this.messageSeen = response.data[0].seen;
87
+ this.messageRead = response.data[0].read;
88
+ this.showSettingsModal = false;
89
+ })
90
+ .catch((err) => {
91
+ console.error('err', err);
92
+ });
93
+ }
94
+ toggleSettingsModal() {
95
+ this.showSettingsModal = !this.showSettingsModal;
96
+ ;
97
+ if (this.showSettingsModal) {
98
+ this.settingsOpened.emit(this.messageId);
99
+ }
100
+ }
101
+ render() {
102
+ return (h("div", { class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: el => this.stylingContainer = el },
103
+ this.badge ? h("div", { class: "AvatarContainer" },
104
+ h("div", { class: "Avatar" },
105
+ h("img", { class: "AvatarImage", src: this.badge }))) : '',
106
+ h("div", { class: "ContentContainer" },
107
+ h("p", null, this.content),
108
+ h("p", { class: "Date" }, formatDistanceToNow(new Date(this.date), { addSuffix: true, locale: dateFnsLocale(this.language) }))),
109
+ h("div", { class: "Settings", onClick: () => this.toggleSettingsModal() },
110
+ h("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
111
+ 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" }))),
112
+ this.showSettingsModal ? h("div", { class: "SettingsDropdown" },
113
+ h("button", { onClick: () => this.markAsRead(this.messageId) },
114
+ h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
115
+ 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" })),
116
+ "Mark as read"),
117
+ h("button", { onClick: () => this.deleteMessage(this.messageId) },
118
+ h("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
119
+ 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" })),
120
+ "Remove the message")) : '',
121
+ this.messageSeen ? '' : h("div", { class: "UnseenButton" },
122
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "10px", height: "10px", viewBox: "0 0 16 16", fill: "none" },
123
+ 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" }),
124
+ h("defs", null,
125
+ h("linearGradient", { id: "paint0_linear_1722_2699", x1: "8", y1: "13", x2: "8", y2: "3", gradientUnits: "userSpaceOnUse" },
126
+ h("stop", { "stop-color": "#FF512F" }),
127
+ h("stop", { offset: "1", "stop-color": "#DD2476" })))))));
128
+ }
129
+ static get is() { return "nuts-notification"; }
130
+ static get originalStyleUrls() { return {
131
+ "$": ["nuts-notification.scss"]
132
+ }; }
133
+ static get styleUrls() { return {
134
+ "$": ["nuts-notification.css"]
135
+ }; }
136
+ static get properties() { return {
137
+ "badge": {
138
+ "type": "string",
139
+ "mutable": false,
140
+ "complexType": {
141
+ "original": "string",
142
+ "resolved": "string",
143
+ "references": {}
144
+ },
145
+ "required": false,
146
+ "optional": false,
147
+ "docs": {
148
+ "tags": [],
149
+ "text": ""
150
+ },
151
+ "attribute": "badge",
152
+ "reflect": true
153
+ },
154
+ "content": {
155
+ "type": "string",
156
+ "mutable": false,
157
+ "complexType": {
158
+ "original": "string",
159
+ "resolved": "string",
160
+ "references": {}
161
+ },
162
+ "required": false,
163
+ "optional": false,
164
+ "docs": {
165
+ "tags": [],
166
+ "text": ""
167
+ },
168
+ "attribute": "content",
169
+ "reflect": true
170
+ },
171
+ "date": {
172
+ "type": "string",
173
+ "mutable": false,
174
+ "complexType": {
175
+ "original": "string",
176
+ "resolved": "string",
177
+ "references": {}
178
+ },
179
+ "required": false,
180
+ "optional": false,
181
+ "docs": {
182
+ "tags": [],
183
+ "text": ""
184
+ },
185
+ "attribute": "date",
186
+ "reflect": true
187
+ },
188
+ "showSettings": {
189
+ "type": "boolean",
190
+ "mutable": false,
191
+ "complexType": {
192
+ "original": "boolean",
193
+ "resolved": "boolean",
194
+ "references": {}
195
+ },
196
+ "required": false,
197
+ "optional": false,
198
+ "docs": {
199
+ "tags": [],
200
+ "text": ""
201
+ },
202
+ "attribute": "show-settings",
203
+ "reflect": true
204
+ },
205
+ "read": {
206
+ "type": "boolean",
207
+ "mutable": false,
208
+ "complexType": {
209
+ "original": "boolean",
210
+ "resolved": "boolean",
211
+ "references": {}
212
+ },
213
+ "required": false,
214
+ "optional": false,
215
+ "docs": {
216
+ "tags": [],
217
+ "text": ""
218
+ },
219
+ "attribute": "read",
220
+ "reflect": true
221
+ },
222
+ "seen": {
223
+ "type": "boolean",
224
+ "mutable": false,
225
+ "complexType": {
226
+ "original": "boolean",
227
+ "resolved": "boolean",
228
+ "references": {}
229
+ },
230
+ "required": false,
231
+ "optional": false,
232
+ "docs": {
233
+ "tags": [],
234
+ "text": ""
235
+ },
236
+ "attribute": "seen",
237
+ "reflect": true
238
+ },
239
+ "language": {
240
+ "type": "string",
241
+ "mutable": false,
242
+ "complexType": {
243
+ "original": "string",
244
+ "resolved": "string",
245
+ "references": {}
246
+ },
247
+ "required": false,
248
+ "optional": false,
249
+ "docs": {
250
+ "tags": [],
251
+ "text": ""
252
+ },
253
+ "attribute": "language",
254
+ "reflect": true
255
+ },
256
+ "userId": {
257
+ "type": "string",
258
+ "mutable": false,
259
+ "complexType": {
260
+ "original": "string",
261
+ "resolved": "string",
262
+ "references": {}
263
+ },
264
+ "required": false,
265
+ "optional": false,
266
+ "docs": {
267
+ "tags": [],
268
+ "text": ""
269
+ },
270
+ "attribute": "user-id",
271
+ "reflect": true
272
+ },
273
+ "messageId": {
274
+ "type": "string",
275
+ "mutable": false,
276
+ "complexType": {
277
+ "original": "string",
278
+ "resolved": "string",
279
+ "references": {}
280
+ },
281
+ "required": false,
282
+ "optional": false,
283
+ "docs": {
284
+ "tags": [],
285
+ "text": ""
286
+ },
287
+ "attribute": "message-id",
288
+ "reflect": true
289
+ },
290
+ "operatorId": {
291
+ "type": "string",
292
+ "mutable": false,
293
+ "complexType": {
294
+ "original": "string",
295
+ "resolved": "string",
296
+ "references": {}
297
+ },
298
+ "required": false,
299
+ "optional": false,
300
+ "docs": {
301
+ "tags": [],
302
+ "text": ""
303
+ },
304
+ "attribute": "operator-id",
305
+ "reflect": true
306
+ },
307
+ "token": {
308
+ "type": "string",
309
+ "mutable": false,
310
+ "complexType": {
311
+ "original": "string",
312
+ "resolved": "string",
313
+ "references": {}
314
+ },
315
+ "required": false,
316
+ "optional": false,
317
+ "docs": {
318
+ "tags": [],
319
+ "text": ""
320
+ },
321
+ "attribute": "token",
322
+ "reflect": true
323
+ },
324
+ "backendUrl": {
325
+ "type": "string",
326
+ "mutable": false,
327
+ "complexType": {
328
+ "original": "string",
329
+ "resolved": "string",
330
+ "references": {}
331
+ },
332
+ "required": false,
333
+ "optional": false,
334
+ "docs": {
335
+ "tags": [],
336
+ "text": ""
337
+ },
338
+ "attribute": "backend-url",
339
+ "reflect": true
340
+ },
341
+ "clientStyling": {
342
+ "type": "string",
343
+ "mutable": true,
344
+ "complexType": {
345
+ "original": "string",
346
+ "resolved": "string",
347
+ "references": {}
348
+ },
349
+ "required": false,
350
+ "optional": false,
351
+ "docs": {
352
+ "tags": [],
353
+ "text": "Client custom styling via inline styles"
354
+ },
355
+ "attribute": "client-styling",
356
+ "reflect": true,
357
+ "defaultValue": "''"
358
+ },
359
+ "clientStylingUrl": {
360
+ "type": "string",
361
+ "mutable": false,
362
+ "complexType": {
363
+ "original": "string",
364
+ "resolved": "string",
365
+ "references": {}
366
+ },
367
+ "required": false,
368
+ "optional": false,
369
+ "docs": {
370
+ "tags": [],
371
+ "text": "Custom styling url for the novu iFrame, formatted as a JSON object according to the documentation: https://docs.novu.co/notification-center/custom-styling/"
372
+ },
373
+ "attribute": "client-styling-url",
374
+ "reflect": true
375
+ }
376
+ }; }
377
+ static get states() { return {
378
+ "showSettingsModal": {},
379
+ "messageSeen": {},
380
+ "messageRead": {}
381
+ }; }
382
+ static get events() { return [{
383
+ "method": "messageDeteled",
384
+ "name": "messageDeleted",
385
+ "bubbles": true,
386
+ "cancelable": true,
387
+ "composed": true,
388
+ "docs": {
389
+ "tags": [],
390
+ "text": ""
391
+ },
392
+ "complexType": {
393
+ "original": "any",
394
+ "resolved": "any",
395
+ "references": {}
396
+ }
397
+ }, {
398
+ "method": "settingsOpened",
399
+ "name": "settingsOpened",
400
+ "bubbles": true,
401
+ "cancelable": true,
402
+ "composed": true,
403
+ "docs": {
404
+ "tags": [],
405
+ "text": ""
406
+ },
407
+ "complexType": {
408
+ "original": "any",
409
+ "resolved": "any",
410
+ "references": {}
411
+ }
412
+ }]; }
413
+ static get listeners() { return [{
414
+ "name": "allNotificationsRead",
415
+ "method": "allNotificationsReadHandler",
416
+ "target": "window",
417
+ "capture": false,
418
+ "passive": false
419
+ }, {
420
+ "name": "settingsOpened",
421
+ "method": "settingsOpenedHandler",
422
+ "target": "window",
423
+ "capture": false,
424
+ "passive": false
425
+ }]; }
426
+ }
@@ -0,0 +1,75 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .Popover {
6
+ padding: 15px 0px;
7
+ height: auto;
8
+ border-radius: 7px;
9
+ box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 20px;
10
+ background: #1e1e26;
11
+ margin: 0px;
12
+ font-family: inherit;
13
+ color: #333737;
14
+ direction: ltr;
15
+ width: 420px;
16
+ z-index: 999;
17
+ }
18
+ .Popover .Header {
19
+ display: flex;
20
+ justify-content: space-between;
21
+ padding: 0 20px 10px 20px;
22
+ box-shadow: 0px 5px 5px -5px rgba(0, 0, 0, 0.55);
23
+ }
24
+ .Popover .Header .Title {
25
+ color: white;
26
+ font-size: 20px;
27
+ font-style: normal;
28
+ font-weight: 700;
29
+ line-height: 24px;
30
+ text-align: center;
31
+ }
32
+ .Popover .Header .Title .UnseenCounter {
33
+ text-decoration: none;
34
+ box-sizing: border-box;
35
+ display: inline-flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ text-transform: uppercase;
39
+ border-radius: 10px;
40
+ letter-spacing: 0.25px;
41
+ text-overflow: ellipsis;
42
+ overflow: hidden;
43
+ padding: 0px;
44
+ margin-left: 10px;
45
+ width: 25px;
46
+ height: 20px;
47
+ pointer-events: none;
48
+ border: none;
49
+ background: linear-gradient(0deg, #ff512f 0%, #dd2476 100%);
50
+ font-family: inherit;
51
+ line-height: 14px;
52
+ color: white;
53
+ font-weight: bold;
54
+ font-size: 12px;
55
+ }
56
+ .Popover .Header .MarkAsRead {
57
+ margin-top: 5px;
58
+ margin-right: 10px;
59
+ font-size: 14px;
60
+ font-style: normal;
61
+ font-weight: 400;
62
+ line-height: 17px;
63
+ color: #828299;
64
+ cursor: pointer;
65
+ pointer-events: auto;
66
+ opacity: 0.5;
67
+ }
68
+ .Popover .Header .MarkAsRead:hover {
69
+ opacity: 0.7;
70
+ transition: 250ms;
71
+ }
72
+ .Popover .NotificationList {
73
+ height: 400px;
74
+ overflow: auto;
75
+ }