@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.
Files changed (111) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +3 -0
  3. package/lib/append-class-names.d.ts +6 -0
  4. package/lib/append-class-names.js +84 -0
  5. package/lib/batch.d.ts +4 -0
  6. package/lib/batch.js +38 -0
  7. package/lib/camilize.d.ts +1 -0
  8. package/lib/camilize.js +29 -0
  9. package/lib/category-trail.d.ts +14 -0
  10. package/lib/category-trail.js +96 -0
  11. package/lib/create-params.d.ts +21 -0
  12. package/lib/create-params.js +108 -0
  13. package/lib/data-uri-to-blob.d.ts +2 -0
  14. package/lib/data-uri-to-blob.js +20 -0
  15. package/lib/debug.d.ts +52 -0
  16. package/lib/debug.js +155 -0
  17. package/lib/deep-clone.d.ts +2 -0
  18. package/lib/deep-clone.js +21 -0
  19. package/lib/find-and-activate-stored-widgets.d.ts +9 -0
  20. package/lib/find-and-activate-stored-widgets.js +27 -0
  21. package/lib/find-category-by-id.d.ts +6 -0
  22. package/lib/find-category-by-id.js +89 -0
  23. package/lib/format-date.d.ts +2 -0
  24. package/lib/format-date.js +23 -0
  25. package/lib/format-url.d.ts +2 -0
  26. package/lib/format-url.js +111 -0
  27. package/lib/get-cookie.d.ts +1 -0
  28. package/lib/get-cookie.js +18 -0
  29. package/lib/has-non-empty-categories.d.ts +2 -0
  30. package/lib/has-non-empty-categories.js +23 -0
  31. package/lib/hash.d.ts +1 -0
  32. package/lib/hash.js +16 -0
  33. package/lib/html-parent-contains.d.ts +7 -0
  34. package/lib/html-parent-contains.js +21 -0
  35. package/lib/index.d.ts +27 -0
  36. package/lib/index.js +57 -0
  37. package/lib/is-anchor-link.d.ts +2 -0
  38. package/lib/is-anchor-link.js +9 -0
  39. package/lib/kebab-case.d.ts +1 -0
  40. package/lib/kebab-case.js +9 -0
  41. package/lib/lock.d.ts +9 -0
  42. package/lib/lock.js +78 -0
  43. package/lib/merge-deep.d.ts +7 -0
  44. package/lib/merge-deep.js +72 -0
  45. package/lib/notify-data-loaded.d.ts +6 -0
  46. package/lib/notify-data-loaded.js +96 -0
  47. package/lib/remove-null-and-undefined-values.d.ts +6 -0
  48. package/lib/remove-null-and-undefined-values.js +12 -0
  49. package/lib/set-cookie.d.ts +1 -0
  50. package/lib/set-cookie.js +12 -0
  51. package/lib/shallow-compare.d.ts +6 -0
  52. package/lib/shallow-compare.js +25 -0
  53. package/lib/uuid.d.ts +1 -0
  54. package/lib/uuid.js +12 -0
  55. package/lib/wait-for.d.ts +20 -0
  56. package/lib/wait-for.js +52 -0
  57. package/lib-esm/append-class-names.d.ts +6 -0
  58. package/lib-esm/append-class-names.js +77 -0
  59. package/lib-esm/batch.d.ts +4 -0
  60. package/lib-esm/batch.js +36 -0
  61. package/lib-esm/camilize.d.ts +1 -0
  62. package/lib-esm/camilize.js +26 -0
  63. package/lib-esm/category-trail.d.ts +14 -0
  64. package/lib-esm/category-trail.js +87 -0
  65. package/lib-esm/create-params.d.ts +21 -0
  66. package/lib-esm/create-params.js +105 -0
  67. package/lib-esm/data-uri-to-blob.d.ts +2 -0
  68. package/lib-esm/data-uri-to-blob.js +18 -0
  69. package/lib-esm/debug.d.ts +52 -0
  70. package/lib-esm/debug.js +151 -0
  71. package/lib-esm/deep-clone.d.ts +2 -0
  72. package/lib-esm/deep-clone.js +19 -0
  73. package/lib-esm/find-and-activate-stored-widgets.d.ts +9 -0
  74. package/lib-esm/find-and-activate-stored-widgets.js +25 -0
  75. package/lib-esm/find-category-by-id.d.ts +6 -0
  76. package/lib-esm/find-category-by-id.js +87 -0
  77. package/lib-esm/format-date.d.ts +2 -0
  78. package/lib-esm/format-date.js +21 -0
  79. package/lib-esm/format-url.d.ts +2 -0
  80. package/lib-esm/format-url.js +109 -0
  81. package/lib-esm/get-cookie.d.ts +1 -0
  82. package/lib-esm/get-cookie.js +15 -0
  83. package/lib-esm/has-non-empty-categories.d.ts +2 -0
  84. package/lib-esm/has-non-empty-categories.js +18 -0
  85. package/lib-esm/hash.d.ts +1 -0
  86. package/lib-esm/hash.js +13 -0
  87. package/lib-esm/html-parent-contains.d.ts +7 -0
  88. package/lib-esm/html-parent-contains.js +19 -0
  89. package/lib-esm/index.d.ts +27 -0
  90. package/lib-esm/index.js +24 -0
  91. package/lib-esm/is-anchor-link.d.ts +2 -0
  92. package/lib-esm/is-anchor-link.js +7 -0
  93. package/lib-esm/kebab-case.d.ts +1 -0
  94. package/lib-esm/kebab-case.js +6 -0
  95. package/lib-esm/lock.d.ts +9 -0
  96. package/lib-esm/lock.js +75 -0
  97. package/lib-esm/merge-deep.d.ts +7 -0
  98. package/lib-esm/merge-deep.js +67 -0
  99. package/lib-esm/notify-data-loaded.d.ts +6 -0
  100. package/lib-esm/notify-data-loaded.js +94 -0
  101. package/lib-esm/remove-null-and-undefined-values.d.ts +6 -0
  102. package/lib-esm/remove-null-and-undefined-values.js +10 -0
  103. package/lib-esm/set-cookie.d.ts +1 -0
  104. package/lib-esm/set-cookie.js +9 -0
  105. package/lib-esm/shallow-compare.d.ts +6 -0
  106. package/lib-esm/shallow-compare.js +23 -0
  107. package/lib-esm/uuid.d.ts +1 -0
  108. package/lib-esm/uuid.js +9 -0
  109. package/lib-esm/wait-for.d.ts +20 -0
  110. package/lib-esm/wait-for.js +50 -0
  111. package/package.json +35 -0
