@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,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface NutsPopover extends Components.NutsPopover, HTMLElement {}
4
+ export const NutsPopover: {
5
+ prototype: NutsPopover;
6
+ new (): NutsPopover;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { N as NutsPopover$1, d as defineCustomElement$1 } from './nuts-popover2.js';
2
+
3
+ const NutsPopover = NutsPopover$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { NutsPopover, defineCustomElement };
@@ -0,0 +1,119 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { d as defineCustomElement$1 } from './nuts-notification2.js';
3
+
4
+ const nutsPopoverCss = ":host{display:block}.Popover{padding:15px 0px;height:auto;border-radius:7px;box-shadow:rgba(0, 0, 0, 0.2) 0px 5px 20px;background:#1e1e26;margin:0px;font-family:inherit;color:#333737;direction:ltr;width:420px;z-index:999}.Popover .Header{display:flex;justify-content:space-between;padding:0 20px 10px 20px;box-shadow:0px 5px 5px -5px rgba(0, 0, 0, 0.55)}.Popover .Header .Title{color:white;font-size:20px;font-style:normal;font-weight:700;line-height:24px;text-align:center}.Popover .Header .Title .UnseenCounter{text-decoration:none;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;text-transform:uppercase;border-radius:10px;letter-spacing:0.25px;text-overflow:ellipsis;overflow:hidden;padding:0px;margin-left:10px;width:25px;height:20px;pointer-events:none;border:none;background:linear-gradient(0deg, #ff512f 0%, #dd2476 100%);font-family:inherit;line-height:14px;color:white;font-weight:bold;font-size:12px}.Popover .Header .MarkAsRead{margin-top:5px;margin-right:10px;font-size:14px;font-style:normal;font-weight:400;line-height:17px;color:#828299;cursor:pointer;pointer-events:auto;opacity:0.5}.Popover .Header .MarkAsRead:hover{opacity:0.7;transition:250ms}.Popover .NotificationList{height:400px;overflow:auto}";
5
+
6
+ const NutsPopover = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.allNotificationsRead = createEvent(this, "allNotificationsRead", 7);
11
+ /**
12
+ * Client custom styling via inline styles
13
+ */
14
+ this.clientStyling = '';
15
+ this.isLoading = true;
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
+ messageDeteledHandler(event) {
36
+ this.notifications = this.notifications.filter((item) => {
37
+ return item._id != event.detail;
38
+ });
39
+ }
40
+ newNotificationHandler(event) {
41
+ this.notifications = [event.detail, ...this.notifications];
42
+ }
43
+ getNotifications() {
44
+ let url = new URL(`${this.backendUrl}/v1/widgets/notifications/feed`);
45
+ const headers = new Headers();
46
+ headers.append('Authorization', `Bearer ${this.token || ''}`);
47
+ headers.append('Content-Type', 'application/json');
48
+ url.searchParams.append('page', '0');
49
+ const options = {
50
+ method: 'GET',
51
+ headers,
52
+ };
53
+ fetch(url.href, options)
54
+ .then((res) => res.json())
55
+ .then((response) => {
56
+ this.isLoading = false;
57
+ this.notifications = response.data;
58
+ });
59
+ }
60
+ markAllAsRead() {
61
+ let url = new URL(`${this.backendUrl}/v1/widgets/messages/read`);
62
+ const headers = new Headers();
63
+ headers.append('Authorization', `Bearer ${this.token || ''}`);
64
+ const options = {
65
+ method: 'POST',
66
+ body: JSON.stringify({}),
67
+ headers,
68
+ };
69
+ fetch(url.href, options)
70
+ .then((res) => res.json())
71
+ .then(() => {
72
+ this.allNotificationsRead.emit();
73
+ })
74
+ .catch((err) => {
75
+ console.error('err', err);
76
+ });
77
+ }
78
+ connectedCallback() {
79
+ this.getNotifications();
80
+ }
81
+ render() {
82
+ return (h("div", { class: "Popover", ref: el => this.stylingContainer = el }, h("div", { class: "Header" }, h("div", { class: "Title" }, "Notifications", this.unseenCount > 0 ? h("div", { class: "UnseenCounter" }, this.unseenCount) : ''), h("div", { class: "MarkAsRead", onClick: () => this.markAllAsRead() }, "Mark all as read")), h("div", { class: "NotificationList" }, !this.isLoading && this.notifications.map((item) => {
83
+ var _a;
84
+ return (h("nuts-notification", { "client-styling": this.clientStyling, key: item.id, "user-id": this.userId, "operator-id": this.operatorId, content: item.content, "message-id": item.id, badge: ((_a = item.actor) === null || _a === void 0 ? void 0 : _a.data) || '', date: item.createdAt, read: item.read, seen: item.seen, language: this.language, token: this.token, "backend-url": this.backendUrl }));
85
+ }))));
86
+ }
87
+ static get style() { return nutsPopoverCss; }
88
+ }, [0, "nuts-popover", {
89
+ "language": [513],
90
+ "userId": [513, "user-id"],
91
+ "operatorId": [513, "operator-id"],
92
+ "token": [513],
93
+ "backendUrl": [513, "backend-url"],
94
+ "unseenCount": [514, "unseen-count"],
95
+ "clientStyling": [1537, "client-styling"],
96
+ "clientStylingUrl": [513, "client-styling-url"],
97
+ "notifications": [32],
98
+ "isLoading": [32]
99
+ }, [[8, "messageDeleted", "messageDeteledHandler"], [8, "newNotification", "newNotificationHandler"]]]);
100
+ function defineCustomElement() {
101
+ if (typeof customElements === "undefined") {
102
+ return;
103
+ }
104
+ const components = ["nuts-popover", "nuts-notification"];
105
+ components.forEach(tagName => { switch (tagName) {
106
+ case "nuts-popover":
107
+ if (!customElements.get(tagName)) {
108
+ customElements.define(tagName, NutsPopover);
109
+ }
110
+ break;
111
+ case "nuts-notification":
112
+ if (!customElements.get(tagName)) {
113
+ defineCustomElement$1();
114
+ }
115
+ break;
116
+ } });
117
+ }
118
+
119
+ export { NutsPopover as N, defineCustomElement as d };