@telia-ace/knowledge-widget-components-notification-row 1.0.4 → 1.0.9
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/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/notification-row-component.d.ts +0 -0
- package/{lib-esm → dist}/notification-row.d.ts +0 -0
- package/dist/notification-row.js +344 -0
- package/dist/notification-row.js.map +1 -0
- package/package.json +12 -13
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -7
- package/lib/notification-row-component.d.ts +0 -15
- package/lib/notification-row-component.js +0 -138
- package/lib/notification-row.d.ts +0 -6
- package/lib/notification-row.js +0 -207
- package/lib-esm/index.js +0 -2
- package/lib-esm/notification-row-component.js +0 -111
- package/lib-esm/notification-row.js +0 -182
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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 NotificationRowComponent = (container) => {
|
|
24
|
+
const { events } = container.get("$widget");
|
|
25
|
+
const [subscribe, unsubscribe] = createEventSubscriber(events);
|
|
26
|
+
return createReactComponent(container, "notification-row", import("./notification-row.js"), (component) => {
|
|
27
|
+
const fetch = (params) => {
|
|
28
|
+
component.writeProperties(__spreadProps(__spreadValues({}, component.properties()), {
|
|
29
|
+
loading: true,
|
|
30
|
+
error: void 0,
|
|
31
|
+
notifications: []
|
|
32
|
+
}));
|
|
33
|
+
component.actions.dispatch("fetch", { params });
|
|
34
|
+
};
|
|
35
|
+
component.actions.create("fetch", ({
|
|
36
|
+
error,
|
|
37
|
+
topNotifications,
|
|
38
|
+
bottomNotifications,
|
|
39
|
+
middleNotifications
|
|
40
|
+
}) => {
|
|
41
|
+
if (error) {
|
|
42
|
+
return component.actions.dispatch("fetched", {
|
|
43
|
+
error,
|
|
44
|
+
loading: true,
|
|
45
|
+
notifications: []
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
let newNotifications = [];
|
|
49
|
+
const { notifications, types = [] } = component.properties();
|
|
50
|
+
if (types.length) {
|
|
51
|
+
if (types.indexOf("top") > -1) {
|
|
52
|
+
newNotifications = newNotifications.concat(topNotifications);
|
|
53
|
+
}
|
|
54
|
+
if (types.indexOf("middle") > -1) {
|
|
55
|
+
newNotifications = newNotifications.concat(middleNotifications);
|
|
56
|
+
}
|
|
57
|
+
if (types.indexOf("bottom") > -1) {
|
|
58
|
+
newNotifications = newNotifications.concat(bottomNotifications);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
newNotifications = topNotifications;
|
|
62
|
+
}
|
|
63
|
+
return component.actions.dispatch("fetched", {
|
|
64
|
+
notifications: newNotifications.length ? newNotifications : notifications,
|
|
65
|
+
loading: false
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
component.actions.create("fetched", (input) => {
|
|
69
|
+
return component.writeProperties(__spreadProps(__spreadValues({}, input), { loading: false }));
|
|
70
|
+
});
|
|
71
|
+
container.getAsync("router").then((router) => {
|
|
72
|
+
const { params } = router.getRouteData();
|
|
73
|
+
fetch(params);
|
|
74
|
+
});
|
|
75
|
+
subscribe("router:changed", (event, { current }) => {
|
|
76
|
+
fetch(current.routeData.params);
|
|
77
|
+
});
|
|
78
|
+
return () => {
|
|
79
|
+
unsubscribe();
|
|
80
|
+
};
|
|
81
|
+
}).then(() => {
|
|
82
|
+
return extendComponent(container, "notification-row", (component) => {
|
|
83
|
+
component.actions.watch("notification-row.fetch", (input, next) => {
|
|
84
|
+
return container.getAsync("dataClient").then((dataClient) => dataClient.fetch(DataType.RowNotifications, {
|
|
85
|
+
categories: [
|
|
86
|
+
input.params.guideCategory,
|
|
87
|
+
input.params.contactCategory
|
|
88
|
+
].filter((c) => !!c),
|
|
89
|
+
searchPhrase: input.params.phrase
|
|
90
|
+
})).then(next).catch((error) => {
|
|
91
|
+
if (error) {
|
|
92
|
+
return next(error);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}).then(() => {
|
|
98
|
+
unsubscribe();
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
export { NotificationRowComponent as default };
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/notification-row-component.ts"],"sourcesContent":["import {\r\n createEventSubscriber,\r\n extendComponent,\r\n Notification,\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\ntype NotificationType = 'top' | 'middle' | 'bottom';\r\nexport type NotificationRowComponentProps = {\r\n types: NotificationType[];\r\n allowPaging?: boolean;\r\n notifications?: Notification[]; // internal\r\n expandable?: boolean;\r\n pageNextAriaLabel?: string;\r\n pagePreviousAriaLabel?: string;\r\n closeAriaLabel?: string;\r\n expandAriaLabel?: string;\r\n};\r\n\r\ntype FetchResults = NotificationResults & { error: any };\r\n\r\nexport const NotificationRowComponent = (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-row',\r\n import('./notification-row'),\r\n (component) => {\r\n const fetch = (params: { [key: string]: any }) => {\r\n component.writeProperties({\r\n ...component.properties<NotificationRowComponentProps>(),\r\n loading: true,\r\n error: undefined,\r\n notifications: [],\r\n });\r\n component.actions.dispatch('fetch', { params });\r\n };\r\n\r\n component.actions.create(\r\n 'fetch',\r\n ({\r\n error,\r\n topNotifications,\r\n bottomNotifications,\r\n middleNotifications,\r\n }: FetchResults) => {\r\n if (error) {\r\n return component.actions.dispatch('fetched', {\r\n error,\r\n loading: true,\r\n notifications: [],\r\n });\r\n }\r\n\r\n let newNotifications: Notification[] = [];\r\n const { notifications, types = [] } =\r\n component.properties<NotificationRowComponentProps>();\r\n if (types.length) {\r\n if (types.indexOf('top') > -1) {\r\n newNotifications = newNotifications.concat(topNotifications);\r\n }\r\n if (types.indexOf('middle') > -1) {\r\n newNotifications = newNotifications.concat(middleNotifications);\r\n }\r\n if (types.indexOf('bottom') > -1) {\r\n newNotifications = newNotifications.concat(bottomNotifications);\r\n }\r\n } else {\r\n newNotifications = topNotifications;\r\n }\r\n\r\n return component.actions.dispatch('fetched', {\r\n notifications: newNotifications.length ? newNotifications : notifications,\r\n loading: false,\r\n });\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 return () => {\r\n unsubscribe();\r\n };\r\n }\r\n )\r\n .then(() => {\r\n return extendComponent(container, 'notification-row', (component) => {\r\n component.actions.watch('notification-row.fetch', (input, next) => {\r\n return container\r\n .getAsync('dataClient')\r\n .then((dataClient: DataClient) =>\r\n dataClient.fetch(DataType.RowNotifications, {\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 NotificationRowComponent;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBa,MAAA,2BAA2B,CAAC,cAAyB;AAC9D,QAAM,EAAE,WAAmB,UAAU,IAAI,SAAS;AAClD,QAAM,CAAC,WAAW,eAAe,sBAAsB,MAAM;AAE7D,SAAO,qBACH,WACA,oBACA,OAAO,0BACP,CAAC,cAAc;AACL,UAAA,QAAQ,CAAC,WAAmC;AAC9C,gBAAU,gBAAgB,iCACnB,UAAU,WAA0C,IADjC;AAAA,QAEtB,SAAS;AAAA,QACT,OAAO;AAAA,QACP,eAAe,CAAC;AAAA,MAAA,EACnB;AACD,gBAAU,QAAQ,SAAS,SAAS,EAAE,OAAQ,CAAA;AAAA,IAAA;AAGxC,cAAA,QAAQ,OACd,SACA,CAAC;AAAA,MACG;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,UACgB;AAChB,UAAI,OAAO;AACA,eAAA,UAAU,QAAQ,SAAS,WAAW;AAAA,UACzC;AAAA,UACA,SAAS;AAAA,UACT,eAAe,C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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
|
|
File without changes
|
|
@@ -0,0 +1,344 @@
|
|
|
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 { useProperties, useContainer, createEmptyComponent, SymbolBadge, genericHtml, linkTabStyle, borderTabStyle, Html, Button } from "@telia-ace/knowledge-widget-ui";
|
|
33
|
+
import { readStorage, StorageMedium, createStorageWriter, StorageCategory } from "@telia-ace/widget-services";
|
|
34
|
+
import { appendClassNames } from "@telia-ace/widget-utilities";
|
|
35
|
+
import React, { useState, useEffect } from "react";
|
|
36
|
+
import styled, { css } from "styled-components";
|
|
37
|
+
const STORAGE_KEY = "closed-notifications";
|
|
38
|
+
const infocusableHtml = {
|
|
39
|
+
transform: {
|
|
40
|
+
a: (_a) => {
|
|
41
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
42
|
+
return /* @__PURE__ */ React.createElement("a", __spreadProps(__spreadValues({}, props), {
|
|
43
|
+
tabIndex: -1
|
|
44
|
+
}), children);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const NotificationRow = (_c) => {
|
|
49
|
+
var _d = _c, { className } = _d, other = __objRest(_d, ["className"]);
|
|
50
|
+
const {
|
|
51
|
+
types = [],
|
|
52
|
+
allowPaging = true,
|
|
53
|
+
notifications = [],
|
|
54
|
+
expandable = false,
|
|
55
|
+
closeAriaLabel = "",
|
|
56
|
+
pageNextAriaLabel = "",
|
|
57
|
+
pagePreviousAriaLabel = "",
|
|
58
|
+
expandAriaLabel = ""
|
|
59
|
+
} = useProperties();
|
|
60
|
+
const [expanded, setExpanded] = useState(false);
|
|
61
|
+
const [closed, setClosed] = useState([]);
|
|
62
|
+
const [index, setIndex] = useState(0);
|
|
63
|
+
const container = useContainer();
|
|
64
|
+
const [write, setWriter] = useState();
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (container) {
|
|
67
|
+
readStorage(container, STORAGE_KEY, StorageMedium.Session).then((closed2 = []) => setClosed(closed2));
|
|
68
|
+
createStorageWriter(container, STORAGE_KEY, StorageCategory.Functional).then((writer) => setWriter(() => writer));
|
|
69
|
+
}
|
|
70
|
+
}, [container]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (container) {
|
|
73
|
+
readStorage(container, STORAGE_KEY, StorageMedium.Session).then((storedClosed = []) => {
|
|
74
|
+
closed.forEach((id) => storedClosed.indexOf(id) === -1 && storedClosed.push(id));
|
|
75
|
+
if (write) {
|
|
76
|
+
write(storedClosed);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}, [closed, container, write]);
|
|
81
|
+
const filtered = notifications.filter(({ id }) => closed.indexOf(id) === -1);
|
|
82
|
+
const { length } = filtered;
|
|
83
|
+
if (!filtered.length) {
|
|
84
|
+
return createEmptyComponent(container, __spreadProps(__spreadValues({}, other), {
|
|
85
|
+
className: appendClassNames(className, "humany-notification-row")
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
if (allowPaging) {
|
|
89
|
+
const notification = filtered[index] || filtered[index + 1] || filtered[index - 1];
|
|
90
|
+
if (!notification) {
|
|
91
|
+
return createEmptyComponent(container, __spreadProps(__spreadValues({}, other), {
|
|
92
|
+
className: appendClassNames(className, "humany-notification-row")
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
const { id, body } = notification || {};
|
|
96
|
+
const toggleExpand = () => setExpanded(!expanded);
|
|
97
|
+
return /* @__PURE__ */ React.createElement(Wrapper, __spreadProps(__spreadValues({}, other), {
|
|
98
|
+
"aria-expanded": expandable ? expanded : true,
|
|
99
|
+
"aria-label": expandAriaLabel,
|
|
100
|
+
tabIndex: expandable ? 0 : -1,
|
|
101
|
+
className: appendClassNames(className, "humany-notification-row"),
|
|
102
|
+
"data-pageable": length > 1,
|
|
103
|
+
"data-types": types,
|
|
104
|
+
"data-allow-paging": allowPaging,
|
|
105
|
+
"data-expandable": expandable,
|
|
106
|
+
onKeyDown: (e) => {
|
|
107
|
+
if (e.key === "Enter") {
|
|
108
|
+
toggleExpand();
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
onClick: toggleExpand
|
|
112
|
+
}), /* @__PURE__ */ React.createElement(CloseButton, {
|
|
113
|
+
"aria-label": closeAriaLabel,
|
|
114
|
+
onClick: () => {
|
|
115
|
+
setIndex(filtered.indexOf(notification));
|
|
116
|
+
setClosed([...closed, id]);
|
|
117
|
+
}
|
|
118
|
+
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
119
|
+
symbol: { type: "Svg", content: "close" }
|
|
120
|
+
})), /* @__PURE__ */ React.createElement(StyledHtml, {
|
|
121
|
+
htmlParseInstruction: !expandable || expanded ? void 0 : infocusableHtml,
|
|
122
|
+
"data-pageable": length > 1,
|
|
123
|
+
"data-notification": id,
|
|
124
|
+
"data-expandable": expandable,
|
|
125
|
+
"data-expanded": expanded,
|
|
126
|
+
html: body
|
|
127
|
+
}), length > 1 && /* @__PURE__ */ React.createElement(Pager, null, /* @__PURE__ */ React.createElement(StyledButton, {
|
|
128
|
+
"aria-label": pagePreviousAriaLabel,
|
|
129
|
+
"data-disabled": index === 0,
|
|
130
|
+
onClick: (e) => {
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
if (index > 0) {
|
|
133
|
+
setIndex(index - 1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, /* @__PURE__ */ React.createElement(StyledSymbolBadge, {
|
|
137
|
+
size: 10,
|
|
138
|
+
symbol: { type: "Svg", content: "caret-left" }
|
|
139
|
+
})), /* @__PURE__ */ React.createElement("span", null, index + 1, "/", length), /* @__PURE__ */ React.createElement(StyledButton, {
|
|
140
|
+
"aria-label": pageNextAriaLabel,
|
|
141
|
+
"data-disabled": index + 1 >= length,
|
|
142
|
+
onClick: (e) => {
|
|
143
|
+
e.stopPropagation();
|
|
144
|
+
if (index < length - 1) {
|
|
145
|
+
setIndex(index + 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, /* @__PURE__ */ React.createElement(StyledSymbolBadge, {
|
|
149
|
+
size: 10,
|
|
150
|
+
symbol: { type: "Svg", content: "caret-right" }
|
|
151
|
+
}))));
|
|
152
|
+
}
|
|
153
|
+
return /* @__PURE__ */ React.createElement(Wrapper, __spreadProps(__spreadValues({}, other), {
|
|
154
|
+
className: appendClassNames(className, "humany-notification-row"),
|
|
155
|
+
"data-pageable": false,
|
|
156
|
+
"data-types": types,
|
|
157
|
+
"data-allow-paging": false
|
|
158
|
+
}), filtered.map((notification) => {
|
|
159
|
+
if (!notification) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const { id, body } = notification;
|
|
163
|
+
return /* @__PURE__ */ React.createElement(StyledHtml, {
|
|
164
|
+
key: id,
|
|
165
|
+
"data-pageable": false,
|
|
166
|
+
"data-expandable": expandable,
|
|
167
|
+
"data-expanded": expanded,
|
|
168
|
+
"data-notification": id,
|
|
169
|
+
html: body
|
|
170
|
+
});
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
const Wrapper = styled.div`
|
|
174
|
+
${genericHtml}
|
|
175
|
+
padding: ${(p) => p.theme.sizes.normal} ${(p) => {
|
|
176
|
+
var _a;
|
|
177
|
+
return ((_a = p.theme.sizes) == null ? void 0 : _a.cardinal) * 12;
|
|
178
|
+
}}px;
|
|
179
|
+
background-color: ${(p) => {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
if (p["data-types"].length) {
|
|
182
|
+
if (p["data-types"].indexOf("top") > -1) {
|
|
183
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.warning;
|
|
184
|
+
}
|
|
185
|
+
if (p["data-types"].indexOf("bottom") > -1) {
|
|
186
|
+
return "transparent";
|
|
187
|
+
}
|
|
188
|
+
return (_b = p.theme.colors) == null ? void 0 : _b.primary;
|
|
189
|
+
}
|
|
190
|
+
return (_c = p.theme.colors) == null ? void 0 : _c.warning;
|
|
191
|
+
}};
|
|
192
|
+
color: ${(p) => {
|
|
193
|
+
var _a;
|
|
194
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
195
|
+
}};
|
|
196
|
+
border-radius: ${(p) => p.theme.borderRadius};
|
|
197
|
+
text-align: center;
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
position: relative;
|
|
201
|
+
cursor: ${(p) => p["data-expandable"] ? "pointer" : "default"};
|
|
202
|
+
overflow: hidden;
|
|
203
|
+
|
|
204
|
+
i {
|
|
205
|
+
color: ${(p) => {
|
|
206
|
+
var _a;
|
|
207
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
208
|
+
}};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
a {
|
|
212
|
+
color: ${(p) => {
|
|
213
|
+
var _a;
|
|
214
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.link;
|
|
215
|
+
}};
|
|
216
|
+
&:focus {
|
|
217
|
+
${(p) => {
|
|
218
|
+
var _a;
|
|
219
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && linkTabStyle;
|
|
220
|
+
}}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
${(p) => {
|
|
225
|
+
var _a;
|
|
226
|
+
return !p["data-allow-paging"] && css`
|
|
227
|
+
flex-wrap: wrap;
|
|
228
|
+
|
|
229
|
+
> div {
|
|
230
|
+
min-width: 100%;
|
|
231
|
+
margin: ${((_a = p.theme.sizes) == null ? void 0 : _a.cardinal) * 2}px;
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
234
|
+
}};
|
|
235
|
+
|
|
236
|
+
${(p) => {
|
|
237
|
+
var _a;
|
|
238
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
239
|
+
&:focus {
|
|
240
|
+
${StyledHtml} {
|
|
241
|
+
${borderTabStyle}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
245
|
+
}}
|
|
246
|
+
`;
|
|
247
|
+
const StyledHtml = styled(Html)`
|
|
248
|
+
flex: 1;
|
|
249
|
+
font-size: ${(p) => {
|
|
250
|
+
var _a;
|
|
251
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
252
|
+
}};
|
|
253
|
+
line-height: 1.6em;
|
|
254
|
+
font-weight: 300;
|
|
255
|
+
|
|
256
|
+
${(p) => p["data-expandable"] && !p["data-expanded"] && css`
|
|
257
|
+
max-width: 100%;
|
|
258
|
+
|
|
259
|
+
p {
|
|
260
|
+
display: none;
|
|
261
|
+
&:first-child {
|
|
262
|
+
display: block;
|
|
263
|
+
margin-bottom: 0;
|
|
264
|
+
white-space: nowrap;
|
|
265
|
+
overflow: hidden;
|
|
266
|
+
text-overflow: ellipsis;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
`}
|
|
270
|
+
`;
|
|
271
|
+
const Pager = styled.div`
|
|
272
|
+
text-align: center;
|
|
273
|
+
width: 100%;
|
|
274
|
+
span {
|
|
275
|
+
font-size: ${(p) => {
|
|
276
|
+
var _a;
|
|
277
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.small;
|
|
278
|
+
}};
|
|
279
|
+
display: inline-block;
|
|
280
|
+
width: 30px;
|
|
281
|
+
text-align: center;
|
|
282
|
+
}
|
|
283
|
+
`;
|
|
284
|
+
const StyledButton = styled(Button)`
|
|
285
|
+
background-color: transparent;
|
|
286
|
+
border: none;
|
|
287
|
+
cursor: pointer;
|
|
288
|
+
transition: opacity 200ms ease-out;
|
|
289
|
+
justify-self: flex-end;
|
|
290
|
+
align-self: flex-start;
|
|
291
|
+
padding: ${(p) => {
|
|
292
|
+
var _a;
|
|
293
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
294
|
+
}} svg {
|
|
295
|
+
display: block;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
&:focus {
|
|
299
|
+
${(p) => {
|
|
300
|
+
var _a;
|
|
301
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && borderTabStyle;
|
|
302
|
+
}}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
${(p) => p["data-disabled"] ? css`
|
|
306
|
+
opacity: 0.8;
|
|
307
|
+
` : css`
|
|
308
|
+
@media (hover) {
|
|
309
|
+
&:hover {
|
|
310
|
+
opacity: 0.5;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
`}
|
|
314
|
+
`;
|
|
315
|
+
const CloseButton = styled(StyledButton)`
|
|
316
|
+
position: absolute;
|
|
317
|
+
top: 7.5px;
|
|
318
|
+
right: 7.5px;
|
|
319
|
+
width: 25px;
|
|
320
|
+
height: auto;
|
|
321
|
+
padding: ${(p) => {
|
|
322
|
+
var _a, _b;
|
|
323
|
+
return `calc(${(_a = p.theme.sizes) == null ? void 0 : _a.small}/2) ${(_b = p.theme.sizes) == null ? void 0 : _b.small}`;
|
|
324
|
+
}} svg {
|
|
325
|
+
vertical-align: middle;
|
|
326
|
+
line,
|
|
327
|
+
path {
|
|
328
|
+
stroke: ${(p) => {
|
|
329
|
+
var _a;
|
|
330
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
331
|
+
}};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
`;
|
|
335
|
+
const StyledSymbolBadge = styled(SymbolBadge)`
|
|
336
|
+
line {
|
|
337
|
+
stroke: #ffffff;
|
|
338
|
+
}
|
|
339
|
+
`;
|
|
340
|
+
styled.div`
|
|
341
|
+
display: none;
|
|
342
|
+
`;
|
|
343
|
+
export { NotificationRow as default };
|
|
344
|
+
//# sourceMappingURL=notification-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-row.js","sources":["../src/notification-row.tsx"],"sourcesContent":["import {\r\n borderTabStyle,\r\n Button,\r\n createEmptyComponent,\r\n genericHtml,\r\n Html,\r\n linkTabStyle,\r\n SymbolBadge,\r\n useContainer,\r\n useProperties,\r\n} from '@telia-ace/knowledge-widget-ui';\r\nimport {\r\n createStorageWriter,\r\n readStorage,\r\n StorageCategory,\r\n StorageMedium,\r\n StorageWriter,\r\n} from '@telia-ace/widget-services';\r\nimport { appendClassNames } from '@telia-ace/widget-utilities';\r\nimport React, { useEffect, useState } from 'react';\r\nimport styled, { css } from 'styled-components';\r\nimport { NotificationRowComponentProps } from './notification-row-component';\r\n\r\ntype Props = {\r\n className: string;\r\n};\r\n\r\nconst STORAGE_KEY = 'closed-notifications';\r\n\r\nconst infocusableHtml = {\r\n transform: {\r\n a: ({ children, ...props }: React.ComponentProps<'a'>) => (\r\n <a {...props} tabIndex={-1}>\r\n {children}\r\n </a>\r\n ),\r\n },\r\n};\r\n\r\nconst NotificationRow: React.SFC<Props> = ({ className, ...other }) => {\r\n const {\r\n types = [],\r\n allowPaging = true,\r\n notifications = [],\r\n expandable = false,\r\n closeAriaLabel = '',\r\n pageNextAriaLabel = '',\r\n pagePreviousAriaLabel = '',\r\n expandAriaLabel = '',\r\n } = useProperties<NotificationRowComponentProps>();\r\n const [expanded, setExpanded] = useState(false);\r\n const [closed, setClosed] = useState<string[]>([]);\r\n const [index, setIndex] = useState(0);\r\n\r\n const container = useContainer();\r\n const [write, setWriter] = useState<StorageWriter | undefined>();\r\n\r\n useEffect(() => {\r\n if (container) {\r\n readStorage<string[]>(container, STORAGE_KEY, StorageMedium.Session).then(\r\n (closed = []) => setClosed(closed)\r\n );\r\n\r\n createStorageWriter(container, STORAGE_KEY, StorageCategory.Functional).then((writer) =>\r\n setWriter(() => writer)\r\n );\r\n }\r\n }, [container]);\r\n\r\n useEffect(() => {\r\n if (container) {\r\n readStorage<string[]>(container, STORAGE_KEY, StorageMedium.Session).then(\r\n (storedClosed = []) => {\r\n closed.forEach(\r\n (id) => storedClosed.indexOf(id) === -1 && storedClosed.push(id)\r\n );\r\n if (write) {\r\n write(storedClosed);\r\n }\r\n }\r\n );\r\n }\r\n }, [closed, container, write]);\r\n\r\n const filtered = notifications.filter(({ id }) => closed.indexOf(id) === -1);\r\n\r\n const { length } = filtered;\r\n\r\n if (!filtered.length) {\r\n return createEmptyComponent(container, {\r\n ...other,\r\n className: appendClassNames(className, 'humany-notification-row'),\r\n });\r\n }\r\n\r\n if (allowPaging) {\r\n const notification = filtered[index] || filtered[index + 1] || filtered[index - 1];\r\n\r\n if (!notification) {\r\n return createEmptyComponent(container, {\r\n ...other,\r\n className: appendClassNames(className, 'humany-notification-row'),\r\n });\r\n }\r\n\r\n const { id, body } = notification || {};\r\n const toggleExpand = () => setExpanded(!expanded);\r\n\r\n return (\r\n <Wrapper\r\n {...other}\r\n aria-expanded={expandable ? expanded : true}\r\n aria-label={expandAriaLabel}\r\n tabIndex={expandable ? 0 : -1}\r\n className={appendClassNames(className, 'humany-notification-row')}\r\n data-pageable={length > 1}\r\n data-types={types}\r\n data-allow-paging={allowPaging}\r\n data-expandable={expandable}\r\n onKeyDown={(e: React.KeyboardEvent) => {\r\n if (e.key === 'Enter') {\r\n toggleExpand();\r\n }\r\n }}\r\n onClick={toggleExpand}\r\n >\r\n <CloseButton\r\n aria-label={closeAriaLabel}\r\n onClick={() => {\r\n setIndex(filtered.indexOf(notification));\r\n setClosed([...closed, id]);\r\n }}\r\n >\r\n <SymbolBadge symbol={{ type: 'Svg', content: 'close' }} />\r\n </CloseButton>\r\n <StyledHtml\r\n htmlParseInstruction={!expandable || expanded ? undefined : infocusableHtml}\r\n data-pageable={length > 1}\r\n data-notification={id}\r\n data-expandable={expandable}\r\n data-expanded={expanded}\r\n html={body}\r\n />\r\n {length > 1 && (\r\n <Pager>\r\n <StyledButton\r\n aria-label={pagePreviousAriaLabel}\r\n data-disabled={index === 0}\r\n onClick={(e) => {\r\n e.stopPropagation();\r\n if (index > 0) {\r\n setIndex(index - 1);\r\n }\r\n }}\r\n >\r\n <StyledSymbolBadge\r\n size={10}\r\n symbol={{ type: 'Svg', content: 'caret-left' }}\r\n />\r\n </StyledButton>\r\n <span>\r\n {index + 1}/{length}\r\n </span>\r\n <StyledButton\r\n aria-label={pageNextAriaLabel}\r\n data-disabled={index + 1 >= length}\r\n onClick={(e) => {\r\n e.stopPropagation();\r\n if (index < length - 1) {\r\n setIndex(index + 1);\r\n }\r\n }}\r\n >\r\n <StyledSymbolBadge\r\n size={10}\r\n symbol={{ type: 'Svg', content: 'caret-right' }}\r\n />\r\n </StyledButton>\r\n </Pager>\r\n )}\r\n </Wrapper>\r\n );\r\n }\r\n\r\n return (\r\n <Wrapper\r\n {...other}\r\n className={appendClassNames(className, 'humany-notification-row')}\r\n data-pageable={false}\r\n data-types={types}\r\n data-allow-paging={false}\r\n >\r\n {filtered.map((notification) => {\r\n if (!notification) {\r\n return null;\r\n }\r\n\r\n const { id, body } = notification;\r\n\r\n return (\r\n <StyledHtml\r\n key={id}\r\n data-pageable={false}\r\n data-expandable={expandable}\r\n data-expanded={expanded}\r\n data-notification={id}\r\n html={body}\r\n />\r\n );\r\n })}\r\n </Wrapper>\r\n );\r\n};\r\n\r\nconst Wrapper = styled.div<{ 'data-types': string[]; 'data-allow-paging': boolean } & any>`\r\n ${genericHtml}\r\n padding: ${(p) => p.theme.sizes.normal} ${(p) => p.theme.sizes?.cardinal * 12}px;\r\n background-color: ${(p) => {\r\n if (p['data-types'].length) {\r\n if (p['data-types'].indexOf('top') > -1) {\r\n return p.theme.colors?.warning;\r\n }\r\n if (p['data-types'].indexOf('bottom') > -1) {\r\n return 'transparent';\r\n }\r\n\r\n return p.theme.colors?.primary;\r\n }\r\n return p.theme.colors?.warning;\r\n }};\r\n color: ${(p) => p.theme.colors?.text};\r\n border-radius: ${(p) => p.theme.borderRadius};\r\n text-align: center;\r\n display: flex;\r\n flex-direction: column;\r\n position: relative;\r\n cursor: ${(p) => (p['data-expandable'] ? 'pointer' : 'default')};\r\n overflow: hidden;\r\n\r\n i {\r\n color: ${(p) => p.theme.colors?.text};\r\n }\r\n\r\n a {\r\n color: ${(p) => p.theme.colors?.link};\r\n &:focus {\r\n ${(p) => p.theme.accessibility?.isTabbing && linkTabStyle}\r\n }\r\n }\r\n\r\n ${(p) =>\r\n !p['data-allow-paging'] &&\r\n css`\r\n flex-wrap: wrap;\r\n\r\n > div {\r\n min-width: 100%;\r\n margin: ${p.theme.sizes?.cardinal * 2}px;\r\n }\r\n `};\r\n\r\n ${(p) =>\r\n p.theme.accessibility?.isTabbing &&\r\n css`\r\n &:focus {\r\n ${StyledHtml} {\r\n ${borderTabStyle}\r\n }\r\n }\r\n `}\r\n`;\r\n\r\nconst StyledHtml = styled(Html)<{\r\n 'data-pageable': boolean;\r\n 'data-expandable': boolean;\r\n 'data-expanded': boolean;\r\n}>`\r\n flex: 1;\r\n font-size: ${(p) => p.theme.fonts?.normal};\r\n line-height: 1.6em;\r\n font-weight: 300;\r\n\r\n ${(p) =>\r\n p['data-expandable'] &&\r\n !p['data-expanded'] &&\r\n css`\r\n max-width: 100%;\r\n\r\n p {\r\n display: none;\r\n &:first-child {\r\n display: block;\r\n margin-bottom: 0;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n }\r\n }\r\n `}\r\n`;\r\n\r\nconst Pager = styled.div`\r\n text-align: center;\r\n width: 100%;\r\n span {\r\n font-size: ${(p) => p.theme.fonts?.small};\r\n display: inline-block;\r\n width: 30px;\r\n text-align: center;\r\n }\r\n`;\r\n\r\nconst StyledButton = styled(Button)<{ 'data-disabled'?: boolean }>`\r\n background-color: transparent;\r\n border: none;\r\n cursor: pointer;\r\n transition: opacity 200ms ease-out;\r\n justify-self: flex-end;\r\n align-self: flex-start;\r\n padding: ${(p) => p.theme.sizes?.small} svg {\r\n display: block;\r\n }\r\n\r\n &:focus {\r\n ${(p) => p.theme.accessibility?.isTabbing && borderTabStyle}\r\n }\r\n\r\n ${(p) =>\r\n p['data-disabled']\r\n ? css`\r\n opacity: 0.8;\r\n `\r\n : css`\r\n @media (hover) {\r\n &:hover {\r\n opacity: 0.5;\r\n }\r\n }\r\n `}\r\n`;\r\n\r\nconst CloseButton = styled(StyledButton)`\r\n position: absolute;\r\n top: 7.5px;\r\n right: 7.5px;\r\n width: 25px;\r\n height: auto;\r\n padding: ${(p) => `calc(${p.theme.sizes?.small}/2) ${p.theme.sizes?.small}`} svg {\r\n vertical-align: middle;\r\n line,\r\n path {\r\n stroke: ${(p) => p.theme.colors?.text};\r\n }\r\n }\r\n`;\r\n\r\nconst StyledSymbolBadge = styled(SymbolBadge)`\r\n line {\r\n stroke: #ffffff;\r\n }\r\n`;\r\n\r\nconst Empty = styled.div`\r\n display: none;\r\n`;\r\n\r\nexport default NotificationRow;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,cAAc;AAEpB,MAAM,kBAAkB;AAAA,EACpB,WAAW;AAAA,IACP,GAAG,CAAC;AAAA,mBAAE,eAAF,IAAe,kBAAf,IAAe,CAAb;AACD,mCAAA,cAAA,KAAA,iCAAM,QAAN;AAAA,QAAa,UAAU;AAAA,MAAA,IACnB,QACL;AAAA;AAAA,EAER;AACJ;AAEA,MAAM,kBAAoC,CAAC,OAA4B;AAA5B,eAAE,gBAAF,IAAgB,kBAAhB,IAAgB,CAAd;AACnC,QAAA;AAAA,IACF,QAAQ,CAAC;AAAA,IACT,cAAc;AAAA,IACd,gBAAgB,CAAC;AAAA,IACjB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,oBAAoB;AAAA,IACpB,wBAAwB;AAAA,IACxB,kBAAkB;AAAA,MAClB,cAA6C;AACjD,QAAM,CAAC,UAAU,eAAe,SAAS,KAAK;AAC9C,QAAM,CAAC,QAAQ,aAAa,SAAmB,CAAE,CAAA;AACjD,QAAM,CAAC,OAAO,YAAY,SAAS,CAAC;AAEpC,QAAM,YAAY;AACZ,QAAA,CAAC,OAAO,aAAa,SAAoC;AAE/D,YAAU,MAAM;AACZ,QAAI,WAAW;AACX,kBAAsB,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G/C,CAAC,MACC,EAAE,mBACI;AAAA;AAAA,kBAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASd,MAAM,cAAc,OAAO,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAMxB,CAAC,MAAM;;AAAA,iBAAQ,QAAE,MAAM,UAAR,mBAAe,YAAY,QAAE,MAAM,UAAR,mBAAe;AAAA;AAAA;AAAA;AAAA;AAAA,sBAIlD,CAAC,MAAM;;AAAA,iBAAE,MAAM,WAAR,mBAAgB;AAAA;AAAA;AAAA;AAAA;AAK7C,MAAM,oBAAoB,OAAO,WAAW;AAAA;AAAA;AAAA;AAAA;AAM9B,OAAO;AAAA;AAAA;;"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-components-notification-row",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Notification row 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
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"module": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
13
13
|
"LICENSE.txt",
|
|
14
14
|
"README.md",
|
|
15
|
-
"
|
|
16
|
-
"lib-esm/"
|
|
15
|
+
"dist/"
|
|
17
16
|
],
|
|
18
17
|
"publishConfig": {
|
|
19
18
|
"access": "public"
|
|
20
19
|
},
|
|
21
20
|
"scripts": {
|
|
22
|
-
"clean": "
|
|
23
|
-
"
|
|
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.
|
|
29
|
-
"@telia-ace/knowledge-widget-types-grid": "^1.0.
|
|
30
|
-
"@telia-ace/knowledge-widget-ui": "^1.0.
|
|
31
|
-
"@telia-ace/widget-services": "^1.0.
|
|
27
|
+
"@telia-ace/knowledge-widget-core": "^1.0.7",
|
|
28
|
+
"@telia-ace/knowledge-widget-types-grid": "^1.0.14",
|
|
29
|
+
"@telia-ace/knowledge-widget-ui": "^1.0.11",
|
|
30
|
+
"@telia-ace/widget-services": "^1.0.5",
|
|
32
31
|
"@telia-ace/widget-utilities": "^1.0.1",
|
|
33
32
|
"@webprovisions/platform": "^1.1.2"
|
|
34
33
|
},
|
|
@@ -42,5 +41,5 @@
|
|
|
42
41
|
"@types/react-dom": "^16.8.0",
|
|
43
42
|
"@types/styled-components": "^5.1.7"
|
|
44
43
|
},
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "6223de72a56dbb4dfa05c2d22d6e2a6e55795d57"
|
|
46
45
|
}
|
package/lib/index.d.ts
DELETED
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_row_component_1 = __importDefault(require("./notification-row-component"));
|
|
7
|
-
exports.default = notification_row_component_1.default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Notification } from '@telia-ace/knowledge-widget-core';
|
|
2
|
-
import { Container } from '@webprovisions/platform';
|
|
3
|
-
declare type NotificationType = 'top' | 'middle' | 'bottom';
|
|
4
|
-
export declare type NotificationRowComponentProps = {
|
|
5
|
-
types: NotificationType[];
|
|
6
|
-
allowPaging?: boolean;
|
|
7
|
-
notifications?: Notification[];
|
|
8
|
-
expandable?: boolean;
|
|
9
|
-
pageNextAriaLabel?: string;
|
|
10
|
-
pagePreviousAriaLabel?: string;
|
|
11
|
-
closeAriaLabel?: string;
|
|
12
|
-
expandAriaLabel?: string;
|
|
13
|
-
};
|
|
14
|
-
export declare const NotificationRowComponent: (container: Container) => Promise<void>;
|
|
15
|
-
export default NotificationRowComponent;
|
|
@@ -1,138 +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.NotificationRowComponent = 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 NotificationRowComponent = 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-row', Promise.resolve().then(function () { return __importStar(require('./notification-row')); }), function (component) {
|
|
61
|
-
var fetch = function (params) {
|
|
62
|
-
component.writeProperties(__assign(__assign({}, component.properties()), { loading: true, error: undefined, notifications: [] }));
|
|
63
|
-
component.actions.dispatch('fetch', { params: params });
|
|
64
|
-
};
|
|
65
|
-
component.actions.create('fetch', function (_a) {
|
|
66
|
-
var error = _a.error, topNotifications = _a.topNotifications, bottomNotifications = _a.bottomNotifications, middleNotifications = _a.middleNotifications;
|
|
67
|
-
if (error) {
|
|
68
|
-
return component.actions.dispatch('fetched', {
|
|
69
|
-
error: error,
|
|
70
|
-
loading: true,
|
|
71
|
-
notifications: [],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
var newNotifications = [];
|
|
75
|
-
var _b = component.properties(), notifications = _b.notifications, _c = _b.types, types = _c === void 0 ? [] : _c;
|
|
76
|
-
if (types.length) {
|
|
77
|
-
if (types.indexOf('top') > -1) {
|
|
78
|
-
newNotifications = newNotifications.concat(topNotifications);
|
|
79
|
-
}
|
|
80
|
-
if (types.indexOf('middle') > -1) {
|
|
81
|
-
newNotifications = newNotifications.concat(middleNotifications);
|
|
82
|
-
}
|
|
83
|
-
if (types.indexOf('bottom') > -1) {
|
|
84
|
-
newNotifications = newNotifications.concat(bottomNotifications);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
newNotifications = topNotifications;
|
|
89
|
-
}
|
|
90
|
-
return component.actions.dispatch('fetched', {
|
|
91
|
-
notifications: newNotifications.length ? newNotifications : notifications,
|
|
92
|
-
loading: false,
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
component.actions.create('fetched', function (input) {
|
|
96
|
-
return component.writeProperties(__assign(__assign({}, input), { loading: false }));
|
|
97
|
-
});
|
|
98
|
-
container.getAsync('router').then(function (router) {
|
|
99
|
-
var params = router.getRouteData().params;
|
|
100
|
-
fetch(params);
|
|
101
|
-
});
|
|
102
|
-
subscribe('router:changed', function (event, _a) {
|
|
103
|
-
var current = _a.current;
|
|
104
|
-
fetch(current.routeData.params);
|
|
105
|
-
});
|
|
106
|
-
return function () {
|
|
107
|
-
unsubscribe();
|
|
108
|
-
};
|
|
109
|
-
})
|
|
110
|
-
.then(function () {
|
|
111
|
-
return (0, knowledge_widget_core_1.extendComponent)(container, 'notification-row', function (component) {
|
|
112
|
-
component.actions.watch('notification-row.fetch', function (input, next) {
|
|
113
|
-
return container
|
|
114
|
-
.getAsync('dataClient')
|
|
115
|
-
.then(function (dataClient) {
|
|
116
|
-
return dataClient.fetch(knowledge_widget_types_grid_1.DataType.RowNotifications, {
|
|
117
|
-
categories: [
|
|
118
|
-
input.params.guideCategory,
|
|
119
|
-
input.params.contactCategory,
|
|
120
|
-
].filter(function (c) { return !!c; }),
|
|
121
|
-
searchPhrase: input.params.phrase,
|
|
122
|
-
});
|
|
123
|
-
})
|
|
124
|
-
.then(next)
|
|
125
|
-
.catch(function (error) {
|
|
126
|
-
if (error) {
|
|
127
|
-
return next(error);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
})
|
|
133
|
-
.then(function () {
|
|
134
|
-
unsubscribe();
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
exports.NotificationRowComponent = NotificationRowComponent;
|
|
138
|
-
exports.default = exports.NotificationRowComponent;
|
package/lib/notification-row.js
DELETED
|
@@ -1,207 +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
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
68
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
69
|
-
if (ar || !(i in from)) {
|
|
70
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
71
|
-
ar[i] = from[i];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
75
|
-
};
|
|
76
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
-
var knowledge_widget_ui_1 = require("@telia-ace/knowledge-widget-ui");
|
|
78
|
-
var widget_services_1 = require("@telia-ace/widget-services");
|
|
79
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
80
|
-
var react_1 = __importStar(require("react"));
|
|
81
|
-
var styled_components_1 = __importStar(require("styled-components"));
|
|
82
|
-
var STORAGE_KEY = 'closed-notifications';
|
|
83
|
-
var infocusableHtml = {
|
|
84
|
-
transform: {
|
|
85
|
-
a: function (_a) {
|
|
86
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
87
|
-
return (react_1.default.createElement("a", __assign({}, props, { tabIndex: -1 }), children));
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
var NotificationRow = function (_a) {
|
|
92
|
-
var className = _a.className, other = __rest(_a, ["className"]);
|
|
93
|
-
var _b = (0, knowledge_widget_ui_1.useProperties)(), _c = _b.types, types = _c === void 0 ? [] : _c, _d = _b.allowPaging, allowPaging = _d === void 0 ? true : _d, _e = _b.notifications, notifications = _e === void 0 ? [] : _e, _f = _b.expandable, expandable = _f === void 0 ? false : _f, _g = _b.closeAriaLabel, closeAriaLabel = _g === void 0 ? '' : _g, _h = _b.pageNextAriaLabel, pageNextAriaLabel = _h === void 0 ? '' : _h, _j = _b.pagePreviousAriaLabel, pagePreviousAriaLabel = _j === void 0 ? '' : _j, _k = _b.expandAriaLabel, expandAriaLabel = _k === void 0 ? '' : _k;
|
|
94
|
-
var _l = __read((0, react_1.useState)(false), 2), expanded = _l[0], setExpanded = _l[1];
|
|
95
|
-
var _m = __read((0, react_1.useState)([]), 2), closed = _m[0], setClosed = _m[1];
|
|
96
|
-
var _o = __read((0, react_1.useState)(0), 2), index = _o[0], setIndex = _o[1];
|
|
97
|
-
var container = (0, knowledge_widget_ui_1.useContainer)();
|
|
98
|
-
var _p = __read((0, react_1.useState)(), 2), write = _p[0], setWriter = _p[1];
|
|
99
|
-
(0, react_1.useEffect)(function () {
|
|
100
|
-
if (container) {
|
|
101
|
-
(0, widget_services_1.readStorage)(container, STORAGE_KEY, widget_services_1.StorageMedium.Session).then(function (closed) {
|
|
102
|
-
if (closed === void 0) { closed = []; }
|
|
103
|
-
return setClosed(closed);
|
|
104
|
-
});
|
|
105
|
-
(0, widget_services_1.createStorageWriter)(container, STORAGE_KEY, widget_services_1.StorageCategory.Functional).then(function (writer) {
|
|
106
|
-
return setWriter(function () { return writer; });
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}, [container]);
|
|
110
|
-
(0, react_1.useEffect)(function () {
|
|
111
|
-
if (container) {
|
|
112
|
-
(0, widget_services_1.readStorage)(container, STORAGE_KEY, widget_services_1.StorageMedium.Session).then(function (storedClosed) {
|
|
113
|
-
if (storedClosed === void 0) { storedClosed = []; }
|
|
114
|
-
closed.forEach(function (id) { return storedClosed.indexOf(id) === -1 && storedClosed.push(id); });
|
|
115
|
-
if (write) {
|
|
116
|
-
write(storedClosed);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}, [closed, container, write]);
|
|
121
|
-
var filtered = notifications.filter(function (_a) {
|
|
122
|
-
var id = _a.id;
|
|
123
|
-
return closed.indexOf(id) === -1;
|
|
124
|
-
});
|
|
125
|
-
var length = filtered.length;
|
|
126
|
-
if (!filtered.length) {
|
|
127
|
-
return (0, knowledge_widget_ui_1.createEmptyComponent)(container, __assign(__assign({}, other), { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-notification-row') }));
|
|
128
|
-
}
|
|
129
|
-
if (allowPaging) {
|
|
130
|
-
var notification_1 = filtered[index] || filtered[index + 1] || filtered[index - 1];
|
|
131
|
-
if (!notification_1) {
|
|
132
|
-
return (0, knowledge_widget_ui_1.createEmptyComponent)(container, __assign(__assign({}, other), { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-notification-row') }));
|
|
133
|
-
}
|
|
134
|
-
var _q = notification_1 || {}, id_1 = _q.id, body = _q.body;
|
|
135
|
-
var toggleExpand_1 = function () { return setExpanded(!expanded); };
|
|
136
|
-
return (react_1.default.createElement(Wrapper, __assign({}, other, { "aria-expanded": expandable ? expanded : true, "aria-label": expandAriaLabel, tabIndex: expandable ? 0 : -1, className: (0, widget_utilities_1.appendClassNames)(className, 'humany-notification-row'), "data-pageable": length > 1, "data-types": types, "data-allow-paging": allowPaging, "data-expandable": expandable, onKeyDown: function (e) {
|
|
137
|
-
if (e.key === 'Enter') {
|
|
138
|
-
toggleExpand_1();
|
|
139
|
-
}
|
|
140
|
-
}, onClick: toggleExpand_1 }),
|
|
141
|
-
react_1.default.createElement(CloseButton, { "aria-label": closeAriaLabel, onClick: function () {
|
|
142
|
-
setIndex(filtered.indexOf(notification_1));
|
|
143
|
-
setClosed(__spreadArray(__spreadArray([], __read(closed), false), [id_1], false));
|
|
144
|
-
} },
|
|
145
|
-
react_1.default.createElement(knowledge_widget_ui_1.SymbolBadge, { symbol: { type: 'Svg', content: 'close' } })),
|
|
146
|
-
react_1.default.createElement(StyledHtml, { htmlParseInstruction: !expandable || expanded ? undefined : infocusableHtml, "data-pageable": length > 1, "data-notification": id_1, "data-expandable": expandable, "data-expanded": expanded, html: body }),
|
|
147
|
-
length > 1 && (react_1.default.createElement(Pager, null,
|
|
148
|
-
react_1.default.createElement(StyledButton, { "aria-label": pagePreviousAriaLabel, "data-disabled": index === 0, onClick: function (e) {
|
|
149
|
-
e.stopPropagation();
|
|
150
|
-
if (index > 0) {
|
|
151
|
-
setIndex(index - 1);
|
|
152
|
-
}
|
|
153
|
-
} },
|
|
154
|
-
react_1.default.createElement(StyledSymbolBadge, { size: 10, symbol: { type: 'Svg', content: 'caret-left' } })),
|
|
155
|
-
react_1.default.createElement("span", null,
|
|
156
|
-
index + 1,
|
|
157
|
-
"/",
|
|
158
|
-
length),
|
|
159
|
-
react_1.default.createElement(StyledButton, { "aria-label": pageNextAriaLabel, "data-disabled": index + 1 >= length, onClick: function (e) {
|
|
160
|
-
e.stopPropagation();
|
|
161
|
-
if (index < length - 1) {
|
|
162
|
-
setIndex(index + 1);
|
|
163
|
-
}
|
|
164
|
-
} },
|
|
165
|
-
react_1.default.createElement(StyledSymbolBadge, { size: 10, symbol: { type: 'Svg', content: 'caret-right' } }))))));
|
|
166
|
-
}
|
|
167
|
-
return (react_1.default.createElement(Wrapper, __assign({}, other, { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-notification-row'), "data-pageable": false, "data-types": types, "data-allow-paging": false }), filtered.map(function (notification) {
|
|
168
|
-
if (!notification) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
var id = notification.id, body = notification.body;
|
|
172
|
-
return (react_1.default.createElement(StyledHtml, { key: id, "data-pageable": false, "data-expandable": expandable, "data-expanded": expanded, "data-notification": id, html: body }));
|
|
173
|
-
})));
|
|
174
|
-
};
|
|
175
|
-
var Wrapper = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n padding: ", " ", "px;\n background-color: ", ";\n color: ", ";\n border-radius: ", ";\n text-align: center;\n display: flex;\n flex-direction: column;\n position: relative;\n cursor: ", ";\n overflow: hidden;\n\n i {\n color: ", ";\n }\n\n a {\n color: ", ";\n &:focus {\n ", "\n }\n }\n\n ", ";\n\n ", "\n"], ["\n ", "\n padding: ", " ", "px;\n background-color: ", ";\n color: ", ";\n border-radius: ", ";\n text-align: center;\n display: flex;\n flex-direction: column;\n position: relative;\n cursor: ", ";\n overflow: hidden;\n\n i {\n color: ", ";\n }\n\n a {\n color: ", ";\n &:focus {\n ", "\n }\n }\n\n ", ";\n\n ", "\n"])), knowledge_widget_ui_1.genericHtml, function (p) { return p.theme.sizes.normal; }, function (p) { var _a; return ((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.cardinal) * 12; }, function (p) {
|
|
176
|
-
var _a, _b, _c;
|
|
177
|
-
if (p['data-types'].length) {
|
|
178
|
-
if (p['data-types'].indexOf('top') > -1) {
|
|
179
|
-
return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.warning;
|
|
180
|
-
}
|
|
181
|
-
if (p['data-types'].indexOf('bottom') > -1) {
|
|
182
|
-
return 'transparent';
|
|
183
|
-
}
|
|
184
|
-
return (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.primary;
|
|
185
|
-
}
|
|
186
|
-
return (_c = p.theme.colors) === null || _c === void 0 ? void 0 : _c.warning;
|
|
187
|
-
}, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { return p.theme.borderRadius; }, function (p) { return (p['data-expandable'] ? 'pointer' : 'default'); }, 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.colors) === null || _a === void 0 ? void 0 : _a.link; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && knowledge_widget_ui_1.linkTabStyle; }, function (p) {
|
|
188
|
-
var _a;
|
|
189
|
-
return !p['data-allow-paging'] && (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-wrap: wrap;\n\n > div {\n min-width: 100%;\n margin: ", "px;\n }\n "], ["\n flex-wrap: wrap;\n\n > div {\n min-width: 100%;\n margin: ", "px;\n }\n "])), ((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.cardinal) * 2);
|
|
190
|
-
}, function (p) {
|
|
191
|
-
var _a;
|
|
192
|
-
return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:focus {\n ", " {\n ", "\n }\n }\n "], ["\n &:focus {\n ", " {\n ", "\n }\n }\n "])), StyledHtml, knowledge_widget_ui_1.borderTabStyle);
|
|
193
|
-
});
|
|
194
|
-
var StyledHtml = (0, styled_components_1.default)(knowledge_widget_ui_1.Html)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n flex: 1;\n font-size: ", ";\n line-height: 1.6em;\n font-weight: 300;\n\n ", "\n"], ["\n flex: 1;\n font-size: ", ";\n line-height: 1.6em;\n font-weight: 300;\n\n ", "\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) {
|
|
195
|
-
return p['data-expandable'] &&
|
|
196
|
-
!p['data-expanded'] && (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\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 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 "])));
|
|
197
|
-
});
|
|
198
|
-
var Pager = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n text-align: center;\n width: 100%;\n span {\n font-size: ", ";\n display: inline-block;\n width: 30px;\n text-align: center;\n }\n"], ["\n text-align: center;\n width: 100%;\n span {\n font-size: ", ";\n display: inline-block;\n width: 30px;\n text-align: center;\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.small; });
|
|
199
|
-
var StyledButton = (0, styled_components_1.default)(knowledge_widget_ui_1.Button)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\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: ", " svg {\n display: block;\n }\n\n &:focus {\n ", "\n }\n\n ", "\n"], ["\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: ", " svg {\n display: block;\n }\n\n &:focus {\n ", "\n }\n\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.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && knowledge_widget_ui_1.borderTabStyle; }, function (p) {
|
|
200
|
-
return p['data-disabled']
|
|
201
|
-
? (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n opacity: 0.8;\n "], ["\n opacity: 0.8;\n "]))) : (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n @media (hover) {\n &:hover {\n opacity: 0.5;\n }\n }\n "], ["\n @media (hover) {\n &:hover {\n opacity: 0.5;\n }\n }\n "])));
|
|
202
|
-
});
|
|
203
|
-
var CloseButton = (0, styled_components_1.default)(StyledButton)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n position: absolute;\n top: 7.5px;\n right: 7.5px;\n width: 25px;\n height: auto;\n padding: ", " svg {\n vertical-align: middle;\n line,\n path {\n stroke: ", ";\n }\n }\n"], ["\n position: absolute;\n top: 7.5px;\n right: 7.5px;\n width: 25px;\n height: auto;\n padding: ", " svg {\n vertical-align: middle;\n line,\n path {\n stroke: ", ";\n }\n }\n"])), function (p) { var _a, _b; return "calc(".concat((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small, "/2) ").concat((_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.small); }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
|
|
204
|
-
var StyledSymbolBadge = (0, styled_components_1.default)(knowledge_widget_ui_1.SymbolBadge)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n line {\n stroke: #ffffff;\n }\n"], ["\n line {\n stroke: #ffffff;\n }\n"])));
|
|
205
|
-
var Empty = styled_components_1.default.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
206
|
-
exports.default = NotificationRow;
|
|
207
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12;
|
package/lib-esm/index.js
DELETED
|
@@ -1,111 +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 NotificationRowComponent = 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-row', import('./notification-row'), function (component) {
|
|
35
|
-
var fetch = function (params) {
|
|
36
|
-
component.writeProperties(__assign(__assign({}, component.properties()), { loading: true, error: undefined, notifications: [] }));
|
|
37
|
-
component.actions.dispatch('fetch', { params: params });
|
|
38
|
-
};
|
|
39
|
-
component.actions.create('fetch', function (_a) {
|
|
40
|
-
var error = _a.error, topNotifications = _a.topNotifications, bottomNotifications = _a.bottomNotifications, middleNotifications = _a.middleNotifications;
|
|
41
|
-
if (error) {
|
|
42
|
-
return component.actions.dispatch('fetched', {
|
|
43
|
-
error: error,
|
|
44
|
-
loading: true,
|
|
45
|
-
notifications: [],
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
var newNotifications = [];
|
|
49
|
-
var _b = component.properties(), notifications = _b.notifications, _c = _b.types, types = _c === void 0 ? [] : _c;
|
|
50
|
-
if (types.length) {
|
|
51
|
-
if (types.indexOf('top') > -1) {
|
|
52
|
-
newNotifications = newNotifications.concat(topNotifications);
|
|
53
|
-
}
|
|
54
|
-
if (types.indexOf('middle') > -1) {
|
|
55
|
-
newNotifications = newNotifications.concat(middleNotifications);
|
|
56
|
-
}
|
|
57
|
-
if (types.indexOf('bottom') > -1) {
|
|
58
|
-
newNotifications = newNotifications.concat(bottomNotifications);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
newNotifications = topNotifications;
|
|
63
|
-
}
|
|
64
|
-
return component.actions.dispatch('fetched', {
|
|
65
|
-
notifications: newNotifications.length ? newNotifications : notifications,
|
|
66
|
-
loading: false,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
component.actions.create('fetched', function (input) {
|
|
70
|
-
return component.writeProperties(__assign(__assign({}, input), { loading: false }));
|
|
71
|
-
});
|
|
72
|
-
container.getAsync('router').then(function (router) {
|
|
73
|
-
var params = router.getRouteData().params;
|
|
74
|
-
fetch(params);
|
|
75
|
-
});
|
|
76
|
-
subscribe('router:changed', function (event, _a) {
|
|
77
|
-
var current = _a.current;
|
|
78
|
-
fetch(current.routeData.params);
|
|
79
|
-
});
|
|
80
|
-
return function () {
|
|
81
|
-
unsubscribe();
|
|
82
|
-
};
|
|
83
|
-
})
|
|
84
|
-
.then(function () {
|
|
85
|
-
return extendComponent(container, 'notification-row', function (component) {
|
|
86
|
-
component.actions.watch('notification-row.fetch', function (input, next) {
|
|
87
|
-
return container
|
|
88
|
-
.getAsync('dataClient')
|
|
89
|
-
.then(function (dataClient) {
|
|
90
|
-
return dataClient.fetch(DataType.RowNotifications, {
|
|
91
|
-
categories: [
|
|
92
|
-
input.params.guideCategory,
|
|
93
|
-
input.params.contactCategory,
|
|
94
|
-
].filter(function (c) { return !!c; }),
|
|
95
|
-
searchPhrase: input.params.phrase,
|
|
96
|
-
});
|
|
97
|
-
})
|
|
98
|
-
.then(next)
|
|
99
|
-
.catch(function (error) {
|
|
100
|
-
if (error) {
|
|
101
|
-
return next(error);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
})
|
|
107
|
-
.then(function () {
|
|
108
|
-
unsubscribe();
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
export default NotificationRowComponent;
|
|
@@ -1,182 +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
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
44
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
45
|
-
if (ar || !(i in from)) {
|
|
46
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
47
|
-
ar[i] = from[i];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
51
|
-
};
|
|
52
|
-
import { borderTabStyle, Button, createEmptyComponent, genericHtml, Html, linkTabStyle, SymbolBadge, useContainer, useProperties, } from '@telia-ace/knowledge-widget-ui';
|
|
53
|
-
import { createStorageWriter, readStorage, StorageCategory, StorageMedium, } from '@telia-ace/widget-services';
|
|
54
|
-
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
55
|
-
import React, { useEffect, useState } from 'react';
|
|
56
|
-
import styled, { css } from 'styled-components';
|
|
57
|
-
var STORAGE_KEY = 'closed-notifications';
|
|
58
|
-
var infocusableHtml = {
|
|
59
|
-
transform: {
|
|
60
|
-
a: function (_a) {
|
|
61
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
62
|
-
return (React.createElement("a", __assign({}, props, { tabIndex: -1 }), children));
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
var NotificationRow = function (_a) {
|
|
67
|
-
var className = _a.className, other = __rest(_a, ["className"]);
|
|
68
|
-
var _b = useProperties(), _c = _b.types, types = _c === void 0 ? [] : _c, _d = _b.allowPaging, allowPaging = _d === void 0 ? true : _d, _e = _b.notifications, notifications = _e === void 0 ? [] : _e, _f = _b.expandable, expandable = _f === void 0 ? false : _f, _g = _b.closeAriaLabel, closeAriaLabel = _g === void 0 ? '' : _g, _h = _b.pageNextAriaLabel, pageNextAriaLabel = _h === void 0 ? '' : _h, _j = _b.pagePreviousAriaLabel, pagePreviousAriaLabel = _j === void 0 ? '' : _j, _k = _b.expandAriaLabel, expandAriaLabel = _k === void 0 ? '' : _k;
|
|
69
|
-
var _l = __read(useState(false), 2), expanded = _l[0], setExpanded = _l[1];
|
|
70
|
-
var _m = __read(useState([]), 2), closed = _m[0], setClosed = _m[1];
|
|
71
|
-
var _o = __read(useState(0), 2), index = _o[0], setIndex = _o[1];
|
|
72
|
-
var container = useContainer();
|
|
73
|
-
var _p = __read(useState(), 2), write = _p[0], setWriter = _p[1];
|
|
74
|
-
useEffect(function () {
|
|
75
|
-
if (container) {
|
|
76
|
-
readStorage(container, STORAGE_KEY, StorageMedium.Session).then(function (closed) {
|
|
77
|
-
if (closed === void 0) { closed = []; }
|
|
78
|
-
return setClosed(closed);
|
|
79
|
-
});
|
|
80
|
-
createStorageWriter(container, STORAGE_KEY, StorageCategory.Functional).then(function (writer) {
|
|
81
|
-
return setWriter(function () { return writer; });
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}, [container]);
|
|
85
|
-
useEffect(function () {
|
|
86
|
-
if (container) {
|
|
87
|
-
readStorage(container, STORAGE_KEY, StorageMedium.Session).then(function (storedClosed) {
|
|
88
|
-
if (storedClosed === void 0) { storedClosed = []; }
|
|
89
|
-
closed.forEach(function (id) { return storedClosed.indexOf(id) === -1 && storedClosed.push(id); });
|
|
90
|
-
if (write) {
|
|
91
|
-
write(storedClosed);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}, [closed, container, write]);
|
|
96
|
-
var filtered = notifications.filter(function (_a) {
|
|
97
|
-
var id = _a.id;
|
|
98
|
-
return closed.indexOf(id) === -1;
|
|
99
|
-
});
|
|
100
|
-
var length = filtered.length;
|
|
101
|
-
if (!filtered.length) {
|
|
102
|
-
return createEmptyComponent(container, __assign(__assign({}, other), { className: appendClassNames(className, 'humany-notification-row') }));
|
|
103
|
-
}
|
|
104
|
-
if (allowPaging) {
|
|
105
|
-
var notification_1 = filtered[index] || filtered[index + 1] || filtered[index - 1];
|
|
106
|
-
if (!notification_1) {
|
|
107
|
-
return createEmptyComponent(container, __assign(__assign({}, other), { className: appendClassNames(className, 'humany-notification-row') }));
|
|
108
|
-
}
|
|
109
|
-
var _q = notification_1 || {}, id_1 = _q.id, body = _q.body;
|
|
110
|
-
var toggleExpand_1 = function () { return setExpanded(!expanded); };
|
|
111
|
-
return (React.createElement(Wrapper, __assign({}, other, { "aria-expanded": expandable ? expanded : true, "aria-label": expandAriaLabel, tabIndex: expandable ? 0 : -1, className: appendClassNames(className, 'humany-notification-row'), "data-pageable": length > 1, "data-types": types, "data-allow-paging": allowPaging, "data-expandable": expandable, onKeyDown: function (e) {
|
|
112
|
-
if (e.key === 'Enter') {
|
|
113
|
-
toggleExpand_1();
|
|
114
|
-
}
|
|
115
|
-
}, onClick: toggleExpand_1 }),
|
|
116
|
-
React.createElement(CloseButton, { "aria-label": closeAriaLabel, onClick: function () {
|
|
117
|
-
setIndex(filtered.indexOf(notification_1));
|
|
118
|
-
setClosed(__spreadArray(__spreadArray([], __read(closed), false), [id_1], false));
|
|
119
|
-
} },
|
|
120
|
-
React.createElement(SymbolBadge, { symbol: { type: 'Svg', content: 'close' } })),
|
|
121
|
-
React.createElement(StyledHtml, { htmlParseInstruction: !expandable || expanded ? undefined : infocusableHtml, "data-pageable": length > 1, "data-notification": id_1, "data-expandable": expandable, "data-expanded": expanded, html: body }),
|
|
122
|
-
length > 1 && (React.createElement(Pager, null,
|
|
123
|
-
React.createElement(StyledButton, { "aria-label": pagePreviousAriaLabel, "data-disabled": index === 0, onClick: function (e) {
|
|
124
|
-
e.stopPropagation();
|
|
125
|
-
if (index > 0) {
|
|
126
|
-
setIndex(index - 1);
|
|
127
|
-
}
|
|
128
|
-
} },
|
|
129
|
-
React.createElement(StyledSymbolBadge, { size: 10, symbol: { type: 'Svg', content: 'caret-left' } })),
|
|
130
|
-
React.createElement("span", null,
|
|
131
|
-
index + 1,
|
|
132
|
-
"/",
|
|
133
|
-
length),
|
|
134
|
-
React.createElement(StyledButton, { "aria-label": pageNextAriaLabel, "data-disabled": index + 1 >= length, onClick: function (e) {
|
|
135
|
-
e.stopPropagation();
|
|
136
|
-
if (index < length - 1) {
|
|
137
|
-
setIndex(index + 1);
|
|
138
|
-
}
|
|
139
|
-
} },
|
|
140
|
-
React.createElement(StyledSymbolBadge, { size: 10, symbol: { type: 'Svg', content: 'caret-right' } }))))));
|
|
141
|
-
}
|
|
142
|
-
return (React.createElement(Wrapper, __assign({}, other, { className: appendClassNames(className, 'humany-notification-row'), "data-pageable": false, "data-types": types, "data-allow-paging": false }), filtered.map(function (notification) {
|
|
143
|
-
if (!notification) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
var id = notification.id, body = notification.body;
|
|
147
|
-
return (React.createElement(StyledHtml, { key: id, "data-pageable": false, "data-expandable": expandable, "data-expanded": expanded, "data-notification": id, html: body }));
|
|
148
|
-
})));
|
|
149
|
-
};
|
|
150
|
-
var Wrapper = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n padding: ", " ", "px;\n background-color: ", ";\n color: ", ";\n border-radius: ", ";\n text-align: center;\n display: flex;\n flex-direction: column;\n position: relative;\n cursor: ", ";\n overflow: hidden;\n\n i {\n color: ", ";\n }\n\n a {\n color: ", ";\n &:focus {\n ", "\n }\n }\n\n ", ";\n\n ", "\n"], ["\n ", "\n padding: ", " ", "px;\n background-color: ", ";\n color: ", ";\n border-radius: ", ";\n text-align: center;\n display: flex;\n flex-direction: column;\n position: relative;\n cursor: ", ";\n overflow: hidden;\n\n i {\n color: ", ";\n }\n\n a {\n color: ", ";\n &:focus {\n ", "\n }\n }\n\n ", ";\n\n ", "\n"])), genericHtml, function (p) { return p.theme.sizes.normal; }, function (p) { var _a; return ((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.cardinal) * 12; }, function (p) {
|
|
151
|
-
var _a, _b, _c;
|
|
152
|
-
if (p['data-types'].length) {
|
|
153
|
-
if (p['data-types'].indexOf('top') > -1) {
|
|
154
|
-
return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.warning;
|
|
155
|
-
}
|
|
156
|
-
if (p['data-types'].indexOf('bottom') > -1) {
|
|
157
|
-
return 'transparent';
|
|
158
|
-
}
|
|
159
|
-
return (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.primary;
|
|
160
|
-
}
|
|
161
|
-
return (_c = p.theme.colors) === null || _c === void 0 ? void 0 : _c.warning;
|
|
162
|
-
}, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { return p.theme.borderRadius; }, function (p) { return (p['data-expandable'] ? 'pointer' : 'default'); }, 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.colors) === null || _a === void 0 ? void 0 : _a.link; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && linkTabStyle; }, function (p) {
|
|
163
|
-
var _a;
|
|
164
|
-
return !p['data-allow-paging'] && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-wrap: wrap;\n\n > div {\n min-width: 100%;\n margin: ", "px;\n }\n "], ["\n flex-wrap: wrap;\n\n > div {\n min-width: 100%;\n margin: ", "px;\n }\n "])), ((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.cardinal) * 2);
|
|
165
|
-
}, function (p) {
|
|
166
|
-
var _a;
|
|
167
|
-
return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:focus {\n ", " {\n ", "\n }\n }\n "], ["\n &:focus {\n ", " {\n ", "\n }\n }\n "])), StyledHtml, borderTabStyle);
|
|
168
|
-
});
|
|
169
|
-
var StyledHtml = styled(Html)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n flex: 1;\n font-size: ", ";\n line-height: 1.6em;\n font-weight: 300;\n\n ", "\n"], ["\n flex: 1;\n font-size: ", ";\n line-height: 1.6em;\n font-weight: 300;\n\n ", "\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) {
|
|
170
|
-
return p['data-expandable'] &&
|
|
171
|
-
!p['data-expanded'] && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\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 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 "])));
|
|
172
|
-
});
|
|
173
|
-
var Pager = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n text-align: center;\n width: 100%;\n span {\n font-size: ", ";\n display: inline-block;\n width: 30px;\n text-align: center;\n }\n"], ["\n text-align: center;\n width: 100%;\n span {\n font-size: ", ";\n display: inline-block;\n width: 30px;\n text-align: center;\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.small; });
|
|
174
|
-
var StyledButton = styled(Button)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\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: ", " svg {\n display: block;\n }\n\n &:focus {\n ", "\n }\n\n ", "\n"], ["\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: ", " svg {\n display: block;\n }\n\n &:focus {\n ", "\n }\n\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.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && borderTabStyle; }, function (p) {
|
|
175
|
-
return p['data-disabled']
|
|
176
|
-
? css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n opacity: 0.8;\n "], ["\n opacity: 0.8;\n "]))) : css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n @media (hover) {\n &:hover {\n opacity: 0.5;\n }\n }\n "], ["\n @media (hover) {\n &:hover {\n opacity: 0.5;\n }\n }\n "])));
|
|
177
|
-
});
|
|
178
|
-
var CloseButton = styled(StyledButton)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n position: absolute;\n top: 7.5px;\n right: 7.5px;\n width: 25px;\n height: auto;\n padding: ", " svg {\n vertical-align: middle;\n line,\n path {\n stroke: ", ";\n }\n }\n"], ["\n position: absolute;\n top: 7.5px;\n right: 7.5px;\n width: 25px;\n height: auto;\n padding: ", " svg {\n vertical-align: middle;\n line,\n path {\n stroke: ", ";\n }\n }\n"])), function (p) { var _a, _b; return "calc(".concat((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small, "/2) ").concat((_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.small); }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
|
|
179
|
-
var StyledSymbolBadge = styled(SymbolBadge)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n line {\n stroke: #ffffff;\n }\n"], ["\n line {\n stroke: #ffffff;\n }\n"])));
|
|
180
|
-
var Empty = styled.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
181
|
-
export default NotificationRow;
|
|
182
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12;
|