@telia-ace/knowledge-widget-components-notification-row 1.0.38-experimental.9 → 1.0.38

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.
package/dist/index.js CHANGED
@@ -1,16 +1,80 @@
1
- import { createEventSubscriber as e } from "@telia-ace/knowledge-widget-core";
2
- import { createWebComponent as n } from "@telia-ace/widget-ui";
3
- const i = (o) => {
4
- const { events: t } = o.get("$widget");
5
- return e(t), n(
6
- o,
1
+ var m = Object.defineProperty, b = Object.defineProperties;
2
+ var C = Object.getOwnPropertyDescriptors;
3
+ var g = Object.getOwnPropertySymbols;
4
+ var y = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
5
+ var p = (t, e, i) => e in t ? m(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, h = (t, e) => {
6
+ for (var i in e || (e = {}))
7
+ y.call(e, i) && p(t, i, e[i]);
8
+ if (g)
9
+ for (var i of g(e))
10
+ R.call(e, i) && p(t, i, e[i]);
11
+ return t;
12
+ }, d = (t, e) => b(t, C(e));
13
+ import { createEventSubscriber as v, extendComponent as x } from "@telia-ace/knowledge-widget-core";
14
+ import { DataType as D } from "@telia-ace/knowledge-widget-types-grid";
15
+ import { createReactComponent as N } from "@telia-ace/knowledge-widget-ui";
16
+ const O = (t) => {
17
+ const { events: e } = t.get("$widget"), [i, u] = v(e);
18
+ return N(
19
+ t,
7
20
  "notification-row",
8
- import("./notification-row-wrapper.0c7a13c6.js"),
21
+ import("./notification-row.5162cdbf.js"),
9
22
  (r) => {
23
+ const s = (a) => {
24
+ r.writeProperties(d(h({}, r.properties()), {
25
+ loading: !0,
26
+ error: void 0,
27
+ notifications: []
28
+ })), r.actions.dispatch("fetch", { params: a });
29
+ };
30
+ return r.actions.create(
31
+ "fetch",
32
+ ({
33
+ error: a,
34
+ topNotifications: o,
35
+ bottomNotifications: f,
36
+ middleNotifications: l
37
+ }) => {
38
+ if (a)
39
+ return r.actions.dispatch("fetched", {
40
+ error: a,
41
+ loading: !0,
42
+ notifications: []
43
+ });
44
+ let n = [];
45
+ const { notifications: w, types: c = [] } = r.properties();
46
+ return c.length ? (c.indexOf("top") > -1 && (n = n.concat(o)), c.indexOf("middle") > -1 && (n = n.concat(l)), c.indexOf("bottom") > -1 && (n = n.concat(f))) : n = o, r.actions.dispatch("fetched", {
47
+ notifications: n.length ? n : w,
48
+ loading: !1
49
+ });
50
+ }
51
+ ), r.actions.create("fetched", (a) => r.writeProperties(d(h({}, a), { loading: !1 }))), t.getAsync("router").then((a) => {
52
+ const { params: o } = a.getRouteData();
53
+ s(o);
54
+ }), i("router:changed", (a, { current: o }) => {
55
+ s(o.routeData.params);
56
+ }), () => {
57
+ u();
58
+ };
10
59
  }
11
- );
12
- }, p = i;
60
+ ).then(() => x(t, "notification-row", (r) => {
61
+ r.actions.watch("notification-row.fetch", (s, a) => t.getAsync("dataClient").then(
62
+ (o) => o.fetch(D.RowNotifications, {
63
+ categories: [
64
+ s.params.guideCategory,
65
+ s.params.contactCategory
66
+ ].filter((f) => !!f),
67
+ searchPhrase: s.params.phrase
68
+ })
69
+ ).then(a).catch((o) => {
70
+ if (o)
71
+ return a(o);
72
+ }));
73
+ })).then(() => {
74
+ u();
75
+ });
76
+ }, S = O;
13
77
  export {
14
- p as default
78
+ S as default
15
79
  };
16
80
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/notification-row-component.ts"],"sourcesContent":["import { createEventSubscriber } from '@telia-ace/knowledge-widget-core';\nimport { createWebComponent } from '@telia-ace/widget-ui';\n// import { createWebComponent } from '@telia-ace/knowledge-widget-ui';\nimport { Container, Widget } from '@webprovisions/platform';\n\n// const NotificationRowComponent = (container: Container) => {\n// return createWebComponent(\n// container,\n// 'notification-row',\n// import('./notification-row-wrapper')\n// );\n// };\n\ntype NotificationType = 'top' | 'middle' | 'bottom';\nexport type NotificationRowComponentProps = {\n types: NotificationType[];\n allowPaging?: boolean;\n notifications?: Notification[]; // internal\n expandable?: boolean;\n pageNextAriaLabel?: string;\n pagePreviousAriaLabel?: string;\n closeAriaLabel?: string;\n expandAriaLabel?: string;\n};\n\nexport const NotificationRowComponent = (container: Container) => {\n const { events }: Widget = container.get('$widget');\n const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n return createWebComponent(\n container,\n 'notification-row',\n import('./notification-row-wrapper'),\n (component: any) => {}\n );\n};\n\nexport default NotificationRowComponent;\n\n// import {\n// createEventSubscriber,\n// extendComponent,\n// Notification,\n// } from '@telia-ace/knowledge-widget-core';\n// import { DataClient, DataType, NotificationResults } from '@telia-ace/knowledge-widget-types-grid';\n// import { createReactComponent } from '@telia-ace/knowledge-widget-ui';\n// import { Container, Widget } from '@webprovisions/platform';\n\n// type NotificationType = 'top' | 'middle' | 'bottom';\n// export type NotificationRowComponentProps = {\n// types: NotificationType[];\n// allowPaging?: boolean;\n// notifications?: Notification[]; // internal\n// expandable?: boolean;\n// pageNextAriaLabel?: string;\n// pagePreviousAriaLabel?: string;\n// closeAriaLabel?: string;\n// expandAriaLabel?: string;\n// };\n\n// type FetchResults = NotificationResults & { error: any };\n\n// export const NotificationRowComponent = (container: Container) => {\n// const { events }: Widget = container.get('$widget');\n// const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n// return createReactComponent(\n// container,\n// 'notification-row',\n// import('./notification-row'),\n// (component) => {\n// const fetch = (params: { [key: string]: any }) => {\n// component.writeProperties({\n// ...component.properties<NotificationRowComponentProps>(),\n// loading: true,\n// error: undefined,\n// notifications: [],\n// });\n// component.actions.dispatch('fetch', { params });\n// };\n\n// component.actions.create(\n// 'fetch',\n// ({\n// error,\n// topNotifications,\n// bottomNotifications,\n// middleNotifications,\n// }: FetchResults) => {\n// if (error) {\n// return component.actions.dispatch('fetched', {\n// error,\n// loading: true,\n// notifications: [],\n// });\n// }\n\n// let newNotifications: Notification[] = [];\n// const { notifications, types = [] } =\n// component.properties<NotificationRowComponentProps>();\n// if (types.length) {\n// if (types.indexOf('top') > -1) {\n// newNotifications = newNotifications.concat(topNotifications);\n// }\n// if (types.indexOf('middle') > -1) {\n// newNotifications = newNotifications.concat(middleNotifications);\n// }\n// if (types.indexOf('bottom') > -1) {\n// newNotifications = newNotifications.concat(bottomNotifications);\n// }\n// } else {\n// newNotifications = topNotifications;\n// }\n\n// return component.actions.dispatch('fetched', {\n// notifications: newNotifications.length ? newNotifications : notifications,\n// loading: false,\n// });\n// }\n// );\n\n// component.actions.create('fetched', (input) => {\n// return component.writeProperties({ ...input, loading: false });\n// });\n\n// container.getAsync('router').then((router) => {\n// const { params } = router.getRouteData();\n// fetch(params);\n// });\n\n// subscribe('router:changed', (event: any, { current }: any) => {\n// fetch(current.routeData.params);\n// });\n\n// return () => {\n// unsubscribe();\n// };\n// }\n// )\n// .then(() => {\n// return extendComponent(container, 'notification-row', (component) => {\n// component.actions.watch('notification-row.fetch', (input, next) => {\n// return container\n// .getAsync('dataClient')\n// .then((dataClient: DataClient) =>\n// dataClient.fetch(DataType.RowNotifications, {\n// categories: [\n// input.params.guideCategory,\n// input.params.contactCategory,\n// ].filter((c) => !!c),\n// searchPhrase: input.params.phrase,\n// })\n// )\n// .then(next)\n// .catch((error) => {\n// if (error) {\n// return next(error);\n// }\n// });\n// });\n// });\n// })\n// .then(() => {\n// unsubscribe();\n// });\n// };\n\n// export default NotificationRowComponent;\n"],"names":["NotificationRowComponent","container","events","createEventSubscriber","createWebComponent","component","NotificationRowComponent$1"],"mappings":";;AAyBa,MAAAA,IAA2B,CAACC,MAAyB;AAC9D,QAAM,EAAE,QAAAC,EAAmB,IAAAD,EAAU,IAAI,SAAS;AACjB,SAAAE,EAAsBD,CAAM,GAEtDE;AAAA,IACHH;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,CAACI,MAAmB;AAAA,IAAC;AAAA,EAAA;AAE7B,GAEAC,IAAeN;"}
1
+ {"version":3,"file":"index.js","sources":["../src/notification-row-component.ts"],"sourcesContent":["import {\n createEventSubscriber,\n extendComponent,\n Notification,\n} from '@telia-ace/knowledge-widget-core';\nimport { DataClient, DataType, NotificationResults } from '@telia-ace/knowledge-widget-types-grid';\nimport { createReactComponent } from '@telia-ace/knowledge-widget-ui';\nimport { Container, Widget } from '@webprovisions/platform';\n\ntype NotificationType = 'top' | 'middle' | 'bottom';\nexport type NotificationRowComponentProps = {\n types: NotificationType[];\n allowPaging?: boolean;\n notifications?: Notification[]; // internal\n expandable?: boolean;\n pageNextAriaLabel?: string;\n pagePreviousAriaLabel?: string;\n closeAriaLabel?: string;\n expandAriaLabel?: string;\n};\n\ntype FetchResults = NotificationResults & { error: any };\n\nexport const NotificationRowComponent = (container: Container) => {\n const { events }: Widget = container.get('$widget');\n const [subscribe, unsubscribe] = createEventSubscriber(events);\n\n return createReactComponent(\n container,\n 'notification-row',\n import('./notification-row'),\n (component) => {\n const fetch = (params: { [key: string]: any }) => {\n component.writeProperties({\n ...component.properties<NotificationRowComponentProps>(),\n loading: true,\n error: undefined,\n notifications: [],\n });\n component.actions.dispatch('fetch', { params });\n };\n\n component.actions.create(\n 'fetch',\n ({\n error,\n topNotifications,\n bottomNotifications,\n middleNotifications,\n }: FetchResults) => {\n if (error) {\n return component.actions.dispatch('fetched', {\n error,\n loading: true,\n notifications: [],\n });\n }\n\n let newNotifications: Notification[] = [];\n const { notifications, types = [] } =\n component.properties<NotificationRowComponentProps>();\n if (types.length) {\n if (types.indexOf('top') > -1) {\n newNotifications = newNotifications.concat(topNotifications);\n }\n if (types.indexOf('middle') > -1) {\n newNotifications = newNotifications.concat(middleNotifications);\n }\n if (types.indexOf('bottom') > -1) {\n newNotifications = newNotifications.concat(bottomNotifications);\n }\n } else {\n newNotifications = topNotifications;\n }\n\n return component.actions.dispatch('fetched', {\n notifications: newNotifications.length ? newNotifications : notifications,\n loading: false,\n });\n }\n );\n\n component.actions.create('fetched', (input) => {\n return component.writeProperties({ ...input, loading: false });\n });\n\n container.getAsync('router').then((router) => {\n const { params } = router.getRouteData();\n fetch(params);\n });\n\n subscribe('router:changed', (event: any, { current }: any) => {\n fetch(current.routeData.params);\n });\n\n return () => {\n unsubscribe();\n };\n }\n )\n .then(() => {\n return extendComponent(container, 'notification-row', (component) => {\n component.actions.watch('notification-row.fetch', (input, next) => {\n return container\n .getAsync('dataClient')\n .then((dataClient: DataClient) =>\n dataClient.fetch(DataType.RowNotifications, {\n categories: [\n input.params.guideCategory,\n input.params.contactCategory,\n ].filter((c) => !!c),\n searchPhrase: input.params.phrase,\n })\n )\n .then(next)\n .catch((error) => {\n if (error) {\n return next(error);\n }\n });\n });\n });\n })\n .then(() => {\n unsubscribe();\n });\n};\n\nexport default NotificationRowComponent;\n"],"names":["NotificationRowComponent","container","events","subscribe","unsubscribe","createEventSubscriber","createReactComponent","component","fetch","params","__spreadProps","__spreadValues","error","topNotifications","bottomNotifications","middleNotifications","newNotifications","notifications","types","input","router","event","current","extendComponent","next","dataClient","DataType","c","NotificationRowComponent$1"],"mappings":";;;;;;;;;;;;;;;AAuBa,MAAAA,IAA2B,CAACC,MAAyB;AAC9D,QAAM,EAAE,QAAAC,EAAmB,IAAAD,EAAU,IAAI,SAAS,GAC5C,CAACE,GAAWC,CAAW,IAAIC,EAAsBH,CAAM;AAEtD,SAAAI;AAAA,IACHL;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,CAACM,MAAc;AACL,YAAAC,IAAQ,CAACC,MAAmC;AAC9C,QAAAF,EAAU,gBAAgBG,EAAAC,EAAA,IACnBJ,EAAU,WAA0C,IADjC;AAAA,UAEtB,SAAS;AAAA,UACT,OAAO;AAAA,UACP,eAAe,CAAC;AAAA,QAAA,EACnB,GACDA,EAAU,QAAQ,SAAS,SAAS,EAAE,QAAAE,EAAQ,CAAA;AAAA,MAAA;AAGlD,aAAAF,EAAU,QAAQ;AAAA,QACd;AAAA,QACA,CAAC;AAAA,UACG,OAAAK;AAAA,UACA,kBAAAC;AAAA,UACA,qBAAAC;AAAA,UAC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EAAW,MAAMC,EAAS,kBAAkB;AAAA,QACxC,YAAY;AAAA,UACRP,EAAM,OAAO;AAAA,UACbA,EAAM,OAAO;AAAA,UACf,OAAO,CAACQ,MAAM,CAAC,CAACA,CAAC;AAAA,QACnB,cAAcR,EAAM,OAAO;AAAA,MAAA,CAC9B;AAAA,MAEJ,KAAKK,CAAI,EACT,MAAM,CAACZ,MAAU;AACd,UAAIA;AACA,eAAOY,EAAKZ,CAAK;AAAA,IACrB,CACH,CACR;AAAA,EAAA,CACJ,CACJ,EACA,KAAK,MAAM;AACI,IAAAR;EAAA,CACf;AACT,GAEAwB,IAAe5B;"}
@@ -1,3 +1,4 @@
1
+ import { Notification } from '@telia-ace/knowledge-widget-core';
1
2
  import { Container } from '@webprovisions/platform';
2
3
  type NotificationType = 'top' | 'middle' | 'bottom';
3
4
  export type NotificationRowComponentProps = {
@@ -0,0 +1,325 @@
1
+ var V = Object.defineProperty, X = Object.defineProperties;
2
+ var Z = Object.getOwnPropertyDescriptors;
3
+ var y = Object.getOwnPropertySymbols;
4
+ var I = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
5
+ var H = (e, t, a) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a, f = (e, t) => {
6
+ for (var a in t || (t = {}))
7
+ I.call(t, a) && H(e, a, t[a]);
8
+ if (y)
9
+ for (var a of y(t))
10
+ L.call(t, a) && H(e, a, t[a]);
11
+ return e;
12
+ }, g = (e, t) => X(e, Z(t));
13
+ var k = (e, t) => {
14
+ var a = {};
15
+ for (var n in e)
16
+ I.call(e, n) && t.indexOf(n) < 0 && (a[n] = e[n]);
17
+ if (e != null && y)
18
+ for (var n of y(e))
19
+ t.indexOf(n) < 0 && L.call(e, n) && (a[n] = e[n]);
20
+ return a;
21
+ };
22
+ import { css as b } from "@emotion/react";
23
+ import c from "@emotion/styled";
24
+ import { useProperties as ee, useContainer as te, createEmptyComponent as N, SymbolBadge as F, genericHtml as ae, linkTabStyle as ne, borderTabStyle as G, Html as oe, Button as ie } from "@telia-ace/knowledge-widget-ui";
25
+ import { readStorage as R, StorageMedium as T, createStorageWriter as le, StorageCategory as re } from "@telia-ace/widget-services";
26
+ import { appendClassNames as w } from "@telia-ace/widget-utilities";
27
+ import i, { useState as $, useEffect as W } from "react";
28
+ const z = "closed-notifications", se = {
29
+ transform: {
30
+ a: (a) => {
31
+ var n = a, { children: e } = n, t = k(n, ["children"]);
32
+ return /* @__PURE__ */ i.createElement("a", g(f({}, t), { tabIndex: -1 }), e);
33
+ }
34
+ }
35
+ }, xe = (a) => {
36
+ var n = a, { className: e } = n, t = k(n, ["className"]);
37
+ const {
38
+ types: P = [],
39
+ allowPaging: O = !0,
40
+ notifications: M = [],
41
+ expandable: m = !1,
42
+ closeAriaLabel: Y = "",
43
+ pageNextAriaLabel: _ = "",
44
+ pagePreviousAriaLabel: q = "",
45
+ expandAriaLabel: J = ""
46
+ } = ee(), [h, Q] = $(!1), [x, A] = $([]), [l, v] = $(0), r = te(), [E, U] = $();
47
+ W(() => {
48
+ r && (R(r, z, T.Session).then(
49
+ (o = []) => A(o)
50
+ ), le(r, z, re.Functional).then(
51
+ (o) => U(() => o)
52
+ ));
53
+ }, [r]), W(() => {
54
+ r && R(r, z, T.Session).then(
55
+ (o = []) => {
56
+ x.forEach(
57
+ (s) => o.indexOf(s) === -1 && o.push(s)
58
+ ), E && E(o);
59
+ }
60
+ );
61
+ }, [x, r, E]);
62
+ const d = M.filter(({ id: o }) => x.indexOf(o) === -1), { length: p } = d;
63
+ if (!d.length)
64
+ return N(r, g(f({}, t), {
65
+ className: w(e, "humany-notification-row")
66
+ }));
67
+ if (O) {
68
+ const o = d[l] || d[l + 1] || d[l - 1];
69
+ if (!o)
70
+ return N(r, g(f({}, t), {
71
+ className: w(e, "humany-notification-row")
72
+ }));
73
+ const { id: s, body: S } = o || {}, B = () => Q(!h);
74
+ return /* @__PURE__ */ i.createElement(
75
+ K,
76
+ g(f({}, t), {
77
+ "aria-expanded": m ? h : !0,
78
+ "aria-label": J,
79
+ tabIndex: m ? 0 : -1,
80
+ className: w(e, "humany-notification-row"),
81
+ "data-pageable": p > 1,
82
+ "data-types": P,
83
+ "data-allow-paging": O,
84
+ "data-expandable": m,
85
+ onKeyDown: (u) => {
86
+ u.key === "Enter" && B();
87
+ },
88
+ onClick: B
89
+ }),
90
+ /* @__PURE__ */ i.createElement(
91
+ ce,
92
+ {
93
+ "aria-label": Y,
94
+ onClick: () => {
95
+ v(d.indexOf(o)), A([...x, s]);
96
+ }
97
+ },
98
+ /* @__PURE__ */ i.createElement(F, { symbol: { type: "Svg", content: "close" } })
99
+ ),
100
+ /* @__PURE__ */ i.createElement(
101
+ j,
102
+ {
103
+ htmlParseInstruction: !m || h ? void 0 : se,
104
+ "data-pageable": p > 1,
105
+ "data-notification": s,
106
+ "data-expandable": m,
107
+ "data-expanded": h,
108
+ html: S
109
+ }
110
+ ),
111
+ p > 1 && /* @__PURE__ */ i.createElement(de, null, /* @__PURE__ */ i.createElement(
112
+ C,
113
+ {
114
+ "aria-label": q,
115
+ "data-disabled": l === 0,
116
+ onClick: (u) => {
117
+ u.stopPropagation(), l > 0 && v(l - 1);
118
+ }
119
+ },
120
+ /* @__PURE__ */ i.createElement(
121
+ D,
122
+ {
123
+ size: 10,
124
+ symbol: { type: "Svg", content: "caret-left" }
125
+ }
126
+ )
127
+ ), /* @__PURE__ */ i.createElement("span", null, l + 1, "/", p), /* @__PURE__ */ i.createElement(
128
+ C,
129
+ {
130
+ "aria-label": _,
131
+ "data-disabled": l + 1 >= p,
132
+ onClick: (u) => {
133
+ u.stopPropagation(), l < p - 1 && v(l + 1);
134
+ }
135
+ },
136
+ /* @__PURE__ */ i.createElement(
137
+ D,
138
+ {
139
+ size: 10,
140
+ symbol: { type: "Svg", content: "caret-right" }
141
+ }
142
+ )
143
+ ))
144
+ );
145
+ }
146
+ return /* @__PURE__ */ i.createElement(
147
+ K,
148
+ g(f({}, t), {
149
+ className: w(e, "humany-notification-row"),
150
+ "data-pageable": !1,
151
+ "data-types": P,
152
+ "data-allow-paging": !1
153
+ }),
154
+ d.map((o) => {
155
+ if (!o)
156
+ return null;
157
+ const { id: s, body: S } = o;
158
+ return /* @__PURE__ */ i.createElement(
159
+ j,
160
+ {
161
+ key: s,
162
+ "data-pageable": !1,
163
+ "data-expandable": m,
164
+ "data-expanded": h,
165
+ "data-notification": s,
166
+ html: S
167
+ }
168
+ );
169
+ })
170
+ );
171
+ }, K = c.div`
172
+ ${ae}
173
+ padding: ${(e) => {
174
+ var t;
175
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
176
+ }} ${(e) => {
177
+ var t;
178
+ return ((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 12;
179
+ }}px;
180
+ background-color: ${(e) => {
181
+ var t, a, n;
182
+ return e["data-types"].length ? e["data-types"].indexOf("top") > -1 ? (t = e.theme.colors) == null ? void 0 : t.warning : e["data-types"].indexOf("bottom") > -1 ? "transparent" : (a = e.theme.colors) == null ? void 0 : a.primary : (n = e.theme.colors) == null ? void 0 : n.warning;
183
+ }};
184
+ color: ${(e) => {
185
+ var t;
186
+ return (t = e.theme.colors) == null ? void 0 : t.text;
187
+ }};
188
+ border-radius: ${(e) => e.theme.borderRadius};
189
+ text-align: center;
190
+ display: flex;
191
+ flex-direction: column;
192
+ position: relative;
193
+ cursor: ${(e) => e["data-expandable"] ? "pointer" : "default"};
194
+ overflow: hidden;
195
+
196
+ i {
197
+ color: ${(e) => {
198
+ var t;
199
+ return (t = e.theme.colors) == null ? void 0 : t.text;
200
+ }};
201
+ }
202
+
203
+ a {
204
+ color: ${(e) => {
205
+ var t;
206
+ return (t = e.theme.colors) == null ? void 0 : t.link;
207
+ }};
208
+ &:focus-visible {
209
+ ${ne}
210
+ }
211
+ }
212
+
213
+ ${(e) => {
214
+ var t;
215
+ return !e["data-allow-paging"] && b`
216
+ flex-wrap: wrap;
217
+
218
+ > div {
219
+ min-width: 100%;
220
+ margin: ${((t = e.theme.sizes) == null ? void 0 : t.cardinal) * 2}px;
221
+ }
222
+ `;
223
+ }};
224
+
225
+ ${(e) => b`
226
+ &:focus-visible {
227
+ .humany-html {
228
+ ${G(e)}
229
+ }
230
+ }
231
+ `}
232
+ `, j = c(oe)`
233
+ flex: 1;
234
+ font-size: ${(e) => {
235
+ var t;
236
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
237
+ }};
238
+ line-height: 1.6em;
239
+ font-weight: 300;
240
+
241
+ ${(e) => e["data-expandable"] && !e["data-expanded"] && b`
242
+ max-width: 100%;
243
+
244
+ p {
245
+ display: none;
246
+ &:first-child {
247
+ display: block;
248
+ margin-bottom: 0;
249
+ white-space: nowrap;
250
+ overflow: hidden;
251
+ text-overflow: ellipsis;
252
+ }
253
+ }
254
+ `}
255
+ `, de = c.div`
256
+ text-align: center;
257
+ width: 100%;
258
+ span {
259
+ font-size: ${(e) => {
260
+ var t;
261
+ return (t = e.theme.fonts) == null ? void 0 : t.small;
262
+ }};
263
+ display: inline-block;
264
+ width: 30px;
265
+ text-align: center;
266
+ }
267
+ `, C = c(ie)`
268
+ background-color: transparent;
269
+ border: none;
270
+ cursor: pointer;
271
+ transition: opacity 200ms ease-out;
272
+ justify-self: flex-end;
273
+ align-self: flex-start;
274
+ padding: ${(e) => {
275
+ var t;
276
+ return (t = e.theme.sizes) == null ? void 0 : t.small;
277
+ }} svg {
278
+ display: block;
279
+ }
280
+
281
+ &:focus-visible {
282
+ ${G}
283
+ }
284
+
285
+ ${(e) => e["data-disabled"] ? b`
286
+ opacity: 0.8;
287
+ ` : b`
288
+ @media (hover) {
289
+ &:hover {
290
+ opacity: 0.5;
291
+ }
292
+ }
293
+ `}
294
+ `, ce = c(C)`
295
+ position: absolute;
296
+ top: 7.5px;
297
+ right: 7.5px;
298
+ width: 25px;
299
+ height: auto;
300
+ padding: ${(e) => {
301
+ var t, a;
302
+ return `calc(${(t = e.theme.sizes) == null ? void 0 : t.small}/2) ${(a = e.theme.sizes) == null ? void 0 : a.small}`;
303
+ }};
304
+ svg {
305
+ vertical-align: middle;
306
+ line,
307
+ path {
308
+ stroke: ${(e) => {
309
+ var t;
310
+ return (t = e.theme.colors) == null ? void 0 : t.text;
311
+ }};
312
+ }
313
+ }
314
+ `, D = c(F)`
315
+ line {
316
+ stroke: #ffffff;
317
+ }
318
+ `;
319
+ c.div`
320
+ display: none;
321
+ `;
322
+ export {
323
+ xe as default
324
+ };
325
+ //# sourceMappingURL=notification-row.5162cdbf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-row.5162cdbf.js","sources":["../src/notification-row.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport {\n borderTabStyle,\n Button,\n createEmptyComponent,\n genericHtml,\n Html,\n linkTabStyle,\n SymbolBadge,\n useContainer,\n useProperties,\n} from '@telia-ace/knowledge-widget-ui';\nimport {\n createStorageWriter,\n readStorage,\n StorageCategory,\n StorageMedium,\n StorageWriter,\n} from '@telia-ace/widget-services';\nimport { appendClassNames } from '@telia-ace/widget-utilities';\nimport React, { useEffect, useState } from 'react';\nimport { NotificationRowComponentProps } from './notification-row-component';\n\ntype Props = {\n className: string;\n};\n\nconst STORAGE_KEY = 'closed-notifications';\n\nconst infocusableHtml = {\n transform: {\n a: ({ children, ...props }: React.ComponentProps<'a'>) => (\n <a {...props} tabIndex={-1}>\n {children}\n </a>\n ),\n },\n};\n\nconst NotificationRow: React.FC<Props> = ({ className, ...other }) => {\n const {\n types = [],\n allowPaging = true,\n notifications = [],\n expandable = false,\n closeAriaLabel = '',\n pageNextAriaLabel = '',\n pagePreviousAriaLabel = '',\n expandAriaLabel = '',\n } = useProperties<NotificationRowComponentProps>();\n const [expanded, setExpanded] = useState(false);\n const [closed, setClosed] = useState<string[]>([]);\n const [index, setIndex] = useState(0);\n\n const container = useContainer();\n const [write, setWriter] = useState<StorageWriter | undefined>();\n\n useEffect(() => {\n if (container) {\n readStorage<string[]>(container, STORAGE_KEY, StorageMedium.Session).then(\n (closed = []) => setClosed(closed)\n );\n\n createStorageWriter(container, STORAGE_KEY, StorageCategory.Functional).then((writer) =>\n setWriter(() => writer)\n );\n }\n }, [container]);\n\n useEffect(() => {\n if (container) {\n readStorage<string[]>(container, STORAGE_KEY, StorageMedium.Session).then(\n (storedClosed = []) => {\n closed.forEach(\n (id) => storedClosed.indexOf(id) === -1 && storedClosed.push(id)\n );\n if (write) {\n write(storedClosed);\n }\n }\n );\n }\n }, [closed, container, write]);\n\n const filtered = notifications.filter(({ id }) => closed.indexOf(id) === -1);\n\n const { length } = filtered;\n\n if (!filtered.length) {\n return createEmptyComponent(container, {\n ...other,\n className: appendClassNames(className, 'humany-notification-row'),\n });\n }\n\n if (allowPaging) {\n const notification = filtered[index] || filtered[index + 1] || filtered[index - 1];\n\n if (!notification) {\n return createEmptyComponent(container, {\n ...other,\n className: appendClassNames(className, 'humany-notification-row'),\n });\n }\n\n const { id, body } = notification || {};\n const toggleExpand = () => setExpanded(!expanded);\n\n return (\n <Wrapper\n {...other}\n aria-expanded={expandable ? expanded : true}\n aria-label={expandAriaLabel}\n tabIndex={expandable ? 0 : -1}\n className={appendClassNames(className, 'humany-notification-row')}\n data-pageable={length > 1}\n data-types={types}\n data-allow-paging={allowPaging}\n data-expandable={expandable}\n onKeyDown={(e: React.KeyboardEvent) => {\n if (e.key === 'Enter') {\n toggleExpand();\n }\n }}\n onClick={toggleExpand}\n >\n <CloseButton\n aria-label={closeAriaLabel}\n onClick={() => {\n setIndex(filtered.indexOf(notification));\n setClosed([...closed, id]);\n }}\n >\n <SymbolBadge symbol={{ type: 'Svg', content: 'close' }} />\n </CloseButton>\n <StyledHtml\n htmlParseInstruction={!expandable || expanded ? undefined : infocusableHtml}\n data-pageable={length > 1}\n data-notification={id}\n data-expandable={expandable}\n data-expanded={expanded}\n html={body}\n />\n {length > 1 && (\n <Pager>\n <StyledButton\n aria-label={pagePreviousAriaLabel}\n data-disabled={index === 0}\n onClick={(e) => {\n e.stopPropagation();\n if (index > 0) {\n setIndex(index - 1);\n }\n }}\n >\n <StyledSymbolBadge\n size={10}\n symbol={{ type: 'Svg', content: 'caret-left' }}\n />\n </StyledButton>\n <span>\n {index + 1}/{length}\n </span>\n <StyledButton\n aria-label={pageNextAriaLabel}\n data-disabled={index + 1 >= length}\n onClick={(e) => {\n e.stopPropagation();\n if (index < length - 1) {\n setIndex(index + 1);\n }\n }}\n >\n <StyledSymbolBadge\n size={10}\n symbol={{ type: 'Svg', content: 'caret-right' }}\n />\n </StyledButton>\n </Pager>\n )}\n </Wrapper>\n );\n }\n\n return (\n <Wrapper\n {...other}\n className={appendClassNames(className, 'humany-notification-row')}\n data-pageable={false}\n data-types={types}\n data-allow-paging={false}\n >\n {filtered.map((notification) => {\n if (!notification) {\n return null;\n }\n\n const { id, body } = notification;\n\n return (\n <StyledHtml\n key={id}\n data-pageable={false}\n data-expandable={expandable}\n data-expanded={expanded}\n data-notification={id}\n html={body}\n />\n );\n })}\n </Wrapper>\n );\n};\n\nconst Wrapper = styled.div<{ 'data-types': string[]; 'data-allow-paging': boolean } & any>`\n ${genericHtml}\n padding: ${(p) => p.theme.sizes?.normal} ${(p) => p.theme.sizes?.cardinal * 12}px;\n background-color: ${(p) => {\n if (p['data-types'].length) {\n if (p['data-types'].indexOf('top') > -1) {\n return p.theme.colors?.warning;\n }\n if (p['data-types'].indexOf('bottom') > -1) {\n return 'transparent';\n }\n\n return p.theme.colors?.primary;\n }\n return p.theme.colors?.warning;\n }};\n color: ${(p) => p.theme.colors?.text};\n border-radius: ${(p) => p.theme.borderRadius};\n text-align: center;\n display: flex;\n flex-direction: column;\n position: relative;\n cursor: ${(p) => (p['data-expandable'] ? 'pointer' : 'default')};\n overflow: hidden;\n\n i {\n color: ${(p) => p.theme.colors?.text};\n }\n\n a {\n color: ${(p) => p.theme.colors?.link};\n &:focus-visible {\n ${linkTabStyle}\n }\n }\n\n ${(p) =>\n !p['data-allow-paging'] &&\n css`\n flex-wrap: wrap;\n\n > div {\n min-width: 100%;\n margin: ${p.theme.sizes?.cardinal * 2}px;\n }\n `};\n\n ${(p) =>\n css`\n &:focus-visible {\n .humany-html {\n ${borderTabStyle(p)}\n }\n }\n `}\n`;\n\nconst StyledHtml = styled(Html)<{\n 'data-pageable': boolean;\n 'data-expandable': boolean;\n 'data-expanded': boolean;\n}>`\n flex: 1;\n font-size: ${(p) => p.theme.fonts?.normal};\n line-height: 1.6em;\n font-weight: 300;\n\n ${(p) =>\n p['data-expandable'] &&\n !p['data-expanded'] &&\n css`\n max-width: 100%;\n\n p {\n display: none;\n &:first-child {\n display: block;\n margin-bottom: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n `}\n`;\n\nconst Pager = styled.div`\n text-align: center;\n width: 100%;\n span {\n font-size: ${(p) => p.theme.fonts?.small};\n display: inline-block;\n width: 30px;\n text-align: center;\n }\n`;\n\nconst StyledButton = styled(Button)<{ 'data-disabled'?: boolean }>`\n background-color: transparent;\n border: none;\n cursor: pointer;\n transition: opacity 200ms ease-out;\n justify-self: flex-end;\n align-self: flex-start;\n padding: ${(p) => p.theme.sizes?.small} svg {\n display: block;\n }\n\n &:focus-visible {\n ${borderTabStyle}\n }\n\n ${(p) =>\n p['data-disabled']\n ? css`\n opacity: 0.8;\n `\n : css`\n @media (hover) {\n &:hover {\n opacity: 0.5;\n }\n }\n `}\n`;\n\nconst CloseButton = styled(StyledButton)`\n position: absolute;\n top: 7.5px;\n right: 7.5px;\n width: 25px;\n height: auto;\n padding: ${(p) => `calc(${p.theme.sizes?.small}/2) ${p.theme.sizes?.small}`};\n svg {\n vertical-align: middle;\n line,\n path {\n stroke: ${(p) => p.theme.colors?.text};\n }\n }\n`;\n\nconst StyledSymbolBadge = styled(SymbolBadge)`\n line {\n stroke: #ffffff;\n }\n`;\n\nconst Empty = styled.div`\n display: none;\n`;\n\nexport default NotificationRow;\n"],"names":["STORAGE_KEY","infocusableHtml","_a","_b","children","props","__objRest","React","__spreadProps","__spreadValues","NotificationRow","className","other","types","allowPaging","notifications","expandable","closeAriaLabel","pageNextAriaLabel","pagePreviousAriaLabel","expandAriaLabel","useProperties","expanded","setExpanded","useState","closed","setClosed","index","setIndex","container","useContainer","write","setWriter","useEffect","readStorage","StorageMedium","createStorageWriter","StorageCategory","writer","storedClosed","id","filtered","length","createEmptyComponent","appendClassNames","notification","body","toggleExpand","Wrapper","e","CloseButton","SymbolBadge","StyledHtml","Pager","StyledButton","StyledSymbolBadge","styled","genericHtml","p","_c","linkTabStyle","css","borderTabStyle","Html","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAMA,IAAc,wBAEdC,KAAkB;AAAA,EACpB,WAAW;AAAA,IACP,GAAG,CAACC,MACC;AADD,UAAAC,IAAAD,GAAE,YAAAE,MAAFD,GAAeE,IAAAC,EAAfH,GAAe,CAAb;AACD,6BAAAI,EAAA,cAAA,KAAAC,EAAAC,EAAA,IAAMJ,IAAN,EAAa,UAAU,GAAA,IACnBD,CACL;AAAA;AAAA,EAER;AACJ,GAEMM,KAAmC,CAACR,MAA4B;AAA5B,MAAAC,IAAAD,GAAE,aAAAS,MAAFR,GAAgBS,IAAAN,EAAhBH,GAAgB,CAAd;AAClC,QAAA;AAAA,IACF,OAAAU,IAAQ,CAAC;AAAA,IACT,aAAAC,IAAc;AAAA,IACd,eAAAC,IAAgB,CAAC;AAAA,IACjB,YAAAC,IAAa;AAAA,IACb,gBAAAC,IAAiB;AAAA,IACjB,mBAAAC,IAAoB;AAAA,IACpB,uBAAAC,IAAwB;AAAA,IACxB,iBAAAC,IAAkB;AAAA,MAClBC,GAA6C,GAC3C,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GACxC,CAACC,GAAQC,CAAS,IAAIF,EAAmB,CAAE,CAAA,GAC3C,CAACG,GAAOC,CAAQ,IAAIJ,EAAS,CAAC,GAE9BK,IAAYC,MACZ,CAACC,GAAOC,CAAS,IAAIR,EAAoC;AAE/D,EAAAS,EAAU,M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AAR,gBAAAxD,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA,MAIjC,CAACwD,MACCA,EAAE,sBACF,CAACA,EAAE,oBACHG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAgBFR,KAAQG,EAAO;AAAA;AAAA;AAAA;AAAA,qBAIA,CAACE,MAAM;;AAAA,UAAAxD,IAAAwD,EAAE,MAAM,UAAR,gBAAAxD,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAOrCoD,IAAeE,EAAOQ,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOnB,CAACN,MAAM;;AAAA,UAAAxD,IAAAwD,EAAE,MAAM,UAAR,gBAAAxD,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAK3B4D;AAAA;AAAA;AAAA,MAGJ,CAACJ,MACCA,EAAE,mBACIG;AAAA;AAAA,kBAGAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GASRX,KAAcM,EAAOF,CAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAMxB,CAACI,MAAM;;AAAA,kBAAQxD,IAAAwD,EAAE,MAAM,UAAR,gBAAAxD,EAAe,aAAYC,IAAAuD,EAAE,MAAM,UAAR,gBAAAvD,EAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKlD,CAACuD,MAAM;;AAAA,UAAAxD,IAAAwD,EAAE,MAAM,WAAR,gBAAAxD,EAAgB;AAAA;AAAA;AAAA;AAAA,GAKvCqD,IAAoBC,EAAOL,CAAW;AAAA;AAAA;AAAA;AAAA;AAM9BK,EAAO;AAAA;AAAA;"}
@@ -1,20 +1,6 @@
1
- import { LitElement, nothing } from 'lit';
2
- export default class NotificationRow extends LitElement {
3
- _allowPaging: boolean;
4
- _expandable: boolean;
5
- _closeAriaLabel: string;
6
- _pageNextAriaLabel: string;
7
- _expandAriaLabel: string;
8
- _pagePreviousAriaLabel: string;
9
- _types: string[];
10
- _notifications: any[];
11
- closed: string[];
12
- expanded: boolean;
13
- index: number;
14
- static styles: import("lit").CSSResult[];
15
- constructor();
16
- connectedCallback(): void;
17
- private _toggleExpand;
18
- private getBackgroundColor;
19
- render(): typeof nothing | import("lit").TemplateResult<1>;
20
- }
1
+ import React from 'react';
2
+ type Props = {
3
+ className: string;
4
+ };
5
+ declare const NotificationRow: React.FC<Props>;
6
+ export default NotificationRow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-notification-row",
3
- "version": "1.0.38-experimental.9",
3
+ "version": "1.0.38",
4
4
  "description": "Notification row component for ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -21,19 +21,16 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "dependencies": {
24
- "@telia-ace/knowledge-data-client": "^1.0.2-experimental.1",
25
- "@telia-ace/knowledge-widget-core": "1.0.34-experimental.9",
26
- "@telia-ace/knowledge-widget-types-grid": "1.0.45-experimental.9",
27
- "@telia-ace/knowledge-widget-ui": "1.0.40-experimental.9",
28
- "@telia-ace/widget-services": "^1.0.21-experimental.19",
29
- "@telia-ace/widget-ui": "^1.0.28-experimental.19",
30
- "@telia-ace/widget-utilities": "^1.0.10-experimental.19",
24
+ "@telia-ace/knowledge-widget-core": "^1.0.34",
25
+ "@telia-ace/knowledge-widget-types-grid": "^1.0.45",
26
+ "@telia-ace/knowledge-widget-ui": "^1.0.40",
27
+ "@telia-ace/widget-services": "^1.0.20",
28
+ "@telia-ace/widget-utilities": "^1.0.9",
31
29
  "@webprovisions/platform": "^1.1.2"
32
30
  },
33
31
  "peerDependencies": {
34
32
  "@emotion/react": "^11.10.5",
35
33
  "@emotion/styled": "^11.10.5",
36
- "lit": "^2.6.0",
37
34
  "react": "^18.2.0",
38
35
  "react-dom": "^18.2.0"
39
36
  },
@@ -42,7 +39,6 @@
42
39
  "@emotion/styled": "^11.10.5",
43
40
  "@types/react": "^18.0.26",
44
41
  "@types/react-dom": "^18.0.10",
45
- "lit": "^2.6.1",
46
42
  "react": "^18.2.0",
47
43
  "react-dom": "^18.2.0"
48
44
  },
