@telia-ace/knowledge-widget-plugins 1.0.12 → 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,100 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (_) try {
32
- 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;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- import { Plugin } from '@telia-ace/knowledge-widget-core';
53
- import denyAutoExpandContactMethodsHandler from './deny-auto-expand-contact-methods-handler';
54
- import hideBackOnSingleContactMethodHandler from './hide-back-on-single-contact-method-handler';
55
- import searchGuideListKeyboardNavigationHandler from './search-guide-list-keyboard-navigation-handler';
56
- var MiscBehaviorPlugin = /** @class */ (function (_super) {
57
- __extends(MiscBehaviorPlugin, _super);
58
- function MiscBehaviorPlugin(container, settings) {
59
- if (settings === void 0) { settings = {}; }
60
- var _this = _super.call(this, container) || this;
61
- _this.settings = settings;
62
- _this.listeners = [];
63
- return _this;
64
- }
65
- MiscBehaviorPlugin.prototype.initialize = function () {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var _a;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
70
- case 0:
71
- _a = this;
72
- return [4 /*yield*/, Promise.all([
73
- Promise.resolve(hideBackOnSingleContactMethodHandler(this.container, this.settings)),
74
- Promise.resolve(denyAutoExpandContactMethodsHandler(this.container, this.settings)),
75
- Promise.resolve(searchGuideListKeyboardNavigationHandler(this.container, this.settings)),
76
- ]).then(function (listenerArray) {
77
- var listeners = [];
78
- listenerArray.forEach(function (a) { return a.forEach(function (l) { return listeners.push(l); }); });
79
- listeners.forEach(function (_a) {
80
- var parent = _a.parent, type = _a.type, handler = _a.handler;
81
- parent.addEventListener(type, handler);
82
- });
83
- return listeners;
84
- })];
85
- case 1:
86
- _a.listeners = _b.sent();
87
- return [2 /*return*/];
88
- }
89
- });
90
- });
91
- };
92
- MiscBehaviorPlugin.prototype.deactivate = function () {
93
- this.listeners.forEach(function (listener) {
94
- var parent = listener.parent, handler = listener.handler, type = listener.type;
95
- parent.removeEventListener(type, handler);
96
- });
97
- };
98
- return MiscBehaviorPlugin;
99
- }(Plugin));
100
- export default MiscBehaviorPlugin;
@@ -1,139 +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
- var __read = (this && this.__read) || function (o, n) {
38
- var m = typeof Symbol === "function" && o[Symbol.iterator];
39
- if (!m) return o;
40
- var i = m.call(o), r, ar = [], e;
41
- try {
42
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43
- }
44
- catch (error) { e = { error: error }; }
45
- finally {
46
- try {
47
- if (r && !r.done && (m = i["return"])) m.call(i);
48
- }
49
- finally { if (e) throw e.error; }
50
- }
51
- return ar;
52
- };
53
- var isQuickFilterOpen = function (searchElements) {
54
- return searchElements.reduce(function (acc, current) {
55
- if (acc) {
56
- return acc;
57
- }
58
- var _a = __read(Array.from((current === null || current === void 0 ? void 0 : current.getElementsByClassName('humany-quick-filter-dropdown')) || []), 1), element = _a[0];
59
- if (element) {
60
- return true;
61
- }
62
- return false;
63
- }, false);
64
- };
65
- var isSearchElementFocused = function (searchElements) {
66
- return searchElements.reduce(function (acc, current) {
67
- if (acc) {
68
- return acc;
69
- }
70
- var _a = __read(Array.from((current === null || current === void 0 ? void 0 : current.getElementsByTagName('input')) || []), 1), input = _a[0];
71
- if (input && input === document.activeElement) {
72
- return true;
73
- }
74
- return false;
75
- }, false);
76
- };
77
- var getGuideListLinks = function () {
78
- return Array.from(document.querySelectorAll('[data-component-type="guide-list"]')).reduce(function (acc, current) {
79
- var links = Array.from(current.getElementsByTagName('a'));
80
- links.forEach(function (l) { return acc.push(l); });
81
- return acc;
82
- }, []);
83
- };
84
- /**
85
- * Will focus guide-list when focusing search-input and pressing arrow-down key
86
- */
87
- export default (function (container, settings) { return __awaiter(void 0, void 0, void 0, function () {
88
- var _a, searchToGuideListArrowKeyNavigation;
89
- return __generator(this, function (_b) {
90
- _a = settings.searchToGuideListArrowKeyNavigation, searchToGuideListArrowKeyNavigation = _a === void 0 ? false : _a;
91
- if (searchToGuideListArrowKeyNavigation) {
92
- return [2 /*return*/, container.getAsync('components').then(function (platform) {
93
- var all = platform.nodes.all;
94
- var searchComponentIds = all.filter(function (n) { return n.type === 'search'; }).map(function (n) { return n.id; });
95
- var listeners = [];
96
- listeners.push({
97
- parent: window,
98
- type: 'keydown',
99
- handler: function (e) {
100
- var _a, _b, _c, _d;
101
- var searchComponentElements = [];
102
- searchComponentIds.forEach(function (id) {
103
- var element = document.getElementById(id);
104
- if (element) {
105
- searchComponentElements.push(element);
106
- }
107
- });
108
- var quickFilterDropdownOpen = isQuickFilterOpen(searchComponentElements);
109
- var searchElementIsFocused = isSearchElementFocused(searchComponentElements);
110
- var guideListLinks = getGuideListLinks();
111
- var guideListLinkFocusIndex = guideListLinks.indexOf(document.activeElement);
112
- if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') &&
113
- (searchElementIsFocused || guideListLinkFocusIndex > -1)) {
114
- e.preventDefault();
115
- }
116
- if (e.key === 'ArrowDown' &&
117
- searchElementIsFocused &&
118
- !quickFilterDropdownOpen) {
119
- guideListLinks[0].focus();
120
- }
121
- else {
122
- if (e.key === 'ArrowUp' && guideListLinkFocusIndex === 0) {
123
- (_b = (_a = searchComponentElements[0]) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('input')[0]) === null || _b === void 0 ? void 0 : _b.focus();
124
- }
125
- else if (e.key === 'ArrowUp' && guideListLinkFocusIndex > -1) {
126
- (_c = guideListLinks[guideListLinkFocusIndex - 1]) === null || _c === void 0 ? void 0 : _c.focus();
127
- }
128
- else if (e.key === 'ArrowDown' && guideListLinkFocusIndex > -1) {
129
- (_d = guideListLinks[guideListLinkFocusIndex + 1]) === null || _d === void 0 ? void 0 : _d.focus();
130
- }
131
- }
132
- },
133
- });
134
- return listeners;
135
- })];
136
- }
137
- return [2 /*return*/, Promise.resolve([])];
138
- });
139
- }); });