@telia-ace/knowledge-widget-components-notification-row 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +6 -0
- package/README.md +3 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/notification-row-component.d.ts +15 -0
- package/lib/notification-row-component.js +138 -0
- package/lib/notification-row.d.ts +6 -0
- package/lib/notification-row.js +207 -0
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +2 -0
- package/lib-esm/notification-row-component.d.ts +15 -0
- package/lib-esm/notification-row-component.js +111 -0
- package/lib-esm/notification-row.d.ts +6 -0
- package/lib-esm/notification-row.js +182 -0
- package/package.json +44 -0
package/LICENSE.txt
ADDED
package/README.md
ADDED
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,138 @@
|
|
|
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;
|
|
@@ -0,0 +1,207 @@
|
|
|
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.Necessary).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
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,111 @@
|
|
|
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;
|
|
@@ -0,0 +1,182 @@
|
|
|
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.Necessary).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;
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/knowledge-widget-components-notification-row",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Notification row component for ACE Knowledge Widgets.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "Telia Company AB",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"telia"
|
|
9
|
+
],
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"module": "lib-esm/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"README.md",
|
|
15
|
+
"lib/",
|
|
16
|
+
"lib-esm/"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "cleandir lib && cleandir lib-esm",
|
|
23
|
+
"compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"typings": "lib/index.d.ts",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@telia-ace/knowledge-widget-core": "^1.0.1",
|
|
29
|
+
"@telia-ace/knowledge-widget-types-grid": "^1.0.1",
|
|
30
|
+
"@telia-ace/knowledge-widget-ui": "^1.0.1",
|
|
31
|
+
"@telia-ace/widget-services": "^1.0.1",
|
|
32
|
+
"@telia-ace/widget-utilities": "^1.0.1",
|
|
33
|
+
"@webprovisions/platform": "^1.1.2",
|
|
34
|
+
"react": "^17.0.2",
|
|
35
|
+
"react-dom": "^17.0.2",
|
|
36
|
+
"styled-components": "^4.3.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/react": "^17.0.39",
|
|
40
|
+
"@types/react-dom": "^17.0.13",
|
|
41
|
+
"@types/styled-components": "^5.1.7"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "58b00b80f6a1e4a3c13f4291cb29b9422ea1aa4a"
|
|
44
|
+
}
|