ag-common 0.0.418 → 0.0.419
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/dist/api/helpers/api.js +34 -35
- package/dist/api/helpers/aws.js +9 -13
- package/dist/api/helpers/cloudfront.js +7 -24
- package/dist/api/helpers/dynamo.js +85 -134
- package/dist/api/helpers/dynamoInfra.js +14 -19
- package/dist/api/helpers/enforceDynamoProvisionCap.js +14 -18
- package/dist/api/helpers/index.js +14 -30
- package/dist/api/helpers/openApiHelpers.d.ts +2 -3
- package/dist/api/helpers/openApiHelpers.js +34 -37
- package/dist/api/helpers/s3.js +81 -126
- package/dist/api/helpers/ses.js +9 -28
- package/dist/api/helpers/sqs.js +9 -26
- package/dist/api/helpers/ssm.js +8 -14
- package/dist/api/helpers/sts.js +16 -34
- package/dist/api/helpers/validateOpenApi.js +92 -103
- package/dist/api/helpers/validations.js +29 -46
- package/dist/api/index.js +2 -18
- package/dist/api/openapi-prefix.js +25 -38
- package/dist/api/types/aws.js +1 -2
- package/dist/api/types/index.js +1 -17
- package/dist/common/const.js +2 -5
- package/dist/common/helpers/array.js +8 -19
- package/dist/common/helpers/async.js +10 -28
- package/dist/common/helpers/binary.js +5 -10
- package/dist/common/helpers/date.js +14 -25
- package/dist/common/helpers/email.js +5 -11
- package/dist/common/helpers/func.js +3 -7
- package/dist/common/helpers/generator.js +9 -24
- package/dist/common/helpers/groupBy.js +3 -9
- package/dist/common/helpers/hashCode.js +3 -9
- package/dist/common/helpers/i18n.js +9 -17
- package/dist/common/helpers/index.js +18 -34
- package/dist/common/helpers/log.js +16 -28
- package/dist/common/helpers/math.js +9 -21
- package/dist/common/helpers/memo.js +3 -7
- package/dist/common/helpers/object.js +20 -35
- package/dist/common/helpers/random.js +4 -10
- package/dist/common/helpers/secondsInNearest.js +2 -7
- package/dist/common/helpers/sleep.js +1 -5
- package/dist/common/helpers/string/base64.js +2 -7
- package/dist/common/helpers/string/chunk.js +1 -5
- package/dist/common/helpers/string/contains.js +2 -7
- package/dist/common/helpers/string/getExtendedStringSegment.js +5 -9
- package/dist/common/helpers/string/index.js +10 -26
- package/dist/common/helpers/string/json.js +1 -5
- package/dist/common/helpers/string/object.js +1 -5
- package/dist/common/helpers/string/surround.js +1 -5
- package/dist/common/helpers/string/trim.js +2 -7
- package/dist/common/helpers/string/truncate.js +1 -5
- package/dist/common/helpers/string/url.js +4 -9
- package/dist/common/index.js +2 -18
- package/dist/index.js +3 -19
- package/dist/ui/components/BorderGradient/index.js +18 -25
- package/dist/ui/components/Button/index.js +17 -25
- package/dist/ui/components/Chevron/index.js +9 -16
- package/dist/ui/components/Close/index.js +6 -13
- package/dist/ui/components/Confirm/Dialog.js +9 -25
- package/dist/ui/components/Confirm/Modal.js +20 -27
- package/dist/ui/components/Confirm/index.js +3 -19
- package/dist/ui/components/Confirm/types.js +1 -2
- package/dist/ui/components/DropdownList/Base.js +33 -64
- package/dist/ui/components/DropdownList/Dialog.js +8 -24
- package/dist/ui/components/DropdownList/index.js +2 -18
- package/dist/ui/components/DropdownList/types.js +1 -2
- package/dist/ui/components/FlexColumn/index.js +4 -14
- package/dist/ui/components/FlexRow/index.js +4 -14
- package/dist/ui/components/HeadersRaw/index.js +20 -27
- package/dist/ui/components/HorizontalScrollBar/index.js +6 -34
- package/dist/ui/components/Icon/index.js +9 -16
- package/dist/ui/components/Image/index.js +10 -28
- package/dist/ui/components/InfiniteScroll/index.js +18 -50
- package/dist/ui/components/KebabDots/index.js +6 -13
- package/dist/ui/components/Loader/index.js +9 -39
- package/dist/ui/components/Modal/Dialog.js +7 -23
- package/dist/ui/components/Modal/Modal.js +19 -49
- package/dist/ui/components/Modal/index.js +3 -19
- package/dist/ui/components/Modal/types.js +1 -2
- package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +26 -34
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +12 -19
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +6 -11
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +8 -15
- package/dist/ui/components/OpenApiCodeBlock/curl/index.js +14 -21
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +8 -15
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +3 -8
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +27 -34
- package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +11 -18
- package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +7 -17
- package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +6 -15
- package/dist/ui/components/OpenApiCodeBlock/index.js +2 -18
- package/dist/ui/components/OpenApiCodeBlock/types.js +1 -2
- package/dist/ui/components/PieChart/index.js +11 -18
- package/dist/ui/components/ProgressBar/index.js +15 -45
- package/dist/ui/components/Prompt/Dialog.js +7 -23
- package/dist/ui/components/Prompt/Modal.js +25 -55
- package/dist/ui/components/Prompt/index.js +2 -18
- package/dist/ui/components/RowOrColumn/index.js +7 -17
- package/dist/ui/components/Search/AutoHideSearchBox.js +24 -56
- package/dist/ui/components/Search/Base.js +21 -52
- package/dist/ui/components/Search/Dialog.js +10 -26
- package/dist/ui/components/Search/Inline.js +3 -10
- package/dist/ui/components/Search/Modal.js +10 -17
- package/dist/ui/components/Search/SearchBox.js +26 -58
- package/dist/ui/components/Search/index.js +7 -23
- package/dist/ui/components/Search/types.js +1 -2
- package/dist/ui/components/Sidebar/index.js +18 -25
- package/dist/ui/components/SparkLine/index.js +17 -27
- package/dist/ui/components/Table/index.js +15 -22
- package/dist/ui/components/TextEdit/CheckboxEdit.js +21 -51
- package/dist/ui/components/TextEdit/ColourEdit.js +17 -44
- package/dist/ui/components/TextEdit/LengthBox.js +5 -12
- package/dist/ui/components/TextEdit/ListboxEdit.js +15 -42
- package/dist/ui/components/TextEdit/RadioGroup.js +13 -43
- package/dist/ui/components/TextEdit/TextEdit.js +48 -78
- package/dist/ui/components/TextEdit/common.js +11 -17
- package/dist/ui/components/TextEdit/index.js +6 -22
- package/dist/ui/components/TextEdit/types.js +1 -2
- package/dist/ui/components/TextWithButton/index.js +10 -40
- package/dist/ui/components/TimelineChart/index.js +14 -24
- package/dist/ui/components/Toast/Cross.js +9 -16
- package/dist/ui/components/Toast/Tick.js +4 -11
- package/dist/ui/components/Toast/Warning.js +8 -15
- package/dist/ui/components/Toast/base.js +33 -65
- package/dist/ui/components/Toast/index.js +2 -18
- package/dist/ui/components/Toast/types.js +1 -2
- package/dist/ui/components/UserImage/index.js +17 -48
- package/dist/ui/components/index.js +30 -46
- package/dist/ui/helpers/axiosHelper.js +25 -39
- package/dist/ui/helpers/browserHelpers.js +7 -22
- package/dist/ui/helpers/callOpenApi/cached.js +18 -37
- package/dist/ui/helpers/callOpenApi/direct.js +46 -59
- package/dist/ui/helpers/callOpenApi/helpers.js +25 -40
- package/dist/ui/helpers/callOpenApi/hook.js +47 -36
- package/dist/ui/helpers/callOpenApi/index.js +5 -21
- package/dist/ui/helpers/callOpenApi/types.js +1 -2
- package/dist/ui/helpers/cognito.js +1 -2
- package/dist/ui/helpers/cookie/const.js +2 -5
- package/dist/ui/helpers/cookie/get.js +13 -14
- package/dist/ui/helpers/cookie/index.js +5 -21
- package/dist/ui/helpers/cookie/raw.js +9 -16
- package/dist/ui/helpers/cookie/set.js +10 -15
- package/dist/ui/helpers/cookie/use.js +23 -16
- package/dist/ui/helpers/date.js +10 -15
- package/dist/ui/helpers/debounce.js +5 -10
- package/dist/ui/helpers/dom.js +6 -13
- package/dist/ui/helpers/extractAttributes.js +2 -7
- package/dist/ui/helpers/index.js +25 -41
- package/dist/ui/helpers/jwt.js +1 -2
- package/dist/ui/helpers/plural.js +1 -5
- package/dist/ui/helpers/routes.js +17 -24
- package/dist/ui/helpers/serviceWorker.js +8 -23
- package/dist/ui/helpers/useContextMenu.js +9 -14
- package/dist/ui/helpers/useElementAttribute.js +3 -7
- package/dist/ui/helpers/useGranularHook.js +5 -10
- package/dist/ui/helpers/useInterval.js +8 -12
- package/dist/ui/helpers/useLocalStorage.js +24 -32
- package/dist/ui/helpers/useLockBodyScroll.js +3 -7
- package/dist/ui/helpers/useOnClickOutside.js +7 -12
- package/dist/ui/helpers/useOnScroll.js +15 -21
- package/dist/ui/helpers/useOverloadPageSearch.js +3 -7
- package/dist/ui/helpers/useQueryString.js +14 -20
- package/dist/ui/helpers/useResize.js +8 -12
- package/dist/ui/helpers/useTimeout.js +5 -9
- package/dist/ui/icons/ChevronRight.js +3 -9
- package/dist/ui/icons/CrossIcon.js +5 -12
- package/dist/ui/icons/Door.js +4 -10
- package/dist/ui/icons/HorizontalDots.js +3 -9
- package/dist/ui/icons/Magnify.js +3 -10
- package/dist/ui/icons/Pencil.js +5 -12
- package/dist/ui/icons/Save.js +4 -11
- package/dist/ui/icons/Undo.js +5 -12
- package/dist/ui/icons/UserOutline.js +3 -9
- package/dist/ui/icons/index.js +9 -25
- package/dist/ui/index.js +4 -20
- package/dist/ui/styles/colours.js +7 -12
- package/dist/ui/styles/common.js +14 -22
- package/dist/ui/styles/index.js +4 -20
- package/dist/ui/styles/media.js +7 -10
- package/dist/ui/styles/standaloneStyles.js +10 -16
- package/package.json +18 -17
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.memo = void 0;
|
|
4
|
-
const hashCode_1 = require("./hashCode");
|
|
1
|
+
import { hashCode } from './hashCode';
|
|
5
2
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
3
|
const memoData = {};
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
function memo(func, ...args) {
|
|
9
|
-
const hc =
|
|
5
|
+
export function memo(func, ...args) {
|
|
6
|
+
const hc = hashCode(JSON.stringify(args));
|
|
10
7
|
if (!memoData[hc]) {
|
|
11
8
|
memoData[hc] = func(...args);
|
|
12
9
|
}
|
|
13
10
|
return memoData[hc];
|
|
14
11
|
}
|
|
15
|
-
exports.memo = memo;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isObject = exports.castStringlyObject = exports.removeUndefValuesFromObject = exports.castObject = exports.objectToString = exports.paramsToObject = exports.objectAlphaSort = exports.objectToArray = exports.getObjectKeysAsNumber = exports.objectKeysToLowerCase = exports.isJson = exports.tryJsonParse = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const tryJsonParse = (str, defaultValue) => {
|
|
1
|
+
import { trim } from '.';
|
|
2
|
+
export const tryJsonParse = (str, defaultValue) => {
|
|
6
3
|
if (!str) {
|
|
7
4
|
return null;
|
|
8
5
|
}
|
|
@@ -13,8 +10,7 @@ const tryJsonParse = (str, defaultValue) => {
|
|
|
13
10
|
return defaultValue;
|
|
14
11
|
}
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
function isJson(str) {
|
|
13
|
+
export function isJson(str) {
|
|
18
14
|
try {
|
|
19
15
|
JSON.parse(typeof str === 'string' ? str : JSON.stringify(str));
|
|
20
16
|
}
|
|
@@ -23,8 +19,7 @@ function isJson(str) {
|
|
|
23
19
|
}
|
|
24
20
|
return true;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
const objectKeysToLowerCase = (origObj) => {
|
|
22
|
+
export const objectKeysToLowerCase = (origObj) => {
|
|
28
23
|
if (!origObj || Object.keys(origObj).length === 0) {
|
|
29
24
|
return {};
|
|
30
25
|
}
|
|
@@ -32,17 +27,15 @@ const objectKeysToLowerCase = (origObj) => {
|
|
|
32
27
|
const val = origObj[key];
|
|
33
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
29
|
const newVal = typeof val === 'object'
|
|
35
|
-
?
|
|
30
|
+
? objectKeysToLowerCase(val)
|
|
36
31
|
: val;
|
|
37
32
|
// eslint-disable-next-line no-param-reassign
|
|
38
33
|
newObj[key.toLowerCase()] = newVal;
|
|
39
34
|
return newObj;
|
|
40
35
|
}, {});
|
|
41
36
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
exports.getObjectKeysAsNumber = getObjectKeysAsNumber;
|
|
45
|
-
function objectToArray(obj) {
|
|
37
|
+
export const getObjectKeysAsNumber = (o) => Object.keys(o).map((o2) => parseInt(o2, 10));
|
|
38
|
+
export function objectToArray(obj) {
|
|
46
39
|
if (!obj) {
|
|
47
40
|
return [];
|
|
48
41
|
}
|
|
@@ -52,7 +45,6 @@ function objectToArray(obj) {
|
|
|
52
45
|
});
|
|
53
46
|
return ret;
|
|
54
47
|
}
|
|
55
|
-
exports.objectToArray = objectToArray;
|
|
56
48
|
/**
|
|
57
49
|
* Recursively alphabetically sort an object
|
|
58
50
|
* @param object
|
|
@@ -60,7 +52,7 @@ exports.objectToArray = objectToArray;
|
|
|
60
52
|
* @returns
|
|
61
53
|
*/
|
|
62
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
-
const objectAlphaSort = (object, depthLeft = -1) => {
|
|
55
|
+
export const objectAlphaSort = (object, depthLeft = -1) => {
|
|
64
56
|
if (depthLeft === 0) {
|
|
65
57
|
return object;
|
|
66
58
|
}
|
|
@@ -69,32 +61,30 @@ const objectAlphaSort = (object, depthLeft = -1) => {
|
|
|
69
61
|
.sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : 1))
|
|
70
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
63
|
.reduce((result, key) => {
|
|
72
|
-
result[key] =
|
|
64
|
+
result[key] = objectAlphaSort(object[key], depthLeft - 1);
|
|
73
65
|
return result;
|
|
74
66
|
}, {}));
|
|
75
67
|
}
|
|
76
68
|
else if (Array.isArray(object)) {
|
|
77
|
-
return object.map((obj) =>
|
|
69
|
+
return object.map((obj) => objectAlphaSort(obj, depthLeft - 1));
|
|
78
70
|
}
|
|
79
71
|
else {
|
|
80
72
|
return object;
|
|
81
73
|
}
|
|
82
74
|
};
|
|
83
|
-
exports.objectAlphaSort = objectAlphaSort;
|
|
84
75
|
/**
|
|
85
76
|
* Convert a random object type to a record<string,string>
|
|
86
77
|
* @param entries Could be URLSearchParams
|
|
87
78
|
* @returns
|
|
88
79
|
*/
|
|
89
80
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
function paramsToObject(entries) {
|
|
81
|
+
export function paramsToObject(entries) {
|
|
91
82
|
const result = {};
|
|
92
83
|
for (const [key, value] of entries) {
|
|
93
84
|
result[key] = value;
|
|
94
85
|
}
|
|
95
86
|
return result;
|
|
96
87
|
}
|
|
97
|
-
exports.paramsToObject = paramsToObject;
|
|
98
88
|
/**
|
|
99
89
|
* stringify an object of key values. Could be used to stringify a querystring url
|
|
100
90
|
* @param obj
|
|
@@ -102,7 +92,7 @@ exports.paramsToObject = paramsToObject;
|
|
|
102
92
|
* @param joinKeys
|
|
103
93
|
* @returns
|
|
104
94
|
*/
|
|
105
|
-
function objectToString(obj, joinKeyValue, joinKeys) {
|
|
95
|
+
export function objectToString(obj, joinKeyValue, joinKeys) {
|
|
106
96
|
let ret = '';
|
|
107
97
|
if (!obj || Object.keys(obj).length === 0) {
|
|
108
98
|
return ret;
|
|
@@ -110,52 +100,47 @@ function objectToString(obj, joinKeyValue, joinKeys) {
|
|
|
110
100
|
Object.entries(obj).forEach(([key, value]) => {
|
|
111
101
|
ret += `${joinKeys}${key}${joinKeyValue}${value}`;
|
|
112
102
|
});
|
|
113
|
-
ret =
|
|
103
|
+
ret = trim(ret, joinKeyValue);
|
|
114
104
|
return ret;
|
|
115
105
|
}
|
|
116
|
-
exports.objectToString = objectToString;
|
|
117
106
|
/**
|
|
118
107
|
* run func over values in object. can be used to cast value type string[]|string to string
|
|
119
108
|
* @param orig
|
|
120
109
|
* @param castF
|
|
121
110
|
* @returns
|
|
122
111
|
*/
|
|
123
|
-
const castObject = (orig, castF) => {
|
|
112
|
+
export const castObject = (orig, castF) => {
|
|
124
113
|
const ret = {};
|
|
125
114
|
Object.entries(orig).forEach(([k, v]) => {
|
|
126
115
|
ret[k] = castF(v);
|
|
127
116
|
});
|
|
128
117
|
return ret;
|
|
129
118
|
};
|
|
130
|
-
exports.castObject = castObject;
|
|
131
119
|
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
132
|
-
const removeUndefValuesFromObject = (orig,
|
|
120
|
+
export const removeUndefValuesFromObject = (orig,
|
|
133
121
|
/** other than null or undefined */
|
|
134
122
|
...additionalRemoves) => {
|
|
135
123
|
const ret = {};
|
|
136
124
|
Object.entries(orig).forEach(([k, v]) => {
|
|
137
|
-
if (v !== null && v !== undefined && !
|
|
125
|
+
if (v !== null && v !== undefined && !additionalRemoves?.includes(v)) {
|
|
138
126
|
ret[k] = v;
|
|
139
127
|
}
|
|
140
128
|
});
|
|
141
129
|
return ret;
|
|
142
130
|
};
|
|
143
|
-
exports.removeUndefValuesFromObject = removeUndefValuesFromObject;
|
|
144
131
|
/**
|
|
145
132
|
* cast Record<string,string[]|string> to Record<string,string>. can be used for querystring params
|
|
146
133
|
* @param orig
|
|
147
134
|
* @returns
|
|
148
135
|
*/
|
|
149
|
-
const castStringlyObject = (orig) => {
|
|
150
|
-
const noundef =
|
|
151
|
-
return
|
|
136
|
+
export const castStringlyObject = (orig) => {
|
|
137
|
+
const noundef = removeUndefValuesFromObject(orig);
|
|
138
|
+
return castObject(noundef, (s) => {
|
|
152
139
|
if (Array.isArray(s)) {
|
|
153
140
|
return s.join(',');
|
|
154
141
|
}
|
|
155
142
|
return s;
|
|
156
143
|
});
|
|
157
144
|
};
|
|
158
|
-
exports.castStringlyObject = castStringlyObject;
|
|
159
145
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
|
-
const isObject = (o) => o && typeof o === 'object' && !Array.isArray(o);
|
|
161
|
-
exports.isObject = isObject;
|
|
146
|
+
export const isObject = (o) => o && typeof o === 'object' && !Array.isArray(o);
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shuffle = exports.randomDecimal = exports.random = void 0;
|
|
4
1
|
/** random number up to max. seed defaults to now.getTime() */
|
|
5
|
-
function random(max, seed) {
|
|
2
|
+
export function random(max, seed) {
|
|
6
3
|
seed = seed || new Date().getTime();
|
|
7
4
|
const ret = (seed * 9301 + 49297) % 233280;
|
|
8
5
|
const rnd = ret / 233280;
|
|
9
6
|
return Math.ceil(rnd * max);
|
|
10
7
|
}
|
|
11
|
-
exports.random = random;
|
|
12
8
|
/** between 0 and 1. seed defaults to now.getTime() */
|
|
13
|
-
const randomDecimal = function (seed) {
|
|
9
|
+
export const randomDecimal = function (seed) {
|
|
14
10
|
seed = seed || new Date().getTime();
|
|
15
11
|
const x = Math.sin((seed += 1)) * 10000;
|
|
16
12
|
return x - Math.floor(x);
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
function shuffle(array, seed) {
|
|
14
|
+
export function shuffle(array, seed) {
|
|
20
15
|
let currentIndex = array.length;
|
|
21
16
|
let temporaryValue;
|
|
22
17
|
let randomIndex;
|
|
23
|
-
const r =
|
|
18
|
+
const r = randomDecimal(seed);
|
|
24
19
|
// While there remain elements to shuffle...
|
|
25
20
|
while (currentIndex !== 0) {
|
|
26
21
|
// Pick a remaining element...
|
|
@@ -33,4 +28,3 @@ function shuffle(array, seed) {
|
|
|
33
28
|
}
|
|
34
29
|
return array;
|
|
35
30
|
}
|
|
36
|
-
exports.shuffle = shuffle;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.secondsInNearest = void 0;
|
|
4
1
|
const toFixed = (num, fixed) => {
|
|
5
|
-
var _a, _b;
|
|
6
2
|
const re = new RegExp(`^-?\\d+(?:.\\d{0,${fixed || -1}})?`);
|
|
7
|
-
const x =
|
|
3
|
+
const x = num?.toString()?.match(re)?.[0];
|
|
8
4
|
if (!x) {
|
|
9
5
|
return num;
|
|
10
6
|
}
|
|
@@ -14,7 +10,7 @@ const toFixed = (num, fixed) => {
|
|
|
14
10
|
* @param seconds total seconds > 0
|
|
15
11
|
* @param precision optional precision of number
|
|
16
12
|
*/
|
|
17
|
-
const secondsInNearest = ({ seconds, precision = 2, }) => {
|
|
13
|
+
export const secondsInNearest = ({ seconds, precision = 2, }) => {
|
|
18
14
|
if (seconds <= 0) {
|
|
19
15
|
return 'Now';
|
|
20
16
|
}
|
|
@@ -36,4 +32,3 @@ const secondsInNearest = ({ seconds, precision = 2, }) => {
|
|
|
36
32
|
const v = toFixed(days, precision);
|
|
37
33
|
return `${v} ${v === 1 ? 'day' : 'days'}`;
|
|
38
34
|
};
|
|
39
|
-
exports.secondsInNearest = secondsInNearest;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.fromBase64 = exports.toBase64 = void 0;
|
|
4
|
-
const toBase64 = (str) => Buffer.from(str).toString('base64');
|
|
5
|
-
exports.toBase64 = toBase64;
|
|
6
|
-
const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
7
|
-
exports.fromBase64 = fromBase64;
|
|
1
|
+
export const toBase64 = (str) => Buffer.from(str).toString('base64');
|
|
2
|
+
export const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkString = void 0;
|
|
4
|
-
const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, 'g'));
|
|
5
|
-
exports.chunkString = chunkString;
|
|
1
|
+
export const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, 'g'));
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.containsInsensitive = exports.containsInsensitiveIndex = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* returns >-1 if found
|
|
6
3
|
* @param str
|
|
7
4
|
* @param args
|
|
8
5
|
* @returns
|
|
9
6
|
*/
|
|
10
|
-
function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
|
|
7
|
+
export function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
|
|
11
8
|
if (!str || !args) {
|
|
12
9
|
return -1;
|
|
13
10
|
}
|
|
@@ -22,12 +19,10 @@ function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
|
|
|
22
19
|
}
|
|
23
20
|
return !fromLast ? finds[0] : finds[finds.length - 1];
|
|
24
21
|
}
|
|
25
|
-
exports.containsInsensitiveIndex = containsInsensitiveIndex;
|
|
26
22
|
/**
|
|
27
23
|
* returns true if text is found
|
|
28
24
|
* @param str
|
|
29
25
|
* @param args
|
|
30
26
|
* @returns
|
|
31
27
|
*/
|
|
32
|
-
const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
|
|
33
|
-
exports.containsInsensitive = containsInsensitive;
|
|
28
|
+
export const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExtendedStringSegment = void 0;
|
|
4
|
-
const contains_1 = require("./contains");
|
|
1
|
+
import { containsInsensitiveIndex } from './contains';
|
|
5
2
|
/**
|
|
6
3
|
* will return a piece of text around a found term, and the index it was found
|
|
7
4
|
* @param hay
|
|
8
5
|
* @param needle
|
|
9
6
|
* @returns
|
|
10
7
|
*/
|
|
11
|
-
const getExtendedStringSegment = (hay, needle, blocksOnEitherSide = 5,
|
|
8
|
+
export const getExtendedStringSegment = (hay, needle, blocksOnEitherSide = 5,
|
|
12
9
|
/** can override this if space bounded words are required */
|
|
13
10
|
gapChars = ['\n', '\r\n']) => {
|
|
14
|
-
const fi =
|
|
11
|
+
const fi = containsInsensitiveIndex({ str: hay }, needle);
|
|
15
12
|
if (fi === -1) {
|
|
16
13
|
return undefined;
|
|
17
14
|
}
|
|
18
15
|
let start = fi;
|
|
19
16
|
//we want to extend the partial content back to -(gap) gapChars
|
|
20
17
|
for (let a = 0; a <= blocksOnEitherSide; a += 1) {
|
|
21
|
-
const newstartI =
|
|
18
|
+
const newstartI = containsInsensitiveIndex({ str: hay.substring(0, start), fromLast: true }, ...gapChars);
|
|
22
19
|
if (newstartI !== -1) {
|
|
23
20
|
start = newstartI;
|
|
24
21
|
}
|
|
@@ -26,7 +23,7 @@ gapChars = ['\n', '\r\n']) => {
|
|
|
26
23
|
//and forward
|
|
27
24
|
let end = fi + needle.length;
|
|
28
25
|
for (let a = 0; a <= blocksOnEitherSide; a += 1) {
|
|
29
|
-
const newEndI =
|
|
26
|
+
const newEndI = containsInsensitiveIndex({ str: hay.substring(end) }, ...gapChars);
|
|
30
27
|
if (newEndI !== -1) {
|
|
31
28
|
end += newEndI + 1;
|
|
32
29
|
}
|
|
@@ -41,4 +38,3 @@ gapChars = ['\n', '\r\n']) => {
|
|
|
41
38
|
innerEnd: innerStart + needle.length,
|
|
42
39
|
};
|
|
43
40
|
};
|
|
44
|
-
exports.getExtendedStringSegment = getExtendedStringSegment;
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base64"), exports);
|
|
18
|
-
__exportStar(require("./chunk"), exports);
|
|
19
|
-
__exportStar(require("./contains"), exports);
|
|
20
|
-
__exportStar(require("./getExtendedStringSegment"), exports);
|
|
21
|
-
__exportStar(require("./json"), exports);
|
|
22
|
-
__exportStar(require("./object"), exports);
|
|
23
|
-
__exportStar(require("./surround"), exports);
|
|
24
|
-
__exportStar(require("./trim"), exports);
|
|
25
|
-
__exportStar(require("./truncate"), exports);
|
|
26
|
-
__exportStar(require("./url"), exports);
|
|
1
|
+
export * from './base64';
|
|
2
|
+
export * from './chunk';
|
|
3
|
+
export * from './contains';
|
|
4
|
+
export * from './getExtendedStringSegment';
|
|
5
|
+
export * from './json';
|
|
6
|
+
export * from './object';
|
|
7
|
+
export * from './surround';
|
|
8
|
+
export * from './trim';
|
|
9
|
+
export * from './truncate';
|
|
10
|
+
export * from './url';
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.safeStringify = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* safely handles circular references
|
|
6
3
|
* @param obj
|
|
7
4
|
* @param indent
|
|
8
5
|
* @returns
|
|
9
6
|
*/
|
|
10
|
-
const safeStringify = (obj, indent = 2) => {
|
|
7
|
+
export const safeStringify = (obj, indent = 2) => {
|
|
11
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
9
|
let cache = [];
|
|
13
10
|
const retVal = JSON.stringify(obj, (_key, value) => typeof value === 'object' && value !== null
|
|
@@ -18,4 +15,3 @@ const safeStringify = (obj, indent = 2) => {
|
|
|
18
15
|
cache = null;
|
|
19
16
|
return retVal;
|
|
20
17
|
};
|
|
21
|
-
exports.safeStringify = safeStringify;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToObject = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* object to string - can be used for querystring a=b&c=d etc
|
|
6
3
|
* @param raw eg a=b&c=d
|
|
7
4
|
* @param splitKeyValue eg =
|
|
8
5
|
* @param splitKeys eg &
|
|
9
6
|
*/
|
|
10
|
-
function stringToObject(raw, splitKeyValue, splitKeys) {
|
|
7
|
+
export function stringToObject(raw, splitKeyValue, splitKeys) {
|
|
11
8
|
const ret = {};
|
|
12
9
|
if (!stringToObject) {
|
|
13
10
|
return ret;
|
|
@@ -20,4 +17,3 @@ function stringToObject(raw, splitKeyValue, splitKeys) {
|
|
|
20
17
|
});
|
|
21
18
|
return ret;
|
|
22
19
|
}
|
|
23
|
-
exports.stringToObject = stringToObject;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.surround = void 0;
|
|
4
1
|
/** surround a substring of text with a value */
|
|
5
|
-
const surround = ({ text, start, end, surround, }) => [
|
|
2
|
+
export const surround = ({ text, start, end, surround, }) => [
|
|
6
3
|
surround(text.slice(0, start), false),
|
|
7
4
|
surround(text.slice(start, end), true),
|
|
8
5
|
surround(text.slice(end), false),
|
|
9
6
|
];
|
|
10
|
-
exports.surround = surround;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.trim = exports.trimSide = void 0;
|
|
4
|
-
function trimSide(str, fromStart = true, ...params) {
|
|
1
|
+
export function trimSide(str, fromStart = true, ...params) {
|
|
5
2
|
const pstr = params.join('');
|
|
6
3
|
if (!str) {
|
|
7
4
|
return str;
|
|
@@ -12,8 +9,7 @@ function trimSide(str, fromStart = true, ...params) {
|
|
|
12
9
|
}
|
|
13
10
|
return ret;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
function trim(str, ...params) {
|
|
12
|
+
export function trim(str, ...params) {
|
|
17
13
|
if (!str) {
|
|
18
14
|
return '';
|
|
19
15
|
}
|
|
@@ -21,4 +17,3 @@ function trim(str, ...params) {
|
|
|
21
17
|
str = trimSide(str, false, ...params);
|
|
22
18
|
return str;
|
|
23
19
|
}
|
|
24
|
-
exports.trim = trim;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.truncate = void 0;
|
|
4
|
-
function truncate(str, n, ellip) {
|
|
1
|
+
export function truncate(str, n, ellip) {
|
|
5
2
|
if (!str) {
|
|
6
3
|
return undefined;
|
|
7
4
|
}
|
|
8
5
|
return str.length > n ? str.substr(0, n - 1) + ellip : str;
|
|
9
6
|
}
|
|
10
|
-
exports.truncate = truncate;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidUrl = exports.niceUrl = void 0;
|
|
4
|
-
const trim_1 = require("./trim");
|
|
1
|
+
import { trim } from './trim';
|
|
5
2
|
/**
|
|
6
3
|
* removes protocol, and trailing slashes
|
|
7
4
|
*/
|
|
8
|
-
const niceUrl = (siteUrl) => {
|
|
5
|
+
export const niceUrl = (siteUrl) => {
|
|
9
6
|
if (!siteUrl) {
|
|
10
7
|
return undefined;
|
|
11
8
|
}
|
|
@@ -14,11 +11,10 @@ const niceUrl = (siteUrl) => {
|
|
|
14
11
|
.replace('sc-domain:', '')
|
|
15
12
|
.replace('https://', '')
|
|
16
13
|
.replace('http://', '');
|
|
17
|
-
niceSiteUrl =
|
|
14
|
+
niceSiteUrl = trim(niceSiteUrl, '/');
|
|
18
15
|
return { siteUrl, niceSiteUrl };
|
|
19
16
|
};
|
|
20
|
-
|
|
21
|
-
function isValidUrl(raw) {
|
|
17
|
+
export function isValidUrl(raw) {
|
|
22
18
|
let url;
|
|
23
19
|
try {
|
|
24
20
|
url = new URL(raw);
|
|
@@ -28,4 +24,3 @@ function isValidUrl(raw) {
|
|
|
28
24
|
}
|
|
29
25
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
30
26
|
}
|
|
31
|
-
exports.isValidUrl = isValidUrl;
|
package/dist/common/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./const"), exports);
|
|
18
|
-
__exportStar(require("./helpers"), exports);
|
|
1
|
+
export * from './const';
|
|
2
|
+
export * from './helpers';
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./api"), exports);
|
|
18
|
-
__exportStar(require("./common"), exports);
|
|
19
|
-
__exportStar(require("./ui"), exports);
|
|
1
|
+
export * from './api';
|
|
2
|
+
export * from './common';
|
|
3
|
+
export * from './ui';
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const react_1 = require("@emotion/react");
|
|
8
|
-
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
9
|
-
const react_2 = __importDefault(require("react"));
|
|
10
|
-
const object_1 = require("../../../common/helpers/object");
|
|
11
|
-
const colours_1 = require("../../styles/colours");
|
|
12
|
-
const BGcss = (0, react_1.css) `
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { removeUndefValuesFromObject } from '../../../common/helpers/object';
|
|
5
|
+
import { colours } from '../../styles/colours';
|
|
6
|
+
const BGcss = css `
|
|
13
7
|
display: flex;
|
|
14
8
|
border: 0;
|
|
15
9
|
padding: 3px;
|
|
@@ -24,13 +18,13 @@ const BGcss = (0, react_1.css) `
|
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
20
|
`;
|
|
27
|
-
const BGLink =
|
|
21
|
+
const BGLink = styled.div `
|
|
28
22
|
${BGcss};
|
|
29
23
|
`;
|
|
30
|
-
const BGALink =
|
|
24
|
+
const BGALink = styled.a `
|
|
31
25
|
${BGcss};
|
|
32
26
|
`;
|
|
33
|
-
const Padding =
|
|
27
|
+
const Padding = styled.div `
|
|
34
28
|
justify-content: center;
|
|
35
29
|
align-items: center;
|
|
36
30
|
display: flex;
|
|
@@ -38,14 +32,14 @@ const Padding = styled_1.default.div `
|
|
|
38
32
|
border: 0;
|
|
39
33
|
flex-grow: 1;
|
|
40
34
|
`;
|
|
41
|
-
const FeatureBoxFill = (
|
|
35
|
+
const FeatureBoxFill = styled(Padding) `
|
|
42
36
|
background-image: linear-gradient(to bottom right, var(--left), var(--right));
|
|
43
|
-
color: ${
|
|
37
|
+
color: ${colours.mainLight};
|
|
44
38
|
flex-grow: 1;
|
|
45
39
|
`;
|
|
46
|
-
const BorderGradient = ({ left =
|
|
40
|
+
export const BorderGradient = ({ left = colours.orange, right = colours.orangeRed, children, radius = '2rem', fill = false, padding = '2rem', className, onClick, href, target, rel, noGrow = false, disabled = false, canClick = false, }) => {
|
|
47
41
|
const CCND = canClick && !disabled;
|
|
48
|
-
const style =
|
|
42
|
+
const style = removeUndefValuesFromObject({
|
|
49
43
|
flexGrow: noGrow ? 0 : 1,
|
|
50
44
|
'--left': left,
|
|
51
45
|
'--right': right,
|
|
@@ -63,12 +57,11 @@ const BorderGradient = ({ left = colours_1.colours.orange, right = colours_1.col
|
|
|
63
57
|
style,
|
|
64
58
|
'data-ccnd': CCND,
|
|
65
59
|
};
|
|
66
|
-
const child = (
|
|
67
|
-
!fill &&
|
|
68
|
-
fill &&
|
|
60
|
+
const child = (React.createElement(React.Fragment, null,
|
|
61
|
+
!fill && React.createElement(Padding, { style: { padding } }, children),
|
|
62
|
+
fill && React.createElement(FeatureBoxFill, { style: { padding } }, children)));
|
|
69
63
|
if (href) {
|
|
70
|
-
return
|
|
64
|
+
return React.createElement(BGALink, { ...props }, child);
|
|
71
65
|
}
|
|
72
|
-
return
|
|
66
|
+
return React.createElement(BGLink, { ...props }, child);
|
|
73
67
|
};
|
|
74
|
-
exports.BorderGradient = BorderGradient;
|