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,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.wipeCookies = exports.setCookie = exports.getCookie = exports.getAllCookies = void 0;
|
|
4
|
-
const log_1 = require("../../../common/helpers/log");
|
|
5
|
-
const const_1 = require("./const");
|
|
1
|
+
import { warn } from '../../../common/helpers/log';
|
|
2
|
+
import { expireDate } from './const';
|
|
6
3
|
/**
|
|
7
4
|
* parse cookie string into key values
|
|
8
5
|
* @param cookieString
|
|
9
6
|
* @returns
|
|
10
7
|
*/
|
|
11
|
-
const getAllCookies = (cookieString) => {
|
|
8
|
+
export const getAllCookies = (cookieString) => {
|
|
12
9
|
const cookieKeyValuePairs = {};
|
|
13
10
|
if (!cookieString) {
|
|
14
11
|
return cookieKeyValuePairs;
|
|
@@ -20,35 +17,32 @@ const getAllCookies = (cookieString) => {
|
|
|
20
17
|
}
|
|
21
18
|
return cookieKeyValuePairs;
|
|
22
19
|
};
|
|
23
|
-
exports.getAllCookies = getAllCookies;
|
|
24
20
|
/** get a cookie by name*/
|
|
25
|
-
const getCookie = ({ name, cookieDocument, }) =>
|
|
26
|
-
exports.getCookie = getCookie;
|
|
21
|
+
export const getCookie = ({ name, cookieDocument, }) => getAllCookies(cookieDocument)?.[name];
|
|
27
22
|
/**
|
|
28
23
|
* expiryDays <0 will delete
|
|
29
24
|
* @param param0
|
|
30
25
|
* @returns
|
|
31
26
|
*/
|
|
32
|
-
function setCookie({ name, value, expiryDays = 1, }) {
|
|
27
|
+
export function setCookie({ name, value, expiryDays = 1, }) {
|
|
33
28
|
if (typeof window === undefined) {
|
|
34
29
|
return;
|
|
35
30
|
}
|
|
36
31
|
const d = new Date();
|
|
37
32
|
d.setTime(d.getTime() + expiryDays * 24 * 60 * 60 * 1000);
|
|
38
|
-
const expires = `expires=${!value || expiryDays < 0 ?
|
|
33
|
+
const expires = `expires=${!value || expiryDays < 0 ? expireDate : d.toUTCString()}`;
|
|
39
34
|
document.cookie = `${name}=${!value ? '' : value};${expires};path=/; SameSite=Strict; Secure`;
|
|
40
35
|
}
|
|
41
|
-
exports.setCookie = setCookie;
|
|
42
36
|
/** delete all non httponly cookies */
|
|
43
|
-
function wipeCookies(name) {
|
|
37
|
+
export function wipeCookies(name) {
|
|
44
38
|
if (typeof window === 'undefined') {
|
|
45
|
-
|
|
39
|
+
warn('cant wipe cookies on server');
|
|
46
40
|
return;
|
|
47
41
|
}
|
|
48
42
|
let currentCount = 0;
|
|
49
43
|
// eslint-disable-next-line no-constant-condition
|
|
50
44
|
while (true) {
|
|
51
|
-
if (
|
|
45
|
+
if (getCookie({
|
|
52
46
|
name: name + currentCount,
|
|
53
47
|
cookieDocument: '',
|
|
54
48
|
})) {
|
|
@@ -60,4 +54,3 @@ function wipeCookies(name) {
|
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
|
-
exports.wipeCookies = wipeCookies;
|
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const chunk_1 = require("../../../common/helpers/string/chunk");
|
|
6
|
-
const const_1 = require("./const");
|
|
7
|
-
const raw_1 = require("./raw");
|
|
1
|
+
import { toBase64 } from '../../../common/helpers/string/base64';
|
|
2
|
+
import { chunkString } from '../../../common/helpers/string/chunk';
|
|
3
|
+
import { maxCookieLen } from './const';
|
|
4
|
+
import { setCookie, wipeCookies } from './raw';
|
|
8
5
|
/**
|
|
9
6
|
* json+b64 incoming. chunk. write chunks
|
|
10
7
|
* @param p
|
|
11
8
|
* @returns
|
|
12
9
|
*/
|
|
13
|
-
function setCookieRawWrapper(p) {
|
|
10
|
+
export function setCookieRawWrapper(p) {
|
|
14
11
|
const stringify = (s) => {
|
|
15
12
|
if (p.stringify) {
|
|
16
13
|
return p.stringify(s);
|
|
17
14
|
}
|
|
18
15
|
return JSON.stringify(s);
|
|
19
16
|
};
|
|
20
|
-
|
|
17
|
+
wipeCookies(p.name);
|
|
21
18
|
if (!p.value) {
|
|
22
19
|
return;
|
|
23
20
|
}
|
|
24
|
-
const str =
|
|
25
|
-
const chunks =
|
|
21
|
+
const str = toBase64(stringify(p.value));
|
|
22
|
+
const chunks = chunkString(str, maxCookieLen);
|
|
26
23
|
for (const index1 in chunks) {
|
|
27
24
|
const chunk = chunks[index1];
|
|
28
|
-
|
|
25
|
+
setCookie({ ...p, name: p.name + index1, value: chunk });
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
const setCookieString = (p) => setCookieRawWrapper(Object.assign(Object.assign({}, p), { stringify: (s) => s }));
|
|
33
|
-
exports.setCookieString = setCookieString;
|
|
28
|
+
export const setCookieString = (p) => setCookieRawWrapper({ ...p, stringify: (s) => s });
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const get_1 = require("./get");
|
|
6
|
-
const set_1 = require("./set");
|
|
7
|
-
function useCookie(p) {
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { getCookieRawWrapper } from './get';
|
|
3
|
+
import { setCookieRawWrapper } from './set';
|
|
4
|
+
export function useCookie(p) {
|
|
8
5
|
const parse = (s) => {
|
|
9
6
|
if (!s) {
|
|
10
7
|
return p.defaultValue;
|
|
@@ -20,18 +17,28 @@ function useCookie(p) {
|
|
|
20
17
|
}
|
|
21
18
|
return JSON.stringify(s);
|
|
22
19
|
};
|
|
23
|
-
const [cookie, setCookie] =
|
|
20
|
+
const [cookie, setCookie] = useState(getCookieRawWrapper({ ...p, parse }) || p.defaultValue);
|
|
24
21
|
const setState = (valueRaw) => {
|
|
25
22
|
const value = (valueRaw instanceof Function ? valueRaw(cookie) : valueRaw);
|
|
26
|
-
|
|
23
|
+
setCookieRawWrapper({ ...p, stringify, value });
|
|
27
24
|
setCookie(value);
|
|
28
25
|
};
|
|
29
26
|
return [cookie, setState];
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
export const useCookieString = (p) => useCookie({
|
|
29
|
+
...p,
|
|
30
|
+
parse: (s) => s || '',
|
|
31
|
+
stringify: (s) => s,
|
|
32
|
+
defaultValue: p.defaultValue || '',
|
|
33
|
+
});
|
|
34
|
+
export const useCookieNumber = (p) => useCookie({
|
|
35
|
+
...p,
|
|
36
|
+
parse: (s) => (!s ? undefined : Number.parseFloat(s)),
|
|
37
|
+
stringify: (s) => (!s ? '' : s.toString()),
|
|
38
|
+
defaultValue: p.defaultValue,
|
|
39
|
+
});
|
|
40
|
+
export const useCookieBoolean = (p) => useCookie({
|
|
41
|
+
...p,
|
|
42
|
+
parse: (s) => s === 'true',
|
|
43
|
+
stringify: (s) => s.toString(),
|
|
44
|
+
});
|
package/dist/ui/helpers/date.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getDMY = exports.dateDiffToString = void 0;
|
|
4
|
-
const date_1 = require("../../common/helpers/date");
|
|
5
|
-
const plural_1 = require("./plural");
|
|
1
|
+
import { addDays, dateDiff } from '../../common/helpers/date';
|
|
2
|
+
import { plural } from './plural';
|
|
6
3
|
/**
|
|
7
4
|
* returns appropriate time diff string
|
|
8
5
|
* @param lowDate
|
|
9
6
|
* @param highDate defaults to Date.Now
|
|
10
7
|
* @returns
|
|
11
8
|
*/
|
|
12
|
-
const dateDiffToString = (lowDate, highDate) => {
|
|
9
|
+
export const dateDiffToString = (lowDate, highDate) => {
|
|
13
10
|
if (!lowDate) {
|
|
14
11
|
return '';
|
|
15
12
|
}
|
|
16
|
-
const d =
|
|
13
|
+
const d = dateDiff(lowDate, highDate ?? new Date());
|
|
17
14
|
if (isNaN(d.totalYears)) {
|
|
18
15
|
return '';
|
|
19
16
|
}
|
|
20
|
-
let ts = `${d.totalYears} ${
|
|
17
|
+
let ts = `${d.totalYears} ${plural('yr', d.totalYears)} ago `;
|
|
21
18
|
if (d.totalMinutes < 60) {
|
|
22
|
-
ts = `${d.totalMinutes} ${
|
|
19
|
+
ts = `${d.totalMinutes} ${plural('min', d.totalMinutes)} ago `;
|
|
23
20
|
}
|
|
24
21
|
else if (d.totalHours < 24) {
|
|
25
|
-
ts = `${d.totalHours} ${
|
|
22
|
+
ts = `${d.totalHours} ${plural('hr', d.totalHours)} ago `;
|
|
26
23
|
}
|
|
27
24
|
else if (d.totalDays < 365) {
|
|
28
|
-
ts = `${d.totalDays} ${
|
|
25
|
+
ts = `${d.totalDays} ${plural('day', d.totalDays)} ago `;
|
|
29
26
|
}
|
|
30
27
|
return ts;
|
|
31
28
|
};
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const date1 = (0, date_1.addDays)(date, dayOffset || 0);
|
|
29
|
+
export const getDMY = (date, dayOffset) => {
|
|
30
|
+
const date1 = addDays(date, dayOffset || 0);
|
|
35
31
|
const d = String(date1.getDate()).padStart(2, '0');
|
|
36
32
|
const m = String(date1.getMonth() + 1).padStart(2, '0'); // January is 0!
|
|
37
33
|
const y = date1.getFullYear();
|
|
38
34
|
return `${y}-${m}-${d}`;
|
|
39
35
|
};
|
|
40
|
-
exports.getDMY = getDMY;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useDebounce(value, delay) {
|
|
6
|
-
const [debouncedValue, setDebouncedValue] = (0, react_1.useState)(value);
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export function useDebounce(value, delay) {
|
|
3
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
4
|
+
useEffect(() => {
|
|
8
5
|
const handler = setTimeout(() => {
|
|
9
6
|
setDebouncedValue(value);
|
|
10
7
|
}, delay);
|
|
@@ -14,13 +11,11 @@ function useDebounce(value, delay) {
|
|
|
14
11
|
}, [delay, value]);
|
|
15
12
|
return debouncedValue;
|
|
16
13
|
}
|
|
17
|
-
exports.useDebounce = useDebounce;
|
|
18
14
|
const hashMap = {};
|
|
19
|
-
function debounce(callback, { key, time, }) {
|
|
15
|
+
export function debounce(callback, { key, time, }) {
|
|
20
16
|
clearTimeout(hashMap[key]);
|
|
21
17
|
hashMap[key] = setTimeout(() => {
|
|
22
18
|
delete hashMap[key];
|
|
23
19
|
callback();
|
|
24
20
|
}, time);
|
|
25
21
|
}
|
|
26
|
-
exports.debounce = debounce;
|
package/dist/ui/helpers/dom.js
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isRightClick = exports.filterDataProps = exports.convertRemToPixels = exports.domContains = void 0;
|
|
4
|
-
const array_1 = require("../../common/helpers/array");
|
|
5
|
-
const domContains = (e, x, y) => {
|
|
1
|
+
import { arrayToObject } from '../../common/helpers/array';
|
|
2
|
+
export const domContains = (e, x, y) => {
|
|
6
3
|
if (!e) {
|
|
7
4
|
return false;
|
|
8
5
|
}
|
|
9
6
|
return e.x <= x && x <= e.x + e.width && e.y <= y && y <= e.y + e.height;
|
|
10
7
|
};
|
|
11
|
-
|
|
12
|
-
const convertRemToPixels = (rem) => {
|
|
8
|
+
export const convertRemToPixels = (rem) => {
|
|
13
9
|
let fontSize = '16px';
|
|
14
10
|
if (typeof window !== 'undefined') {
|
|
15
11
|
fontSize = getComputedStyle(document.documentElement).fontSize;
|
|
16
12
|
}
|
|
17
13
|
return rem * parseFloat(fontSize);
|
|
18
14
|
};
|
|
19
|
-
exports.convertRemToPixels = convertRemToPixels;
|
|
20
15
|
/**
|
|
21
16
|
* can use to nested wrap styledcomponent components, but persist data- attributes
|
|
22
17
|
* @param p
|
|
23
18
|
* @returns
|
|
24
19
|
*/
|
|
25
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
const filterDataProps = (p) => {
|
|
21
|
+
export const filterDataProps = (p) => {
|
|
27
22
|
const x = Object.entries(p)
|
|
28
23
|
.filter((r) => r[0].startsWith('data-'))
|
|
29
24
|
.map((r) => r);
|
|
30
|
-
return
|
|
25
|
+
return arrayToObject(x, (s) => s[0], (s) => s[1]);
|
|
31
26
|
};
|
|
32
|
-
|
|
33
|
-
const isRightClick = (event) => {
|
|
27
|
+
export const isRightClick = (event) => {
|
|
34
28
|
//
|
|
35
29
|
let isRightMB = false;
|
|
36
30
|
if ('which' in event)
|
|
@@ -42,4 +36,3 @@ const isRightClick = (event) => {
|
|
|
42
36
|
isRightMB = event.button == 2;
|
|
43
37
|
return isRightMB;
|
|
44
38
|
};
|
|
45
|
-
exports.isRightClick = isRightClick;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.extractAttributes = void 0;
|
|
4
|
-
const extractAttributes = ({ idName }) => {
|
|
5
|
-
var _a;
|
|
6
|
-
if (!((_a = document === null || document === void 0 ? void 0 : document.getElementById(idName)) === null || _a === void 0 ? void 0 : _a.attributes)) {
|
|
1
|
+
export const extractAttributes = ({ idName }) => {
|
|
2
|
+
if (!document?.getElementById(idName)?.attributes) {
|
|
7
3
|
return {};
|
|
8
4
|
}
|
|
9
5
|
const ret = {};
|
|
@@ -14,4 +10,3 @@ const extractAttributes = ({ idName }) => {
|
|
|
14
10
|
});
|
|
15
11
|
return ret;
|
|
16
12
|
};
|
|
17
|
-
exports.extractAttributes = extractAttributes;
|
package/dist/ui/helpers/index.js
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__exportStar(require("./jwt"), exports);
|
|
27
|
-
__exportStar(require("./plural"), exports);
|
|
28
|
-
__exportStar(require("./routes"), exports);
|
|
29
|
-
__exportStar(require("./serviceWorker"), exports);
|
|
30
|
-
__exportStar(require("./useContextMenu"), exports);
|
|
31
|
-
__exportStar(require("./useElementAttribute"), exports);
|
|
32
|
-
__exportStar(require("./useGranularHook"), exports);
|
|
33
|
-
__exportStar(require("./useInterval"), exports);
|
|
34
|
-
__exportStar(require("./useLocalStorage"), exports);
|
|
35
|
-
__exportStar(require("./useLockBodyScroll"), exports);
|
|
36
|
-
__exportStar(require("./useOnClickOutside"), exports);
|
|
37
|
-
__exportStar(require("./useOnScroll"), exports);
|
|
38
|
-
__exportStar(require("./useOverloadPageSearch"), exports);
|
|
39
|
-
__exportStar(require("./useQueryString"), exports);
|
|
40
|
-
__exportStar(require("./useResize"), exports);
|
|
41
|
-
__exportStar(require("./useTimeout"), exports);
|
|
1
|
+
export * from './axiosHelper';
|
|
2
|
+
export * from './browserHelpers';
|
|
3
|
+
export * from './callOpenApi';
|
|
4
|
+
export * from './cognito';
|
|
5
|
+
export * from './cookie';
|
|
6
|
+
export * from './date';
|
|
7
|
+
export * from './debounce';
|
|
8
|
+
export * from './dom';
|
|
9
|
+
export * from './extractAttributes';
|
|
10
|
+
export * from './jwt';
|
|
11
|
+
export * from './plural';
|
|
12
|
+
export * from './routes';
|
|
13
|
+
export * from './serviceWorker';
|
|
14
|
+
export * from './useContextMenu';
|
|
15
|
+
export * from './useElementAttribute';
|
|
16
|
+
export * from './useGranularHook';
|
|
17
|
+
export * from './useInterval';
|
|
18
|
+
export * from './useLocalStorage';
|
|
19
|
+
export * from './useLockBodyScroll';
|
|
20
|
+
export * from './useOnClickOutside';
|
|
21
|
+
export * from './useOnScroll';
|
|
22
|
+
export * from './useOverloadPageSearch';
|
|
23
|
+
export * from './useQueryString';
|
|
24
|
+
export * from './useResize';
|
|
25
|
+
export * from './useTimeout';
|
package/dist/ui/helpers/jwt.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.plural = void 0;
|
|
4
|
-
function plural(word, count) {
|
|
1
|
+
export function plural(word, count) {
|
|
5
2
|
if (!word || !count) {
|
|
6
3
|
return word;
|
|
7
4
|
}
|
|
@@ -10,4 +7,3 @@ function plural(word, count) {
|
|
|
10
7
|
}
|
|
11
8
|
return word;
|
|
12
9
|
}
|
|
13
|
-
exports.plural = plural;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const i18n_1 = require("../../common/helpers/i18n");
|
|
6
|
-
const object_1 = require("../../common/helpers/object");
|
|
7
|
-
const object_2 = require("../../common/helpers/string/object");
|
|
1
|
+
import { parse } from 'url';
|
|
2
|
+
import { getValidatedLang } from '../../common/helpers/i18n';
|
|
3
|
+
import { castStringlyObject } from '../../common/helpers/object';
|
|
4
|
+
import { stringToObject } from '../../common/helpers/string/object';
|
|
8
5
|
const calculateServerHref = ({ host, pathname, }) => {
|
|
9
6
|
if (!host) {
|
|
10
7
|
return undefined;
|
|
@@ -20,21 +17,20 @@ const calculateServerHref = ({ host, pathname, }) => {
|
|
|
20
17
|
return decodeURIComponent(href);
|
|
21
18
|
};
|
|
22
19
|
const getRenderLanguage = ({ defaultHost, url, }) => {
|
|
23
|
-
var _a, _b, _c, _d;
|
|
24
20
|
const prefixReg = new RegExp(`(.*?).(local|${defaultHost.toLowerCase()})`, 'gim');
|
|
25
|
-
const host =
|
|
26
|
-
const prefix = host.trim().length !== 0 &&
|
|
21
|
+
const host = url.host?.toLowerCase()?.trim() ?? '';
|
|
22
|
+
const prefix = host.trim().length !== 0 && prefixReg.exec(host)?.[1];
|
|
27
23
|
if (!prefix) {
|
|
28
24
|
return 'en';
|
|
29
25
|
}
|
|
30
|
-
return
|
|
26
|
+
return getValidatedLang(prefix);
|
|
31
27
|
};
|
|
32
28
|
/**
|
|
33
29
|
* get parsed url. use on client/SSR. defaults to window location if possible
|
|
34
30
|
* @param param0
|
|
35
31
|
* @returns
|
|
36
32
|
*/
|
|
37
|
-
const getClientOrServerReqHref = ({ url: { href, query, protocol }, forceServer = false, userAgent, darkMode, defaultHost, }) => {
|
|
33
|
+
export const getClientOrServerReqHref = ({ url: { href, query, protocol }, forceServer = false, userAgent, darkMode, defaultHost, }) => {
|
|
38
34
|
if (typeof window !== 'undefined') {
|
|
39
35
|
if (!forceServer) {
|
|
40
36
|
href = window.location.href;
|
|
@@ -50,7 +46,7 @@ const getClientOrServerReqHref = ({ url: { href, query, protocol }, forceServer
|
|
|
50
46
|
if (!href) {
|
|
51
47
|
throw new Error('no href');
|
|
52
48
|
}
|
|
53
|
-
const parsed =
|
|
49
|
+
const parsed = parse(href);
|
|
54
50
|
const url = {
|
|
55
51
|
hash: parsed.hash || '',
|
|
56
52
|
host: parsed.host || '',
|
|
@@ -59,44 +55,41 @@ const getClientOrServerReqHref = ({ url: { href, query, protocol }, forceServer
|
|
|
59
55
|
path: `${parsed.path}${parsed.hash || ''}`,
|
|
60
56
|
pathname: parsed.pathname || '',
|
|
61
57
|
protocol: protocol || '',
|
|
62
|
-
query:
|
|
58
|
+
query: { ...query, ...stringToObject(parsed.query || '', '=', '&') },
|
|
63
59
|
};
|
|
64
60
|
return {
|
|
65
61
|
url,
|
|
66
|
-
userAgent: userAgent
|
|
67
|
-
darkMode: darkMode
|
|
62
|
+
userAgent: userAgent ?? '?',
|
|
63
|
+
darkMode: darkMode ?? false,
|
|
68
64
|
lang: getRenderLanguage({ url, defaultHost }),
|
|
69
65
|
defaultHost,
|
|
70
66
|
};
|
|
71
67
|
};
|
|
72
|
-
exports.getClientOrServerReqHref = getClientOrServerReqHref;
|
|
73
68
|
/**
|
|
74
69
|
* get server side parsed url
|
|
75
70
|
* @param param0 * @returns
|
|
76
71
|
*/
|
|
77
|
-
const getServerReq = ({ defaultHost, pathname, query, headers, encrypted, }) => {
|
|
78
|
-
var _a, _b;
|
|
72
|
+
export const getServerReq = ({ defaultHost, pathname, query, headers, encrypted, }) => {
|
|
79
73
|
const href = calculateServerHref({
|
|
80
74
|
host: headers.host || defaultHost,
|
|
81
75
|
pathname,
|
|
82
76
|
});
|
|
83
77
|
let protocol = 'http:';
|
|
84
|
-
if (
|
|
78
|
+
if (headers['x-forwarded-proto']?.includes('https') || encrypted) {
|
|
85
79
|
protocol = 'https:';
|
|
86
80
|
}
|
|
87
81
|
const parsedQuery = !query || Object.keys(query).length === 0
|
|
88
82
|
? undefined
|
|
89
|
-
:
|
|
90
|
-
const ret =
|
|
83
|
+
: castStringlyObject(query);
|
|
84
|
+
const ret = getClientOrServerReqHref({
|
|
91
85
|
url: {
|
|
92
86
|
href,
|
|
93
87
|
query: parsedQuery,
|
|
94
88
|
protocol,
|
|
95
89
|
},
|
|
96
90
|
forceServer: true,
|
|
97
|
-
userAgent:
|
|
91
|
+
userAgent: headers['user-agent']?.toLowerCase(),
|
|
98
92
|
defaultHost,
|
|
99
93
|
});
|
|
100
94
|
return ret;
|
|
101
95
|
};
|
|
102
|
-
exports.getServerReq = getServerReq;
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.uninstallServiceWorkers = void 0;
|
|
13
|
-
const async_1 = require("../../common/helpers/async");
|
|
14
|
-
function uninstallServiceWorkers() {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
if (typeof navigator === 'undefined') {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
yield navigator.serviceWorker
|
|
20
|
-
.getRegistrations()
|
|
21
|
-
.then((registrations) => __awaiter(this, void 0, void 0, function* () { return (0, async_1.asyncForEach)([...registrations], (r) => r.unregister()); }));
|
|
22
|
-
});
|
|
1
|
+
import { asyncForEach } from '../../common/helpers/async';
|
|
2
|
+
export async function uninstallServiceWorkers() {
|
|
3
|
+
if (typeof navigator === 'undefined') {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
await navigator.serviceWorker
|
|
7
|
+
.getRegistrations()
|
|
8
|
+
.then(async (registrations) => asyncForEach([...registrations], (r) => r.unregister()));
|
|
23
9
|
}
|
|
24
|
-
exports.uninstallServiceWorkers = uninstallServiceWorkers;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const [yPos, setYPos] = (0, react_1.useState)('0px');
|
|
8
|
-
const [showMenu, setShowMenu] = (0, react_1.useState)(false);
|
|
9
|
-
const handleContextMenu = (0, react_1.useCallback)(
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
export const useContextMenu = ({ ref, }) => {
|
|
3
|
+
const [xPos, setXPos] = useState('0px');
|
|
4
|
+
const [yPos, setYPos] = useState('0px');
|
|
5
|
+
const [showMenu, setShowMenu] = useState(false);
|
|
6
|
+
const handleContextMenu = useCallback(
|
|
10
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
8
|
(e) => {
|
|
12
|
-
|
|
13
|
-
if (!((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
9
|
+
if (!ref.current?.contains(e.target)) {
|
|
14
10
|
return;
|
|
15
11
|
}
|
|
16
12
|
e.preventDefault();
|
|
@@ -18,13 +14,13 @@ const useContextMenu = ({ ref, }) => {
|
|
|
18
14
|
setYPos(`${e.pageY}px`);
|
|
19
15
|
setShowMenu(true);
|
|
20
16
|
}, [ref]);
|
|
21
|
-
const handleClick =
|
|
17
|
+
const handleClick = useCallback(() => {
|
|
22
18
|
if (!showMenu) {
|
|
23
19
|
return;
|
|
24
20
|
}
|
|
25
21
|
setShowMenu(false);
|
|
26
22
|
}, [showMenu]);
|
|
27
|
-
|
|
23
|
+
useEffect(() => {
|
|
28
24
|
document.addEventListener('click', handleClick);
|
|
29
25
|
document.addEventListener('contextmenu', handleContextMenu);
|
|
30
26
|
return () => {
|
|
@@ -34,4 +30,3 @@ const useContextMenu = ({ ref, }) => {
|
|
|
34
30
|
});
|
|
35
31
|
return { xPos, yPos, showMenu };
|
|
36
32
|
};
|
|
37
|
-
exports.useContextMenu = useContextMenu;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useElementAttribute = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
1
|
+
import { useEffect } from 'react';
|
|
5
2
|
/**
|
|
6
3
|
* add and remove an attribute on an element
|
|
7
4
|
* @param param0
|
|
8
5
|
*/
|
|
9
|
-
function useElementAttribute({ enabled, key, value, element, }) {
|
|
10
|
-
|
|
6
|
+
export function useElementAttribute({ enabled, key, value, element, }) {
|
|
7
|
+
useEffect(() => {
|
|
11
8
|
if (!element) {
|
|
12
9
|
return;
|
|
13
10
|
}
|
|
@@ -20,4 +17,3 @@ function useElementAttribute({ enabled, key, value, element, }) {
|
|
|
20
17
|
return () => element.removeAttribute(key);
|
|
21
18
|
}, [element, enabled, key, value]);
|
|
22
19
|
}
|
|
23
|
-
exports.useElementAttribute = useElementAttribute;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
|
|
6
|
-
const ref = (0, react_1.useRef)();
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export const useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
|
|
3
|
+
const ref = useRef();
|
|
7
4
|
if (!ref.current ||
|
|
8
|
-
!primaryDeps.every((w, i) =>
|
|
5
|
+
!primaryDeps.every((w, i) => Object.is(w, ref.current?.[i])))
|
|
9
6
|
ref.current = [...primaryDeps, ...secondaryDeps];
|
|
10
7
|
return hook(callback, ref.current);
|
|
11
8
|
};
|
|
12
|
-
|
|
13
|
-
const useGranularEffect = (effect, primaryDeps, secondaryDeps) => (0, exports.useGranularHook)(react_1.useEffect, effect, primaryDeps, secondaryDeps);
|
|
14
|
-
exports.useGranularEffect = useGranularEffect;
|
|
9
|
+
export const useGranularEffect = (effect, primaryDeps, secondaryDeps) => useGranularHook(useEffect, effect, primaryDeps, secondaryDeps);
|