@churchapps/helpers 1.0.0 → 1.0.1
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/README.md +3 -1
- package/package.json +2 -1
- package/src/AppearanceHelper.ts +1 -1
- package/src/ErrorHelper.ts +1 -1
- package/src/EventHelper.ts +1 -1
- package/dist/ArrayHelper.d.ts +0 -12
- package/dist/ArrayHelper.d.ts.map +0 -1
- package/dist/ArrayHelper.js +0 -85
- package/dist/ArrayHelper.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@churchapps/helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Library of helper functions not specific to any one ChurchApps project or framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"typescript": "^5.2.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"axios": "^1.5.0",
|
|
32
33
|
"date-fns": "^2.30.0",
|
|
33
34
|
"react-ga4": "^2.1.0",
|
|
34
35
|
"rrule": "^2.7.2"
|
package/src/AppearanceHelper.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class AppearanceHelper {
|
|
|
20
20
|
return appearanceSettings?.favicon_16x16;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
return;
|
|
23
|
+
return null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
public static getLogo(appearanceSettings: AppearanceInterface, defaultLogoLight: string, defaultLogoDark: string, backgroundColor: string) {
|
package/src/ErrorHelper.ts
CHANGED
package/src/EventHelper.ts
CHANGED
package/dist/ArrayHelper.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class ArrayHelper {
|
|
2
|
-
static getIds(array: any[], propertyName: string): string[];
|
|
3
|
-
static sortBy(array: any[], propertyName: string, descending?: boolean): void;
|
|
4
|
-
static getIndex(array: any[], propertyName: string, value: any): number;
|
|
5
|
-
static getOne(array: any[], propertyName: string, value: any): any;
|
|
6
|
-
static getAll(array: any[], propertyName: string, value: any): any[];
|
|
7
|
-
static getAllArray(array: any[], propertyName: string, values: any[]): any[];
|
|
8
|
-
private static compare;
|
|
9
|
-
static getUniqueValues(array: any[], propertyName: string): any[];
|
|
10
|
-
static getDeepValue(item: any, propertyName: string): any;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=ArrayHelper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayHelper.d.ts","sourceRoot":"","sources":["../src/ArrayHelper.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM;IAShD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,GAAE,OAAe;IAS7E,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAQ9D,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAK5D,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAQ5D,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE;IAMpE,OAAO,CAAC,MAAM,CAAC,OAAO;IAYtB,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM;IAUzD,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM;CASpD"}
|
package/dist/ArrayHelper.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayHelper = void 0;
|
|
4
|
-
class ArrayHelper {
|
|
5
|
-
static getIds(array, propertyName) {
|
|
6
|
-
const result = [];
|
|
7
|
-
for (const item of array) {
|
|
8
|
-
const id = item[propertyName]?.toString();
|
|
9
|
-
if (id && result.indexOf(id) === -1)
|
|
10
|
-
result.push(id);
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
static sortBy(array, propertyName, descending = false) {
|
|
15
|
-
array.sort((a, b) => {
|
|
16
|
-
const valA = a[propertyName];
|
|
17
|
-
const valB = b[propertyName];
|
|
18
|
-
if (valA < valB)
|
|
19
|
-
return descending ? 1 : -1;
|
|
20
|
-
else
|
|
21
|
-
return descending ? -1 : 1;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
static getIndex(array, propertyName, value) {
|
|
25
|
-
for (let i = 0; i < array.length; i++) {
|
|
26
|
-
const item = array[i];
|
|
27
|
-
if (ArrayHelper.compare(item, propertyName, value))
|
|
28
|
-
return i;
|
|
29
|
-
}
|
|
30
|
-
return -1;
|
|
31
|
-
}
|
|
32
|
-
static getOne(array, propertyName, value) {
|
|
33
|
-
for (const item of array || [])
|
|
34
|
-
if (ArrayHelper.compare(item, propertyName, value))
|
|
35
|
-
return item;
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
static getAll(array, propertyName, value) {
|
|
39
|
-
const result = [];
|
|
40
|
-
for (const item of array || []) {
|
|
41
|
-
if (ArrayHelper.compare(item, propertyName, value))
|
|
42
|
-
result.push(item);
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
static getAllArray(array, propertyName, values) {
|
|
47
|
-
const result = [];
|
|
48
|
-
for (const item of array || [])
|
|
49
|
-
if (values.indexOf(item[propertyName]) > -1)
|
|
50
|
-
result.push(item);
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
static compare(item, propertyName, value) {
|
|
54
|
-
const propChain = propertyName.split(".");
|
|
55
|
-
if (propChain.length === 1)
|
|
56
|
-
return item[propertyName] === value;
|
|
57
|
-
else {
|
|
58
|
-
let obj = item;
|
|
59
|
-
for (let i = 0; i < propChain.length - 1; i++) {
|
|
60
|
-
if (obj)
|
|
61
|
-
obj = item[propChain[i]];
|
|
62
|
-
}
|
|
63
|
-
return obj[propChain[propChain.length - 1]] === value;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
static getUniqueValues(array, propertyName) {
|
|
67
|
-
const result = [];
|
|
68
|
-
for (const item of array) {
|
|
69
|
-
const val = (propertyName.indexOf(".") === -1) ? item[propertyName] : this.getDeepValue(item, propertyName);
|
|
70
|
-
if (result.indexOf(val) === -1)
|
|
71
|
-
result.push(val);
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
static getDeepValue(item, propertyName) {
|
|
76
|
-
const propertyNames = propertyName.split(".");
|
|
77
|
-
let result = item;
|
|
78
|
-
propertyNames.forEach(name => {
|
|
79
|
-
result = result[name];
|
|
80
|
-
});
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.ArrayHelper = ArrayHelper;
|
|
85
|
-
//# sourceMappingURL=ArrayHelper.js.map
|
package/dist/ArrayHelper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayHelper.js","sourceRoot":"","sources":["../src/ArrayHelper.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACtB,MAAM,CAAC,MAAM,CAAC,KAAY,EAAE,YAAo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,CAAC,CAAC,CAAC,CAAC;aACnC;YACD,OAAO,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC;SACvD;IACH,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,KAAY,EAAE,YAAoB;QACvD,MAAM,MAAM,GAAU,EAAE,CAAC;QAEzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;YAC3G,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClD;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,IAAS,EAAE,YAAoB;QACjD,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,MAAM,GAAQ,IAAI,CAAC;QACvB,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC3B,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF;AA7ED,kCA6EC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayHelper = void 0;
|
|
4
|
-
var ArrayHelper_1 = require("./ArrayHelper");
|
|
5
|
-
Object.defineProperty(exports, "ArrayHelper", { enumerable: true, get: function () { return ArrayHelper_1.ArrayHelper; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAAlC,0GAAA,WAAW,OAAA"}
|