@telia-ace/knowledge-widget-plugins 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/{lib-esm → dist}/favorite/favorite-platform.d.ts +0 -0
  2. package/{lib-esm → dist}/favorite/favorite.d.ts +0 -0
  3. package/{lib-esm → dist}/favorite/index.d.ts +0 -0
  4. package/{lib-esm → dist}/favorite/utils.d.ts +0 -0
  5. package/{lib-esm → dist}/index.d.ts +0 -0
  6. package/dist/index.js +321 -0
  7. package/dist/index.js.map +1 -0
  8. package/{lib-esm → dist}/legacy-resources/index.d.ts +0 -0
  9. package/{lib-esm → dist}/legacy-resources/legacy-resources.d.ts +0 -0
  10. package/{lib-esm → dist}/misc-behavior/deny-auto-expand-contact-methods-handler.d.ts +0 -0
  11. package/{lib-esm → dist}/misc-behavior/hide-back-on-single-contact-method-handler.d.ts +0 -0
  12. package/{lib-esm → dist}/misc-behavior/index.d.ts +0 -0
  13. package/{lib-esm → dist}/misc-behavior/plugin.d.ts +0 -0
  14. package/{lib-esm → dist}/misc-behavior/search-guide-list-keyboard-navigation-handler.d.ts +0 -0
  15. package/package.json +14 -15
  16. package/lib/favorite/favorite-platform.d.ts +0 -9
  17. package/lib/favorite/favorite-platform.js +0 -97
  18. package/lib/favorite/favorite.d.ts +0 -9
  19. package/lib/favorite/favorite.js +0 -34
  20. package/lib/favorite/index.d.ts +0 -2
  21. package/lib/favorite/index.js +0 -7
  22. package/lib/favorite/utils.d.ts +0 -8
  23. package/lib/favorite/utils.js +0 -131
  24. package/lib/index.d.ts +0 -3
  25. package/lib/index.js +0 -12
  26. package/lib/legacy-resources/index.d.ts +0 -2
  27. package/lib/legacy-resources/index.js +0 -7
  28. package/lib/legacy-resources/legacy-resources.d.ts +0 -14
  29. package/lib/legacy-resources/legacy-resources.js +0 -56
  30. package/lib/misc-behavior/deny-auto-expand-contact-methods-handler.d.ts +0 -9
  31. package/lib/misc-behavior/deny-auto-expand-contact-methods-handler.js +0 -70
  32. package/lib/misc-behavior/hide-back-on-single-contact-method-handler.d.ts +0 -8
  33. package/lib/misc-behavior/hide-back-on-single-contact-method-handler.js +0 -126
  34. package/lib/misc-behavior/index.d.ts +0 -2
  35. package/lib/misc-behavior/index.js +0 -7
  36. package/lib/misc-behavior/plugin.d.ts +0 -19
  37. package/lib/misc-behavior/plugin.js +0 -105
  38. package/lib/misc-behavior/search-guide-list-keyboard-navigation-handler.d.ts +0 -7
  39. package/lib/misc-behavior/search-guide-list-keyboard-navigation-handler.js +0 -141
  40. package/lib-esm/favorite/favorite-platform.js +0 -95
  41. package/lib-esm/favorite/favorite.js +0 -29
  42. package/lib-esm/favorite/index.js +0 -2
  43. package/lib-esm/favorite/utils.js +0 -123
  44. package/lib-esm/index.js +0 -3
  45. package/lib-esm/legacy-resources/index.js +0 -2
  46. package/lib-esm/legacy-resources/legacy-resources.js +0 -54
  47. package/lib-esm/misc-behavior/deny-auto-expand-contact-methods-handler.js +0 -68
  48. package/lib-esm/misc-behavior/hide-back-on-single-contact-method-handler.js +0 -124
  49. package/lib-esm/misc-behavior/index.js +0 -2
  50. package/lib-esm/misc-behavior/plugin.js +0 -100
  51. package/lib-esm/misc-behavior/search-guide-list-keyboard-navigation-handler.js +0 -139
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- var isQuickFilterOpen = function (searchElements) {
56
- return searchElements.reduce(function (acc, current) {
57
- if (acc) {
58
- return acc;
59
- }
60
- var _a = __read(Array.from((current === null || current === void 0 ? void 0 : current.getElementsByClassName('humany-quick-filter-dropdown')) || []), 1), element = _a[0];
61
- if (element) {
62
- return true;
63
- }
64
- return false;
65
- }, false);
66
- };
67
- var isSearchElementFocused = function (searchElements) {
68
- return searchElements.reduce(function (acc, current) {
69
- if (acc) {
70
- return acc;
71
- }
72
- var _a = __read(Array.from((current === null || current === void 0 ? void 0 : current.getElementsByTagName('input')) || []), 1), input = _a[0];
73
- if (input && input === document.activeElement) {
74
- return true;
75
- }
76
- return false;
77
- }, false);
78
- };
79
- var getGuideListLinks = function () {
80
- return Array.from(document.querySelectorAll('[data-component-type="guide-list"]')).reduce(function (acc, current) {
81
- var links = Array.from(current.getElementsByTagName('a'));
82
- links.forEach(function (l) { return acc.push(l); });
83
- return acc;
84
- }, []);
85
- };
86
- /**
87
- * Will focus guide-list when focusing search-input and pressing arrow-down key
88
- */
89
- exports.default = (function (container, settings) { return __awaiter(void 0, void 0, void 0, function () {
90
- var _a, searchToGuideListArrowKeyNavigation;
91
- return __generator(this, function (_b) {
92
- _a = settings.searchToGuideListArrowKeyNavigation, searchToGuideListArrowKeyNavigation = _a === void 0 ? false : _a;
93
- if (searchToGuideListArrowKeyNavigation) {
94
- return [2 /*return*/, container.getAsync('components').then(function (platform) {
95
- var all = platform.nodes.all;
96
- var searchComponentIds = all.filter(function (n) { return n.type === 'search'; }).map(function (n) { return n.id; });
97
- var listeners = [];
98
- listeners.push({
99
- parent: window,
100
- type: 'keydown',
101
- handler: function (e) {
102
- var _a, _b, _c, _d;
103
- var searchComponentElements = [];
104
- searchComponentIds.forEach(function (id) {
105
- var element = document.getElementById(id);
106
- if (element) {
107
- searchComponentElements.push(element);
108
- }
109
- });
110
- var quickFilterDropdownOpen = isQuickFilterOpen(searchComponentElements);
111
- var searchElementIsFocused = isSearchElementFocused(searchComponentElements);
112
- var guideListLinks = getGuideListLinks();
113
- var guideListLinkFocusIndex = guideListLinks.indexOf(document.activeElement);
114
- if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') &&
115
- (searchElementIsFocused || guideListLinkFocusIndex > -1)) {
116
- e.preventDefault();
117
- }
118
- if (e.key === 'ArrowDown' &&
119
- searchElementIsFocused &&
120
- !quickFilterDropdownOpen) {
121
- guideListLinks[0].focus();
122
- }
123
- else {
124
- if (e.key === 'ArrowUp' && guideListLinkFocusIndex === 0) {
125
- (_b = (_a = searchComponentElements[0]) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('input')[0]) === null || _b === void 0 ? void 0 : _b.focus();
126
- }
127
- else if (e.key === 'ArrowUp' && guideListLinkFocusIndex > -1) {
128
- (_c = guideListLinks[guideListLinkFocusIndex - 1]) === null || _c === void 0 ? void 0 : _c.focus();
129
- }
130
- else if (e.key === 'ArrowDown' && guideListLinkFocusIndex > -1) {
131
- (_d = guideListLinks[guideListLinkFocusIndex + 1]) === null || _d === void 0 ? void 0 : _d.focus();
132
- }
133
- }
134
- },
135
- });
136
- return listeners;
137
- })];
138
- }
139
- return [2 /*return*/, Promise.resolve([])];
140
- });
141
- }); });
@@ -1,95 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { addFavoriteToStorage, notifyListeners, readFavoritesFromStorage, removeAllFavoritesFromStorage, removeFavoriteFromStorage, } from './utils';
38
- var createFavoritePlatform = function (container) {
39
- var favorites = [];
40
- var initialize = function () {
41
- readFavoritesFromStorage(container).then(function (items) {
42
- favorites = items;
43
- });
44
- };
45
- var get = function () {
46
- return favorites;
47
- };
48
- var add = function (guideId) { return __awaiter(void 0, void 0, void 0, function () {
49
- var updated;
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0: return [4 /*yield*/, addFavoriteToStorage(guideId, container)];
53
- case 1:
54
- updated = _a.sent();
55
- favorites = updated;
56
- notifyListeners(container, { updated: updated });
57
- return [2 /*return*/, updated];
58
- }
59
- });
60
- }); };
61
- var clear = function () { return __awaiter(void 0, void 0, void 0, function () {
62
- var updated;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0: return [4 /*yield*/, removeAllFavoritesFromStorage(container)];
66
- case 1:
67
- updated = _a.sent();
68
- favorites = updated;
69
- notifyListeners(container, { updated: updated });
70
- return [2 /*return*/, updated];
71
- }
72
- });
73
- }); };
74
- var remove = function (guideId) { return __awaiter(void 0, void 0, void 0, function () {
75
- var updated;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0: return [4 /*yield*/, removeFavoriteFromStorage(guideId, container)];
79
- case 1:
80
- updated = _a.sent();
81
- favorites = updated;
82
- notifyListeners(container, { updated: updated });
83
- return [2 /*return*/, updated];
84
- }
85
- });
86
- }); };
87
- initialize();
88
- return {
89
- add: add,
90
- get: get,
91
- clear: clear,
92
- remove: remove,
93
- };
94
- };
95
- export default createFavoritePlatform;
@@ -1,29 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { Plugin } from '@telia-ace/knowledge-widget-core';
17
- import createFavoritePlatform from './favorite-platform';
18
- var FavoritePlugin = /** @class */ (function (_super) {
19
- __extends(FavoritePlugin, _super);
20
- function FavoritePlugin(container, settings) {
21
- var _this = _super.call(this, container) || this;
22
- _this.settings = settings;
23
- _this.handler = createFavoritePlatform(container);
24
- container.register('favorites', _this.handler);
25
- return _this;
26
- }
27
- return FavoritePlugin;
28
- }(Plugin));
29
- export default FavoritePlugin;
@@ -1,2 +0,0 @@
1
- import FavoritePlugin from './favorite';
2
- export default FavoritePlugin;
@@ -1,123 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { createStorageWriter, readStorage, StorageCategory, StorageMedium, } from '@telia-ace/widget-services';
38
- var storageKey = 'favorites';
39
- var createWriter = function (container) { return __awaiter(void 0, void 0, void 0, function () {
40
- return __generator(this, function (_a) {
41
- switch (_a.label) {
42
- case 0: return [4 /*yield*/, createStorageWriter(container, storageKey, StorageCategory.Necessary, {
43
- medium: StorageMedium.Local,
44
- })];
45
- case 1: return [2 /*return*/, _a.sent()];
46
- }
47
- });
48
- }); };
49
- var getStoredFavorites = function (container) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0: return [4 /*yield*/, readStorage(container, storageKey, StorageMedium.Local)];
52
- case 1: return [2 /*return*/, (_a.sent()) || []];
53
- }
54
- }); }); };
55
- export var addFavoriteToStorage = function (guideId, container) { return __awaiter(void 0, void 0, void 0, function () {
56
- var write, favorites, updated;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0: return [4 /*yield*/, createWriter(container)];
60
- case 1:
61
- write = _a.sent();
62
- return [4 /*yield*/, getStoredFavorites(container)];
63
- case 2:
64
- favorites = _a.sent();
65
- if (favorites.indexOf(guideId) > -1) {
66
- return [2 /*return*/, favorites];
67
- }
68
- updated = favorites.concat(guideId);
69
- write(updated);
70
- return [2 /*return*/, updated];
71
- }
72
- });
73
- }); };
74
- export var removeFavoriteFromStorage = function (guideId, container) { return __awaiter(void 0, void 0, void 0, function () {
75
- var write, favorites, updated;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0: return [4 /*yield*/, createWriter(container)];
79
- case 1:
80
- write = _a.sent();
81
- return [4 /*yield*/, getStoredFavorites(container)];
82
- case 2:
83
- favorites = _a.sent();
84
- updated = favorites.filter(function (id) { return id !== guideId; });
85
- write(updated);
86
- return [2 /*return*/, updated];
87
- }
88
- });
89
- }); };
90
- export var readFavoritesFromStorage = function (container) { return __awaiter(void 0, void 0, void 0, function () {
91
- var favorites, e_1;
92
- return __generator(this, function (_a) {
93
- switch (_a.label) {
94
- case 0:
95
- _a.trys.push([0, 2, , 3]);
96
- return [4 /*yield*/, getStoredFavorites(container)];
97
- case 1:
98
- favorites = _a.sent();
99
- return [2 /*return*/, favorites];
100
- case 2:
101
- e_1 = _a.sent();
102
- return [2 /*return*/, []];
103
- case 3: return [2 /*return*/];
104
- }
105
- });
106
- }); };
107
- export var removeAllFavoritesFromStorage = function (container) { return __awaiter(void 0, void 0, void 0, function () {
108
- var write;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0: return [4 /*yield*/, createWriter(container)];
112
- case 1:
113
- write = _a.sent();
114
- write([]);
115
- return [2 /*return*/, []];
116
- }
117
- });
118
- }); };
119
- export var notifyListeners = function (container, data) {
120
- var updated = data.updated;
121
- var events = container.get('$widget').events;
122
- events.dispatch('widget:favorites-updated', { updated: updated });
123
- };
package/lib-esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { default as FavoritePlugin } from './favorite';
2
- export { default as LegacyResourcesPlugin } from './legacy-resources';
3
- export { default as MiscBehaviorPlugin } from './misc-behavior';
@@ -1,2 +0,0 @@
1
- import LegacyResources from './legacy-resources';
2
- export default LegacyResources;
@@ -1,54 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { ResourceLoader } from '@telia-ace/knowledge-resource-loader';
17
- import { Plugin } from '@telia-ace/knowledge-widget-core';
18
- var getHostFromUrl = function (url) {
19
- var parser = document.createElement('a');
20
- parser.href = url;
21
- return "//".concat(parser.hostname, "/");
22
- };
23
- /**
24
- * Downloads legacy resources for a widget. These resources are to be treated as legacy. When the
25
- * Webprovisions bundling service is available these resources should be included as their own
26
- * plugins and be part of the output.
27
- */
28
- var LegacyResourcesPlugin = /** @class */ (function (_super) {
29
- __extends(LegacyResourcesPlugin, _super);
30
- function LegacyResourcesPlugin(container, settings) {
31
- if (settings === void 0) { settings = {}; }
32
- var _this = _super.call(this, container) || this;
33
- _this.widget.events.subscribeOnce('widget:attached', function () {
34
- var _a;
35
- var projection = _this.container.get('$settings').data.projection;
36
- if (projection) {
37
- var host = getHostFromUrl(projection);
38
- var loader = new ResourceLoader();
39
- loader.add("".concat(host, "ClientLibraries/Supplementary/font-awesome-4.7.0/css/font-awesome.min.css")); // tslint:disable-line max-line-length
40
- loader.add("".concat(host).concat((_a = _this.container.parent) === null || _a === void 0 ? void 0 : _a.name, "/widgets.css"));
41
- loader.load();
42
- }
43
- var _b = settings.initialCss, initialCss = _b === void 0 ? '' : _b;
44
- if (initialCss.length) {
45
- var style = document.createElement('style');
46
- style.innerHTML = initialCss;
47
- document.head.appendChild(style);
48
- }
49
- });
50
- return _this;
51
- }
52
- return LegacyResourcesPlugin;
53
- }(Plugin));
54
- export default LegacyResourcesPlugin;
@@ -1,68 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { extendComponent } from '@telia-ace/knowledge-widget-core';
38
- /**
39
- * Sets contactMethod.expanded and contactMethod.inline for contactMethods
40
- * with a clientName that match the regular expression passed in
41
- * the denyAutoExpandContactMethods-setting
42
- */
43
- export default (function (container, settings) { return __awaiter(void 0, void 0, void 0, function () {
44
- var denyAutoExpandContactMethods, regExp_1;
45
- return __generator(this, function (_a) {
46
- denyAutoExpandContactMethods = settings.denyAutoExpandContactMethods;
47
- if (denyAutoExpandContactMethods) {
48
- regExp_1 = new RegExp(denyAutoExpandContactMethods);
49
- extendComponent(container, 'contact-list', function (component) {
50
- component.properties(function (_a) {
51
- var _b = _a.contactMethods, contactMethods = _b === void 0 ? [] : _b;
52
- var deniedContactMethods = contactMethods.filter(function (_a) {
53
- var clientName = _a.clientName;
54
- return regExp_1.test(clientName);
55
- });
56
- if (deniedContactMethods.length) {
57
- deniedContactMethods.forEach(function (cm) {
58
- cm.expanded = false;
59
- cm.inline = false;
60
- });
61
- return { contactMethods: contactMethods };
62
- }
63
- });
64
- });
65
- }
66
- return [2 /*return*/, []];
67
- });
68
- }); });
@@ -1,124 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { DataType } from '@telia-ace/knowledge-widget-types-grid';
38
- import { createStorageWriter, readStorage, StorageCategory } from '@telia-ace/widget-services';
39
- var STORAGE_KEY = 'misc-behavior:hideBackValue';
40
- /**
41
- * Will hide the back-button in the widget-header back-button if there
42
- * is only a single contact method in the contact-list.
43
- */
44
- export default (function (container, settings) { return __awaiter(void 0, void 0, void 0, function () {
45
- var writeToStorage, events;
46
- return __generator(this, function (_a) {
47
- writeToStorage = function (mainWidget, hideBackValue) {
48
- return container.getAsync('dataClient').then(function (dataClient) {
49
- return dataClient
50
- .fetch(DataType.ContactMethodCategories, {})
51
- .then(function (result) {
52
- if (result) {
53
- var _a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
54
- if (hideBackValue === null) {
55
- hideBackValue = categories.length === 0 && contactMethods.length === 1;
56
- return createStorageWriter(mainWidget.container, STORAGE_KEY, StorageCategory.Functional).then(function (write) { return write(hideBackValue); });
57
- }
58
- }
59
- });
60
- });
61
- };
62
- events = container.get('$widget').events;
63
- events.subscribe('widget:render-state-changed', function (event, data) { return __awaiter(void 0, void 0, void 0, function () {
64
- var hideBackOnSingleContactMethod, mainWidget, widget, name_1, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- if (!(event.target.state === 'activated' && data.next === 'open')) return [3 /*break*/, 6];
69
- hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
70
- mainWidget = void 0;
71
- widget = container.get('$widget');
72
- name_1 = widget.name, implementation = widget.implementation;
73
- if (name_1.endsWith('_contact')) {
74
- mainWidget = implementation.widgets.get(name_1.replace('_contact', ''));
75
- }
76
- else if (!name_1.endsWith('_contact-method')) {
77
- mainWidget = widget;
78
- }
79
- if (!mainWidget) return [3 /*break*/, 6];
80
- hideBackValue_1 = null;
81
- return [4 /*yield*/, readStorage(mainWidget.container, STORAGE_KEY)];
82
- case 1:
83
- storedHideBackValue = _a.sent();
84
- return [4 /*yield*/, mainWidget.container.getAsync('components')];
85
- case 2:
86
- componentPlatform = _a.sent();
87
- widgetHeaders = componentPlatform
88
- .components()
89
- .ofType('widget-header')
90
- .select();
91
- if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
92
- hideBackValue_1 = storedHideBackValue;
93
- return [3 /*break*/, 5];
94
- case 3:
95
- if (!hideBackOnSingleContactMethod) return [3 /*break*/, 5];
96
- return [4 /*yield*/, writeToStorage(mainWidget, hideBackValue_1)];
97
- case 4:
98
- _a.sent();
99
- _a.label = 5;
100
- case 5:
101
- /* if hideBackOnSingleContactMethod == true
102
- * or if we have a hideBackValue (from session storage)
103
- * hide back if hideBackValue == true
104
- * and add show-back action watcher
105
- */
106
- if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
107
- if (hideBackValue_1) {
108
- widgetHeaders.actions.dispatch('show-back', false);
109
- }
110
- widgetHeaders.actions.watch('show-back', function (data, next) {
111
- if (hideBackValue_1 && data) {
112
- return next(false);
113
- }
114
- return next(data);
115
- });
116
- }
117
- _a.label = 6;
118
- case 6: return [2 /*return*/];
119
- }
120
- });
121
- }); });
122
- return [2 /*return*/, []];
123
- });
124
- }); });
@@ -1,2 +0,0 @@
1
- import plugin from './plugin';
2
- export default plugin;