@telia-ace/knowledge-widget-components-notification-list 1.0.5 → 1.0.10

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.
File without changes
package/dist/index.js ADDED
@@ -0,0 +1,82 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { createEventSubscriber, extendComponent } from "@telia-ace/knowledge-widget-core";
21
+ import { DataType } from "@telia-ace/knowledge-widget-types-grid";
22
+ import { createReactComponent } from "@telia-ace/knowledge-widget-ui";
23
+ const NotificationListComponent = (container) => {
24
+ const { events } = container.get("$widget");
25
+ const [subscribe, unsubscribe] = createEventSubscriber(events);
26
+ return createReactComponent(container, "notification-list", import("./notification-list.js"), (component) => {
27
+ const fetch = (params) => {
28
+ component.writeProperties(__spreadProps(__spreadValues({}, component.properties()), {
29
+ loading: true,
30
+ error: void 0,
31
+ notificationList: void 0
32
+ }));
33
+ component.actions.dispatch("fetch", { params });
34
+ };
35
+ component.actions.create("fetch", ({ error, notificationLists }) => {
36
+ if (error) {
37
+ return component.actions.dispatch("fetched", {
38
+ error,
39
+ loading: true,
40
+ notificationList: void 0
41
+ });
42
+ }
43
+ const { category, notificationList } = component.properties();
44
+ const properties = {
45
+ notificationList: notificationLists.find((n) => n.id === category) || notificationList
46
+ };
47
+ return component.actions.dispatch("fetched", __spreadProps(__spreadValues({}, properties), {
48
+ loading: true
49
+ }));
50
+ });
51
+ component.actions.create("fetched", (input) => {
52
+ return component.writeProperties(__spreadProps(__spreadValues({}, input), { loading: false }));
53
+ });
54
+ container.getAsync("router").then((router) => {
55
+ const { params } = router.getRouteData();
56
+ fetch(params);
57
+ });
58
+ subscribe("router:changed", (event, { current }) => {
59
+ fetch(current.routeData.params);
60
+ });
61
+ }).then(() => {
62
+ return extendComponent(container, "notification-list", (component) => {
63
+ component.actions.watch("notification-list.fetch", (input, next) => {
64
+ return container.getAsync("dataClient").then((dataClient) => dataClient.fetch(DataType.NotificationLists, {
65
+ categories: [
66
+ input.params.guideCategory,
67
+ input.params.contactCategory
68
+ ].filter((c) => !!c),
69
+ searchPhrase: input.params.phrase
70
+ })).then(next).catch((error) => {
71
+ if (error) {
72
+ return next(error);
73
+ }
74
+ });
75
+ });
76
+ });
77
+ }).then(() => {
78
+ unsubscribe();
79
+ });
80
+ };
81
+ export { NotificationListComponent as default };
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/notification-list-component.ts"],"sourcesContent":["import {\r\n createEventSubscriber,\r\n extendComponent,\r\n NotificationList,\r\n} from '@telia-ace/knowledge-widget-core';\r\nimport { DataClient, DataType, NotificationResults } from '@telia-ace/knowledge-widget-types-grid';\r\nimport { createReactComponent } from '@telia-ace/knowledge-widget-ui';\r\nimport { Container, Widget } from '@webprovisions/platform';\r\n\r\nexport type NotificationListComponentProps = {\r\n category?: string;\r\n showHeader?: boolean;\r\n notificationList?: NotificationList; // internal\r\n};\r\n\r\ntype FetchResults = NotificationResults & { error: any };\r\n\r\nexport const NotificationListComponent = (container: Container) => {\r\n const { events }: Widget = container.get('$widget');\r\n const [subscribe, unsubscribe] = createEventSubscriber(events);\r\n\r\n return createReactComponent(\r\n container,\r\n 'notification-list',\r\n import('./notification-list'),\r\n (component) => {\r\n const fetch = (params: { [key: string]: any }) => {\r\n component.writeProperties({\r\n ...component.properties<NotificationListComponentProps>(),\r\n loading: true,\r\n error: undefined,\r\n notificationList: undefined,\r\n });\r\n component.actions.dispatch('fetch', { params });\r\n };\r\n\r\n component.actions.create('fetch', ({ error, notificationLists }: FetchResults) => {\r\n if (error) {\r\n return component.actions.dispatch('fetched', {\r\n error,\r\n loading: true,\r\n notificationList: undefined,\r\n });\r\n }\r\n\r\n const { category, notificationList } =\r\n component.properties<NotificationListComponentProps>();\r\n\r\n const properties = {\r\n notificationList:\r\n notificationLists.find((n) => n.id === category) || notificationList,\r\n };\r\n\r\n return component.actions.dispatch('fetched', {\r\n ...properties,\r\n loading: true,\r\n });\r\n });\r\n\r\n component.actions.create('fetched', (input) => {\r\n return component.writeProperties({ ...input, loading: false });\r\n });\r\n\r\n container.getAsync('router').then((router) => {\r\n const { params } = router.getRouteData();\r\n fetch(params);\r\n });\r\n\r\n subscribe('router:changed', (event: any, { current }: any) => {\r\n fetch(current.routeData.params);\r\n });\r\n }\r\n )\r\n .then(() => {\r\n return extendComponent(container, 'notification-list', (component) => {\r\n component.actions.watch('notification-list.fetch', (input, next) => {\r\n return container\r\n .getAsync('dataClient')\r\n .then((dataClient: DataClient) =>\r\n dataClient.fetch(DataType.NotificationLists, {\r\n categories: [\r\n input.params.guideCategory,\r\n input.params.contactCategory,\r\n ].filter((c) => !!c),\r\n searchPhrase: input.params.phrase,\r\n })\r\n )\r\n .then(next)\r\n .catch((error) => {\r\n if (error) {\r\n return next(error);\r\n }\r\n });\r\n });\r\n });\r\n })\r\n .then(() => {\r\n unsubscribe();\r\n });\r\n};\r\n\r\nexport default NotificationListComponent;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBa,MAAA,4BAA4B,CAAC,cAAyB;AAC/D,QA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AA2B,CAAC,OAAO,SAAS;AACzD,eAAA,UACF,SAAS,YAAY,EACrB,KAAK,CAAC,eACH,WAAW,MAAM,SAAS,mBAAmB;AAAA,UACzC,YAAY;AAAA,YACR,MAAM,OAAO;AAAA,YACb,MAAM,OAAO;AAAA,YACf,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAAA,UACnB,cAAc,MAAM,OAAO;AAAA,QAAA,CAC9B,CACL,EACC,KAAK,IAAI,EACT,MAAM,CAAC,UAAU;AACd,cAAI,OAAO;AACP,mBAAO,KAAK,KAAK;AAAA,UACrB;AAAA,QAAA,CACH;AAAA,MAAA,CACR;AAAA,IAAA,CACJ;AAAA,EAAA,CACJ,EACA,KAAK,MAAM;AACI;EAAA,CACf;AACT;;"}
File without changes
@@ -0,0 +1,212 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { useContainer, useProperties, createEmptyComponent, DateFormats, Loader, Button, borderTabStyle, ItemList, loadingOpacity, contentBox, itemList, headingElement, Paragraph, genericHtml, SymbolBadge, Timestamp } from "@telia-ace/knowledge-widget-ui";
33
+ import { appendClassNames } from "@telia-ace/widget-utilities";
34
+ import React, { useState } from "react";
35
+ import styled, { css } from "styled-components";
36
+ const NotificationList = (_a) => {
37
+ var _b = _a, { className } = _b, other = __objRest(_b, ["className"]);
38
+ const [expanded, setExpanded] = useState(null);
39
+ const container = useContainer();
40
+ const {
41
+ showHeader,
42
+ notificationList,
43
+ loading = false
44
+ } = useProperties();
45
+ const {
46
+ id,
47
+ title,
48
+ symbol,
49
+ notifications = [],
50
+ defaultHeaderOptions = { visible: true }
51
+ } = notificationList || {};
52
+ if (!notifications.length && !loading) {
53
+ return createEmptyComponent(container, __spreadProps(__spreadValues({}, other), {
54
+ className: appendClassNames(className, "humany-notification-list")
55
+ }));
56
+ }
57
+ return /* @__PURE__ */ React.createElement(StyledItemList, __spreadProps(__spreadValues({}, other), {
58
+ "data-loading": loading,
59
+ "data-show-header": typeof showHeader === "boolean" ? showHeader : defaultHeaderOptions.visible,
60
+ className: appendClassNames(className, "humany-notification-list"),
61
+ "data-notification-category": id,
62
+ header: title,
63
+ symbol,
64
+ items: notifications,
65
+ renderItem: ({ id: id2, title: title2, body, modified, expandable }) => /* @__PURE__ */ React.createElement(StyledItem, {
66
+ key: id2,
67
+ "data-notification": id2,
68
+ "data-expanded": expandable ? expanded === id2 : true
69
+ }, expandable ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StyledButton, {
70
+ title: title2,
71
+ "aria-label": title2,
72
+ "aria-expanded": expanded === id2,
73
+ onClick: () => setExpanded(expanded === id2 ? null : id2)
74
+ }, /* @__PURE__ */ React.createElement("span", null, title2), /* @__PURE__ */ React.createElement(StyledSymbolBadge, {
75
+ size: 11,
76
+ symbol: {
77
+ type: "Svg",
78
+ content: `caret-${expanded === id2 ? "up" : "down"}`
79
+ }
80
+ })), /* @__PURE__ */ React.createElement(StyledParagraph, {
81
+ html: body
82
+ }), modified && /* @__PURE__ */ React.createElement(StyledTimestamp, {
83
+ format: DateFormats.YYYY_MM_DD,
84
+ timestamp: modified
85
+ })) : /* @__PURE__ */ React.createElement(StyledParagraph, {
86
+ html: body
87
+ }))
88
+ }), /* @__PURE__ */ React.createElement(Loader, {
89
+ loading
90
+ }));
91
+ };
92
+ const StyledButton = styled(Button)`
93
+ display: flex;
94
+ justify-content: space-between;
95
+ align-items: center;
96
+ width: 100%;
97
+ text-align: left;
98
+ svg,
99
+ i {
100
+ color: ${(p) => {
101
+ var _a;
102
+ return (_a = p.theme.colors) == null ? void 0 : _a.primary;
103
+ }};
104
+ }
105
+ span {
106
+ color: ${(p) => {
107
+ var _a;
108
+ return (_a = p.theme.colors) == null ? void 0 : _a.text;
109
+ }};
110
+ font-size: ${(p) => {
111
+ var _a;
112
+ return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
113
+ }};
114
+ overflow: hidden;
115
+ text-overflow: ellipsis;
116
+ flex: 1;
117
+ white-space: nowrap;
118
+ }
119
+ &:focus {
120
+ ${(p) => {
121
+ var _a, _b;
122
+ return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
123
+ ${borderTabStyle}
124
+ span {
125
+ color: ${(_b = p.theme.colors) == null ? void 0 : _b.primary};
126
+ text-decoration: underline;
127
+ }
128
+ `;
129
+ }};
130
+ }
131
+ `;
132
+ const StyledItemList = styled(ItemList)`
133
+ ${loadingOpacity}
134
+ ${contentBox}
135
+ ${itemList}
136
+ overflow: hidden;
137
+ justify-content: flex-start;
138
+ padding: ${(p) => {
139
+ var _a;
140
+ return (_a = p.theme.sizes) == null ? void 0 : _a.large;
141
+ }};
142
+ ${(p) => !p["data-show-header"] && css`
143
+ > div {
144
+ ${headingElement("h1", css`
145
+ display: none;
146
+ `)}
147
+ }
148
+ `}
149
+
150
+ @media (hover: hover) {
151
+ button:hover {
152
+ text-decoration: underline;
153
+ }
154
+ }
155
+ `;
156
+ const StyledParagraph = styled(Paragraph)`
157
+ ${genericHtml}
158
+ font-weight: 300;
159
+
160
+ p {
161
+ white-space: normal;
162
+ }
163
+ `;
164
+ const StyledItem = styled.li`
165
+ ${StyledParagraph} {
166
+ display: none;
167
+ &:not(:only-child) {
168
+ ${(p) => {
169
+ var _a, _b, _c;
170
+ return ((_a = p.theme.sizes) == null ? void 0 : _a.cardinal) && ((_b = p.theme.sizes) == null ? void 0 : _b.normal) && css`
171
+ margin: ${(_c = p.theme.sizes) == null ? void 0 : _c.normal} 0;
172
+ `;
173
+ }}
174
+ }
175
+ }
176
+
177
+ ${(p) => p["data-expanded"] && css`
178
+ ${StyledParagraph} {
179
+ display: block;
180
+ }
181
+ `}
182
+
183
+ > span {
184
+ display: block;
185
+ font-weight: 300;
186
+ color: ${(p) => {
187
+ var _a;
188
+ return (_a = p.theme.colors) == null ? void 0 : _a.accent;
189
+ }};
190
+ }
191
+ `;
192
+ const StyledSymbolBadge = styled(SymbolBadge)`
193
+ margin: 0 0 0 ${(p) => {
194
+ var _a;
195
+ return (_a = p.theme.sizes) == null ? void 0 : _a.small;
196
+ }};
197
+ line {
198
+ stroke: ${(p) => {
199
+ var _a;
200
+ return (_a = p.theme.colors) == null ? void 0 : _a.primary;
201
+ }};
202
+ }
203
+ `;
204
+ const StyledTimestamp = styled(Timestamp)`
205
+ font-size: ${(p) => {
206
+ var _a;
207
+ return (_a = p.theme.fonts) == null ? void 0 : _a.small;
208
+ }};
209
+ font-weight: 300;
210
+ `;
211
+ export { NotificationList as default };
212
+ //# sourceMappingURL=notification-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-list.js","sources":["../src/notification-list.tsx"],"sourcesContent":["import { Notification } from '@telia-ace/knowledge-widget-core';\r\nimport {\r\n borderTabStyle,\r\n Button,\r\n contentBox,\r\n createEmptyComponent,\r\n DateFormats,\r\n genericHtml,\r\n headingElement,\r\n ItemList,\r\n itemList,\r\n Loader,\r\n loadingOpacity,\r\n Paragraph,\r\n SymbolBadge,\r\n Timestamp,\r\n useContainer,\r\n useProperties,\r\n} from '@telia-ace/knowledge-widget-ui';\r\nimport { appendClassNames } from '@telia-ace/widget-utilities';\r\nimport React, { useState } from 'react';\r\nimport styled, { css } from 'styled-components';\r\nimport { NotificationListComponentProps } from './notification-list-component';\r\n\r\ntype Props = {\r\n className: string;\r\n};\r\n\r\nconst NotificationList: React.SFC<Props> = ({ className, ...other }) => {\r\n const [expanded, setExpanded] = useState<string | null>(null);\r\n const container = useContainer();\r\n const {\r\n showHeader,\r\n notificationList,\r\n loading = false,\r\n } = useProperties<NotificationListComponentProps>();\r\n\r\n const {\r\n id,\r\n title,\r\n symbol,\r\n notifications = [],\r\n defaultHeaderOptions = { visible: true },\r\n } = notificationList || {};\r\n\r\n if (!notifications.length && !loading) {\r\n return createEmptyComponent(container, {\r\n ...other,\r\n className: appendClassNames(className, 'humany-notification-list'),\r\n });\r\n }\r\n\r\n return (\r\n <StyledItemList\r\n {...other}\r\n data-loading={loading}\r\n data-show-header={\r\n typeof showHeader === 'boolean' ? showHeader : defaultHeaderOptions.visible\r\n }\r\n className={appendClassNames(className, 'humany-notification-list')}\r\n data-notification-category={id}\r\n header={title}\r\n symbol={symbol}\r\n items={notifications}\r\n renderItem={({ id, title, body, modified, expandable }: Notification) => (\r\n <StyledItem\r\n key={id}\r\n data-notification={id}\r\n data-expanded={expandable ? expanded === id : true}\r\n >\r\n {expandable ? (\r\n <>\r\n <StyledButton\r\n title={title}\r\n aria-label={title}\r\n aria-expanded={expanded === id}\r\n onClick={() => setExpanded(expanded === id ? null : id)}\r\n >\r\n <span>{title}</span>\r\n <StyledSymbolBadge\r\n size={11}\r\n symbol={{\r\n type: 'Svg',\r\n content: `caret-${expanded === id ? 'up' : 'down'}`,\r\n }}\r\n />\r\n </StyledButton>\r\n <StyledParagraph html={body} />\r\n {modified && (\r\n <StyledTimestamp\r\n format={DateFormats.YYYY_MM_DD}\r\n timestamp={modified}\r\n />\r\n )}\r\n </>\r\n ) : (\r\n <StyledParagraph html={body} />\r\n )}\r\n </StyledItem>\r\n )}\r\n >\r\n <Loader loading={loading} />\r\n </StyledItemList>\r\n );\r\n};\r\n\r\nconst StyledButton = styled(Button)`\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n width: 100%;\r\n text-align: left;\r\n svg,\r\n i {\r\n color: ${(p) => p.theme.colors?.primary};\r\n }\r\n span {\r\n color: ${(p) => p.theme.colors?.text};\r\n font-size: ${(p) => p.theme.fonts?.normal};\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n flex: 1;\r\n white-space: nowrap;\r\n }\r\n &:focus {\r\n ${(p) =>\r\n p.theme.accessibility?.isTabbing &&\r\n css`\r\n ${borderTabStyle}\r\n span {\r\n color: ${p.theme.colors?.primary};\r\n text-decoration: underline;\r\n }\r\n `};\r\n }\r\n`;\r\n\r\nconst StyledItemList = styled(ItemList)<\r\n {\r\n 'data-loading': boolean;\r\n 'data-show-header': boolean;\r\n } & any\r\n>`\r\n ${loadingOpacity}\r\n ${contentBox}\r\n ${itemList}\r\n overflow: hidden;\r\n justify-content: flex-start;\r\n padding: ${(p) => p.theme.sizes?.large};\r\n ${(p) =>\r\n !p['data-show-header'] &&\r\n css`\r\n > div {\r\n ${headingElement(\r\n 'h1',\r\n css`\r\n display: none;\r\n `\r\n )}\r\n }\r\n `}\r\n\r\n @media (hover: hover) {\r\n button:hover {\r\n text-decoration: underline;\r\n }\r\n }\r\n`;\r\n\r\nconst StyledParagraph = styled(Paragraph)`\r\n ${genericHtml}\r\n font-weight: 300;\r\n\r\n p {\r\n white-space: normal;\r\n }\r\n`;\r\n\r\nconst StyledItem = styled.li<{ 'data-expanded': boolean }>`\r\n ${StyledParagraph} {\r\n display: none;\r\n &:not(:only-child) {\r\n ${(p) =>\r\n p.theme.sizes?.cardinal &&\r\n p.theme.sizes?.normal &&\r\n css`\r\n margin: ${p.theme.sizes?.normal} 0;\r\n `}\r\n }\r\n }\r\n\r\n ${(p) =>\r\n p['data-expanded'] &&\r\n css`\r\n ${StyledParagraph} {\r\n display: block;\r\n }\r\n `}\r\n\r\n > span {\r\n display: block;\r\n font-weight: 300;\r\n color: ${(p) => p.theme.colors?.accent};\r\n }\r\n`;\r\n\r\nconst StyledSymbolBadge = styled(SymbolBadge)`\r\n margin: 0 0 0 ${(p) => p.theme.sizes?.small};\r\n line {\r\n stroke: ${(p) => p.theme.colors?.primary};\r\n }\r\n`;\r\n\r\nconst StyledTimestamp = styled(Timestamp)`\r\n font-size: ${(p) => p.theme.fonts?.small};\r\n font-weight: 300;\r\n`;\r\n\r\nexport default NotificationList;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,mBAAqC,CAAC,OAA4B;AAA5B,eAAE,gBAAF,IAAgB,kBAAhB,IAAgB,CAAd;AAC1C,QAAM,CAAC,UAAU,eAAe,SAAwB,IAAI;AAC5D,QAAM,YAAY;AACZ,QAAA;AAAA,IACF;AAAA,IACA;AAAA,IACA,UAAU;AAAA,MACV,cAA8C;AAE5C,QAAA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,CAAC;AAAA,IACjB,uBAAuB,EAAE,SAAS,KAAK;AAAA,MACvC,oBAAoB,CAAA;AAExB,MAAI,CAAC,cAAc,UAAU,CAAC,SAAS;AACnC,WAAO,qBAAqB,WAAW,iCAChC,QADgC;AAAA,MAEnC,WAAW,iBAAiB,WAAW,0BAA0B;AAAA,IAAA,EACpE;AAAA,EACL;AAEA,SACK,sBAAA,cAAA,gBAAA,iCACO,QADP;AAAA,IAEG,gBAAc;AAAA,IACd,oBACI,OAAO,eAAe,YAAY,aAAa,qBAAqB;AAAA,IAExE,WAA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@@ -1,34 +1,33 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-components-notification-list",
3
- "version": "1.0.5",
3
+ "version": "1.0.10",
4
4
  "description": "Notification list component for ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
7
7
  "keywords": [
8
8
  "telia"
9
9
  ],
10
- "main": "lib/index.js",
11
- "module": "lib-esm/index.js",
10
+ "module": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
12
  "files": [
13
13
  "LICENSE.txt",
14
14
  "README.md",
15
- "lib/",
16
- "lib-esm/"
15
+ "dist/"
17
16
  ],
18
17
  "publishConfig": {
19
18
  "access": "public"
20
19
  },
21
20
  "scripts": {
22
- "clean": "cleandir lib && cleandir lib-esm",
23
- "compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
21
+ "clean": "rimraf ./dist",
22
+ "precompile": "tsc -emitDeclarationOnly",
23
+ "compile": "vite build"
24
24
  },
25
25
  "sideEffects": false,
26
- "typings": "lib/index.d.ts",
27
26
  "dependencies": {
28
- "@telia-ace/knowledge-widget-core": "^1.0.6",
29
- "@telia-ace/knowledge-widget-types-grid": "^1.0.12",
30
- "@telia-ace/knowledge-widget-ui": "^1.0.9",
31
- "@telia-ace/widget-utilities": "^1.0.1",
27
+ "@telia-ace/knowledge-widget-core": "^1.0.8",
28
+ "@telia-ace/knowledge-widget-types-grid": "^1.0.15",
29
+ "@telia-ace/knowledge-widget-ui": "^1.0.12",
30
+ "@telia-ace/widget-utilities": "^1.0.2",
32
31
  "@webprovisions/platform": "^1.1.2"
33
32
  },
34
33
  "peerDependencies": {
@@ -41,5 +40,5 @@
41
40
  "@types/react-dom": "^16.8.0",
42
41
  "@types/styled-components": "^5.1.7"
43
42
  },
44
- "gitHead": "1d81c21570237e665e19ff62f5345d55d524be27"
43
+ "gitHead": "c26936286e303a87e65a8df1d1269349f42ea043"
45
44
  }
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import NotificationListComponent from './notification-list-component';
2
- export default NotificationListComponent;
package/lib/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var notification_list_component_1 = __importDefault(require("./notification-list-component"));
7
- exports.default = notification_list_component_1.default;
@@ -1,9 +0,0 @@
1
- import { NotificationList } from '@telia-ace/knowledge-widget-core';
2
- import { Container } from '@webprovisions/platform';
3
- export declare type NotificationListComponentProps = {
4
- category?: string;
5
- showHeader?: boolean;
6
- notificationList?: NotificationList;
7
- };
8
- export declare const NotificationListComponent: (container: Container) => Promise<void>;
9
- export default NotificationListComponent;
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __read = (this && this.__read) || function (o, n) {
37
- var m = typeof Symbol === "function" && o[Symbol.iterator];
38
- if (!m) return o;
39
- var i = m.call(o), r, ar = [], e;
40
- try {
41
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42
- }
43
- catch (error) { e = { error: error }; }
44
- finally {
45
- try {
46
- if (r && !r.done && (m = i["return"])) m.call(i);
47
- }
48
- finally { if (e) throw e.error; }
49
- }
50
- return ar;
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.NotificationListComponent = void 0;
54
- var knowledge_widget_core_1 = require("@telia-ace/knowledge-widget-core");
55
- var knowledge_widget_types_grid_1 = require("@telia-ace/knowledge-widget-types-grid");
56
- var knowledge_widget_ui_1 = require("@telia-ace/knowledge-widget-ui");
57
- var NotificationListComponent = function (container) {
58
- var events = container.get('$widget').events;
59
- var _a = __read((0, knowledge_widget_core_1.createEventSubscriber)(events), 2), subscribe = _a[0], unsubscribe = _a[1];
60
- return (0, knowledge_widget_ui_1.createReactComponent)(container, 'notification-list', Promise.resolve().then(function () { return __importStar(require('./notification-list')); }), function (component) {
61
- var fetch = function (params) {
62
- component.writeProperties(__assign(__assign({}, component.properties()), { loading: true, error: undefined, notificationList: undefined }));
63
- component.actions.dispatch('fetch', { params: params });
64
- };
65
- component.actions.create('fetch', function (_a) {
66
- var error = _a.error, notificationLists = _a.notificationLists;
67
- if (error) {
68
- return component.actions.dispatch('fetched', {
69
- error: error,
70
- loading: true,
71
- notificationList: undefined,
72
- });
73
- }
74
- var _b = component.properties(), category = _b.category, notificationList = _b.notificationList;
75
- var properties = {
76
- notificationList: notificationLists.find(function (n) { return n.id === category; }) || notificationList,
77
- };
78
- return component.actions.dispatch('fetched', __assign(__assign({}, properties), { loading: true }));
79
- });
80
- component.actions.create('fetched', function (input) {
81
- return component.writeProperties(__assign(__assign({}, input), { loading: false }));
82
- });
83
- container.getAsync('router').then(function (router) {
84
- var params = router.getRouteData().params;
85
- fetch(params);
86
- });
87
- subscribe('router:changed', function (event, _a) {
88
- var current = _a.current;
89
- fetch(current.routeData.params);
90
- });
91
- })
92
- .then(function () {
93
- return (0, knowledge_widget_core_1.extendComponent)(container, 'notification-list', function (component) {
94
- component.actions.watch('notification-list.fetch', function (input, next) {
95
- return container
96
- .getAsync('dataClient')
97
- .then(function (dataClient) {
98
- return dataClient.fetch(knowledge_widget_types_grid_1.DataType.NotificationLists, {
99
- categories: [
100
- input.params.guideCategory,
101
- input.params.contactCategory,
102
- ].filter(function (c) { return !!c; }),
103
- searchPhrase: input.params.phrase,
104
- });
105
- })
106
- .then(next)
107
- .catch(function (error) {
108
- if (error) {
109
- return next(error);
110
- }
111
- });
112
- });
113
- });
114
- })
115
- .then(function () {
116
- unsubscribe();
117
- });
118
- };
119
- exports.NotificationListComponent = NotificationListComponent;
120
- exports.default = exports.NotificationListComponent;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- declare type Props = {
3
- className: string;
4
- };
5
- declare const NotificationList: React.SFC<Props>;
6
- export default NotificationList;
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __rest = (this && this.__rest) || function (s, e) {
41
- var t = {};
42
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
- t[p] = s[p];
44
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
- t[p[i]] = s[p[i]];
48
- }
49
- return t;
50
- };
51
- var __read = (this && this.__read) || function (o, n) {
52
- var m = typeof Symbol === "function" && o[Symbol.iterator];
53
- if (!m) return o;
54
- var i = m.call(o), r, ar = [], e;
55
- try {
56
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
57
- }
58
- catch (error) { e = { error: error }; }
59
- finally {
60
- try {
61
- if (r && !r.done && (m = i["return"])) m.call(i);
62
- }
63
- finally { if (e) throw e.error; }
64
- }
65
- return ar;
66
- };
67
- Object.defineProperty(exports, "__esModule", { value: true });
68
- var knowledge_widget_ui_1 = require("@telia-ace/knowledge-widget-ui");
69
- var widget_utilities_1 = require("@telia-ace/widget-utilities");
70
- var react_1 = __importStar(require("react"));
71
- var styled_components_1 = __importStar(require("styled-components"));
72
- var NotificationList = function (_a) {
73
- var className = _a.className, other = __rest(_a, ["className"]);
74
- var _b = __read((0, react_1.useState)(null), 2), expanded = _b[0], setExpanded = _b[1];
75
- var container = (0, knowledge_widget_ui_1.useContainer)();
76
- var _c = (0, knowledge_widget_ui_1.useProperties)(), showHeader = _c.showHeader, notificationList = _c.notificationList, _d = _c.loading, loading = _d === void 0 ? false : _d;
77
- var _e = notificationList || {}, id = _e.id, title = _e.title, symbol = _e.symbol, _f = _e.notifications, notifications = _f === void 0 ? [] : _f, _g = _e.defaultHeaderOptions, defaultHeaderOptions = _g === void 0 ? { visible: true } : _g;
78
- if (!notifications.length && !loading) {
79
- return (0, knowledge_widget_ui_1.createEmptyComponent)(container, __assign(__assign({}, other), { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-notification-list') }));
80
- }
81
- return (react_1.default.createElement(StyledItemList, __assign({}, other, { "data-loading": loading, "data-show-header": typeof showHeader === 'boolean' ? showHeader : defaultHeaderOptions.visible, className: (0, widget_utilities_1.appendClassNames)(className, 'humany-notification-list'), "data-notification-category": id, header: title, symbol: symbol, items: notifications, renderItem: function (_a) {
82
- var id = _a.id, title = _a.title, body = _a.body, modified = _a.modified, expandable = _a.expandable;
83
- return (react_1.default.createElement(StyledItem, { key: id, "data-notification": id, "data-expanded": expandable ? expanded === id : true }, expandable ? (react_1.default.createElement(react_1.default.Fragment, null,
84
- react_1.default.createElement(StyledButton, { title: title, "aria-label": title, "aria-expanded": expanded === id, onClick: function () { return setExpanded(expanded === id ? null : id); } },
85
- react_1.default.createElement("span", null, title),
86
- react_1.default.createElement(StyledSymbolBadge, { size: 11, symbol: {
87
- type: 'Svg',
88
- content: "caret-".concat(expanded === id ? 'up' : 'down'),
89
- } })),
90
- react_1.default.createElement(StyledParagraph, { html: body }),
91
- modified && (react_1.default.createElement(StyledTimestamp, { format: knowledge_widget_ui_1.DateFormats.YYYY_MM_DD, timestamp: modified })))) : (react_1.default.createElement(StyledParagraph, { html: body }))));
92
- } }),
93
- react_1.default.createElement(knowledge_widget_ui_1.Loader, { loading: loading })));
94
- };
95
- var StyledButton = (0, styled_components_1.default)(knowledge_widget_ui_1.Button)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n text-align: left;\n svg,\n i {\n color: ", ";\n }\n span {\n color: ", ";\n font-size: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n flex: 1;\n white-space: nowrap;\n }\n &:focus {\n ", ";\n }\n"], ["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n text-align: left;\n svg,\n i {\n color: ", ";\n }\n span {\n color: ", ";\n font-size: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n flex: 1;\n white-space: nowrap;\n }\n &:focus {\n ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) {
96
- var _a, _b;
97
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n span {\n color: ", ";\n text-decoration: underline;\n }\n "], ["\n ", "\n span {\n color: ", ";\n text-decoration: underline;\n }\n "])), knowledge_widget_ui_1.borderTabStyle, (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.primary);
98
- });
99
- var StyledItemList = (0, styled_components_1.default)(knowledge_widget_ui_1.ItemList)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n overflow: hidden;\n justify-content: flex-start;\n padding: ", ";\n ", "\n\n @media (hover: hover) {\n button:hover {\n text-decoration: underline;\n }\n }\n"], ["\n ", "\n ", "\n ", "\n overflow: hidden;\n justify-content: flex-start;\n padding: ", ";\n ", "\n\n @media (hover: hover) {\n button:hover {\n text-decoration: underline;\n }\n }\n"])), knowledge_widget_ui_1.loadingOpacity, knowledge_widget_ui_1.contentBox, knowledge_widget_ui_1.itemList, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) {
100
- return !p['data-show-header'] && (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n > div {\n ", "\n }\n "], ["\n > div {\n ", "\n }\n "])), (0, knowledge_widget_ui_1.headingElement)('h1', (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])))));
101
- });
102
- var StyledParagraph = (0, styled_components_1.default)(knowledge_widget_ui_1.Paragraph)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n font-weight: 300;\n\n p {\n white-space: normal;\n }\n"], ["\n ", "\n font-weight: 300;\n\n p {\n white-space: normal;\n }\n"])), knowledge_widget_ui_1.genericHtml);
103
- var StyledItem = styled_components_1.default.li(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", " {\n display: none;\n &:not(:only-child) {\n ", "\n }\n }\n\n ", "\n\n > span {\n display: block;\n font-weight: 300;\n color: ", ";\n }\n"], ["\n ", " {\n display: none;\n &:not(:only-child) {\n ", "\n }\n }\n\n ", "\n\n > span {\n display: block;\n font-weight: 300;\n color: ", ";\n }\n"])), StyledParagraph, function (p) {
104
- var _a, _b, _c;
105
- return ((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.cardinal) &&
106
- ((_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.normal) && (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: ", " 0;\n "], ["\n margin: ", " 0;\n "])), (_c = p.theme.sizes) === null || _c === void 0 ? void 0 : _c.normal);
107
- }, function (p) {
108
- return p['data-expanded'] && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n ", " {\n display: block;\n }\n "], ["\n ", " {\n display: block;\n }\n "])), StyledParagraph);
109
- }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; });
110
- var StyledSymbolBadge = (0, styled_components_1.default)(knowledge_widget_ui_1.SymbolBadge)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin: 0 0 0 ", ";\n line {\n stroke: ", ";\n }\n"], ["\n margin: 0 0 0 ", ";\n line {\n stroke: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; });
111
- var StyledTimestamp = (0, styled_components_1.default)(knowledge_widget_ui_1.Timestamp)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", ";\n font-weight: 300;\n"], ["\n font-size: ", ";\n font-weight: 300;\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.small; });
112
- exports.default = NotificationList;
113
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
package/lib-esm/index.js DELETED
@@ -1,2 +0,0 @@
1
- import NotificationListComponent from './notification-list-component';
2
- export default NotificationListComponent;
@@ -1,93 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __read = (this && this.__read) || function (o, n) {
13
- var m = typeof Symbol === "function" && o[Symbol.iterator];
14
- if (!m) return o;
15
- var i = m.call(o), r, ar = [], e;
16
- try {
17
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
- }
19
- catch (error) { e = { error: error }; }
20
- finally {
21
- try {
22
- if (r && !r.done && (m = i["return"])) m.call(i);
23
- }
24
- finally { if (e) throw e.error; }
25
- }
26
- return ar;
27
- };
28
- import { createEventSubscriber, extendComponent, } from '@telia-ace/knowledge-widget-core';
29
- import { DataType } from '@telia-ace/knowledge-widget-types-grid';
30
- import { createReactComponent } from '@telia-ace/knowledge-widget-ui';
31
- export var NotificationListComponent = function (container) {
32
- var events = container.get('$widget').events;
33
- var _a = __read(createEventSubscriber(events), 2), subscribe = _a[0], unsubscribe = _a[1];
34
- return createReactComponent(container, 'notification-list', import('./notification-list'), function (component) {
35
- var fetch = function (params) {
36
- component.writeProperties(__assign(__assign({}, component.properties()), { loading: true, error: undefined, notificationList: undefined }));
37
- component.actions.dispatch('fetch', { params: params });
38
- };
39
- component.actions.create('fetch', function (_a) {
40
- var error = _a.error, notificationLists = _a.notificationLists;
41
- if (error) {
42
- return component.actions.dispatch('fetched', {
43
- error: error,
44
- loading: true,
45
- notificationList: undefined,
46
- });
47
- }
48
- var _b = component.properties(), category = _b.category, notificationList = _b.notificationList;
49
- var properties = {
50
- notificationList: notificationLists.find(function (n) { return n.id === category; }) || notificationList,
51
- };
52
- return component.actions.dispatch('fetched', __assign(__assign({}, properties), { loading: true }));
53
- });
54
- component.actions.create('fetched', function (input) {
55
- return component.writeProperties(__assign(__assign({}, input), { loading: false }));
56
- });
57
- container.getAsync('router').then(function (router) {
58
- var params = router.getRouteData().params;
59
- fetch(params);
60
- });
61
- subscribe('router:changed', function (event, _a) {
62
- var current = _a.current;
63
- fetch(current.routeData.params);
64
- });
65
- })
66
- .then(function () {
67
- return extendComponent(container, 'notification-list', function (component) {
68
- component.actions.watch('notification-list.fetch', function (input, next) {
69
- return container
70
- .getAsync('dataClient')
71
- .then(function (dataClient) {
72
- return dataClient.fetch(DataType.NotificationLists, {
73
- categories: [
74
- input.params.guideCategory,
75
- input.params.contactCategory,
76
- ].filter(function (c) { return !!c; }),
77
- searchPhrase: input.params.phrase,
78
- });
79
- })
80
- .then(next)
81
- .catch(function (error) {
82
- if (error) {
83
- return next(error);
84
- }
85
- });
86
- });
87
- });
88
- })
89
- .then(function () {
90
- unsubscribe();
91
- });
92
- };
93
- export default NotificationListComponent;
@@ -1,88 +0,0 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- var __assign = (this && this.__assign) || function () {
6
- __assign = Object.assign || function(t) {
7
- for (var s, i = 1, n = arguments.length; i < n; i++) {
8
- s = arguments[i];
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
- t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
- var __rest = (this && this.__rest) || function (s, e) {
17
- var t = {};
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
- t[p] = s[p];
20
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
- t[p[i]] = s[p[i]];
24
- }
25
- return t;
26
- };
27
- var __read = (this && this.__read) || function (o, n) {
28
- var m = typeof Symbol === "function" && o[Symbol.iterator];
29
- if (!m) return o;
30
- var i = m.call(o), r, ar = [], e;
31
- try {
32
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33
- }
34
- catch (error) { e = { error: error }; }
35
- finally {
36
- try {
37
- if (r && !r.done && (m = i["return"])) m.call(i);
38
- }
39
- finally { if (e) throw e.error; }
40
- }
41
- return ar;
42
- };
43
- import { borderTabStyle, Button, contentBox, createEmptyComponent, DateFormats, genericHtml, headingElement, ItemList, itemList, Loader, loadingOpacity, Paragraph, SymbolBadge, Timestamp, useContainer, useProperties, } from '@telia-ace/knowledge-widget-ui';
44
- import { appendClassNames } from '@telia-ace/widget-utilities';
45
- import React, { useState } from 'react';
46
- import styled, { css } from 'styled-components';
47
- var NotificationList = function (_a) {
48
- var className = _a.className, other = __rest(_a, ["className"]);
49
- var _b = __read(useState(null), 2), expanded = _b[0], setExpanded = _b[1];
50
- var container = useContainer();
51
- var _c = useProperties(), showHeader = _c.showHeader, notificationList = _c.notificationList, _d = _c.loading, loading = _d === void 0 ? false : _d;
52
- var _e = notificationList || {}, id = _e.id, title = _e.title, symbol = _e.symbol, _f = _e.notifications, notifications = _f === void 0 ? [] : _f, _g = _e.defaultHeaderOptions, defaultHeaderOptions = _g === void 0 ? { visible: true } : _g;
53
- if (!notifications.length && !loading) {
54
- return createEmptyComponent(container, __assign(__assign({}, other), { className: appendClassNames(className, 'humany-notification-list') }));
55
- }
56
- return (React.createElement(StyledItemList, __assign({}, other, { "data-loading": loading, "data-show-header": typeof showHeader === 'boolean' ? showHeader : defaultHeaderOptions.visible, className: appendClassNames(className, 'humany-notification-list'), "data-notification-category": id, header: title, symbol: symbol, items: notifications, renderItem: function (_a) {
57
- var id = _a.id, title = _a.title, body = _a.body, modified = _a.modified, expandable = _a.expandable;
58
- return (React.createElement(StyledItem, { key: id, "data-notification": id, "data-expanded": expandable ? expanded === id : true }, expandable ? (React.createElement(React.Fragment, null,
59
- React.createElement(StyledButton, { title: title, "aria-label": title, "aria-expanded": expanded === id, onClick: function () { return setExpanded(expanded === id ? null : id); } },
60
- React.createElement("span", null, title),
61
- React.createElement(StyledSymbolBadge, { size: 11, symbol: {
62
- type: 'Svg',
63
- content: "caret-".concat(expanded === id ? 'up' : 'down'),
64
- } })),
65
- React.createElement(StyledParagraph, { html: body }),
66
- modified && (React.createElement(StyledTimestamp, { format: DateFormats.YYYY_MM_DD, timestamp: modified })))) : (React.createElement(StyledParagraph, { html: body }))));
67
- } }),
68
- React.createElement(Loader, { loading: loading })));
69
- };
70
- var StyledButton = styled(Button)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n text-align: left;\n svg,\n i {\n color: ", ";\n }\n span {\n color: ", ";\n font-size: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n flex: 1;\n white-space: nowrap;\n }\n &:focus {\n ", ";\n }\n"], ["\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n text-align: left;\n svg,\n i {\n color: ", ";\n }\n span {\n color: ", ";\n font-size: ", ";\n overflow: hidden;\n text-overflow: ellipsis;\n flex: 1;\n white-space: nowrap;\n }\n &:focus {\n ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) {
71
- var _a, _b;
72
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n span {\n color: ", ";\n text-decoration: underline;\n }\n "], ["\n ", "\n span {\n color: ", ";\n text-decoration: underline;\n }\n "])), borderTabStyle, (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.primary);
73
- });
74
- var StyledItemList = styled(ItemList)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n overflow: hidden;\n justify-content: flex-start;\n padding: ", ";\n ", "\n\n @media (hover: hover) {\n button:hover {\n text-decoration: underline;\n }\n }\n"], ["\n ", "\n ", "\n ", "\n overflow: hidden;\n justify-content: flex-start;\n padding: ", ";\n ", "\n\n @media (hover: hover) {\n button:hover {\n text-decoration: underline;\n }\n }\n"])), loadingOpacity, contentBox, itemList, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) {
75
- return !p['data-show-header'] && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n > div {\n ", "\n }\n "], ["\n > div {\n ", "\n }\n "])), headingElement('h1', css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])))));
76
- });
77
- var StyledParagraph = styled(Paragraph)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n font-weight: 300;\n\n p {\n white-space: normal;\n }\n"], ["\n ", "\n font-weight: 300;\n\n p {\n white-space: normal;\n }\n"])), genericHtml);
78
- var StyledItem = styled.li(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n ", " {\n display: none;\n &:not(:only-child) {\n ", "\n }\n }\n\n ", "\n\n > span {\n display: block;\n font-weight: 300;\n color: ", ";\n }\n"], ["\n ", " {\n display: none;\n &:not(:only-child) {\n ", "\n }\n }\n\n ", "\n\n > span {\n display: block;\n font-weight: 300;\n color: ", ";\n }\n"])), StyledParagraph, function (p) {
79
- var _a, _b, _c;
80
- return ((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.cardinal) &&
81
- ((_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.normal) && css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: ", " 0;\n "], ["\n margin: ", " 0;\n "])), (_c = p.theme.sizes) === null || _c === void 0 ? void 0 : _c.normal);
82
- }, function (p) {
83
- return p['data-expanded'] && css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n ", " {\n display: block;\n }\n "], ["\n ", " {\n display: block;\n }\n "])), StyledParagraph);
84
- }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; });
85
- var StyledSymbolBadge = styled(SymbolBadge)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin: 0 0 0 ", ";\n line {\n stroke: ", ";\n }\n"], ["\n margin: 0 0 0 ", ";\n line {\n stroke: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; });
86
- var StyledTimestamp = styled(Timestamp)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", ";\n font-weight: 300;\n"], ["\n font-size: ", ";\n font-weight: 300;\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.small; });
87
- export default NotificationList;
88
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;