@telia-ace/widget-utilities 1.0.0 → 1.0.3

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 (113) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +3 -3
  3. package/{lib-esm → dist}/append-class-names.d.ts +0 -0
  4. package/{lib-esm → dist}/batch.d.ts +0 -0
  5. package/{lib-esm → dist}/camilize.d.ts +0 -0
  6. package/{lib-esm → dist}/category-trail.d.ts +0 -0
  7. package/{lib-esm → dist}/create-params.d.ts +0 -0
  8. package/{lib-esm → dist}/data-uri-to-blob.d.ts +0 -0
  9. package/{lib-esm → dist}/debug.d.ts +0 -0
  10. package/{lib-esm → dist}/deep-clone.d.ts +0 -0
  11. package/{lib-esm → dist}/find-and-activate-stored-widgets.d.ts +0 -0
  12. package/{lib-esm → dist}/find-category-by-id.d.ts +0 -0
  13. package/{lib-esm → dist}/format-date.d.ts +0 -0
  14. package/{lib-esm → dist}/format-url.d.ts +0 -0
  15. package/{lib-esm → dist}/get-cookie.d.ts +0 -0
  16. package/{lib-esm → dist}/has-non-empty-categories.d.ts +0 -0
  17. package/{lib-esm → dist}/hash.d.ts +0 -0
  18. package/{lib-esm → dist}/html-parent-contains.d.ts +0 -0
  19. package/{lib-esm → dist}/index.d.ts +0 -0
  20. package/dist/index.js +802 -0
  21. package/dist/index.js.map +1 -0
  22. package/{lib-esm → dist}/is-anchor-link.d.ts +0 -0
  23. package/{lib-esm → dist}/kebab-case.d.ts +0 -0
  24. package/{lib-esm → dist}/lock.d.ts +0 -0
  25. package/{lib-esm → dist}/merge-deep.d.ts +0 -0
  26. package/{lib-esm → dist}/notify-data-loaded.d.ts +0 -0
  27. package/{lib-esm → dist}/remove-null-and-undefined-values.d.ts +0 -0
  28. package/{lib-esm → dist}/set-cookie.d.ts +0 -0
  29. package/{lib-esm → dist}/shallow-compare.d.ts +0 -0
  30. package/{lib-esm → dist}/uuid.d.ts +0 -0
  31. package/{lib-esm → dist}/wait-for.d.ts +0 -0
  32. package/package.json +36 -35
  33. package/lib/append-class-names.d.ts +0 -6
  34. package/lib/append-class-names.js +0 -84
  35. package/lib/batch.d.ts +0 -4
  36. package/lib/batch.js +0 -38
  37. package/lib/camilize.d.ts +0 -1
  38. package/lib/camilize.js +0 -29
  39. package/lib/category-trail.d.ts +0 -14
  40. package/lib/category-trail.js +0 -96
  41. package/lib/create-params.d.ts +0 -21
  42. package/lib/create-params.js +0 -108
  43. package/lib/data-uri-to-blob.d.ts +0 -2
  44. package/lib/data-uri-to-blob.js +0 -20
  45. package/lib/debug.d.ts +0 -52
  46. package/lib/debug.js +0 -155
  47. package/lib/deep-clone.d.ts +0 -2
  48. package/lib/deep-clone.js +0 -21
  49. package/lib/find-and-activate-stored-widgets.d.ts +0 -9
  50. package/lib/find-and-activate-stored-widgets.js +0 -27
  51. package/lib/find-category-by-id.d.ts +0 -6
  52. package/lib/find-category-by-id.js +0 -89
  53. package/lib/format-date.d.ts +0 -2
  54. package/lib/format-date.js +0 -23
  55. package/lib/format-url.d.ts +0 -2
  56. package/lib/format-url.js +0 -111
  57. package/lib/get-cookie.d.ts +0 -1
  58. package/lib/get-cookie.js +0 -18
  59. package/lib/has-non-empty-categories.d.ts +0 -2
  60. package/lib/has-non-empty-categories.js +0 -23
  61. package/lib/hash.d.ts +0 -1
  62. package/lib/hash.js +0 -16
  63. package/lib/html-parent-contains.d.ts +0 -7
  64. package/lib/html-parent-contains.js +0 -21
  65. package/lib/index.d.ts +0 -27
  66. package/lib/index.js +0 -57
  67. package/lib/is-anchor-link.d.ts +0 -2
  68. package/lib/is-anchor-link.js +0 -9
  69. package/lib/kebab-case.d.ts +0 -1
  70. package/lib/kebab-case.js +0 -9
  71. package/lib/lock.d.ts +0 -9
  72. package/lib/lock.js +0 -78
  73. package/lib/merge-deep.d.ts +0 -7
  74. package/lib/merge-deep.js +0 -72
  75. package/lib/notify-data-loaded.d.ts +0 -6
  76. package/lib/notify-data-loaded.js +0 -96
  77. package/lib/remove-null-and-undefined-values.d.ts +0 -6
  78. package/lib/remove-null-and-undefined-values.js +0 -12
  79. package/lib/set-cookie.d.ts +0 -1
  80. package/lib/set-cookie.js +0 -12
  81. package/lib/shallow-compare.d.ts +0 -6
  82. package/lib/shallow-compare.js +0 -25
  83. package/lib/uuid.d.ts +0 -1
  84. package/lib/uuid.js +0 -12
  85. package/lib/wait-for.d.ts +0 -20
  86. package/lib/wait-for.js +0 -52
  87. package/lib-esm/append-class-names.js +0 -77
  88. package/lib-esm/batch.js +0 -36
  89. package/lib-esm/camilize.js +0 -26
  90. package/lib-esm/category-trail.js +0 -87
  91. package/lib-esm/create-params.js +0 -105
  92. package/lib-esm/data-uri-to-blob.js +0 -18
  93. package/lib-esm/debug.js +0 -151
  94. package/lib-esm/deep-clone.js +0 -19
  95. package/lib-esm/find-and-activate-stored-widgets.js +0 -25
  96. package/lib-esm/find-category-by-id.js +0 -87
  97. package/lib-esm/format-date.js +0 -21
  98. package/lib-esm/format-url.js +0 -109
  99. package/lib-esm/get-cookie.js +0 -15
  100. package/lib-esm/has-non-empty-categories.js +0 -18
  101. package/lib-esm/hash.js +0 -13
  102. package/lib-esm/html-parent-contains.js +0 -19
  103. package/lib-esm/index.js +0 -24
  104. package/lib-esm/is-anchor-link.js +0 -7
  105. package/lib-esm/kebab-case.js +0 -6
  106. package/lib-esm/lock.js +0 -75
  107. package/lib-esm/merge-deep.js +0 -67
  108. package/lib-esm/notify-data-loaded.js +0 -94
  109. package/lib-esm/remove-null-and-undefined-values.js +0 -10
  110. package/lib-esm/set-cookie.js +0 -9
  111. package/lib-esm/shallow-compare.js +0 -23
  112. package/lib-esm/uuid.js +0 -9
  113. package/lib-esm/wait-for.js +0 -50
