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