@telia-ace/knowledge-widget-plugins 1.0.14 → 1.0.17
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 +5 -5
- package/README.md +3 -3
- package/{lib-esm → dist}/favorite/favorite-platform.d.ts +9 -9
- package/{lib → dist}/favorite/favorite.d.ts +9 -9
- package/{lib-esm → dist}/favorite/index.d.ts +2 -2
- package/{lib → dist}/favorite/utils.d.ts +8 -8
- package/{lib → dist}/index.d.ts +3 -3
- package/dist/index.js +321 -0
- package/dist/index.js.map +1 -0
- package/{lib → dist}/legacy-resources/index.d.ts +2 -2
- package/{lib → dist}/legacy-resources/legacy-resources.d.ts +14 -14
- package/{lib → dist}/misc-behavior/deny-auto-expand-contact-methods-handler.d.ts +9 -9
- package/{lib → dist}/misc-behavior/hide-back-on-single-contact-method-handler.d.ts +8 -8
- package/{lib → dist}/misc-behavior/index.d.ts +2 -2
- package/{lib-esm → dist}/misc-behavior/plugin.d.ts +19 -19
- package/{lib → dist}/misc-behavior/search-guide-list-keyboard-navigation-handler.d.ts +7 -7
- package/package.json +16 -17
- package/lib/favorite/favorite-platform.d.ts +0 -9
- package/lib/favorite/favorite-platform.js +0 -97
- 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.js +0 -131
- package/lib/index.js +0 -12
- package/lib/legacy-resources/index.js +0 -7
- package/lib/legacy-resources/legacy-resources.js +0 -56
- package/lib/misc-behavior/deny-auto-expand-contact-methods-handler.js +0 -70
- package/lib/misc-behavior/hide-back-on-single-contact-method-handler.js +0 -126
- 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.js +0 -141
- package/lib-esm/favorite/favorite-platform.js +0 -95
- package/lib-esm/favorite/favorite.d.ts +0 -9
- package/lib-esm/favorite/favorite.js +0 -29
- package/lib-esm/favorite/index.js +0 -2
- package/lib-esm/favorite/utils.d.ts +0 -8
- package/lib-esm/favorite/utils.js +0 -123
- package/lib-esm/index.d.ts +0 -3
- package/lib-esm/index.js +0 -3
- package/lib-esm/legacy-resources/index.d.ts +0 -2
- package/lib-esm/legacy-resources/index.js +0 -2
- package/lib-esm/legacy-resources/legacy-resources.d.ts +0 -14
- package/lib-esm/legacy-resources/legacy-resources.js +0 -54
- package/lib-esm/misc-behavior/deny-auto-expand-contact-methods-handler.d.ts +0 -9
- 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.d.ts +0 -8
- package/lib-esm/misc-behavior/hide-back-on-single-contact-method-handler.js +0 -124
- package/lib-esm/misc-behavior/index.d.ts +0 -2
- 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.d.ts +0 -7
- package/lib-esm/misc-behavior/search-guide-list-keyboard-navigation-handler.js +0 -139
package/package.json
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/knowledge-widget-plugins",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Plugins for ACE Knowledge Widgets.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"telia"
|
|
9
9
|
],
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"module": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
12
|
"files": [
|
|
13
13
|
"LICENSE.txt",
|
|
14
14
|
"README.md",
|
|
15
|
-
"
|
|
16
|
-
"lib-esm/"
|
|
15
|
+
"dist/"
|
|
17
16
|
],
|
|
18
17
|
"publishConfig": {
|
|
19
18
|
"access": "public"
|
|
20
19
|
},
|
|
21
20
|
"scripts": {
|
|
22
|
-
"clean": "
|
|
23
|
-
"
|
|
21
|
+
"clean": "rimraf ./dist",
|
|
22
|
+
"precompile": "tsc -emitDeclarationOnly",
|
|
23
|
+
"compile": "vite build"
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
26
|
-
"typings": "lib/index.d.ts",
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@telia-ace/knowledge-resource-loader": "^1.0.
|
|
29
|
-
"@telia-ace/knowledge-widget-adapters": "^1.0.
|
|
30
|
-
"@telia-ace/knowledge-widget-core": "^1.0.
|
|
31
|
-
"@telia-ace/knowledge-widget-types-grid": "^1.0.
|
|
32
|
-
"@telia-ace/knowledge-widget-ui": "^1.0.
|
|
33
|
-
"@telia-ace/widget-routing": "^1.0.
|
|
34
|
-
"@telia-ace/widget-services": "^1.0.
|
|
35
|
-
"@telia-ace/widget-utilities": "^1.0.
|
|
27
|
+
"@telia-ace/knowledge-resource-loader": "^1.0.1",
|
|
28
|
+
"@telia-ace/knowledge-widget-adapters": "^1.0.16",
|
|
29
|
+
"@telia-ace/knowledge-widget-core": "^1.0.9",
|
|
30
|
+
"@telia-ace/knowledge-widget-types-grid": "^1.0.16",
|
|
31
|
+
"@telia-ace/knowledge-widget-ui": "^1.0.13",
|
|
32
|
+
"@telia-ace/widget-routing": "^1.0.8",
|
|
33
|
+
"@telia-ace/widget-services": "^1.0.7",
|
|
34
|
+
"@telia-ace/widget-utilities": "^1.0.2",
|
|
36
35
|
"@webprovisions/platform": "^1.1.2"
|
|
37
36
|
},
|
|
38
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "a8bf8e5c1ca56a4749cd8ec47f756b13431394b4"
|
|
39
38
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,97 +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 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;
|
package/lib/favorite/favorite.js
DELETED
|
@@ -1,34 +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 __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;
|
package/lib/favorite/index.d.ts
DELETED
package/lib/favorite/index.js
DELETED
|
@@ -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 favorite_1 = __importDefault(require("./favorite"));
|
|
7
|
-
exports.default = favorite_1.default;
|
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.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,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,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,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
|
-
}
|