@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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// todo: consolidate with merge in component platform
|
|
4
|
+
var deepClone = function (data) {
|
|
5
|
+
var out = {};
|
|
6
|
+
var value;
|
|
7
|
+
var key;
|
|
8
|
+
// If it's not an object return the original data
|
|
9
|
+
if (typeof data !== 'object' || data === null) {
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
// Create array if data is array, otherwise create an object
|
|
13
|
+
out = Array.isArray(data) ? [] : {};
|
|
14
|
+
for (key in data) {
|
|
15
|
+
value = data[key];
|
|
16
|
+
// Copy nested objects and arrays recursively
|
|
17
|
+
out[key] = typeof value === 'object' && value !== null ? deepClone(value) : value;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
};
|
|
21
|
+
exports.default = deepClone;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: (implementation: any) => null | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Looks for stored widgets on the implementation in localStorage
|
|
4
|
+
* and adds a trigger link to the DOM.
|
|
5
|
+
*
|
|
6
|
+
* TODO: A more robust version have been discussed, where the storageService is added to the
|
|
7
|
+
* implementation instead of the widget.
|
|
8
|
+
*/
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var _1 = require(".");
|
|
4
|
+
/**
|
|
5
|
+
* Looks for stored widgets on the implementation in localStorage
|
|
6
|
+
* and adds a trigger link to the DOM.
|
|
7
|
+
*
|
|
8
|
+
* TODO: A more robust version have been discussed, where the storageService is added to the
|
|
9
|
+
* implementation instead of the widget.
|
|
10
|
+
*/
|
|
11
|
+
exports.default = (function (implementation) {
|
|
12
|
+
if (!implementation) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
var implementationStorage = localStorage.getItem("humany_".concat((0, _1.hash)(implementation.tenant + implementation.name)));
|
|
16
|
+
if (implementationStorage) {
|
|
17
|
+
var activeStickyWidget = JSON.parse(implementationStorage).activeStickyWidget;
|
|
18
|
+
if (activeStickyWidget && activeStickyWidget.value) {
|
|
19
|
+
var widget = implementation.widgets.get(activeStickyWidget.value);
|
|
20
|
+
if (widget) {
|
|
21
|
+
var el = document.createElement('a');
|
|
22
|
+
el.setAttribute('href', "//".concat(implementation.bindings[0], "/").concat(activeStickyWidget.value));
|
|
23
|
+
document.body.appendChild(el);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
+
function step(op) {
|
|
7
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
+
while (_) try {
|
|
9
|
+
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;
|
|
10
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
+
switch (op[0]) {
|
|
12
|
+
case 0: case 1: t = op; break;
|
|
13
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
+
default:
|
|
17
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
+
if (t[2]) _.ops.pop();
|
|
22
|
+
_.trys.pop(); continue;
|
|
23
|
+
}
|
|
24
|
+
op = body.call(thisArg, _);
|
|
25
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var __values = (this && this.__values) || function(o) {
|
|
30
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
31
|
+
if (m) return m.call(o);
|
|
32
|
+
if (o && typeof o.length === "number") return {
|
|
33
|
+
next: function () {
|
|
34
|
+
if (o && i >= o.length) o = void 0;
|
|
35
|
+
return { value: o && o[i++], done: !o };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
/**
|
|
42
|
+
* Recursively find items
|
|
43
|
+
* @param data Data to look in
|
|
44
|
+
*/
|
|
45
|
+
function processData(data) {
|
|
46
|
+
var i, val;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (!data) {
|
|
51
|
+
return [2 /*return*/];
|
|
52
|
+
}
|
|
53
|
+
i = 0;
|
|
54
|
+
_a.label = 1;
|
|
55
|
+
case 1:
|
|
56
|
+
if (!(i < data.length)) return [3 /*break*/, 5];
|
|
57
|
+
val = data[i];
|
|
58
|
+
return [4 /*yield*/, val];
|
|
59
|
+
case 2:
|
|
60
|
+
_a.sent();
|
|
61
|
+
if (!val.items) return [3 /*break*/, 4];
|
|
62
|
+
return [5 /*yield**/, __values(processData(val.items))];
|
|
63
|
+
case 3:
|
|
64
|
+
_a.sent();
|
|
65
|
+
_a.label = 4;
|
|
66
|
+
case 4:
|
|
67
|
+
i++;
|
|
68
|
+
return [3 /*break*/, 1];
|
|
69
|
+
case 5: return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Find a category by it's ID
|
|
75
|
+
* @param id Id of category to find
|
|
76
|
+
*/
|
|
77
|
+
var findCategoryById = function (id, categories) {
|
|
78
|
+
var it = processData(categories);
|
|
79
|
+
var res = it.next();
|
|
80
|
+
var found = null;
|
|
81
|
+
while (!res.done) {
|
|
82
|
+
if (res.value.id === id) {
|
|
83
|
+
found = res.value;
|
|
84
|
+
}
|
|
85
|
+
res = it.next();
|
|
86
|
+
}
|
|
87
|
+
return found;
|
|
88
|
+
};
|
|
89
|
+
exports.default = findCategoryById;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = (function (date, includeTime) {
|
|
4
|
+
if (includeTime === void 0) { includeTime = false; }
|
|
5
|
+
var d = new Date(date);
|
|
6
|
+
var month = "".concat(d.getMonth() + 1);
|
|
7
|
+
var day = "".concat(d.getDate());
|
|
8
|
+
var year = d.getFullYear();
|
|
9
|
+
if (month.length < 2)
|
|
10
|
+
month = "0".concat(month);
|
|
11
|
+
if (day.length < 2)
|
|
12
|
+
day = "0".concat(day);
|
|
13
|
+
if (includeTime) {
|
|
14
|
+
var hours = "".concat(d.getHours());
|
|
15
|
+
var minutes = "".concat(d.getMinutes());
|
|
16
|
+
if (hours.length < 2)
|
|
17
|
+
hours = "0".concat(hours);
|
|
18
|
+
if (minutes.length < 2)
|
|
19
|
+
minutes = "0".concat(minutes);
|
|
20
|
+
return "".concat([year, month, day].join('-'), " ").concat([hours, minutes].join(':'));
|
|
21
|
+
}
|
|
22
|
+
return [year, month, day].join('-');
|
|
23
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var formatUrl = function (url) {
|
|
4
|
+
if (!url) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
var replacements = [
|
|
8
|
+
{ from: /[äæǽ]+/gi, to: 'ae' },
|
|
9
|
+
{ from: /[öœ]+/gi, to: 'oe' },
|
|
10
|
+
{ from: /[ü]+/gi, to: 'ue' },
|
|
11
|
+
{ from: /[Ä]+/gi, to: 'Ae' },
|
|
12
|
+
{ from: /[Ü]+/gi, to: 'Ue' },
|
|
13
|
+
{ from: /[Ö]+/gi, to: 'Oe' },
|
|
14
|
+
{ from: /[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi, to: 'A' },
|
|
15
|
+
{ from: /[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi, to: 'a' },
|
|
16
|
+
{ from: /[Б]+/gi, to: 'B' },
|
|
17
|
+
{ from: /[б]+/gi, to: 'b' },
|
|
18
|
+
{ from: /[ÇĆĈĊČ]+/gi, to: 'C' },
|
|
19
|
+
{ from: /[çćĉċč]+/gi, to: 'c' },
|
|
20
|
+
{ from: /[Д]+/gi, to: 'D' },
|
|
21
|
+
{ from: /[д]+/gi, to: 'd' },
|
|
22
|
+
{ from: /[ÐĎĐΔ]+/gi, to: 'Dj' },
|
|
23
|
+
{ from: /[ðďđδ]+/gi, to: 'dj' },
|
|
24
|
+
{ from: /[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi, to: 'E' },
|
|
25
|
+
{ from: /[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi, to: 'e' },
|
|
26
|
+
{ from: /[Ф]+/gi, to: 'F' },
|
|
27
|
+
{ from: /[ф]+/gi, to: 'f' },
|
|
28
|
+
{ from: /[ĜĞĠĢΓГҐ]+/gi, to: 'G' },
|
|
29
|
+
{ from: /[ĝğġģγгґ]+/gi, to: 'g' },
|
|
30
|
+
{ from: /[ĤĦ]+/gi, to: 'H' },
|
|
31
|
+
{ from: /[ĥħ]+/gi, to: 'h' },
|
|
32
|
+
{ from: /[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi, to: 'I' },
|
|
33
|
+
{ from: /[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi, to: 'i' },
|
|
34
|
+
{ from: /[Ĵ]+/gi, to: 'J' },
|
|
35
|
+
{ from: /[ĵ]+/gi, to: 'j' },
|
|
36
|
+
{ from: /[ĶΚК]+/gi, to: 'K' },
|
|
37
|
+
{ from: /[ķκк]+/gi, to: 'k' },
|
|
38
|
+
{ from: /[ĹĻĽĿŁΛЛ]+/gi, to: 'L' },
|
|
39
|
+
{ from: /[ĺļľŀłλл]+/gi, to: 'l' },
|
|
40
|
+
{ from: /[М]+/gi, to: 'M' },
|
|
41
|
+
{ from: /[м]+/gi, to: 'm' },
|
|
42
|
+
{ from: /[ÑŃŅŇΝН]+/gi, to: 'N' },
|
|
43
|
+
{ from: /[ñńņňʼnνн]+/gi, to: 'n' },
|
|
44
|
+
{ from: /[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi, to: 'O' },
|
|
45
|
+
{ from: /[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi, to: 'o' },
|
|
46
|
+
{ from: /[П]+/gi, to: 'P' },
|
|
47
|
+
{ from: /[п]+/gi, to: 'p' },
|
|
48
|
+
{ from: /[ŔŖŘΡР]+/gi, to: 'R' },
|
|
49
|
+
{ from: /[ŕŗřρр]+/gi, to: 'r' },
|
|
50
|
+
{ from: /[ŚŜŞȘŠΣС]+/gi, to: 'S' },
|
|
51
|
+
{ from: /[śŝşșšſσςс]+/gi, to: 's' },
|
|
52
|
+
{ from: /[ȚŢŤŦτТ]+/gi, to: 'T' },
|
|
53
|
+
{ from: /[țţťŧт]+/gi, to: 't' },
|
|
54
|
+
{ from: /[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi, to: 'U' },
|
|
55
|
+
{ from: /[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi, to: 'u' },
|
|
56
|
+
{ from: /[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi, to: 'Y' },
|
|
57
|
+
{ from: /[ýÿŷỳỹỷỵй]+/gi, to: 'y' },
|
|
58
|
+
{ from: /[В]+/gi, to: 'V' },
|
|
59
|
+
{ from: /[в]+/gi, to: 'v' },
|
|
60
|
+
{ from: /[Ŵ]+/gi, to: 'W' },
|
|
61
|
+
{ from: /[ŵ]+/gi, to: 'w' },
|
|
62
|
+
{ from: /[ŹŻŽΖЗ]+/gi, to: 'Z' },
|
|
63
|
+
{ from: /[źżžζз]+/gi, to: 'z' },
|
|
64
|
+
{ from: /[ÆǼ]+/gi, to: 'AE' },
|
|
65
|
+
{ from: /[ß]+/gi, to: 'ss' },
|
|
66
|
+
{ from: /[IJ]+/gi, to: 'IJ' },
|
|
67
|
+
{ from: /[ij]+/gi, to: 'ij' },
|
|
68
|
+
{ from: /[Œ]+/gi, to: 'OE' },
|
|
69
|
+
{ from: /[ƒ]+/gi, to: 'f' },
|
|
70
|
+
{ from: /[ξ]+/gi, to: 'ks' },
|
|
71
|
+
{ from: /[π]+/gi, to: 'p' },
|
|
72
|
+
{ from: /[β]+/gi, to: 'v' },
|
|
73
|
+
{ from: /[μ]+/gi, to: 'm' },
|
|
74
|
+
{ from: /[ψ]+/gi, to: 'ps' },
|
|
75
|
+
{ from: /[Ё]+/gi, to: 'Yo' },
|
|
76
|
+
{ from: /[ё]+/gi, to: 'yo' },
|
|
77
|
+
{ from: /[Є]+/gi, to: 'Ye' },
|
|
78
|
+
{ from: /[є]+/gi, to: 'ye' },
|
|
79
|
+
{ from: /[Ї]+/gi, to: 'Yi' },
|
|
80
|
+
{ from: /[Ж]+/gi, to: 'Zh' },
|
|
81
|
+
{ from: /[ж]+/gi, to: 'zh' },
|
|
82
|
+
{ from: /[Х]+/gi, to: 'Kh' },
|
|
83
|
+
{ from: /[х]+/gi, to: 'kh' },
|
|
84
|
+
{ from: /[Ц]+/gi, to: 'Ts' },
|
|
85
|
+
{ from: /[ц]+/gi, to: 'ts' },
|
|
86
|
+
{ from: /[Ч]+/gi, to: 'Ch' },
|
|
87
|
+
{ from: /[ч]+/gi, to: 'ch' },
|
|
88
|
+
{ from: /[Ш]+/gi, to: 'Sh' },
|
|
89
|
+
{ from: /[ш]+/gi, to: 'sh' },
|
|
90
|
+
{ from: /[Щ]+/gi, to: 'Shch' },
|
|
91
|
+
{ from: /[щ]+/gi, to: 'shch' },
|
|
92
|
+
{ from: /[ЪъЬь]+/gi, to: '' },
|
|
93
|
+
{ from: /[Ю]+/gi, to: 'Yu' },
|
|
94
|
+
{ from: /[ю]+/gi, to: 'yu' },
|
|
95
|
+
{ from: /[Я]+/gi, to: 'Ya' },
|
|
96
|
+
{ from: /[я]+/gi, to: 'ya' },
|
|
97
|
+
];
|
|
98
|
+
var alphanumericExpression = /[^a-zA-Z0-9]+/g;
|
|
99
|
+
var trailingDashExpression = /[-]$/;
|
|
100
|
+
var parsed = url;
|
|
101
|
+
for (var i in replacements) {
|
|
102
|
+
if (replacements.hasOwnProperty(i) && replacements[i].from.test(url)) {
|
|
103
|
+
parsed = parsed.replace(replacements[i].from, replacements[i].to);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
parsed = parsed.replace(alphanumericExpression, '-');
|
|
107
|
+
parsed = parsed.replace(trailingDashExpression, '');
|
|
108
|
+
parsed = parsed.toLowerCase();
|
|
109
|
+
return parsed || 'humany';
|
|
110
|
+
};
|
|
111
|
+
exports.default = formatUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCookie(cookieName: string): string | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function getCookie(cookieName) {
|
|
4
|
+
var documentCookie = document.cookie;
|
|
5
|
+
if (documentCookie.length > 0) {
|
|
6
|
+
var start = documentCookie.indexOf("".concat(cookieName, "="));
|
|
7
|
+
if (start !== -1) {
|
|
8
|
+
start = start + cookieName.length + 1;
|
|
9
|
+
var end = documentCookie.indexOf(';', start);
|
|
10
|
+
if (end === -1) {
|
|
11
|
+
end = documentCookie.length;
|
|
12
|
+
}
|
|
13
|
+
return unescape(documentCookie.substring(start, end));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
exports.default = getCookie;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkForEmptyCategories = void 0;
|
|
4
|
+
function checkForEmptyCategories(items, v) {
|
|
5
|
+
if (v === void 0) { v = false; }
|
|
6
|
+
var value = v;
|
|
7
|
+
items.forEach(function (i) {
|
|
8
|
+
if ((typeof i.guidesCount === 'number' && i.guidesCount !== 0) ||
|
|
9
|
+
(typeof i.matchCount === 'number' && i.matchCount !== 0)) {
|
|
10
|
+
value = true;
|
|
11
|
+
}
|
|
12
|
+
if (i.items) {
|
|
13
|
+
value = checkForEmptyCategories(i.items, value);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
exports.checkForEmptyCategories = checkForEmptyCategories;
|
|
19
|
+
function hasNonEmptyCategories(items, v) {
|
|
20
|
+
if (v === void 0) { v = false; }
|
|
21
|
+
return checkForEmptyCategories(items, v);
|
|
22
|
+
}
|
|
23
|
+
exports.default = hasNonEmptyCategories;
|
package/lib/hash.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (s: string): string;
|
package/lib/hash.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function default_1(s) {
|
|
4
|
+
var hash = 0;
|
|
5
|
+
if (s.length === 0) {
|
|
6
|
+
return hash.toString();
|
|
7
|
+
}
|
|
8
|
+
// tslint:disable-next-line:no-increment-decrement
|
|
9
|
+
for (var i = 0; i < s.length; i++) {
|
|
10
|
+
var char = s.charCodeAt(i);
|
|
11
|
+
hash = (hash << 5) - hash + char;
|
|
12
|
+
hash = hash & hash;
|
|
13
|
+
}
|
|
14
|
+
return hash.toString();
|
|
15
|
+
}
|
|
16
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether or not the passed child is a descendant
|
|
5
|
+
* of the passed parent.
|
|
6
|
+
* Will return true if falsey parent or child.
|
|
7
|
+
*/
|
|
8
|
+
exports.default = (function (parent, child) {
|
|
9
|
+
if (!parent || !child) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
var node = child.parentNode;
|
|
13
|
+
var hasChild = false;
|
|
14
|
+
while (node !== null) {
|
|
15
|
+
if (node === parent) {
|
|
16
|
+
hasChild = true;
|
|
17
|
+
}
|
|
18
|
+
node = node.parentNode;
|
|
19
|
+
}
|
|
20
|
+
return hasChild;
|
|
21
|
+
});
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { default as appendClassNames } from './append-class-names';
|
|
2
|
+
export { default as createBatch } from './batch';
|
|
3
|
+
export type { Batch, BatchFunction } from './batch';
|
|
4
|
+
export { default as camilize } from './camilize';
|
|
5
|
+
export { buildCategoryTrail, categoryTrail, getCategoryTrailAsObjects } from './category-trail';
|
|
6
|
+
export { default as createParams } from './create-params';
|
|
7
|
+
export type { Params, ParamValue } from './create-params';
|
|
8
|
+
export { default as dataURItoBlob } from './data-uri-to-blob';
|
|
9
|
+
export { debugLog, Logger } from './debug';
|
|
10
|
+
export { default as deepClone } from './deep-clone';
|
|
11
|
+
export { default as findAndActivateStoredWidgets } from './find-and-activate-stored-widgets';
|
|
12
|
+
export { default as findCategoryById } from './find-category-by-id';
|
|
13
|
+
export { default as formatDate } from './format-date';
|
|
14
|
+
export { default as formatUrl } from './format-url';
|
|
15
|
+
export { default as getCookie } from './get-cookie';
|
|
16
|
+
export { default as hash } from './hash';
|
|
17
|
+
export { default as htmlParentContains } from './html-parent-contains';
|
|
18
|
+
export { default as kebabCase } from './kebab-case';
|
|
19
|
+
export { default as lock } from './lock';
|
|
20
|
+
export { default as mergeDeep } from './merge-deep';
|
|
21
|
+
export { default as notifyDataLoaded } from './notify-data-loaded';
|
|
22
|
+
export { default as removeNullAndUndefinedValues } from './remove-null-and-undefined-values';
|
|
23
|
+
export { default as setCookie } from './set-cookie';
|
|
24
|
+
export { default as shallowCompare } from './shallow-compare';
|
|
25
|
+
export { default as uuid } from './uuid';
|
|
26
|
+
export { default as WaitFor } from './wait-for';
|
|
27
|
+
export type { WaitForOptions } from './wait-for';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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.WaitFor = exports.uuid = exports.shallowCompare = exports.setCookie = exports.removeNullAndUndefinedValues = exports.notifyDataLoaded = exports.mergeDeep = exports.lock = exports.kebabCase = exports.htmlParentContains = exports.hash = exports.getCookie = exports.formatUrl = exports.formatDate = exports.findCategoryById = exports.findAndActivateStoredWidgets = exports.deepClone = exports.Logger = exports.debugLog = exports.dataURItoBlob = exports.createParams = exports.getCategoryTrailAsObjects = exports.categoryTrail = exports.buildCategoryTrail = exports.camilize = exports.createBatch = exports.appendClassNames = void 0;
|
|
7
|
+
var append_class_names_1 = require("./append-class-names");
|
|
8
|
+
Object.defineProperty(exports, "appendClassNames", { enumerable: true, get: function () { return __importDefault(append_class_names_1).default; } });
|
|
9
|
+
var batch_1 = require("./batch");
|
|
10
|
+
Object.defineProperty(exports, "createBatch", { enumerable: true, get: function () { return __importDefault(batch_1).default; } });
|
|
11
|
+
var camilize_1 = require("./camilize");
|
|
12
|
+
Object.defineProperty(exports, "camilize", { enumerable: true, get: function () { return __importDefault(camilize_1).default; } });
|
|
13
|
+
var category_trail_1 = require("./category-trail");
|
|
14
|
+
Object.defineProperty(exports, "buildCategoryTrail", { enumerable: true, get: function () { return category_trail_1.buildCategoryTrail; } });
|
|
15
|
+
Object.defineProperty(exports, "categoryTrail", { enumerable: true, get: function () { return category_trail_1.categoryTrail; } });
|
|
16
|
+
Object.defineProperty(exports, "getCategoryTrailAsObjects", { enumerable: true, get: function () { return category_trail_1.getCategoryTrailAsObjects; } });
|
|
17
|
+
var create_params_1 = require("./create-params");
|
|
18
|
+
Object.defineProperty(exports, "createParams", { enumerable: true, get: function () { return __importDefault(create_params_1).default; } });
|
|
19
|
+
var data_uri_to_blob_1 = require("./data-uri-to-blob");
|
|
20
|
+
Object.defineProperty(exports, "dataURItoBlob", { enumerable: true, get: function () { return __importDefault(data_uri_to_blob_1).default; } });
|
|
21
|
+
var debug_1 = require("./debug");
|
|
22
|
+
Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return debug_1.debugLog; } });
|
|
23
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return debug_1.Logger; } });
|
|
24
|
+
var deep_clone_1 = require("./deep-clone");
|
|
25
|
+
Object.defineProperty(exports, "deepClone", { enumerable: true, get: function () { return __importDefault(deep_clone_1).default; } });
|
|
26
|
+
var find_and_activate_stored_widgets_1 = require("./find-and-activate-stored-widgets");
|
|
27
|
+
Object.defineProperty(exports, "findAndActivateStoredWidgets", { enumerable: true, get: function () { return __importDefault(find_and_activate_stored_widgets_1).default; } });
|
|
28
|
+
var find_category_by_id_1 = require("./find-category-by-id");
|
|
29
|
+
Object.defineProperty(exports, "findCategoryById", { enumerable: true, get: function () { return __importDefault(find_category_by_id_1).default; } });
|
|
30
|
+
var format_date_1 = require("./format-date");
|
|
31
|
+
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return __importDefault(format_date_1).default; } });
|
|
32
|
+
var format_url_1 = require("./format-url");
|
|
33
|
+
Object.defineProperty(exports, "formatUrl", { enumerable: true, get: function () { return __importDefault(format_url_1).default; } });
|
|
34
|
+
var get_cookie_1 = require("./get-cookie");
|
|
35
|
+
Object.defineProperty(exports, "getCookie", { enumerable: true, get: function () { return __importDefault(get_cookie_1).default; } });
|
|
36
|
+
var hash_1 = require("./hash");
|
|
37
|
+
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_1).default; } });
|
|
38
|
+
var html_parent_contains_1 = require("./html-parent-contains");
|
|
39
|
+
Object.defineProperty(exports, "htmlParentContains", { enumerable: true, get: function () { return __importDefault(html_parent_contains_1).default; } });
|
|
40
|
+
var kebab_case_1 = require("./kebab-case");
|
|
41
|
+
Object.defineProperty(exports, "kebabCase", { enumerable: true, get: function () { return __importDefault(kebab_case_1).default; } });
|
|
42
|
+
var lock_1 = require("./lock");
|
|
43
|
+
Object.defineProperty(exports, "lock", { enumerable: true, get: function () { return __importDefault(lock_1).default; } });
|
|
44
|
+
var merge_deep_1 = require("./merge-deep");
|
|
45
|
+
Object.defineProperty(exports, "mergeDeep", { enumerable: true, get: function () { return __importDefault(merge_deep_1).default; } });
|
|
46
|
+
var notify_data_loaded_1 = require("./notify-data-loaded");
|
|
47
|
+
Object.defineProperty(exports, "notifyDataLoaded", { enumerable: true, get: function () { return __importDefault(notify_data_loaded_1).default; } });
|
|
48
|
+
var remove_null_and_undefined_values_1 = require("./remove-null-and-undefined-values");
|
|
49
|
+
Object.defineProperty(exports, "removeNullAndUndefinedValues", { enumerable: true, get: function () { return __importDefault(remove_null_and_undefined_values_1).default; } });
|
|
50
|
+
var set_cookie_1 = require("./set-cookie");
|
|
51
|
+
Object.defineProperty(exports, "setCookie", { enumerable: true, get: function () { return __importDefault(set_cookie_1).default; } });
|
|
52
|
+
var shallow_compare_1 = require("./shallow-compare");
|
|
53
|
+
Object.defineProperty(exports, "shallowCompare", { enumerable: true, get: function () { return __importDefault(shallow_compare_1).default; } });
|
|
54
|
+
var uuid_1 = require("./uuid");
|
|
55
|
+
Object.defineProperty(exports, "uuid", { enumerable: true, get: function () { return __importDefault(uuid_1).default; } });
|
|
56
|
+
var wait_for_1 = require("./wait-for");
|
|
57
|
+
Object.defineProperty(exports, "WaitFor", { enumerable: true, get: function () { return __importDefault(wait_for_1).default; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Determine if href starts with a hashtag
|
|
4
|
+
var isAnchorLink = function (href) {
|
|
5
|
+
var re = new RegExp('^#', 'i');
|
|
6
|
+
var match = re.test(href);
|
|
7
|
+
return match;
|
|
8
|
+
};
|
|
9
|
+
exports.default = isAnchorLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function kebabCase(string: string): string;
|
package/lib/lock.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type Task = () => Promise<any> | any;
|
|
2
|
+
export declare type AddTask = (task: Task) => Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a lock for the specified owner that allows only one executing
|
|
5
|
+
* task simultaneously.
|
|
6
|
+
* @param key Lock owner.
|
|
7
|
+
*/
|
|
8
|
+
export default function lock(key: object, lockWarningTime?: number, lockErrorTime?: number): AddTask;
|
|
9
|
+
export {};
|
package/lib/lock.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var debug_1 = require("./debug");
|
|
4
|
+
var Queue = /** @class */ (function () {
|
|
5
|
+
function Queue(lockWarningTime, lockErrorTime) {
|
|
6
|
+
this.lockWarningTime = lockWarningTime;
|
|
7
|
+
this.lockErrorTime = lockErrorTime;
|
|
8
|
+
this.tasks = [];
|
|
9
|
+
this.current = Promise.resolve();
|
|
10
|
+
this.next = this.next.bind(this);
|
|
11
|
+
}
|
|
12
|
+
Queue.prototype.add = function (task, resolve, reject, done) {
|
|
13
|
+
this.tasks.push({ task: task, resolve: resolve, reject: reject, done: done });
|
|
14
|
+
this.next();
|
|
15
|
+
};
|
|
16
|
+
Queue.prototype.next = function () {
|
|
17
|
+
var _this = this;
|
|
18
|
+
this.current = this.current.then(function () {
|
|
19
|
+
var next = _this.tasks.shift();
|
|
20
|
+
if (next) {
|
|
21
|
+
var errorTimeout_1; // NodeJS.Timeout
|
|
22
|
+
var warningTimeout_1 = setTimeout(function () {
|
|
23
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
+
// tslint:disable-next-line max-line-length
|
|
25
|
+
debug_1.Logger.warn("A lock has exceeded ".concat(_this.lockWarningTime, " ms. Waiting additional ").concat(_this.lockErrorTime, " ms before rejecting the task."), next);
|
|
26
|
+
}
|
|
27
|
+
errorTimeout_1 = setTimeout(function () {
|
|
28
|
+
next.reject('lock timeout exceeded');
|
|
29
|
+
}, _this.lockErrorTime);
|
|
30
|
+
}, _this.lockWarningTime);
|
|
31
|
+
var taskPromise_1 = Promise.resolve(next.task()).then(function (result) {
|
|
32
|
+
clearTimeout(warningTimeout_1);
|
|
33
|
+
clearTimeout(errorTimeout_1);
|
|
34
|
+
return result;
|
|
35
|
+
});
|
|
36
|
+
return Promise.resolve(taskPromise_1)
|
|
37
|
+
.then(_this.next)
|
|
38
|
+
.then(function () {
|
|
39
|
+
return taskPromise_1.then(function (data) {
|
|
40
|
+
next.done();
|
|
41
|
+
next.resolve(data);
|
|
42
|
+
});
|
|
43
|
+
})
|
|
44
|
+
.catch(function (reason) {
|
|
45
|
+
next.done();
|
|
46
|
+
next.reject(reason);
|
|
47
|
+
return _this.next();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
return Queue;
|
|
54
|
+
}());
|
|
55
|
+
var locks = new WeakMap();
|
|
56
|
+
/**
|
|
57
|
+
* Creates a lock for the specified owner that allows only one executing
|
|
58
|
+
* task simultaneously.
|
|
59
|
+
* @param key Lock owner.
|
|
60
|
+
*/
|
|
61
|
+
function lock(key, lockWarningTime, lockErrorTime) {
|
|
62
|
+
if (lockWarningTime === void 0) { lockWarningTime = 5000; }
|
|
63
|
+
if (lockErrorTime === void 0) { lockErrorTime = 1000; }
|
|
64
|
+
if (!locks.has(key)) {
|
|
65
|
+
locks.set(key, new Queue(lockWarningTime, lockErrorTime));
|
|
66
|
+
}
|
|
67
|
+
return function (task) {
|
|
68
|
+
return new Promise(function (resolve, reject) {
|
|
69
|
+
var queue = locks.get(key);
|
|
70
|
+
queue.add(task, resolve, reject, function () {
|
|
71
|
+
if (!queue.tasks.length) {
|
|
72
|
+
locks.delete(key);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
exports.default = lock;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param target Target to merge into
|
|
3
|
+
* @param sources Source to merge into target
|
|
4
|
+
* @returns Clone (new reference) with merged sources
|
|
5
|
+
*/
|
|
6
|
+
declare const mergeDeep: <Target, Source>(target: Target, ...sources: Source[]) => Target & Source;
|
|
7
|
+
export default mergeDeep;
|