@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
package/LICENSE.txt
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
export declare type FavoritePlatform = {
|
|
3
|
+
add: (guideId: string) => Promise<string[]>;
|
|
4
|
+
remove: (guideId: string) => Promise<string[]>;
|
|
5
|
+
clear: () => Promise<string[]>;
|
|
6
|
+
get: () => string[];
|
|
7
|
+
};
|
|
8
|
+
declare const createFavoritePlatform: (container: Container) => FavoritePlatform;
|
|
9
|
+
export default createFavoritePlatform;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 utils_1 = require("./utils");
|
|
40
|
+
var createFavoritePlatform = function (container) {
|
|
41
|
+
var favorites = [];
|
|
42
|
+
var initialize = function () {
|
|
43
|
+
(0, utils_1.readFavoritesFromStorage)(container).then(function (items) {
|
|
44
|
+
favorites = items;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var get = function () {
|
|
48
|
+
return favorites;
|
|
49
|
+
};
|
|
50
|
+
var add = function (guideId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var updated;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0: return [4 /*yield*/, (0, utils_1.addFavoriteToStorage)(guideId, container)];
|
|
55
|
+
case 1:
|
|
56
|
+
updated = _a.sent();
|
|
57
|
+
favorites = updated;
|
|
58
|
+
(0, utils_1.notifyListeners)(container, { updated: updated });
|
|
59
|
+
return [2 /*return*/, updated];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}); };
|
|
63
|
+
var clear = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
var updated;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0: return [4 /*yield*/, (0, utils_1.removeAllFavoritesFromStorage)(container)];
|
|
68
|
+
case 1:
|
|
69
|
+
updated = _a.sent();
|
|
70
|
+
favorites = updated;
|
|
71
|
+
(0, utils_1.notifyListeners)(container, { updated: updated });
|
|
72
|
+
return [2 /*return*/, updated];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}); };
|
|
76
|
+
var remove = function (guideId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
var updated;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0: return [4 /*yield*/, (0, utils_1.removeFavoriteFromStorage)(guideId, container)];
|
|
81
|
+
case 1:
|
|
82
|
+
updated = _a.sent();
|
|
83
|
+
favorites = updated;
|
|
84
|
+
(0, utils_1.notifyListeners)(container, { updated: updated });
|
|
85
|
+
return [2 /*return*/, updated];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); };
|
|
89
|
+
initialize();
|
|
90
|
+
return {
|
|
91
|
+
add: add,
|
|
92
|
+
get: get,
|
|
93
|
+
clear: clear,
|
|
94
|
+
remove: remove,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.default = createFavoritePlatform;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Plugin } from '@telia-ace/knowledge-widget-core';
|
|
2
|
+
import { Container } from '@webprovisions/platform';
|
|
3
|
+
import { FavoritePlatform } from './favorite-platform';
|
|
4
|
+
export declare type FavoritePluginSettings = {};
|
|
5
|
+
export default class FavoritePlugin extends Plugin {
|
|
6
|
+
settings: FavoritePluginSettings;
|
|
7
|
+
handler: FavoritePlatform;
|
|
8
|
+
constructor(container: Container, settings: FavoritePluginSettings);
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var knowledge_widget_core_1 = require("@telia-ace/knowledge-widget-core");
|
|
22
|
+
var favorite_platform_1 = __importDefault(require("./favorite-platform"));
|
|
23
|
+
var FavoritePlugin = /** @class */ (function (_super) {
|
|
24
|
+
__extends(FavoritePlugin, _super);
|
|
25
|
+
function FavoritePlugin(container, settings) {
|
|
26
|
+
var _this = _super.call(this, container) || this;
|
|
27
|
+
_this.settings = settings;
|
|
28
|
+
_this.handler = (0, favorite_platform_1.default)(container);
|
|
29
|
+
container.register('favorites', _this.handler);
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
return FavoritePlugin;
|
|
33
|
+
}(knowledge_widget_core_1.Plugin));
|
|
34
|
+
exports.default = FavoritePlugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var favorite_1 = __importDefault(require("./favorite"));
|
|
7
|
+
exports.default = favorite_1.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
export declare const addFavoriteToStorage: (guideId: string, container: Container) => Promise<string[]>;
|
|
3
|
+
export declare const removeFavoriteFromStorage: (guideId: string, container: Container) => Promise<string[]>;
|
|
4
|
+
export declare const readFavoritesFromStorage: (container: Container) => Promise<string[]>;
|
|
5
|
+
export declare const removeAllFavoritesFromStorage: (container: Container) => Promise<never[]>;
|
|
6
|
+
export declare const notifyListeners: (container: Container, data: {
|
|
7
|
+
updated: string[];
|
|
8
|
+
}) => void;
|
|
@@ -0,0 +1,131 @@
|
|
|
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
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var legacy_resources_1 = __importDefault(require("./legacy-resources"));
|
|
7
|
+
exports.default = legacy_resources_1.default;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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;
|
|
@@ -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,70 @@
|
|
|
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
|
+
}); });
|
|
@@ -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,110 @@
|
|
|
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 hideBackOnSingleContactMethod, mainWidget, widget, name, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders, dataClient, result, _a, categories, _b, contactMethods;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
|
|
52
|
+
widget = container.get('$widget');
|
|
53
|
+
name = widget.name, implementation = widget.implementation;
|
|
54
|
+
if (name.endsWith('_contact')) {
|
|
55
|
+
mainWidget = implementation.widgets.get(name.replace('_contact', ''));
|
|
56
|
+
}
|
|
57
|
+
else if (!name.endsWith('_contact-method')) {
|
|
58
|
+
mainWidget = widget;
|
|
59
|
+
}
|
|
60
|
+
if (!mainWidget) return [3 /*break*/, 7];
|
|
61
|
+
hideBackValue_1 = null;
|
|
62
|
+
return [4 /*yield*/, (0, widget_services_1.readStorage)(mainWidget.container, STORAGE_KEY)];
|
|
63
|
+
case 1:
|
|
64
|
+
storedHideBackValue = _c.sent();
|
|
65
|
+
return [4 /*yield*/, mainWidget.container.getAsync('components')];
|
|
66
|
+
case 2:
|
|
67
|
+
componentPlatform = _c.sent();
|
|
68
|
+
widgetHeaders = componentPlatform.components().ofType('widget-header').select();
|
|
69
|
+
if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
|
|
70
|
+
hideBackValue_1 = storedHideBackValue;
|
|
71
|
+
return [3 /*break*/, 6];
|
|
72
|
+
case 3:
|
|
73
|
+
if (!hideBackOnSingleContactMethod) return [3 /*break*/, 6];
|
|
74
|
+
return [4 /*yield*/, container.getAsync('dataClient')];
|
|
75
|
+
case 4:
|
|
76
|
+
dataClient = _c.sent();
|
|
77
|
+
return [4 /*yield*/, (dataClient === null || dataClient === void 0 ? void 0 : dataClient.fetch(knowledge_widget_types_grid_1.DataType.ContactMethodCategories, {}))];
|
|
78
|
+
case 5:
|
|
79
|
+
result = (_c.sent()) ||
|
|
80
|
+
Promise.resolve();
|
|
81
|
+
if (result) {
|
|
82
|
+
_a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
|
|
83
|
+
if (hideBackValue_1 === null) {
|
|
84
|
+
hideBackValue_1 = categories.length === 0 && contactMethods.length === 1;
|
|
85
|
+
(0, widget_services_1.createStorageWriter)(mainWidget.container, STORAGE_KEY, widget_services_1.StorageCategory.Necessary).then(function (write) { return write(hideBackValue_1); });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
_c.label = 6;
|
|
89
|
+
case 6:
|
|
90
|
+
/* if hideBackOnSingleContactMethod == true
|
|
91
|
+
* or if we have a hideBackValue (from session storage)
|
|
92
|
+
* hide back if hideBackValue == true
|
|
93
|
+
* and add show-back action watcher
|
|
94
|
+
*/
|
|
95
|
+
if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
|
|
96
|
+
if (hideBackValue_1) {
|
|
97
|
+
widgetHeaders.actions.dispatch('show-back', false);
|
|
98
|
+
}
|
|
99
|
+
widgetHeaders.actions.watch('show-back', function (data, next) {
|
|
100
|
+
if (hideBackValue_1 && data) {
|
|
101
|
+
return next(false);
|
|
102
|
+
}
|
|
103
|
+
return next(data);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
_c.label = 7;
|
|
107
|
+
case 7: return [2 /*return*/, []];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var plugin_1 = __importDefault(require("./plugin"));
|
|
7
|
+
exports.default = plugin_1.default;
|