@@ -1,9 +0,0 @@
1
- import { ReactiveControllerHost } from 'lit';
2
- import { DataProvider } from '@telia-ace/widget-ui';
3
- export declare class NotificationRowDataProvider extends DataProvider {
4
- host: ReactiveControllerHost;
5
- constructor(host: ReactiveControllerHost);
6
- hostConnected(): void;
7
- initialize(): Promise<void>;
8
- _fetch(): Promise<void>;
9
- }
@@ -1,339 +0,0 @@
1
- var P = Object.defineProperty, k = Object.defineProperties;
2
- var A = Object.getOwnPropertyDescriptors;
3
- var y = Object.getOwnPropertySymbols, C = Object.getPrototypeOf, L = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable, O = Reflect.get;
4
- var w = (i, t, e) => t in i ? P(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, b = (i, t) => {
5
- for (var e in t || (t = {}))
6
- L.call(t, e) && w(i, e, t[e]);
7
- if (y)
8
- for (var e of y(t))
9
- z.call(t, e) && w(i, e, t[e]);
10
- return i;
11
- }, f = (i, t) => k(i, A(t));
12
- var m = (i, t, e) => O(C(i), e, t);
13
- var u = (i, t, e) => new Promise((o, n) => {
14
- var a = (c) => {
15
- try {
16
- p(e.next(c));
17
- } catch (h) {
18
- n(h);
19
- }
20
- }, s = (c) => {
21
- try {
22
- p(e.throw(c));
23
- } catch (h) {
24
- n(h);
25
- }
26
- }, p = (c) => c.done ? o(c.value) : Promise.resolve(c.value).then(a, s);
27
- p((e = e.apply(i, t)).next());
28
- });
29
- import { DataClient as N } from "@telia-ace/knowledge-data-client";
30
- import { DataProvider as E, WidgetComponentMixin as S, NodeConnector as D } from "@telia-ace/widget-ui";
31
- import { LitElement as B, nothing as v, html as g, css as R } from "lit";
32
- import { property as d, state as $ } from "lit/decorators.js";
33
- import { classMap as _ } from "lit/directives/class-map.js";
34
- class x extends E {
35
- constructor(t) {
36
- super(t), (this.host = t).addController(this);
37
- }
38
- hostConnected() {
39
- this.initialize();
40
- }
41
- initialize() {
42
- return u(this, null, function* () {
43
- yield m(x.prototype, this, "initialize").call(this), this._fetch();
44
- });
45
- }
46
- _fetch() {
47
- return u(this, null, function* () {
48
- if (!this.node || !this.container)
49
- return;
50
- this.node.writeProperties(f(b({}, this.node.attributes.properties), {
51
- loading: !0,
52
- error: void 0,
53
- notifications: []
54
- }));
55
- const t = yield N.getInstance(this.container);
56
- if (!t) {
57
- console.warn("Unable to get DataClient in NotificationRow.");
58
- return;
59
- }
60
- const {
61
- topNotifications: e = [],
62
- bottomNotifications: o = [],
63
- middleNotifications: n = []
64
- } = yield t.fetch("row-notices", {});
65
- let a = [];
66
- const { notifications: s, types: p = [] } = this.node.attributes.properties;
67
- p.length ? (p.indexOf("top") > -1 && (a = a.concat(e)), p.indexOf("middle") > -1 && (a = a.concat(n)), p.indexOf("bottom") > -1 && (a = a.concat(o))) : a = e, this.node.writeProperties(f(b({}, this.node.attributes.properties), {
68
- loading: !1,
69
- error: void 0,
70
- notifications: a.length ? a : s
71
- }));
72
- });
73
- }
74
- }
75
- var j = Object.defineProperty, K = Object.getOwnPropertyDescriptor, l = (i, t, e, o) => {
76
- for (var n = o > 1 ? void 0 : o ? K(t, e) : t, a = i.length - 1, s; a >= 0; a--)
77
- (s = i[a]) && (n = (o ? s(t, e, n) : s(n)) || n);
78
- return o && n && j(t, e, n), n;
79
- };
80
- class r extends B {
81
- constructor() {
82
- super(), this._closeAriaLabel = "", this._pagePreviousAriaLabel = "", this._pageNextAriaLabel = "", this._types = [], this._notifications = [], this._expandable = !1, this._allowPaging = !1, this.expanded = !1, this.index = 0, this.closed = [];
83
- }
84
- connectedCallback() {
85
- super.connectedCallback();
86
- }
87
- _toggleExpand() {
88
- this.expanded = !this.expanded;
89
- }
90
- getBackgroundColor() {
91
- return this._types.length ? this._types.indexOf("top") > -1 ? "--colors-warning" : this._types.indexOf("bottom") > -1 ? "--colors-transparent" : "--colors-primary" : "--colors-warning";
92
- }
93
- render() {
94
- this.style.setProperty(
95
- "--notification-row-background-default",
96
- `var(${this.getBackgroundColor()})`
97
- );
98
- const t = this._notifications.filter(({ id: o }) => this.closed.indexOf(o) === -1);
99
- if (!t.length)
100
- return v;
101
- const e = {
102
- "humany-notification-row": !0,
103
- "notification-row": !0,
104
- expandable: this._expandable,
105
- expanded: this.expanded,
106
- "not-expandable": this._expandable && !this.expanded
107
- };
108
- if (this._allowPaging = !0, this._allowPaging) {
109
- const o = t[this.index] || t[this.index + 1] || t[this.index - 1], { id: n, body: a } = o || {};
110
- return g`
111
- <!-- onKeyDown={(e: React.KeyboardEvent) => {
112
- if (e.key === 'Enter') {
113
- toggleExpand();
114
- }
115
- }}
116
- onClick={toggleExpand} -->
117
- <div
118
- class=${_(e)}
119
- part="container"
120
- data-expandable=${this._expandable}
121
- data-allow-paging=${this._allowPaging}
122
- aria-expanded=${this._expandable ? this.expanded : !0}
123
- aria-label=${this._expandAriaLabel}
124
- tabindex=${this._expandable ? 0 : -1}
125
- @click=${() => {
126
- this._toggleExpand();
127
- }}
128
- >
129
- <ui-button
130
- class="notification-row-close-button"
131
- part="close-button"
132
- aria-label=${this._closeAriaLabel}
133
- @click=${() => {
134
- this.index = t.indexOf(o), this.closed = [...this.closed, n];
135
- }}
136
- >
137
- <ui-symbol-badge .symbol=${{ type: "Svg", content: "close" }} />
138
- </ui-button>
139
- <ui-html
140
- data-pageable=${length > 1}
141
- data-notification=${n}
142
- data-expandable=${this._expandable}
143
- data-expanded=${this.expanded}
144
- .html=${a}
145
- ></ui-html>
146
- <div class="notification-row-pager" part="pager">
147
- <ui-button
148
- aria-label=${this._pagePreviousAriaLabel}
149
- data-disabled=${this.index === 0}
150
- @click=${(s) => {
151
- s.stopPropagation(), this.index > 0 && (this.index -= 1);
152
- }}
153
- part="arrow-button"
154
- >
155
- <ui-symbol-badge
156
- .size=${10}
157
- .symbol=${{ type: "Svg", content: "caret-left" }}
158
- part="arrow-icon"
159
- />
160
- </ui-button>
161
- <span> ${this.index + 1}/${t.length} </span>
162
- <ui-button
163
- aria-label=${this._pageNextAriaLabel}
164
- data-disabled=${this.index + 1 >= t.length}
165
- @click=${(s) => {
166
- s.stopPropagation(), this.index < t.length - 1 && (this.index += 1);
167
- }}
168
- part="arrow-button"
169
- >
170
- <ui-symbol-badge
171
- .size=${10}
172
- .symbol=${{ type: "Svg", content: "caret-right" }}
173
- part="arrow-icon"
174
- />
175
- </ui-button>
176
- </div>
177
- </div>
178
- `;
179
- }
180
- return g`
181
- <div part="container" class=${_(e)} data-expandable=${this._expandable}>
182
- ${t.map((o) => o ? g` <ui-html .html=${o.body} /> ` : v)}
183
- </div>
184
- `;
185
- }
186
- }
187
- r.styles = [
188
- R`
189
- :host::part(close-button) {
190
- position: absolute;
191
- top: 7.5px;
192
- right: 7.5px;
193
- width: 25px;
194
- height: auto;
195
- padding: calc(var(--size-small) / 2) var(--size-small);
196
- }
197
-
198
- :host::part(pager) {
199
- text-align: center;
200
- width: 100%;
201
- }
202
-
203
- :host::part(pager) span {
204
- font-size: var(--fonts-small);
205
- display: inline-block;
206
- width: 30px;
207
- text-align: center;
208
- }
209
-
210
- i {
211
- color: var(--colors-text);
212
- }
213
-
214
- a {
215
- color: var(--colors-link);
216
- }
217
-
218
- .notification-row {
219
- padding: var(--size-normal) calc(var(--cardinal) * 12);
220
- text-align: center;
221
- display: flex;
222
- flex-direction: column;
223
- position: relative;
224
- overflow: hidden;
225
- background-color: var(
226
- --notification-row-background,
227
- var(--notification-row-background-default)
228
- );
229
- color: var(--colors-text);
230
- border-radius: var(--borderRadius);
231
- }
232
-
233
- .notification-row.expandable {
234
- cursor: pointer;
235
- }
236
-
237
- .notification-row.not-expandable ui-html {
238
- max-width: 100%;
239
- }
240
-
241
- .notification-row.not-expandable ui-html p {
242
- display: none;
243
- }
244
- .notification-row.not-expandable ui-html p:first-child {
245
- display: block;
246
- margin-bottom: 0;
247
- white-space: nowrap;
248
- overflow: hidden;
249
- text-overflow: ellipsis;
250
- }
251
-
252
- .notification-row[data-allow-paging='false'] {
253
- flex-wrap: wrap;
254
- }
255
- .notification-row[data-allow-paging='false'] > div {
256
- min-width: 100%;
257
- margin: var(--cardinal * 2);
258
- }
259
-
260
- ui-html {
261
- flex: 1;
262
- font-size: var(--fonts-normal);
263
- line-height: 1.6em;
264
- font-weight: 300;
265
- }
266
-
267
- ui-button::part(container) {
268
- background-color: transparent;
269
- border: none;
270
- cursor: pointer;
271
- transition: opacity 200ms ease-out;
272
- justify-self: flex-end;
273
- align-self: flex-start;
274
- padding: var(--size-small);
275
- }
276
-
277
- ui-button::part(container):focus-visible {
278
- outline: var(--accessibility-border);
279
- color: var(--accessibility-colors-inactiveText);
280
- border-color: transparent;
281
- }
282
-
283
- ui-button::part(container[data-disabled]) {
284
- display: none;
285
- }
286
-
287
- ui-button[data-disabled='true']::part(container) {
288
- opacity: 0.8;
289
- }
290
-
291
- @media (hover: hover) {
292
- ui-button[data-disabled='false']:hover::part(container) {
293
- opacity: 0.5;
294
- }
295
- }
296
- `
297
- ];
298
- l([
299
- d({ type: Boolean })
300
- ], r.prototype, "_allowPaging", 2);
301
- l([
302
- d({ type: Boolean })
303
- ], r.prototype, "_expandable", 2);
304
- l([
305
- d({ type: String })
306
- ], r.prototype, "_closeAriaLabel", 2);
307
- l([
308
- d({ type: String })
309
- ], r.prototype, "_pageNextAriaLabel", 2);
310
- l([
311
- d({ type: String })
312
- ], r.prototype, "_expandAriaLabel", 2);
313
- l([
314
- d({ type: String })
315
- ], r.prototype, "_pagePreviousAriaLabel", 2);
316
- l([
317
- d({ type: Array })
318
- ], r.prototype, "_types", 2);
319
- l([
320
- d({ type: Array })
321
- ], r.prototype, "_notifications", 2);
322
- l([
323
- $()
324
- ], r.prototype, "closed", 2);
325
- l([
326
- d({ reflect: !0 })
327
- ], r.prototype, "expanded", 2);
328
- l([
329
- $()
330
- ], r.prototype, "index", 2);
331
- class F extends S(r) {
332
- constructor() {
333
- super(), this.connector = new D(this), this.dataProvider = new x(this);
334
- }
335
- }
336
- export {
337
- F as default
338
- };
339
- //# sourceMappingURL=notification-row-wrapper.0c7a13c6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notification-row-wrapper.0c7a13c6.js","sources":["../src/notification-row-data-provider.ts","../src/notification-row.ts","../src/notification-row-wrapper.ts"],"sourcesContent":["import { ReactiveControllerHost } from 'lit';\n// import { DataProvider } from 'types-web';\nimport { DataClient } from '@telia-ace/knowledge-data-client';\nimport { DataProvider } from '@telia-ace/widget-ui';\n\n// class DataProvider {\n// private _host: HTMLElement;\n// node: ComponentNode | undefined;\n// nodeId: string = '';\n// container: Container | undefined;\n\n// constructor(elem: HTMLElement) {\n// this._host = elem;\n// }\n\n// async initialize() {\n// this.nodeId = (this._host as any).getAttribute('nodeId');\n\n// if (!this.nodeId) {\n// console.warn('Could not get node id in DataProvider.');\n// return;\n// }\n\n// this.container = this._requestInstance('container');\n\n// if (!this.container) {\n// console.warn('Could not get data in DataProvider. Container was not defined.');\n// return;\n// }\n// const platform = await ComponentPlatform.getInstance(this.container);\n// this.node = platform.nodes.get(this.nodeId);\n\n// if (!this.node) {\n// console.warn(`Could not get component node with ID: ${this.nodeId}.`);\n// return;\n// }\n// }\n\n// _requestInstance(key: string) {\n// const event = new CustomEvent<{ key: string; instance?: any }>('request-instance', {\n// detail: { key },\n// bubbles: true,\n// composed: true,\n// cancelable: true,\n// });\n// (this._host as any).dispatchEvent(event);\n\n// return event.detail.instance;\n// }\n// }\n\nexport class NotificationRowDataProvider extends DataProvider {\n host;\n\n constructor(host: ReactiveControllerHost) {\n super(host as any);\n (this.host = host).addController(this);\n }\n\n hostConnected() {\n this.initialize();\n }\n\n async initialize() {\n await super.initialize();\n\n this._fetch();\n }\n\n async _fetch() {\n if (!this.node || !this.container) {\n return;\n }\n this.node.writeProperties({\n ...this.node.attributes.properties,\n loading: true,\n error: undefined,\n notifications: [],\n });\n\n const dataClient = await DataClient.getInstance(this.container);\n\n if (!dataClient) {\n console.warn('Unable to get DataClient in NotificationRow.');\n return;\n }\n\n const {\n topNotifications = [],\n bottomNotifications = [],\n middleNotifications = [],\n } = await (dataClient as any).fetch('row-notices', {\n // categories: [ TODO: missing\n // input.params.guideCategory,\n // input.params.contactCategory,\n // ].filter((c) => !!c),\n // searchPhrase: input.params.phrase,\n });\n // const {\n // topNotifications = [],\n // bottomNotifications = [],\n // middleNotifications = [],\n // } = await this.container?.getAsync('dataClient').then((dataClient) => {\n // return dataClient.fetch('row-notices', {\n // // categories: [ TODO: missing\n // // input.params.guideCategory,\n // // input.params.contactCategory,\n // // ].filter((c) => !!c),\n // // searchPhrase: input.params.phrase,\n // });\n // });\n\n let newNotifications: Notification[] = [];\n const { notifications, types = [] } = this.node.attributes.properties;\n if (types.length) {\n if (types.indexOf('top') > -1) {\n newNotifications = newNotifications.concat(topNotifications);\n }\n if (types.indexOf('middle') > -1) {\n newNotifications = newNotifications.concat(middleNotifications);\n }\n if (types.indexOf('bottom') > -1) {\n newNotifications = newNotifications.concat(bottomNotifications);\n }\n } else {\n newNotifications = topNotifications;\n }\n\n this.node.writeProperties({\n ...this.node.attributes.properties,\n loading: false,\n error: undefined,\n notifications: newNotifications.length ? newNotifications : notifications,\n });\n }\n}\n","import { css, html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nexport default class NotificationRow extends LitElement {\n @property({ type: Boolean })\n declare _allowPaging;\n\n @property({ type: Boolean })\n declare _expandable;\n\n @property({ type: String })\n declare _closeAriaLabel: string;\n\n @property({ type: String })\n declare _pageNextAriaLabel: string;\n\n @property({ type: String })\n declare _expandAriaLabel: string;\n\n @property({ type: String })\n declare _pagePreviousAriaLabel;\n\n @property({ type: Array })\n declare _types: string[];\n\n @property({ type: Array })\n declare _notifications: any[]; // TODO: no any\n\n @state()\n declare closed: string[];\n\n @property({ reflect: true })\n declare expanded: boolean;\n\n @state()\n declare index: number;\n\n // const CloseButton = styled(StyledButton)`\n // svg {\n // vertical-align: middle;\n // line,\n // path {\n // stroke: ${(p) => p.theme.colors?.text};\n // }\n // }\n // `;\n\n static styles = [\n // genericHtml,\n css`\n :host::part(close-button) {\n position: absolute;\n top: 7.5px;\n right: 7.5px;\n width: 25px;\n height: auto;\n padding: calc(var(--size-small) / 2) var(--size-small);\n }\n\n :host::part(pager) {\n text-align: center;\n width: 100%;\n }\n\n :host::part(pager) span {\n font-size: var(--fonts-small);\n display: inline-block;\n width: 30px;\n text-align: center;\n }\n\n i {\n color: var(--colors-text);\n }\n\n a {\n color: var(--colors-link);\n }\n\n .notification-row {\n padding: var(--size-normal) calc(var(--cardinal) * 12);\n text-align: center;\n display: flex;\n flex-direction: column;\n position: relative;\n overflow: hidden;\n background-color: var(\n --notification-row-background,\n var(--notification-row-background-default)\n );\n color: var(--colors-text);\n border-radius: var(--borderRadius);\n }\n\n .notification-row.expandable {\n cursor: pointer;\n }\n\n .notification-row.not-expandable ui-html {\n max-width: 100%;\n }\n\n .notification-row.not-expandable ui-html p {\n display: none;\n }\n .notification-row.not-expandable ui-html p:first-child {\n display: block;\n margin-bottom: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .notification-row[data-allow-paging='false'] {\n flex-wrap: wrap;\n }\n .notification-row[data-allow-paging='false'] > div {\n min-width: 100%;\n margin: var(--cardinal * 2);\n }\n\n ui-html {\n flex: 1;\n font-size: var(--fonts-normal);\n line-height: 1.6em;\n font-weight: 300;\n }\n\n ui-button::part(container) {\n background-color: transparent;\n border: none;\n cursor: pointer;\n transition: opacity 200ms ease-out;\n justify-self: flex-end;\n align-self: flex-start;\n padding: var(--size-small);\n }\n\n ui-button::part(container):focus-visible {\n outline: var(--accessibility-border);\n color: var(--accessibility-colors-inactiveText);\n border-color: transparent;\n }\n\n ui-button::part(container[data-disabled]) {\n display: none;\n }\n\n ui-button[data-disabled='true']::part(container) {\n opacity: 0.8;\n }\n\n @media (hover: hover) {\n ui-button[data-disabled='false']:hover::part(container) {\n opacity: 0.5;\n }\n }\n `,\n ];\n\n constructor() {\n super();\n this._closeAriaLabel = '';\n this._pagePreviousAriaLabel = '';\n this._pageNextAriaLabel = '';\n this._types = [];\n this._notifications = [];\n this._expandable = false;\n this._allowPaging = false;\n this.expanded = false;\n this.index = 0;\n this.closed = [];\n }\n\n connectedCallback() {\n super.connectedCallback();\n }\n\n private _toggleExpand() {\n this.expanded = !this.expanded;\n }\n\n private getBackgroundColor() {\n if (this._types.length) {\n if (this._types.indexOf('top') > -1) {\n return '--colors-warning';\n } else if (this._types.indexOf('bottom') > -1) {\n return '--colors-transparent';\n }\n return '--colors-primary';\n }\n return '--colors-warning';\n }\n\n render() {\n this.style.setProperty(\n '--notification-row-background-default',\n `var(${this.getBackgroundColor()})`\n );\n\n const filtered = this._notifications.filter(({ id }) => this.closed.indexOf(id) === -1);\n\n if (!filtered.length) {\n return nothing;\n }\n const classes = {\n 'humany-notification-row': true,\n 'notification-row': true,\n expandable: this._expandable,\n expanded: this.expanded,\n 'not-expandable': this._expandable && !this.expanded,\n };\n\n this._allowPaging = true;\n\n if (this._allowPaging) {\n const notification =\n filtered[this.index] || filtered[this.index + 1] || filtered[this.index - 1];\n\n const { id, body } = notification || {};\n\n return html`\n <!-- onKeyDown={(e: React.KeyboardEvent) => {\n if (e.key === 'Enter') {\n toggleExpand();\n }\n }}\n onClick={toggleExpand} -->\n <div\n class=${classMap(classes)}\n part=\"container\"\n data-expandable=${this._expandable}\n data-allow-paging=${this._allowPaging}\n aria-expanded=${this._expandable ? this.expanded : true}\n aria-label=${this._expandAriaLabel}\n tabindex=${this._expandable ? 0 : -1}\n @click=${() => {\n this._toggleExpand();\n }}\n >\n <ui-button\n class=\"notification-row-close-button\"\n part=\"close-button\"\n aria-label=${this._closeAriaLabel}\n @click=${() => {\n this.index = filtered.indexOf(notification);\n this.closed = [...this.closed, id];\n }}\n >\n <ui-symbol-badge .symbol=${{ type: 'Svg', content: 'close' }} />\n </ui-button>\n <ui-html\n data-pageable=${length > 1}\n data-notification=${id}\n data-expandable=${this._expandable}\n data-expanded=${this.expanded}\n .html=${body}\n ></ui-html>\n <div class=\"notification-row-pager\" part=\"pager\">\n <ui-button\n aria-label=${this._pagePreviousAriaLabel}\n data-disabled=${this.index === 0}\n @click=${(e: Event) => {\n e.stopPropagation();\n if (this.index > 0) {\n this.index -= 1;\n }\n }}\n part=\"arrow-button\"\n >\n <ui-symbol-badge\n .size=${10}\n .symbol=${{ type: 'Svg', content: 'caret-left' }}\n part=\"arrow-icon\"\n />\n </ui-button>\n <span> ${this.index + 1}/${filtered.length} </span>\n <ui-button\n aria-label=${this._pageNextAriaLabel}\n data-disabled=${this.index + 1 >= filtered.length}\n @click=${(e: Event) => {\n e.stopPropagation();\n if (this.index < filtered.length - 1) {\n this.index += 1;\n }\n }}\n part=\"arrow-button\"\n >\n <ui-symbol-badge\n .size=${10}\n .symbol=${{ type: 'Svg', content: 'caret-right' }}\n part=\"arrow-icon\"\n />\n </ui-button>\n </div>\n </div>\n `;\n }\n\n // data-pageable=\"false\"\n // data-types=${types}\n // data-allow-paging=\"false\"\n // className={appendClassNames(className, 'humany-notification-row')}\n return html`\n <div part=\"container\" class=${classMap(classes)} data-expandable=${this._expandable}>\n ${filtered.map((notification) => {\n if (!notification) {\n return nothing;\n }\n\n return html` <ui-html .html=${notification.body} /> `;\n })}\n </div>\n `;\n }\n}\n","import { NotificationRowDataProvider } from './notification-row-data-provider';\n\nimport { NodeConnector, WidgetComponentMixin } from '@telia-ace/widget-ui';\nimport NotificationRow from './notification-row';\n\nexport default class NotificationRowWrapper extends WidgetComponentMixin(NotificationRow) {\n connector = new NodeConnector(this);\n dataProvider = new NotificationRowDataProvider(this);\n\n constructor() {\n super();\n }\n}\n"],"names":["NotificationRowDataProvider","DataProvider","host","__async","__superGet","__spreadProps","__spreadValues","dataClient","DataClient","topNotifications","bottomNotifications","middleNotifications","newNotifications","notifications","types","NotificationRow","LitElement","filtered","id","nothing","classes","notification","body","html","classMap","e","css","__decorateClass","property","state","NotificationRowWrapper","WidgetComponentMixin","NodeConnector"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,MAAMA,UAAoCC,EAAa;AAAA,EAG1D,YAAYC,GAA8B;AACtC,UAAMA,CAAW,IAChB,KAAK,OAAOA,GAAM,cAAc,IAAI;AAAA,EACzC;AAAA,EAEA,gBAAgB;AACZ,SAAK,WAAW;AAAA,EACpB;AAAA,EAEM,aAAa;AAAA,WAAAC,EAAA;AACf,YAAMC,EAAAJ,EAAA,iBAAM,mBAAN,OAEN,KAAK,OAAO;AAAA,IAChB;AAAA;AAAA,EAEM,SAAS;AAAA,WAAAG,EAAA;AACX,UAAI,CAAC,KAAK,QAAQ,CAAC,KAAK;AACpB;AAEJ,WAAK,KAAK,gBAAgBE,EAAAC,EAAA,IACnB,KAAK,KAAK,WAAW,aADF;AAAA,QAEtB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,eAAe,CAAC;AAAA,MAAA,EACnB;AAED,YAAMC,IAAa,MAAMC,EAAW,YAAY,KAAK,SAAS;AAE9D,UAAI,CAACD,GAAY;AACb,gBAAQ,KAAK,8CAA8C;AAC3D;AAAA,MACJ;AAEM,YAAA;AAAA,QACF,kBAAAE,IAAmB,CAAC;AAAA,QACpB,qBAAAC,IAAsB,CAAC;AAAA,QACvB,qBAAAC,IAAsB,CAAC;AAAA,UACvB,MAAOJ,EAAmB,MAAM,eAAe,CAMlD,CAAA;AAeD,UAAIK,IAAmC,CAAA;AACjC,YAAA,EAAE,eAAAC,GAAe,OAAAC,IAAQ,OAAO,KAAK,KAAK,WAAW;AAC3D,MAAIA,EAAM,UACFA,EAAM,QAAQ,KAAK,IAAI,OACJF,IAAAA,EAAiB,OAAOH,CAAgB,IAE3DK,EAAM,QAAQ,QAAQ,IAAI,OACPF,IAAAA,EAAiB,OAA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AA;AAAA,EADPC,EAAS,EAAE,MAAM,QAAQ;AAAA,GAVTb,EAWT,WAAA,sBAAA,CAAA;AAGAY,EAAA;AAAA,EADPC,EAAS,EAAE,MAAM,QAAQ;AAAA,GAbTb,EAcT,WAAA,oBAAA,CAAA;AAGAY,EAAA;AAAA,EADPC,EAAS,EAAE,MAAM,QAAQ;AAAA,GAhBTb,EAiBT,WAAA,0BAAA,CAAA;AAGAY,EAAA;AAAA,EADPC,EAAS,EAAE,MAAM,OAAO;AAAA,GAnBRb,EAoBT,WAAA,UAAA,CAAA;AAGAY,EAAA;AAAA,EADPC,EAAS,EAAE,MAAM,OAAO;AAAA,GAtBRb,EAuBT,WAAA,kBAAA,CAAA;AAGAY,EAAA;AAAA,EADPE,EAAM;AAAA,GAzBUd,EA0BT,WAAA,UAAA,CAAA;AAGAY,EAAA;AAAA,EADPC,EAAS,EAAE,SAAS,IAAM;AAAA,GA5BVb,EA6BT,WAAA,YAAA,CAAA;AAGAY,EAAA;AAAA,EADPE,EAAM;AAAA,GA/BUd,EAgCT,WAAA,SAAA,CAAA;AC/BS,MAAAe,UAA+BC,EAAqBhB,CAAe,EAAE;AAAA,EAItF,cAAc;AACJ,aAJE,KAAA,YAAA,IAAIiB,EAAc,IAAI,GACnB,KAAA,eAAA,IAAIhC,EAA4B,IAAI;AAAA,EAInD;AACJ;"}
@@ -1,10 +0,0 @@
1
- import { NotificationRowDataProvider } from './notification-row-data-provider';
2
- import { NodeConnector } from '@telia-ace/widget-ui';
3
- import NotificationRow from './notification-row';
4
- declare const NotificationRowWrapper_base: import("@telia-ace/widget-ui").WidgetComponentConstructor<import("@telia-ace/widget-ui/dist/mixins/widget-component").WidgetComponentInterface> & typeof NotificationRow;
5
- export default class NotificationRowWrapper extends NotificationRowWrapper_base {
6
- connector: NodeConnector;
7
- dataProvider: NotificationRowDataProvider;
8
- constructor();
9
- }
10
- export {};