@telia-ace/knowledge-widget-plugins 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/favorite/favorite-platform.d.ts +9 -0
- package/lib/favorite/favorite-platform.js +97 -0
- package/lib/favorite/favorite.d.ts +9 -0
- package/lib/favorite/favorite.js +34 -0
- package/lib/favorite/index.d.ts +2 -0
- package/lib/favorite/index.js +7 -0
- package/lib/favorite/utils.d.ts +8 -0
- package/lib/favorite/utils.js +131 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +12 -0
- package/lib/legacy-resources/index.d.ts +2 -0
- package/lib/legacy-resources/index.js +7 -0
- package/lib/legacy-resources/legacy-resources.d.ts +14 -0
- package/lib/legacy-resources/legacy-resources.js +56 -0
- package/lib/misc-behavior/deny-auto-expand-contact-methods-handler.d.ts +9 -0
- package/lib/misc-behavior/deny-auto-expand-contact-methods-handler.js +70 -0
- package/lib/misc-behavior/hide-back-on-single-contact-method-handler.d.ts +8 -0
- package/lib/misc-behavior/hide-back-on-single-contact-method-handler.js +110 -0
- package/lib/misc-behavior/index.d.ts +2 -0
- package/lib/misc-behavior/index.js +7 -0
- package/lib/misc-behavior/plugin.d.ts +19 -0
- package/lib/misc-behavior/plugin.js +105 -0
- package/lib/misc-behavior/search-guide-list-keyboard-navigation-handler.d.ts +7 -0
- package/lib/misc-behavior/search-guide-list-keyboard-navigation-handler.js +141 -0
- package/lib-esm/favorite/favorite-platform.d.ts +9 -0
- package/lib-esm/favorite/favorite-platform.js +95 -0
- package/lib-esm/favorite/favorite.d.ts +9 -0
- package/lib-esm/favorite/favorite.js +29 -0
- package/lib-esm/favorite/index.d.ts +2 -0
- package/lib-esm/favorite/index.js +2 -0
- package/lib-esm/favorite/utils.d.ts +8 -0
- package/lib-esm/favorite/utils.js +123 -0
- package/lib-esm/index.d.ts +3 -0
- package/lib-esm/index.js +3 -0
- package/lib-esm/legacy-resources/index.d.ts +2 -0
- package/lib-esm/legacy-resources/index.js +2 -0
- package/lib-esm/legacy-resources/legacy-resources.d.ts +14 -0
- package/lib-esm/legacy-resources/legacy-resources.js +54 -0
- package/lib-esm/misc-behavior/deny-auto-expand-contact-methods-handler.d.ts +9 -0
- package/lib-esm/misc-behavior/deny-auto-expand-contact-methods-handler.js +68 -0
- package/lib-esm/misc-behavior/hide-back-on-single-contact-method-handler.d.ts +8 -0
- package/lib-esm/misc-behavior/hide-back-on-single-contact-method-handler.js +108 -0
- package/lib-esm/misc-behavior/index.d.ts +2 -0
- package/lib-esm/misc-behavior/index.js +2 -0
- package/lib-esm/misc-behavior/plugin.d.ts +19 -0
- package/lib-esm/misc-behavior/plugin.js +100 -0
- package/lib-esm/misc-behavior/search-guide-list-keyboard-navigation-handler.d.ts +7 -0
- package/lib-esm/misc-behavior/search-guide-list-keyboard-navigation-handler.js +139 -0
- package/package.json +39 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import { Settings } from './plugin';
|
|
3
|
+
declare const _default: (container: Container, settings: Settings) => Promise<never[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Sets contactMethod.expanded and contactMethod.inline for contactMethods
|
|
6
|
+
* with a clientName that match the regular expression passed in
|
|
7
|
+
* the denyAutoExpandContactMethods-setting
|
|
8
|
+
*/
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
}); });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import { Settings } from './plugin';
|
|
3
|
+
declare const _default: (container: Container, settings: Settings) => Promise<never[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Will hide the back-button in the widget-header back-button if there
|
|
6
|
+
* is only a single contact method in the contact-list.
|
|
7
|
+
*/
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 hideBackOnSingleContactMethod, mainWidget, widget, name, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders, dataClient, result, _a, categories, _b, contactMethods;
|
|
46
|
+
return __generator(this, function (_c) {
|
|
47
|
+
switch (_c.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
|
|
50
|
+
widget = container.get('$widget');
|
|
51
|
+
name = widget.name, implementation = widget.implementation;
|
|
52
|
+
if (name.endsWith('_contact')) {
|
|
53
|
+
mainWidget = implementation.widgets.get(name.replace('_contact', ''));
|
|
54
|
+
}
|
|
55
|
+
else if (!name.endsWith('_contact-method')) {
|
|
56
|
+
mainWidget = widget;
|
|
57
|
+
}
|
|
58
|
+
if (!mainWidget) return [3 /*break*/, 7];
|
|
59
|
+
hideBackValue_1 = null;
|
|
60
|
+
return [4 /*yield*/, readStorage(mainWidget.container, STORAGE_KEY)];
|
|
61
|
+
case 1:
|
|
62
|
+
storedHideBackValue = _c.sent();
|
|
63
|
+
return [4 /*yield*/, mainWidget.container.getAsync('components')];
|
|
64
|
+
case 2:
|
|
65
|
+
componentPlatform = _c.sent();
|
|
66
|
+
widgetHeaders = componentPlatform.components().ofType('widget-header').select();
|
|
67
|
+
if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
|
|
68
|
+
hideBackValue_1 = storedHideBackValue;
|
|
69
|
+
return [3 /*break*/, 6];
|
|
70
|
+
case 3:
|
|
71
|
+
if (!hideBackOnSingleContactMethod) return [3 /*break*/, 6];
|
|
72
|
+
return [4 /*yield*/, container.getAsync('dataClient')];
|
|
73
|
+
case 4:
|
|
74
|
+
dataClient = _c.sent();
|
|
75
|
+
return [4 /*yield*/, (dataClient === null || dataClient === void 0 ? void 0 : dataClient.fetch(DataType.ContactMethodCategories, {}))];
|
|
76
|
+
case 5:
|
|
77
|
+
result = (_c.sent()) ||
|
|
78
|
+
Promise.resolve();
|
|
79
|
+
if (result) {
|
|
80
|
+
_a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
|
|
81
|
+
if (hideBackValue_1 === null) {
|
|
82
|
+
hideBackValue_1 = categories.length === 0 && contactMethods.length === 1;
|
|
83
|
+
createStorageWriter(mainWidget.container, STORAGE_KEY, StorageCategory.Necessary).then(function (write) { return write(hideBackValue_1); });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_c.label = 6;
|
|
87
|
+
case 6:
|
|
88
|
+
/* if hideBackOnSingleContactMethod == true
|
|
89
|
+
* or if we have a hideBackValue (from session storage)
|
|
90
|
+
* hide back if hideBackValue == true
|
|
91
|
+
* and add show-back action watcher
|
|
92
|
+
*/
|
|
93
|
+
if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
|
|
94
|
+
if (hideBackValue_1) {
|
|
95
|
+
widgetHeaders.actions.dispatch('show-back', false);
|
|
96
|
+
}
|
|
97
|
+
widgetHeaders.actions.watch('show-back', function (data, next) {
|
|
98
|
+
if (hideBackValue_1 && data) {
|
|
99
|
+
return next(false);
|
|
100
|
+
}
|
|
101
|
+
return next(data);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
_c.label = 7;
|
|
105
|
+
case 7: return [2 /*return*/, []];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}); });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plugin } from '@telia-ace/knowledge-widget-core';
|
|
2
|
+
import { Container } from '@webprovisions/platform';
|
|
3
|
+
export declare type Settings = {
|
|
4
|
+
denyAutoExpandContactMethods?: string;
|
|
5
|
+
hideBackOnSingleContactMethod?: boolean;
|
|
6
|
+
searchToGuideListArrowKeyNavigation?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare type Listerners = {
|
|
9
|
+
parent: HTMLElement | Window;
|
|
10
|
+
handler: (...args: any[]) => void;
|
|
11
|
+
type: string;
|
|
12
|
+
}[];
|
|
13
|
+
export default class MiscBehaviorPlugin extends Plugin {
|
|
14
|
+
settings: Settings;
|
|
15
|
+
listeners: Listerners;
|
|
16
|
+
constructor(container: Container, settings?: Settings);
|
|
17
|
+
initialize(): Promise<void>;
|
|
18
|
+
deactivate(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import { Listerners, Settings } from './plugin';
|
|
3
|
+
declare const _default: (container: Container, settings: Settings) => Promise<Listerners>;
|
|
4
|
+
/**
|
|
5
|
+
* Will focus guide-list when focusing search-input and pressing arrow-down key
|
|
6
|
+
*/
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
}); });
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/knowledge-widget-plugins",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Plugins 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-resource-loader": "^1.0.0",
|
|
29
|
+
"@telia-ace/knowledge-widget-adapters": "^1.0.1",
|
|
30
|
+
"@telia-ace/knowledge-widget-core": "^1.0.1",
|
|
31
|
+
"@telia-ace/knowledge-widget-types-grid": "^1.0.1",
|
|
32
|
+
"@telia-ace/knowledge-widget-ui": "^1.0.1",
|
|
33
|
+
"@telia-ace/widget-routing": "^1.0.1",
|
|
34
|
+
"@telia-ace/widget-services": "^1.0.1",
|
|
35
|
+
"@telia-ace/widget-utilities": "^1.0.1",
|
|
36
|
+
"@webprovisions/platform": "^1.1.2"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "2df7de1fc7344c709b46911133e9e50f7cab8e5c"
|
|
39
|
+
}
|