@@ -0,0 +1,105 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ export default function createParams(args) {
13
+ if (args === void 0) { args = {}; }
14
+ 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"]);
15
+ var params = {};
16
+ Object.keys(other).forEach(function (k) {
17
+ if (typeof args[k] === 'string') {
18
+ params[k] = args[k];
19
+ }
20
+ });
21
+ if (typeof phrase === 'string' && phrase.length) {
22
+ params.phrase = phrase;
23
+ }
24
+ if (phrase === null) {
25
+ params.phrase = phrase;
26
+ }
27
+ if (typeof guideCategory === 'string' && guideCategory !== '0') {
28
+ params.guideCategory = guideCategory;
29
+ }
30
+ if (typeof guideCategory === 'number' && guideCategory !== 0) {
31
+ params.guideCategory = guideCategory;
32
+ }
33
+ if (typeof guideCategory === 'object' && guideCategory !== null) {
34
+ if (typeof guideCategory.id === 'string' && guideCategory.id !== '0') {
35
+ params.guideCategory = guideCategory.id;
36
+ }
37
+ if (typeof guideCategory.id === 'number' && guideCategory.id !== 0) {
38
+ params.guideCategory = guideCategory.id;
39
+ }
40
+ }
41
+ if (typeof contactCategory === 'string' && contactCategory !== '0') {
42
+ params.contactCategory = contactCategory;
43
+ }
44
+ if (typeof contactCategory === 'number' && contactCategory !== 0) {
45
+ params.contactCategory = contactCategory;
46
+ }
47
+ if (typeof contactCategory === 'object' && contactCategory !== null) {
48
+ if (typeof contactCategory.id === 'string' && contactCategory.id !== '0') {
49
+ params.contactCategory = contactCategory.id;
50
+ }
51
+ if (typeof contactCategory.id === 'number' && contactCategory.id !== 0) {
52
+ params.contactCategory = contactCategory.id;
53
+ }
54
+ }
55
+ if (typeof category === 'string' && category !== '0') {
56
+ params.category = category;
57
+ }
58
+ if (typeof category === 'number' && category !== 0) {
59
+ params.category = category;
60
+ }
61
+ if (typeof category === 'object' && category !== null) {
62
+ if (typeof category.id === 'string' && category.id !== '0') {
63
+ params.category = category.id;
64
+ }
65
+ if (typeof category.id === 'number' && category.id !== 0) {
66
+ params.category = category.id;
67
+ }
68
+ }
69
+ if (id) {
70
+ params.id = id;
71
+ }
72
+ if (uriName &&
73
+ (!!+params.category ||
74
+ !!+params.guideCategory ||
75
+ !!+params.guide ||
76
+ !!+params.contactCategory ||
77
+ !!+params.contactMethod)) {
78
+ params.uriName = uriName;
79
+ }
80
+ if (connectionKey) {
81
+ params.connectionKey = connectionKey;
82
+ }
83
+ if (take) {
84
+ params.take = take;
85
+ }
86
+ if (sorting) {
87
+ params.sorting = sorting;
88
+ }
89
+ if (typeof accordion === 'string' && accordion.length > 0) {
90
+ params.accordion = accordion;
91
+ }
92
+ if (typeof tag === 'string' && tag !== '0') {
93
+ params.tag = tag;
94
+ }
95
+ if (typeof tag === 'number' && tag !== 0) {
96
+ params.tag = tag;
97
+ }
98
+ if (typeof tagId === 'string' || typeof tagId === 'number') {
99
+ params.tagId = tagId;
100
+ }
101
+ if (typeof tagTitle === 'string') {
102
+ params.tagTitle = tagTitle;
103
+ }
104
+ return params;
105
+ }
@@ -0,0 +1,2 @@
1
+ declare const dataURItoBlob: (dataURI: string) => Blob;
2
+ export default dataURItoBlob;
@@ -0,0 +1,18 @@
1
+ var dataURItoBlob = function (dataURI) {
2
+ var byteString;
3
+ var mimestring;
4
+ if (dataURI.split(',')[0].indexOf('base64') !== -1) {
5
+ byteString = atob(dataURI.split(',')[1]);
6
+ }
7
+ else {
8
+ byteString = decodeURI(dataURI.split(',')[1]);
9
+ }
10
+ mimestring = dataURI.split(',')[0].split(':')[1].split(';')[0];
11
+ var content = [];
12
+ for (var i = 0; i < byteString.length; i++) {
13
+ // tslint:disable-line no-increment-decrement
14
+ content[i] = byteString.charCodeAt(i);
15
+ }
16
+ return new Blob([new Uint8Array(content)], { type: mimestring });
17
+ };
18
+ export default dataURItoBlob;
@@ -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
+ }
@@ -0,0 +1,151 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ /**
27
+ * Checks if process.env.NODE_ENV === 'production'
28
+ * and passes arguments to console.warn().
29
+ */
30
+ export function debugLog() {
31
+ var args = [];
32
+ for (var _i = 0; _i < arguments.length; _i++) {
33
+ args[_i] = arguments[_i];
34
+ }
35
+ return process.env.NODE_ENV !== 'production' && console && console.warn.apply(console, __spreadArray([], __read(args), false));
36
+ }
37
+ var print = function (print, msgOrObj) {
38
+ var args = [];
39
+ for (var _i = 2; _i < arguments.length; _i++) {
40
+ args[_i - 2] = arguments[_i];
41
+ }
42
+ if (typeof msgOrObj === 'string') {
43
+ return print.apply(void 0, __spreadArray(["[humany] ".concat(msgOrObj)], __read(args), false));
44
+ }
45
+ return print.apply(void 0, __spreadArray([msgOrObj], __read(args), false));
46
+ };
47
+ /**
48
+ * Simple internal log-handler
49
+ */
50
+ var Logger = /** @class */ (function () {
51
+ function Logger() {
52
+ var _this = this;
53
+ this.keys = [];
54
+ /**
55
+ * Checks if key already has been logged.
56
+ * If not, passes following args to console.log
57
+ * and stores key in logged messages.
58
+ */
59
+ this.log = function (key) {
60
+ var args = [];
61
+ for (var _i = 1; _i < arguments.length; _i++) {
62
+ args[_i - 1] = arguments[_i];
63
+ }
64
+ return _this.lookup(key, function () { return Logger.log.apply(Logger, __spreadArray([], __read(args), false)); });
65
+ };
66
+ /**
67
+ * Checks if key already has been logged.
68
+ * If not, passes following args to console.warn
69
+ * and stores key in logged messages.
70
+ */
71
+ this.warn = function (key) {
72
+ var args = [];
73
+ for (var _i = 1; _i < arguments.length; _i++) {
74
+ args[_i - 1] = arguments[_i];
75
+ }
76
+ return _this.lookup(key, function () { return Logger.warn.apply(Logger, __spreadArray([], __read(args), false)); });
77
+ };
78
+ /**
79
+ * Checks if key already has been logged.
80
+ * If not, passes following args to console.error
81
+ * and stores key in logged messages.
82
+ */
83
+ this.error = function (key) {
84
+ var args = [];
85
+ for (var _i = 1; _i < arguments.length; _i++) {
86
+ args[_i - 1] = arguments[_i];
87
+ }
88
+ return _this.lookup(key, function () { return Logger.error.apply(Logger, __spreadArray([], __read(args), false)); });
89
+ };
90
+ /**
91
+ * Checks if key already has been logged.
92
+ * If not, passes following args to console.info
93
+ * and stores key in logged messages.
94
+ */
95
+ this.info = function (key) {
96
+ var args = [];
97
+ for (var _i = 1; _i < arguments.length; _i++) {
98
+ args[_i - 1] = arguments[_i];
99
+ }
100
+ return _this.lookup(key, function () { return Logger.info.apply(Logger, __spreadArray([], __read(args), false)); });
101
+ };
102
+ }
103
+ Logger.prototype.lookup = function (key, fn) {
104
+ if (this.keys.indexOf(key) === -1) {
105
+ this.keys.push(key);
106
+ fn();
107
+ }
108
+ };
109
+ /**
110
+ * Passes args to console.log
111
+ */
112
+ Logger.log = function () {
113
+ var args = [];
114
+ for (var _i = 0; _i < arguments.length; _i++) {
115
+ args[_i] = arguments[_i];
116
+ }
117
+ return print.apply(void 0, __spreadArray([console.log], __read(args), false));
118
+ };
119
+ /**
120
+ * Passes args to console.warn
121
+ */
122
+ Logger.warn = function () {
123
+ var args = [];
124
+ for (var _i = 0; _i < arguments.length; _i++) {
125
+ args[_i] = arguments[_i];
126
+ }
127
+ return print.apply(void 0, __spreadArray([console.warn], __read(args), false));
128
+ };
129
+ /**
130
+ * Passes args to console.error
131
+ */
132
+ Logger.error = function () {
133
+ var args = [];
134
+ for (var _i = 0; _i < arguments.length; _i++) {
135
+ args[_i] = arguments[_i];
136
+ }
137
+ return print.apply(void 0, __spreadArray([console.error], __read(args), false));
138
+ };
139
+ /**
140
+ * Passes args to console.info
141
+ */
142
+ Logger.info = function () {
143
+ var args = [];
144
+ for (var _i = 0; _i < arguments.length; _i++) {
145
+ args[_i] = arguments[_i];
146
+ }
147
+ return print.apply(void 0, __spreadArray([console.info], __read(args), false));
148
+ };
149
+ return Logger;
150
+ }());
151
+ export { Logger };
@@ -0,0 +1,2 @@
1
+ declare const deepClone: <Type>(data: Type) => Type;
2
+ export default deepClone;
@@ -0,0 +1,19 @@
1
+ // todo: consolidate with merge in component platform
2
+ var deepClone = function (data) {
3
+ var out = {};
4
+ var value;
5
+ var key;
6
+ // If it's not an object return the original data
7
+ if (typeof data !== 'object' || data === null) {
8
+ return data;
9
+ }
10
+ // Create array if data is array, otherwise create an object
11
+ out = Array.isArray(data) ? [] : {};
12
+ for (key in data) {
13
+ value = data[key];
14
+ // Copy nested objects and arrays recursively
15
+ out[key] = typeof value === 'object' && value !== null ? deepClone(value) : value;
16
+ }
17
+ return out;
18
+ };
19
+ export 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,25 @@
1
+ import { hash } from '.';
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 (function (implementation) {
10
+ if (!implementation) {
11
+ return null;
12
+ }
13
+ var implementationStorage = localStorage.getItem("humany_".concat(hash(implementation.tenant + implementation.name)));
14
+ if (implementationStorage) {
15
+ var activeStickyWidget = JSON.parse(implementationStorage).activeStickyWidget;
16
+ if (activeStickyWidget && activeStickyWidget.value) {
17
+ var widget = implementation.widgets.get(activeStickyWidget.value);
18
+ if (widget) {
19
+ var el = document.createElement('a');
20
+ el.setAttribute('href', "//".concat(implementation.bindings[0], "/").concat(activeStickyWidget.value));
21
+ document.body.appendChild(el);
22
+ }
23
+ }
24
+ }
25
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Find a category by it's ID
3
+ * @param id Id of category to find
4
+ */
5
+ declare const findCategoryById: (id: string, categories: any) => any;
6
+ export default findCategoryById;
@@ -0,0 +1,87 @@
1
+ var __generator = (this && this.__generator) || function (thisArg, body) {
2
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4
+ function verb(n) { return function (v) { return step([n, v]); }; }
5
+ function step(op) {
6
+ if (f) throw new TypeError("Generator is already executing.");
7
+ while (_) try {
8
+ 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;
9
+ if (y = 0, t) op = [op[0] & 2, t.value];
10
+ switch (op[0]) {
11
+ case 0: case 1: t = op; break;
12
+ case 4: _.label++; return { value: op[1], done: false };
13
+ case 5: _.label++; y = op[1]; op = [0]; continue;
14
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
15
+ default:
16
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
17
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
18
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
19
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
20
+ if (t[2]) _.ops.pop();
21
+ _.trys.pop(); continue;
22
+ }
23
+ op = body.call(thisArg, _);
24
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
25
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
26
+ }
27
+ };
28
+ var __values = (this && this.__values) || function(o) {
29
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
+ if (m) return m.call(o);
31
+ if (o && typeof o.length === "number") return {
32
+ next: function () {
33
+ if (o && i >= o.length) o = void 0;
34
+ return { value: o && o[i++], done: !o };
35
+ }
36
+ };
37
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
+ };
39
+ /**
40
+ * Recursively find items
41
+ * @param data Data to look in
42
+ */
43
+ function processData(data) {
44
+ var i, val;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ if (!data) {
49
+ return [2 /*return*/];
50
+ }
51
+ i = 0;
52
+ _a.label = 1;
53
+ case 1:
54
+ if (!(i < data.length)) return [3 /*break*/, 5];
55
+ val = data[i];
56
+ return [4 /*yield*/, val];
57
+ case 2:
58
+ _a.sent();
59
+ if (!val.items) return [3 /*break*/, 4];
60
+ return [5 /*yield**/, __values(processData(val.items))];
61
+ case 3:
62
+ _a.sent();
63
+ _a.label = 4;
64
+ case 4:
65
+ i++;
66
+ return [3 /*break*/, 1];
67
+ case 5: return [2 /*return*/];
68
+ }
69
+ });
70
+ }
71
+ /**
72
+ * Find a category by it's ID
73
+ * @param id Id of category to find
74
+ */
75
+ var findCategoryById = function (id, categories) {
76
+ var it = processData(categories);
77
+ var res = it.next();
78
+ var found = null;
79
+ while (!res.done) {
80
+ if (res.value.id === id) {
81
+ found = res.value;
82
+ }
83
+ res = it.next();
84
+ }
85
+ return found;
86
+ };
87
+ export default findCategoryById;
@@ -0,0 +1,2 @@
1
+ declare const _default: (date: any, includeTime?: boolean) => string;
2
+ export default _default;
@@ -0,0 +1,21 @@
1
+ export default (function (date, includeTime) {
2
+ if (includeTime === void 0) { includeTime = false; }
3
+ var d = new Date(date);
4
+ var month = "".concat(d.getMonth() + 1);
5
+ var day = "".concat(d.getDate());
6
+ var year = d.getFullYear();
7
+ if (month.length < 2)
8
+ month = "0".concat(month);
9
+ if (day.length < 2)
10
+ day = "0".concat(day);
11
+ if (includeTime) {
12
+ var hours = "".concat(d.getHours());
13
+ var minutes = "".concat(d.getMinutes());
14
+ if (hours.length < 2)
15
+ hours = "0".concat(hours);
16
+ if (minutes.length < 2)
17
+ minutes = "0".concat(minutes);
18
+ return "".concat([year, month, day].join('-'), " ").concat([hours, minutes].join(':'));
19
+ }
20
+ return [year, month, day].join('-');
21
+ });
@@ -0,0 +1,2 @@
1
+ declare const formatUrl: (url: string) => string;
2
+ export default formatUrl;
@@ -0,0 +1,109 @@
1
+ var formatUrl = function (url) {
2
+ if (!url) {
3
+ return '';
4
+ }
5
+ var replacements = [
6
+ { from: /[äæǽ]+/gi, to: 'ae' },
7
+ { from: /[öœ]+/gi, to: 'oe' },
8
+ { from: /[ü]+/gi, to: 'ue' },
9
+ { from: /[Ä]+/gi, to: 'Ae' },
10
+ { from: /[Ü]+/gi, to: 'Ue' },
11
+ { from: /[Ö]+/gi, to: 'Oe' },
12
+ { from: /[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi, to: 'A' },
13
+ { from: /[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi, to: 'a' },
14
+ { from: /[Б]+/gi, to: 'B' },
15
+ { from: /[б]+/gi, to: 'b' },
16
+ { from: /[ÇĆĈĊČ]+/gi, to: 'C' },
17
+ { from: /[çćĉċč]+/gi, to: 'c' },
18
+ { from: /[Д]+/gi, to: 'D' },
19
+ { from: /[д]+/gi, to: 'd' },
20
+ { from: /[ÐĎĐΔ]+/gi, to: 'Dj' },
21
+ { from: /[ðďđδ]+/gi, to: 'dj' },
22
+ { from: /[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi, to: 'E' },
23
+ { from: /[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi, to: 'e' },
24
+ { from: /[Ф]+/gi, to: 'F' },
25
+ { from: /[ф]+/gi, to: 'f' },
26
+ { from: /[ĜĞĠĢΓГҐ]+/gi, to: 'G' },
27
+ { from: /[ĝğġģγгґ]+/gi, to: 'g' },
28
+ { from: /[ĤĦ]+/gi, to: 'H' },
29
+ { from: /[ĥħ]+/gi, to: 'h' },
30
+ { from: /[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi, to: 'I' },
31
+ { from: /[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi, to: 'i' },
32
+ { from: /[Ĵ]+/gi, to: 'J' },
33
+ { from: /[ĵ]+/gi, to: 'j' },
34
+ { from: /[ĶΚК]+/gi, to: 'K' },
35
+ { from: /[ķκк]+/gi, to: 'k' },
36
+ { from: /[ĹĻĽĿŁΛЛ]+/gi, to: 'L' },
37
+ { from: /[ĺļľŀłλл]+/gi, to: 'l' },
38
+ { from: /[М]+/gi, to: 'M' },
39
+ { from: /[м]+/gi, to: 'm' },
40
+ { from: /[ÑŃŅŇΝН]+/gi, to: 'N' },
41
+ { from: /[ñńņňʼnνн]+/gi, to: 'n' },
42
+ { from: /[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi, to: 'O' },
43
+ { from: /[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi, to: 'o' },
44
+ { from: /[П]+/gi, to: 'P' },
45
+ { from: /[п]+/gi, to: 'p' },
46
+ { from: /[ŔŖŘΡР]+/gi, to: 'R' },
47
+ { from: /[ŕŗřρр]+/gi, to: 'r' },
48
+ { from: /[ŚŜŞȘŠΣС]+/gi, to: 'S' },
49
+ { from: /[śŝşșšſσςс]+/gi, to: 's' },
50
+ { from: /[ȚŢŤŦτТ]+/gi, to: 'T' },
51
+ { from: /[țţťŧт]+/gi, to: 't' },
52
+ { from: /[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi, to: 'U' },
53
+ { from: /[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi, to: 'u' },
54
+ { from: /[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi, to: 'Y' },
55
+ { from: /[ýÿŷỳỹỷỵй]+/gi, to: 'y' },
56
+ { from: /[В]+/gi, to: 'V' },
57
+ { from: /[в]+/gi, to: 'v' },
58
+ { from: /[Ŵ]+/gi, to: 'W' },
59
+ { from: /[ŵ]+/gi, to: 'w' },
60
+ { from: /[ŹŻŽΖЗ]+/gi, to: 'Z' },
61
+ { from: /[źżžζз]+/gi, to: 'z' },
62
+ { from: /[ÆǼ]+/gi, to: 'AE' },
63
+ { from: /[ß]+/gi, to: 'ss' },
64
+ { from: /[IJ]+/gi, to: 'IJ' },
65
+ { from: /[ij]+/gi, to: 'ij' },
66
+ { from: /[Œ]+/gi, to: 'OE' },
67
+ { from: /[ƒ]+/gi, to: 'f' },
68
+ { from: /[ξ]+/gi, to: 'ks' },
69
+ { from: /[π]+/gi, to: 'p' },
70
+ { from: /[β]+/gi, to: 'v' },
71
+ { from: /[μ]+/gi, to: 'm' },
72
+ { from: /[ψ]+/gi, to: 'ps' },
73
+ { from: /[Ё]+/gi, to: 'Yo' },
74
+ { from: /[ё]+/gi, to: 'yo' },
75
+ { from: /[Є]+/gi, to: 'Ye' },
76
+ { from: /[є]+/gi, to: 'ye' },
77
+ { from: /[Ї]+/gi, to: 'Yi' },
78
+ { from: /[Ж]+/gi, to: 'Zh' },
79
+ { from: /[ж]+/gi, to: 'zh' },
80
+ { from: /[Х]+/gi, to: 'Kh' },
81
+ { from: /[х]+/gi, to: 'kh' },
82
+ { from: /[Ц]+/gi, to: 'Ts' },
83
+ { from: /[ц]+/gi, to: 'ts' },
84
+ { from: /[Ч]+/gi, to: 'Ch' },
85
+ { from: /[ч]+/gi, to: 'ch' },
86
+ { from: /[Ш]+/gi, to: 'Sh' },
87
+ { from: /[ш]+/gi, to: 'sh' },
88
+ { from: /[Щ]+/gi, to: 'Shch' },
89
+ { from: /[щ]+/gi, to: 'shch' },
90
+ { from: /[ЪъЬь]+/gi, to: '' },
91
+ { from: /[Ю]+/gi, to: 'Yu' },
92
+ { from: /[ю]+/gi, to: 'yu' },
93
+ { from: /[Я]+/gi, to: 'Ya' },
94
+ { from: /[я]+/gi, to: 'ya' },
95
+ ];
96
+ var alphanumericExpression = /[^a-zA-Z0-9]+/g;
97
+ var trailingDashExpression = /[-]$/;
98
+ var parsed = url;
99
+ for (var i in replacements) {
100
+ if (replacements.hasOwnProperty(i) && replacements[i].from.test(url)) {
101
+ parsed = parsed.replace(replacements[i].from, replacements[i].to);
102
+ }
103
+ }
104
+ parsed = parsed.replace(alphanumericExpression, '-');
105
+ parsed = parsed.replace(trailingDashExpression, '');
106
+ parsed = parsed.toLowerCase();
107
+ return parsed || 'humany';
108
+ };
109
+ export default formatUrl;
@@ -0,0 +1 @@
1
+ export default function getCookie(cookieName: string): string | null;
@@ -0,0 +1,15 @@
1
+ export default function getCookie(cookieName) {
2
+ var documentCookie = document.cookie;
3
+ if (documentCookie.length > 0) {
4
+ var start = documentCookie.indexOf("".concat(cookieName, "="));
5
+ if (start !== -1) {
6
+ start = start + cookieName.length + 1;
7
+ var end = documentCookie.indexOf(';', start);
8
+ if (end === -1) {
9
+ end = documentCookie.length;
10
+ }
11
+ return unescape(documentCookie.substring(start, end));
12
+ }
13
+ }
14
+ return null;
15
+ }
@@ -0,0 +1,2 @@
1
+ export declare function checkForEmptyCategories(items: any[], v?: boolean): boolean;
2
+ export default function hasNonEmptyCategories(items: any[], v?: boolean): boolean;
@@ -0,0 +1,18 @@
1
+ export function checkForEmptyCategories(items, v) {
2
+ if (v === void 0) { v = false; }
3
+ var value = v;
4
+ items.forEach(function (i) {
5
+ if ((typeof i.guidesCount === 'number' && i.guidesCount !== 0) ||
6
+ (typeof i.matchCount === 'number' && i.matchCount !== 0)) {
7
+ value = true;
8
+ }
9
+ if (i.items) {
10
+ value = checkForEmptyCategories(i.items, value);
11
+ }
12
+ });
13
+ return value;
14
+ }
15
+ export default function hasNonEmptyCategories(items, v) {
16
+ if (v === void 0) { v = false; }
17
+ return checkForEmptyCategories(items, v);
18
+ }