@@ -1,77 +0,0 @@
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
- import { Logger } from '.';
27
- export function uniqueClassArray(classNames) {
28
- var classArray = [];
29
- classNames.forEach(function (c) {
30
- if (classArray.indexOf(c) === -1) {
31
- classArray.push(c);
32
- }
33
- });
34
- return classArray;
35
- }
36
- export function append(className1, className2) {
37
- if (className1 === void 0) { className1 = ''; }
38
- if (className2 === void 0) { className2 = ''; }
39
- var classNames = className1.split(' ').concat(className2.split(' '));
40
- return uniqueClassArray(classNames).join(' ').trim();
41
- }
42
- export function handleFunctionArgument(expression, classes) {
43
- if (Boolean(expression)) {
44
- if (typeof classes === 'string') {
45
- return classes;
46
- }
47
- if (Array.isArray(classes)) {
48
- var className_1 = '';
49
- classes.forEach(function (c) { return (className_1 = append(className_1, c)); });
50
- return className_1;
51
- }
52
- }
53
- }
54
- export default function appendClassNames() {
55
- var args = [];
56
- for (var _i = 0; _i < arguments.length; _i++) {
57
- args[_i] = arguments[_i];
58
- }
59
- var className = '';
60
- if (args.length) {
61
- args.forEach(function (argument) {
62
- if (typeof argument === 'string') {
63
- className = append(className, argument);
64
- }
65
- else if (Array.isArray(argument)) {
66
- className = append(className, handleFunctionArgument.apply(void 0, __spreadArray([], __read(argument), false)));
67
- }
68
- else if (typeof argument !== 'undefined' && argument !== null) {
69
- if (process.env.NODE_ENV !== 'production') {
70
- Logger.warn.apply(Logger, __spreadArray(['appendClassNames: arguments either have' +
71
- 'to be a string or [boolean, ...string[]]. Passed args:'], __read(args), false));
72
- }
73
- }
74
- });
75
- }
76
- return className;
77
- }
package/lib-esm/batch.js DELETED
@@ -1,36 +0,0 @@
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 createBatch = function (delay, createFallback) {
18
- var timeout;
19
- var queue = [];
20
- return function (fn) {
21
- clearTimeout(timeout);
22
- return new Promise(function (resolve, reject) {
23
- queue.push([fn, resolve, reject]);
24
- timeout = setTimeout(function () {
25
- var acc = createFallback();
26
- queue.forEach(function (_a) {
27
- var _b = __read(_a, 3), fn = _b[0], resolve = _b[1], reject = _b[2];
28
- acc = fn(acc);
29
- });
30
- queue = [];
31
- resolve(acc);
32
- }, delay);
33
- });
34
- };
35
- };
36
- export default createBatch;
@@ -1,26 +0,0 @@
1
- export default function camilize(obj) {
2
- var camilizedObject = {};
3
- if (typeof obj === 'number' || typeof obj === 'string') {
4
- return obj;
5
- }
6
- for (var prop in obj) {
7
- if (obj.hasOwnProperty(prop)) {
8
- var p = obj[prop];
9
- var camilizedProp = prop.substring(0, 1).toLowerCase() + prop.substring(1);
10
- if (Object.prototype.toString.call(p) === '[object Array]') {
11
- camilizedObject[camilizedProp] = [];
12
- for (var i = 0, c = p.length; i < c; i++) {
13
- // tslint:disable-line no-increment-decrement
14
- camilizedObject[camilizedProp].push(camilize(p[i]));
15
- }
16
- }
17
- else if (p !== null && typeof p === 'object') {
18
- camilizedObject[camilizedProp] = camilize(p);
19
- }
20
- else {
21
- camilizedObject[camilizedProp] = p;
22
- }
23
- }
24
- }
25
- return camilizedObject;
26
- }
@@ -1,87 +0,0 @@
1
- import createParams from './create-params';
2
- import { default as findCategoryById } from './find-category-by-id';
3
- import formatUrl from './format-url';
4
- function childParentStructure(items, structure, parent) {
5
- if (structure === void 0) { structure = {}; }
6
- items.forEach(function (item) {
7
- if (parent) {
8
- structure[+item.id] = parent;
9
- }
10
- if (item.items) {
11
- childParentStructure(item.items, structure, item.id);
12
- }
13
- });
14
- return structure;
15
- }
16
- export function categoryTrail(id, items, ids, structure) {
17
- if (ids === void 0) { ids = [id]; }
18
- if (structure === void 0) { structure = childParentStructure(items); }
19
- var addAncestors = function (id) {
20
- var parentId = structure[+id];
21
- if (parentId) {
22
- ids.unshift(parentId);
23
- addAncestors(parentId);
24
- }
25
- };
26
- var parentId = structure[+id];
27
- if (parentId) {
28
- ids.unshift(parentId);
29
- addAncestors(parentId);
30
- }
31
- return ids;
32
- }
33
- export var getCategoryTrailAsObjects = function (trail, categories) {
34
- if (typeof trail === 'undefined' || typeof categories === 'undefined') {
35
- return new Map();
36
- }
37
- return new Map(trail.map(function (categoryId) {
38
- var category = findCategoryById(categoryId, categories);
39
- return [categoryId, category];
40
- }));
41
- };
42
- export var buildCategoryTrail = function (routeName, categoryIds, container, dataType) {
43
- if (dataType === void 0) { dataType = 'guide-categories'; }
44
- return container.getAsync('dataClient').then(function (dataClient) {
45
- return dataClient
46
- .fetch(dataType, { expandCategories: 'descendants' })
47
- .then(function (_a) {
48
- var categories = _a.categories;
49
- var buildTrail = function (id) {
50
- var trail = categoryTrail(id, categories);
51
- var objectTrail = getCategoryTrailAsObjects(trail, categories);
52
- var result = [];
53
- trail.forEach(function (categoryId) {
54
- var category = objectTrail.get(categoryId);
55
- if (category) {
56
- result.push({
57
- routeName: routeName,
58
- title: category.title,
59
- symbol: category.symbol,
60
- id: category.id,
61
- routeParams: dataType === 'contact-method-categories'
62
- ? createParams({
63
- contactCategory: category.id,
64
- uriName: formatUrl(category.title),
65
- })
66
- : createParams({
67
- guideCategory: category.id,
68
- uriName: formatUrl(category.title),
69
- }),
70
- });
71
- }
72
- });
73
- return result;
74
- };
75
- if (Array.isArray(categoryIds)) {
76
- return categoryIds.reduce(function (acc, id) {
77
- var result = buildTrail(id);
78
- if (result.length > 0) {
79
- acc.push(result);
80
- }
81
- return acc;
82
- }, []);
83
- }
84
- return buildTrail(categoryIds);
85
- });
86
- });
87
- };
@@ -1,105 +0,0 @@
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
- }
@@ -1,18 +0,0 @@
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;
package/lib-esm/debug.js DELETED
@@ -1,151 +0,0 @@
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 };
@@ -1,19 +0,0 @@
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;
@@ -1,25 +0,0 @@
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
- });
@@ -1,87 +0,0 @@
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;
@@ -1,21 +0,0 @@
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
- });