@telia-ace/widget-utilities 1.0.0
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/append-class-names.d.ts +6 -0
- package/lib/append-class-names.js +84 -0
- package/lib/batch.d.ts +4 -0
- package/lib/batch.js +38 -0
- package/lib/camilize.d.ts +1 -0
- package/lib/camilize.js +29 -0
- package/lib/category-trail.d.ts +14 -0
- package/lib/category-trail.js +96 -0
- package/lib/create-params.d.ts +21 -0
- package/lib/create-params.js +108 -0
- package/lib/data-uri-to-blob.d.ts +2 -0
- package/lib/data-uri-to-blob.js +20 -0
- package/lib/debug.d.ts +52 -0
- package/lib/debug.js +155 -0
- package/lib/deep-clone.d.ts +2 -0
- package/lib/deep-clone.js +21 -0
- package/lib/find-and-activate-stored-widgets.d.ts +9 -0
- package/lib/find-and-activate-stored-widgets.js +27 -0
- package/lib/find-category-by-id.d.ts +6 -0
- package/lib/find-category-by-id.js +89 -0
- package/lib/format-date.d.ts +2 -0
- package/lib/format-date.js +23 -0
- package/lib/format-url.d.ts +2 -0
- package/lib/format-url.js +111 -0
- package/lib/get-cookie.d.ts +1 -0
- package/lib/get-cookie.js +18 -0
- package/lib/has-non-empty-categories.d.ts +2 -0
- package/lib/has-non-empty-categories.js +23 -0
- package/lib/hash.d.ts +1 -0
- package/lib/hash.js +16 -0
- package/lib/html-parent-contains.d.ts +7 -0
- package/lib/html-parent-contains.js +21 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.js +57 -0
- package/lib/is-anchor-link.d.ts +2 -0
- package/lib/is-anchor-link.js +9 -0
- package/lib/kebab-case.d.ts +1 -0
- package/lib/kebab-case.js +9 -0
- package/lib/lock.d.ts +9 -0
- package/lib/lock.js +78 -0
- package/lib/merge-deep.d.ts +7 -0
- package/lib/merge-deep.js +72 -0
- package/lib/notify-data-loaded.d.ts +6 -0
- package/lib/notify-data-loaded.js +96 -0
- package/lib/remove-null-and-undefined-values.d.ts +6 -0
- package/lib/remove-null-and-undefined-values.js +12 -0
- package/lib/set-cookie.d.ts +1 -0
- package/lib/set-cookie.js +12 -0
- package/lib/shallow-compare.d.ts +6 -0
- package/lib/shallow-compare.js +25 -0
- package/lib/uuid.d.ts +1 -0
- package/lib/uuid.js +12 -0
- package/lib/wait-for.d.ts +20 -0
- package/lib/wait-for.js +52 -0
- package/lib-esm/append-class-names.d.ts +6 -0
- package/lib-esm/append-class-names.js +77 -0
- package/lib-esm/batch.d.ts +4 -0
- package/lib-esm/batch.js +36 -0
- package/lib-esm/camilize.d.ts +1 -0
- package/lib-esm/camilize.js +26 -0
- package/lib-esm/category-trail.d.ts +14 -0
- package/lib-esm/category-trail.js +87 -0
- package/lib-esm/create-params.d.ts +21 -0
- package/lib-esm/create-params.js +105 -0
- package/lib-esm/data-uri-to-blob.d.ts +2 -0
- package/lib-esm/data-uri-to-blob.js +18 -0
- package/lib-esm/debug.d.ts +52 -0
- package/lib-esm/debug.js +151 -0
- package/lib-esm/deep-clone.d.ts +2 -0
- package/lib-esm/deep-clone.js +19 -0
- package/lib-esm/find-and-activate-stored-widgets.d.ts +9 -0
- package/lib-esm/find-and-activate-stored-widgets.js +25 -0
- package/lib-esm/find-category-by-id.d.ts +6 -0
- package/lib-esm/find-category-by-id.js +87 -0
- package/lib-esm/format-date.d.ts +2 -0
- package/lib-esm/format-date.js +21 -0
- package/lib-esm/format-url.d.ts +2 -0
- package/lib-esm/format-url.js +109 -0
- package/lib-esm/get-cookie.d.ts +1 -0
- package/lib-esm/get-cookie.js +15 -0
- package/lib-esm/has-non-empty-categories.d.ts +2 -0
- package/lib-esm/has-non-empty-categories.js +18 -0
- package/lib-esm/hash.d.ts +1 -0
- package/lib-esm/hash.js +13 -0
- package/lib-esm/html-parent-contains.d.ts +7 -0
- package/lib-esm/html-parent-contains.js +19 -0
- package/lib-esm/index.d.ts +27 -0
- package/lib-esm/index.js +24 -0
- package/lib-esm/is-anchor-link.d.ts +2 -0
- package/lib-esm/is-anchor-link.js +7 -0
- package/lib-esm/kebab-case.d.ts +1 -0
- package/lib-esm/kebab-case.js +6 -0
- package/lib-esm/lock.d.ts +9 -0
- package/lib-esm/lock.js +75 -0
- package/lib-esm/merge-deep.d.ts +7 -0
- package/lib-esm/merge-deep.js +67 -0
- package/lib-esm/notify-data-loaded.d.ts +6 -0
- package/lib-esm/notify-data-loaded.js +94 -0
- package/lib-esm/remove-null-and-undefined-values.d.ts +6 -0
- package/lib-esm/remove-null-and-undefined-values.js +10 -0
- package/lib-esm/set-cookie.d.ts +1 -0
- package/lib-esm/set-cookie.js +9 -0
- package/lib-esm/shallow-compare.d.ts +6 -0
- package/lib-esm/shallow-compare.js +23 -0
- package/lib-esm/uuid.d.ts +1 -0
- package/lib-esm/uuid.js +9 -0
- package/lib-esm/wait-for.d.ts +20 -0
- package/lib-esm/wait-for.js +50 -0
- package/package.json +35 -0
package/LICENSE.txt
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare type ArgumentHandler = string | [boolean, string | string[]] | undefined;
|
|
2
|
+
export declare function uniqueClassArray(classNames: string[]): string[];
|
|
3
|
+
export declare function append(className1?: string, className2?: string): string;
|
|
4
|
+
export declare function handleFunctionArgument(expression: boolean, classes: string | string[]): string | undefined;
|
|
5
|
+
export default function appendClassNames(...args: ArgumentHandler[]): string;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.handleFunctionArgument = exports.append = exports.uniqueClassArray = void 0;
|
|
29
|
+
var _1 = require(".");
|
|
30
|
+
function uniqueClassArray(classNames) {
|
|
31
|
+
var classArray = [];
|
|
32
|
+
classNames.forEach(function (c) {
|
|
33
|
+
if (classArray.indexOf(c) === -1) {
|
|
34
|
+
classArray.push(c);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return classArray;
|
|
38
|
+
}
|
|
39
|
+
exports.uniqueClassArray = uniqueClassArray;
|
|
40
|
+
function append(className1, className2) {
|
|
41
|
+
if (className1 === void 0) { className1 = ''; }
|
|
42
|
+
if (className2 === void 0) { className2 = ''; }
|
|
43
|
+
var classNames = className1.split(' ').concat(className2.split(' '));
|
|
44
|
+
return uniqueClassArray(classNames).join(' ').trim();
|
|
45
|
+
}
|
|
46
|
+
exports.append = append;
|
|
47
|
+
function handleFunctionArgument(expression, classes) {
|
|
48
|
+
if (Boolean(expression)) {
|
|
49
|
+
if (typeof classes === 'string') {
|
|
50
|
+
return classes;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(classes)) {
|
|
53
|
+
var className_1 = '';
|
|
54
|
+
classes.forEach(function (c) { return (className_1 = append(className_1, c)); });
|
|
55
|
+
return className_1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.handleFunctionArgument = handleFunctionArgument;
|
|
60
|
+
function appendClassNames() {
|
|
61
|
+
var args = [];
|
|
62
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
63
|
+
args[_i] = arguments[_i];
|
|
64
|
+
}
|
|
65
|
+
var className = '';
|
|
66
|
+
if (args.length) {
|
|
67
|
+
args.forEach(function (argument) {
|
|
68
|
+
if (typeof argument === 'string') {
|
|
69
|
+
className = append(className, argument);
|
|
70
|
+
}
|
|
71
|
+
else if (Array.isArray(argument)) {
|
|
72
|
+
className = append(className, handleFunctionArgument.apply(void 0, __spreadArray([], __read(argument), false)));
|
|
73
|
+
}
|
|
74
|
+
else if (typeof argument !== 'undefined' && argument !== null) {
|
|
75
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
76
|
+
_1.Logger.warn.apply(_1.Logger, __spreadArray(['appendClassNames: arguments either have' +
|
|
77
|
+
'to be a string or [boolean, ...string[]]. Passed args:'], __read(args), false));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return className;
|
|
83
|
+
}
|
|
84
|
+
exports.default = appendClassNames;
|
package/lib/batch.d.ts
ADDED
package/lib/batch.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var createBatch = function (delay, createFallback) {
|
|
20
|
+
var timeout;
|
|
21
|
+
var queue = [];
|
|
22
|
+
return function (fn) {
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
return new Promise(function (resolve, reject) {
|
|
25
|
+
queue.push([fn, resolve, reject]);
|
|
26
|
+
timeout = setTimeout(function () {
|
|
27
|
+
var acc = createFallback();
|
|
28
|
+
queue.forEach(function (_a) {
|
|
29
|
+
var _b = __read(_a, 3), fn = _b[0], resolve = _b[1], reject = _b[2];
|
|
30
|
+
acc = fn(acc);
|
|
31
|
+
});
|
|
32
|
+
queue = [];
|
|
33
|
+
resolve(acc);
|
|
34
|
+
}, delay);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.default = createBatch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function camilize(obj: any): any;
|
package/lib/camilize.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function camilize(obj) {
|
|
4
|
+
var camilizedObject = {};
|
|
5
|
+
if (typeof obj === 'number' || typeof obj === 'string') {
|
|
6
|
+
return obj;
|
|
7
|
+
}
|
|
8
|
+
for (var prop in obj) {
|
|
9
|
+
if (obj.hasOwnProperty(prop)) {
|
|
10
|
+
var p = obj[prop];
|
|
11
|
+
var camilizedProp = prop.substring(0, 1).toLowerCase() + prop.substring(1);
|
|
12
|
+
if (Object.prototype.toString.call(p) === '[object Array]') {
|
|
13
|
+
camilizedObject[camilizedProp] = [];
|
|
14
|
+
for (var i = 0, c = p.length; i < c; i++) {
|
|
15
|
+
// tslint:disable-line no-increment-decrement
|
|
16
|
+
camilizedObject[camilizedProp].push(camilize(p[i]));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (p !== null && typeof p === 'object') {
|
|
20
|
+
camilizedObject[camilizedProp] = camilize(p);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
camilizedObject[camilizedProp] = p;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return camilizedObject;
|
|
28
|
+
}
|
|
29
|
+
exports.default = camilize;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
declare type Item = {
|
|
3
|
+
id: string;
|
|
4
|
+
items?: Item[];
|
|
5
|
+
title: string;
|
|
6
|
+
symbol?: any;
|
|
7
|
+
};
|
|
8
|
+
declare type ChildParentStructure = {
|
|
9
|
+
[key: number]: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function categoryTrail(id: string, items: Item[], ids?: string[], structure?: ChildParentStructure): string[];
|
|
12
|
+
export declare const getCategoryTrailAsObjects: (trail: string[], categories: Item[]) => Map<string, Item>;
|
|
13
|
+
export declare const buildCategoryTrail: (routeName: string, categoryIds: string | string[], container: Container, dataType?: 'guide-categories' | 'contact-method-categories') => Promise<any[]>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
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.buildCategoryTrail = exports.getCategoryTrailAsObjects = exports.categoryTrail = void 0;
|
|
7
|
+
var create_params_1 = __importDefault(require("./create-params"));
|
|
8
|
+
var find_category_by_id_1 = __importDefault(require("./find-category-by-id"));
|
|
9
|
+
var format_url_1 = __importDefault(require("./format-url"));
|
|
10
|
+
function childParentStructure(items, structure, parent) {
|
|
11
|
+
if (structure === void 0) { structure = {}; }
|
|
12
|
+
items.forEach(function (item) {
|
|
13
|
+
if (parent) {
|
|
14
|
+
structure[+item.id] = parent;
|
|
15
|
+
}
|
|
16
|
+
if (item.items) {
|
|
17
|
+
childParentStructure(item.items, structure, item.id);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return structure;
|
|
21
|
+
}
|
|
22
|
+
function categoryTrail(id, items, ids, structure) {
|
|
23
|
+
if (ids === void 0) { ids = [id]; }
|
|
24
|
+
if (structure === void 0) { structure = childParentStructure(items); }
|
|
25
|
+
var addAncestors = function (id) {
|
|
26
|
+
var parentId = structure[+id];
|
|
27
|
+
if (parentId) {
|
|
28
|
+
ids.unshift(parentId);
|
|
29
|
+
addAncestors(parentId);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var parentId = structure[+id];
|
|
33
|
+
if (parentId) {
|
|
34
|
+
ids.unshift(parentId);
|
|
35
|
+
addAncestors(parentId);
|
|
36
|
+
}
|
|
37
|
+
return ids;
|
|
38
|
+
}
|
|
39
|
+
exports.categoryTrail = categoryTrail;
|
|
40
|
+
var getCategoryTrailAsObjects = function (trail, categories) {
|
|
41
|
+
if (typeof trail === 'undefined' || typeof categories === 'undefined') {
|
|
42
|
+
return new Map();
|
|
43
|
+
}
|
|
44
|
+
return new Map(trail.map(function (categoryId) {
|
|
45
|
+
var category = (0, find_category_by_id_1.default)(categoryId, categories);
|
|
46
|
+
return [categoryId, category];
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
exports.getCategoryTrailAsObjects = getCategoryTrailAsObjects;
|
|
50
|
+
var buildCategoryTrail = function (routeName, categoryIds, container, dataType) {
|
|
51
|
+
if (dataType === void 0) { dataType = 'guide-categories'; }
|
|
52
|
+
return container.getAsync('dataClient').then(function (dataClient) {
|
|
53
|
+
return dataClient
|
|
54
|
+
.fetch(dataType, { expandCategories: 'descendants' })
|
|
55
|
+
.then(function (_a) {
|
|
56
|
+
var categories = _a.categories;
|
|
57
|
+
var buildTrail = function (id) {
|
|
58
|
+
var trail = categoryTrail(id, categories);
|
|
59
|
+
var objectTrail = (0, exports.getCategoryTrailAsObjects)(trail, categories);
|
|
60
|
+
var result = [];
|
|
61
|
+
trail.forEach(function (categoryId) {
|
|
62
|
+
var category = objectTrail.get(categoryId);
|
|
63
|
+
if (category) {
|
|
64
|
+
result.push({
|
|
65
|
+
routeName: routeName,
|
|
66
|
+
title: category.title,
|
|
67
|
+
symbol: category.symbol,
|
|
68
|
+
id: category.id,
|
|
69
|
+
routeParams: dataType === 'contact-method-categories'
|
|
70
|
+
? (0, create_params_1.default)({
|
|
71
|
+
contactCategory: category.id,
|
|
72
|
+
uriName: (0, format_url_1.default)(category.title),
|
|
73
|
+
})
|
|
74
|
+
: (0, create_params_1.default)({
|
|
75
|
+
guideCategory: category.id,
|
|
76
|
+
uriName: (0, format_url_1.default)(category.title),
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
if (Array.isArray(categoryIds)) {
|
|
84
|
+
return categoryIds.reduce(function (acc, id) {
|
|
85
|
+
var result = buildTrail(id);
|
|
86
|
+
if (result.length > 0) {
|
|
87
|
+
acc.push(result);
|
|
88
|
+
}
|
|
89
|
+
return acc;
|
|
90
|
+
}, []);
|
|
91
|
+
}
|
|
92
|
+
return buildTrail(categoryIds);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
exports.buildCategoryTrail = buildCategoryTrail;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare type Input = {
|
|
2
|
+
phrase?: string;
|
|
3
|
+
category?: ParamValue;
|
|
4
|
+
guideCategory?: ParamValue;
|
|
5
|
+
contactCategory?: ParamValue;
|
|
6
|
+
take?: number;
|
|
7
|
+
connectionKey?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
uriName?: string;
|
|
10
|
+
sorting?: string;
|
|
11
|
+
tag?: string;
|
|
12
|
+
tagId?: string | number;
|
|
13
|
+
tagTitle?: string;
|
|
14
|
+
} & {
|
|
15
|
+
[key: string]: ParamValue;
|
|
16
|
+
};
|
|
17
|
+
export declare type ParamValue = string | number | any;
|
|
18
|
+
export declare type Params = {
|
|
19
|
+
[key: string]: ParamValue;
|
|
20
|
+
};
|
|
21
|
+
export default function createParams(args?: Input): Params;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
function createParams(args) {
|
|
15
|
+
if (args === void 0) { args = {}; }
|
|
16
|
+
var _a = args.phrase, phrase = _a === void 0 ? '' : _a, category = args.category, guideCategory = args.guideCategory, contactCategory = args.contactCategory, take = args.take, connectionKey = args.connectionKey, accordion = args.accordion, id = args.id, uriName = args.uriName, sorting = args.sorting, tag = args.tag, tagId = args.tagId, tagTitle = args.tagTitle, other = __rest(args, ["phrase", "category", "guideCategory", "contactCategory", "take", "connectionKey", "accordion", "id", "uriName", "sorting", "tag", "tagId", "tagTitle"]);
|
|
17
|
+
var params = {};
|
|
18
|
+
Object.keys(other).forEach(function (k) {
|
|
19
|
+
if (typeof args[k] === 'string') {
|
|
20
|
+
params[k] = args[k];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
if (typeof phrase === 'string' && phrase.length) {
|
|
24
|
+
params.phrase = phrase;
|
|
25
|
+
}
|
|
26
|
+
if (phrase === null) {
|
|
27
|
+
params.phrase = phrase;
|
|
28
|
+
}
|
|
29
|
+
if (typeof guideCategory === 'string' && guideCategory !== '0') {
|
|
30
|
+
params.guideCategory = guideCategory;
|
|
31
|
+
}
|
|
32
|
+
if (typeof guideCategory === 'number' && guideCategory !== 0) {
|
|
33
|
+
params.guideCategory = guideCategory;
|
|
34
|
+
}
|
|
35
|
+
if (typeof guideCategory === 'object' && guideCategory !== null) {
|
|
36
|
+
if (typeof guideCategory.id === 'string' && guideCategory.id !== '0') {
|
|
37
|
+
params.guideCategory = guideCategory.id;
|
|
38
|
+
}
|
|
39
|
+
if (typeof guideCategory.id === 'number' && guideCategory.id !== 0) {
|
|
40
|
+
params.guideCategory = guideCategory.id;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (typeof contactCategory === 'string' && contactCategory !== '0') {
|
|
44
|
+
params.contactCategory = contactCategory;
|
|
45
|
+
}
|
|
46
|
+
if (typeof contactCategory === 'number' && contactCategory !== 0) {
|
|
47
|
+
params.contactCategory = contactCategory;
|
|
48
|
+
}
|
|
49
|
+
if (typeof contactCategory === 'object' && contactCategory !== null) {
|
|
50
|
+
if (typeof contactCategory.id === 'string' && contactCategory.id !== '0') {
|
|
51
|
+
params.contactCategory = contactCategory.id;
|
|
52
|
+
}
|
|
53
|
+
if (typeof contactCategory.id === 'number' && contactCategory.id !== 0) {
|
|
54
|
+
params.contactCategory = contactCategory.id;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (typeof category === 'string' && category !== '0') {
|
|
58
|
+
params.category = category;
|
|
59
|
+
}
|
|
60
|
+
if (typeof category === 'number' && category !== 0) {
|
|
61
|
+
params.category = category;
|
|
62
|
+
}
|
|
63
|
+
if (typeof category === 'object' && category !== null) {
|
|
64
|
+
if (typeof category.id === 'string' && category.id !== '0') {
|
|
65
|
+
params.category = category.id;
|
|
66
|
+
}
|
|
67
|
+
if (typeof category.id === 'number' && category.id !== 0) {
|
|
68
|
+
params.category = category.id;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (id) {
|
|
72
|
+
params.id = id;
|
|
73
|
+
}
|
|
74
|
+
if (uriName &&
|
|
75
|
+
(!!+params.category ||
|
|
76
|
+
!!+params.guideCategory ||
|
|
77
|
+
!!+params.guide ||
|
|
78
|
+
!!+params.contactCategory ||
|
|
79
|
+
!!+params.contactMethod)) {
|
|
80
|
+
params.uriName = uriName;
|
|
81
|
+
}
|
|
82
|
+
if (connectionKey) {
|
|
83
|
+
params.connectionKey = connectionKey;
|
|
84
|
+
}
|
|
85
|
+
if (take) {
|
|
86
|
+
params.take = take;
|
|
87
|
+
}
|
|
88
|
+
if (sorting) {
|
|
89
|
+
params.sorting = sorting;
|
|
90
|
+
}
|
|
91
|
+
if (typeof accordion === 'string' && accordion.length > 0) {
|
|
92
|
+
params.accordion = accordion;
|
|
93
|
+
}
|
|
94
|
+
if (typeof tag === 'string' && tag !== '0') {
|
|
95
|
+
params.tag = tag;
|
|
96
|
+
}
|
|
97
|
+
if (typeof tag === 'number' && tag !== 0) {
|
|
98
|
+
params.tag = tag;
|
|
99
|
+
}
|
|
100
|
+
if (typeof tagId === 'string' || typeof tagId === 'number') {
|
|
101
|
+
params.tagId = tagId;
|
|
102
|
+
}
|
|
103
|
+
if (typeof tagTitle === 'string') {
|
|
104
|
+
params.tagTitle = tagTitle;
|
|
105
|
+
}
|
|
106
|
+
return params;
|
|
107
|
+
}
|
|
108
|
+
exports.default = createParams;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var dataURItoBlob = function (dataURI) {
|
|
4
|
+
var byteString;
|
|
5
|
+
var mimestring;
|
|
6
|
+
if (dataURI.split(',')[0].indexOf('base64') !== -1) {
|
|
7
|
+
byteString = atob(dataURI.split(',')[1]);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
byteString = decodeURI(dataURI.split(',')[1]);
|
|
11
|
+
}
|
|
12
|
+
mimestring = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
|
13
|
+
var content = [];
|
|
14
|
+
for (var i = 0; i < byteString.length; i++) {
|
|
15
|
+
// tslint:disable-line no-increment-decrement
|
|
16
|
+
content[i] = byteString.charCodeAt(i);
|
|
17
|
+
}
|
|
18
|
+
return new Blob([new Uint8Array(content)], { type: mimestring });
|
|
19
|
+
};
|
|
20
|
+
exports.default = dataURItoBlob;
|
package/lib/debug.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if process.env.NODE_ENV === 'production'
|
|
3
|
+
* and passes arguments to console.warn().
|
|
4
|
+
*/
|
|
5
|
+
export declare function debugLog(...args: any[]): false | void;
|
|
6
|
+
/**
|
|
7
|
+
* Simple internal log-handler
|
|
8
|
+
*/
|
|
9
|
+
export declare class Logger {
|
|
10
|
+
private keys;
|
|
11
|
+
private lookup;
|
|
12
|
+
/**
|
|
13
|
+
* Passes args to console.log
|
|
14
|
+
*/
|
|
15
|
+
static log: (...args: any[]) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Passes args to console.warn
|
|
18
|
+
*/
|
|
19
|
+
static warn: (...args: any[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Passes args to console.error
|
|
22
|
+
*/
|
|
23
|
+
static error: (...args: any[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Passes args to console.info
|
|
26
|
+
*/
|
|
27
|
+
static info: (...args: any[]) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if key already has been logged.
|
|
30
|
+
* If not, passes following args to console.log
|
|
31
|
+
* and stores key in logged messages.
|
|
32
|
+
*/
|
|
33
|
+
log: (key: string, ...args: any[]) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if key already has been logged.
|
|
36
|
+
* If not, passes following args to console.warn
|
|
37
|
+
* and stores key in logged messages.
|
|
38
|
+
*/
|
|
39
|
+
warn: (key: string, ...args: any[]) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if key already has been logged.
|
|
42
|
+
* If not, passes following args to console.error
|
|
43
|
+
* and stores key in logged messages.
|
|
44
|
+
*/
|
|
45
|
+
error: (key: string, ...args: any[]) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if key already has been logged.
|
|
48
|
+
* If not, passes following args to console.info
|
|
49
|
+
* and stores key in logged messages.
|
|
50
|
+
*/
|
|
51
|
+
info: (key: string, ...args: any[]) => void;
|
|
52
|
+
}
|
package/lib/debug.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.Logger = exports.debugLog = void 0;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if process.env.NODE_ENV === 'production'
|
|
31
|
+
* and passes arguments to console.warn().
|
|
32
|
+
*/
|
|
33
|
+
function debugLog() {
|
|
34
|
+
var args = [];
|
|
35
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
+
args[_i] = arguments[_i];
|
|
37
|
+
}
|
|
38
|
+
return process.env.NODE_ENV !== 'production' && console && console.warn.apply(console, __spreadArray([], __read(args), false));
|
|
39
|
+
}
|
|
40
|
+
exports.debugLog = debugLog;
|
|
41
|
+
var print = function (print, msgOrObj) {
|
|
42
|
+
var args = [];
|
|
43
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
44
|
+
args[_i - 2] = arguments[_i];
|
|
45
|
+
}
|
|
46
|
+
if (typeof msgOrObj === 'string') {
|
|
47
|
+
return print.apply(void 0, __spreadArray(["[humany] ".concat(msgOrObj)], __read(args), false));
|
|
48
|
+
}
|
|
49
|
+
return print.apply(void 0, __spreadArray([msgOrObj], __read(args), false));
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Simple internal log-handler
|
|
53
|
+
*/
|
|
54
|
+
var Logger = /** @class */ (function () {
|
|
55
|
+
function Logger() {
|
|
56
|
+
var _this = this;
|
|
57
|
+
this.keys = [];
|
|
58
|
+
/**
|
|
59
|
+
* Checks if key already has been logged.
|
|
60
|
+
* If not, passes following args to console.log
|
|
61
|
+
* and stores key in logged messages.
|
|
62
|
+
*/
|
|
63
|
+
this.log = function (key) {
|
|
64
|
+
var args = [];
|
|
65
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
66
|
+
args[_i - 1] = arguments[_i];
|
|
67
|
+
}
|
|
68
|
+
return _this.lookup(key, function () { return Logger.log.apply(Logger, __spreadArray([], __read(args), false)); });
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Checks if key already has been logged.
|
|
72
|
+
* If not, passes following args to console.warn
|
|
73
|
+
* and stores key in logged messages.
|
|
74
|
+
*/
|
|
75
|
+
this.warn = function (key) {
|
|
76
|
+
var args = [];
|
|
77
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
78
|
+
args[_i - 1] = arguments[_i];
|
|
79
|
+
}
|
|
80
|
+
return _this.lookup(key, function () { return Logger.warn.apply(Logger, __spreadArray([], __read(args), false)); });
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Checks if key already has been logged.
|
|
84
|
+
* If not, passes following args to console.error
|
|
85
|
+
* and stores key in logged messages.
|
|
86
|
+
*/
|
|
87
|
+
this.error = function (key) {
|
|
88
|
+
var args = [];
|
|
89
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
90
|
+
args[_i - 1] = arguments[_i];
|
|
91
|
+
}
|
|
92
|
+
return _this.lookup(key, function () { return Logger.error.apply(Logger, __spreadArray([], __read(args), false)); });
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Checks if key already has been logged.
|
|
96
|
+
* If not, passes following args to console.info
|
|
97
|
+
* and stores key in logged messages.
|
|
98
|
+
*/
|
|
99
|
+
this.info = function (key) {
|
|
100
|
+
var args = [];
|
|
101
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
102
|
+
args[_i - 1] = arguments[_i];
|
|
103
|
+
}
|
|
104
|
+
return _this.lookup(key, function () { return Logger.info.apply(Logger, __spreadArray([], __read(args), false)); });
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
Logger.prototype.lookup = function (key, fn) {
|
|
108
|
+
if (this.keys.indexOf(key) === -1) {
|
|
109
|
+
this.keys.push(key);
|
|
110
|
+
fn();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Passes args to console.log
|
|
115
|
+
*/
|
|
116
|
+
Logger.log = function () {
|
|
117
|
+
var args = [];
|
|
118
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
119
|
+
args[_i] = arguments[_i];
|
|
120
|
+
}
|
|
121
|
+
return print.apply(void 0, __spreadArray([console.log], __read(args), false));
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Passes args to console.warn
|
|
125
|
+
*/
|
|
126
|
+
Logger.warn = function () {
|
|
127
|
+
var args = [];
|
|
128
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
129
|
+
args[_i] = arguments[_i];
|
|
130
|
+
}
|
|
131
|
+
return print.apply(void 0, __spreadArray([console.warn], __read(args), false));
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Passes args to console.error
|
|
135
|
+
*/
|
|
136
|
+
Logger.error = function () {
|
|
137
|
+
var args = [];
|
|
138
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
139
|
+
args[_i] = arguments[_i];
|
|
140
|
+
}
|
|
141
|
+
return print.apply(void 0, __spreadArray([console.error], __read(args), false));
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Passes args to console.info
|
|
145
|
+
*/
|
|
146
|
+
Logger.info = function () {
|
|
147
|
+
var args = [];
|
|
148
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
149
|
+
args[_i] = arguments[_i];
|
|
150
|
+
}
|
|
151
|
+
return print.apply(void 0, __spreadArray([console.info], __read(args), false));
|
|
152
|
+
};
|
|
153
|
+
return Logger;
|
|
154
|
+
}());
|
|
155
|
+
exports.Logger = Logger;
|