ag-common 0.0.894 → 0.0.896
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/LICENSE.md +2 -3
- package/README.md +2 -2
- package/dist/api/helpers/acm.d.ts +1 -1
- package/dist/api/helpers/acm.js +3 -3
- package/dist/api/helpers/api.d.ts +2 -2
- package/dist/api/helpers/api.js +26 -22
- package/dist/api/helpers/apigw.js +4 -4
- package/dist/api/helpers/aws.js +2 -2
- package/dist/api/helpers/cosmos/delete.d.ts +1 -1
- package/dist/api/helpers/cosmos/delete.js +15 -16
- package/dist/api/helpers/cosmos/get.d.ts +3 -3
- package/dist/api/helpers/cosmos/get.js +26 -32
- package/dist/api/helpers/cosmos/index.d.ts +3 -3
- package/dist/api/helpers/cosmos/index.js +1 -1
- package/dist/api/helpers/cosmos/utils.d.ts +1 -1
- package/dist/api/helpers/cosmos/utils.js +3 -7
- package/dist/api/helpers/cosmos/write.d.ts +1 -1
- package/dist/api/helpers/cosmos/write.js +11 -12
- package/dist/api/helpers/dynamo/delete.d.ts +1 -1
- package/dist/api/helpers/dynamo/delete.js +3 -3
- package/dist/api/helpers/dynamo/get.d.ts +2 -2
- package/dist/api/helpers/dynamo/get.js +20 -14
- package/dist/api/helpers/dynamo/index.d.ts +10 -38
- package/dist/api/helpers/dynamo/index.js +4 -4
- package/dist/api/helpers/dynamo/set.d.ts +1 -1
- package/dist/api/helpers/dynamo/set.js +10 -10
- package/dist/api/helpers/dynamo/types.d.ts +3 -3
- package/dist/api/helpers/dynamo/types.js +1 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.d.ts +13 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.js +3 -4
- package/dist/api/helpers/google/apikey.js +1 -1
- package/dist/api/helpers/google/gemini.d.ts +1 -1
- package/dist/api/helpers/google/gemini.js +43 -45
- package/dist/api/helpers/google/index.d.ts +2 -2
- package/dist/api/helpers/index.d.ts +17 -17
- package/dist/api/helpers/retryOnError.js +6 -11
- package/dist/api/helpers/s3.d.ts +9 -9
- package/dist/api/helpers/s3.js +19 -16
- package/dist/api/helpers/ses.d.ts +1 -1
- package/dist/api/helpers/ses.js +9 -9
- package/dist/api/helpers/sqs.d.ts +1 -1
- package/dist/api/helpers/sqs.js +1 -1
- package/dist/api/helpers/ssm.d.ts +1 -1
- package/dist/api/helpers/ssm.js +2 -2
- package/dist/api/helpers/ssmInfra/apigw.d.ts +6 -6
- package/dist/api/helpers/ssmInfra/apigw.js +6 -10
- package/dist/api/helpers/ssmInfra/dynamo.d.ts +2 -2
- package/dist/api/helpers/ssmInfra/dynamo.js +1 -1
- package/dist/api/helpers/ssmInfra/index.d.ts +4 -4
- package/dist/api/helpers/ssmInfra/s3.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/s3.js +1 -1
- package/dist/api/helpers/ssmInfra/sqs.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/sqs.js +1 -1
- package/dist/api/helpers/sts.d.ts +1 -1
- package/dist/api/helpers/sts.js +4 -4
- package/dist/api/helpers/validations.d.ts +2 -2
- package/dist/api/helpers/validations.js +14 -14
- package/dist/api/helpers/zod.d.ts +1 -1
- package/dist/api/helpers/zod.js +21 -27
- package/dist/api/index.d.ts +2 -2
- package/dist/api/types/aws.d.ts +0 -56
- package/dist/api/types/aws.js +0 -1
- package/dist/api/types/index.d.ts +1 -1
- package/dist/common/helpers/array.js +9 -10
- package/dist/common/helpers/async.js +2 -2
- package/dist/common/helpers/binary.d.ts +1 -1
- package/dist/common/helpers/binary.js +1 -1
- package/dist/common/helpers/csv.d.ts +4 -2
- package/dist/common/helpers/csv.js +8 -12
- package/dist/common/helpers/date.d.ts +2 -4
- package/dist/common/helpers/date.js +2 -2
- package/dist/common/helpers/email.js +2 -2
- package/dist/common/helpers/fetch.js +8 -8
- package/dist/common/helpers/generator.js +2 -2
- package/dist/common/helpers/groupBy.js +0 -2
- package/dist/common/helpers/hashCode.js +2 -6
- package/dist/common/helpers/headers.d.ts +20 -20
- package/dist/common/helpers/headers.js +38 -38
- package/dist/common/helpers/i18n.d.ts +2 -2
- package/dist/common/helpers/i18n.js +5 -6
- package/dist/common/helpers/index.d.ts +25 -25
- package/dist/common/helpers/log.d.ts +1 -1
- package/dist/common/helpers/log.js +30 -30
- package/dist/common/helpers/math.d.ts +2 -2
- package/dist/common/helpers/math.js +6 -6
- package/dist/common/helpers/memo.d.ts +1 -1
- package/dist/common/helpers/memo.js +1 -3
- package/dist/common/helpers/node-cache.d.ts +2 -2
- package/dist/common/helpers/node-cache.js +0 -1
- package/dist/common/helpers/object.d.ts +1 -1
- package/dist/common/helpers/object.js +16 -27
- package/dist/common/helpers/secondsInNearest.js +5 -5
- package/dist/common/helpers/stream.js +4 -6
- package/dist/common/helpers/string/base64.js +2 -2
- package/dist/common/helpers/string/chunk.js +1 -1
- package/dist/common/helpers/string/contains.js +1 -3
- package/dist/common/helpers/string/getExtendedStringSegment.js +1 -1
- package/dist/common/helpers/string/index.d.ts +11 -11
- package/dist/common/helpers/string/json.js +1 -1
- package/dist/common/helpers/string/redact.js +38 -39
- package/dist/common/helpers/string/trim.js +4 -4
- package/dist/common/helpers/string/truncate.js +1 -1
- package/dist/common/helpers/string/url.js +7 -8
- package/dist/common/helpers/withRetry.js +7 -7
- package/dist/common/helpers/xml.d.ts +7 -3
- package/dist/common/helpers/xml.js +33 -36
- package/dist/common/index.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/node/helpers/fetch.js +1 -2
- package/dist/node/helpers/fs.js +2 -2
- package/dist/node/helpers/index.d.ts +2 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/ui/components/DarkMode/Base.d.ts +4 -4
- package/dist/ui/components/DarkMode/Base.js +26 -31
- package/dist/ui/components/DarkMode/index.d.ts +2 -2
- package/dist/ui/components/DarkMode/types.d.ts +5 -5
- package/dist/ui/components/HeadersRaw/index.d.ts +2 -2
- package/dist/ui/components/HeadersRaw/index.js +5 -5
- package/dist/ui/components/Markdown/index.d.ts +1 -1
- package/dist/ui/components/Markdown/index.js +10 -10
- package/dist/ui/components/index.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.js +6 -6
- package/dist/ui/components/shadcn/alert.d.ts +2 -2
- package/dist/ui/components/shadcn/alert.js +6 -6
- package/dist/ui/components/shadcn/avatar.d.ts +2 -2
- package/dist/ui/components/shadcn/avatar.js +4 -4
- package/dist/ui/components/shadcn/button.d.ts +4 -4
- package/dist/ui/components/shadcn/button.js +14 -14
- package/dist/ui/components/shadcn/card.d.ts +2 -2
- package/dist/ui/components/shadcn/card.js +6 -6
- package/dist/ui/components/shadcn/checkbox.d.ts +2 -2
- package/dist/ui/components/shadcn/checkbox.js +3 -3
- package/dist/ui/components/shadcn/dialog.d.ts +10 -10
- package/dist/ui/components/shadcn/dialog.js +9 -11
- package/dist/ui/components/shadcn/divider.d.ts +1 -1
- package/dist/ui/components/shadcn/divider.js +1 -1
- package/dist/ui/components/shadcn/dropdown-list.d.ts +1 -1
- package/dist/ui/components/shadcn/dropdown-list.js +5 -5
- package/dist/ui/components/shadcn/dropdown-menu.d.ts +6 -6
- package/dist/ui/components/shadcn/dropdown-menu.js +11 -11
- package/dist/ui/components/shadcn/index.d.ts +21 -21
- package/dist/ui/components/shadcn/input-selector.d.ts +1 -1
- package/dist/ui/components/shadcn/input-selector.js +10 -12
- package/dist/ui/components/shadcn/input.d.ts +1 -1
- package/dist/ui/components/shadcn/input.js +1 -1
- package/dist/ui/components/shadcn/label.d.ts +3 -3
- package/dist/ui/components/shadcn/label.js +2 -2
- package/dist/ui/components/shadcn/popover.d.ts +2 -2
- package/dist/ui/components/shadcn/popover.js +3 -3
- package/dist/ui/components/shadcn/radio-group.d.ts +2 -2
- package/dist/ui/components/shadcn/radio-group.js +2 -2
- package/dist/ui/components/shadcn/scroll-area.d.ts +2 -2
- package/dist/ui/components/shadcn/scroll-area.js +3 -5
- package/dist/ui/components/shadcn/select.d.ts +2 -2
- package/dist/ui/components/shadcn/select.js +12 -12
- package/dist/ui/components/shadcn/sheet.d.ts +12 -12
- package/dist/ui/components/shadcn/sheet.js +15 -15
- package/dist/ui/components/shadcn/switch.d.ts +2 -2
- package/dist/ui/components/shadcn/switch.js +3 -3
- package/dist/ui/components/shadcn/textarea.d.ts +1 -1
- package/dist/ui/components/shadcn/textarea.js +1 -1
- package/dist/ui/components/shadcn/toast.d.ts +2 -2
- package/dist/ui/components/shadcn/toast.js +25 -25
- package/dist/ui/helpers/cognito.d.ts +1 -1
- package/dist/ui/helpers/cookie/const.js +1 -1
- package/dist/ui/helpers/cookie/get.js +3 -4
- package/dist/ui/helpers/cookie/index.d.ts +5 -5
- package/dist/ui/helpers/cookie/raw.d.ts +1 -1
- package/dist/ui/helpers/cookie/raw.js +8 -9
- package/dist/ui/helpers/cookie/use.d.ts +1 -1
- package/dist/ui/helpers/cookie/use.js +4 -4
- package/dist/ui/helpers/date.js +8 -8
- package/dist/ui/helpers/debounce.js +1 -1
- package/dist/ui/helpers/dom.d.ts +1 -1
- package/dist/ui/helpers/dom.js +4 -14
- package/dist/ui/helpers/index.d.ts +26 -26
- package/dist/ui/helpers/jwt.d.ts +3 -3
- package/dist/ui/helpers/openDialog.d.ts +2 -2
- package/dist/ui/helpers/openDialog.js +8 -8
- package/dist/ui/helpers/plural.js +1 -1
- package/dist/ui/helpers/routes.d.ts +2 -2
- package/dist/ui/helpers/routes.js +14 -15
- package/dist/ui/helpers/serviceWorker.js +1 -1
- package/dist/ui/helpers/useContextMenu.d.ts +1 -1
- package/dist/ui/helpers/useContextMenu.js +9 -10
- package/dist/ui/helpers/useElementAttribute.js +3 -5
- package/dist/ui/helpers/useGranularHook.d.ts +1 -1
- package/dist/ui/helpers/useGranularHook.js +2 -3
- package/dist/ui/helpers/useInterval.d.ts +2 -2
- package/dist/ui/helpers/useInterval.js +2 -2
- package/dist/ui/helpers/useIsInViewport.d.ts +1 -1
- package/dist/ui/helpers/useIsInViewport.js +0 -1
- package/dist/ui/helpers/useLocalStorage.js +6 -6
- package/dist/ui/helpers/useLockBodyScroll.js +2 -2
- package/dist/ui/helpers/useOnClickOutside.d.ts +1 -1
- package/dist/ui/helpers/useOnClickOutside.js +3 -6
- package/dist/ui/helpers/useOnScroll.d.ts +1 -1
- package/dist/ui/helpers/useOnScroll.js +3 -4
- package/dist/ui/helpers/useOverloadPageSearch.js +8 -10
- package/dist/ui/helpers/useQueryString.js +7 -7
- package/dist/ui/helpers/useResize.js +5 -6
- package/dist/ui/helpers/useTimeout.js +1 -1
- package/dist/ui/helpers/useTooltip.d.ts +2 -2
- package/dist/ui/helpers/useTooltip.js +5 -7
- package/dist/ui/helpers/utils.d.ts +2 -2
- package/dist/ui/icons/Checkmark.d.ts +2 -2
- package/dist/ui/icons/Checkmark.js +1 -1
- package/dist/ui/icons/ChevronRight.d.ts +1 -1
- package/dist/ui/icons/Circle.d.ts +2 -2
- package/dist/ui/icons/Circle.js +1 -1
- package/dist/ui/icons/CircleDot.d.ts +2 -2
- package/dist/ui/icons/Cog.d.ts +2 -2
- package/dist/ui/icons/Computer.d.ts +2 -2
- package/dist/ui/icons/Door.d.ts +1 -1
- package/dist/ui/icons/Hamburger.d.ts +1 -1
- package/dist/ui/icons/HorizontalDots.d.ts +1 -1
- package/dist/ui/icons/House.d.ts +2 -2
- package/dist/ui/icons/Magnify.d.ts +2 -2
- package/dist/ui/icons/Magnify.js +1 -1
- package/dist/ui/icons/Moon.d.ts +2 -2
- package/dist/ui/icons/Pencil.d.ts +1 -1
- package/dist/ui/icons/Save.d.ts +1 -1
- package/dist/ui/icons/Sun.d.ts +1 -1
- package/dist/ui/icons/Sun.js +1 -1
- package/dist/ui/icons/Undo.d.ts +1 -1
- package/dist/ui/icons/UserOutline.d.ts +1 -1
- package/dist/ui/icons/Warning.d.ts +2 -2
- package/dist/ui/icons/Warning.js +1 -1
- package/dist/ui/icons/index.d.ts +32 -74
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/styles/colours.js +29 -29
- package/dist/ui/styles/common.d.ts +1 -1
- package/dist/ui/styles/common.js +10 -10
- package/dist/ui/styles/index.d.ts +3 -3
- package/package.json +65 -75
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./const";
|
|
2
|
+
export * from "./get";
|
|
3
|
+
export * from "./raw";
|
|
4
|
+
export * from "./set";
|
|
5
|
+
export * from "./use";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const getAllCookies: (cookieString?: string) => Partial<Record<string, string>>;
|
|
7
7
|
/** get a cookie by name*/
|
|
8
|
-
export declare const getCookie: ({ name, cookieDocument
|
|
8
|
+
export declare const getCookie: ({ name, cookieDocument }: {
|
|
9
9
|
name: string;
|
|
10
10
|
cookieDocument?: string;
|
|
11
11
|
}) => string | undefined;
|
|
@@ -15,16 +15,16 @@ const getAllCookies = (cookieString) => {
|
|
|
15
15
|
if (!cookieString) {
|
|
16
16
|
return cookieKeyValuePairs;
|
|
17
17
|
}
|
|
18
|
-
const cookieArr = cookieString.split(
|
|
18
|
+
const cookieArr = cookieString.split(";");
|
|
19
19
|
for (let i = 0; i < cookieArr.length; i++) {
|
|
20
|
-
const cookieKeyValue = cookieArr[i].split(
|
|
20
|
+
const cookieKeyValue = cookieArr[i].split("=");
|
|
21
21
|
cookieKeyValuePairs[cookieKeyValue[0].trim()] = cookieKeyValue[1]?.trim();
|
|
22
22
|
}
|
|
23
23
|
return cookieKeyValuePairs;
|
|
24
24
|
};
|
|
25
25
|
exports.getAllCookies = getAllCookies;
|
|
26
26
|
/** get a cookie by name*/
|
|
27
|
-
const getCookie = ({ name, cookieDocument
|
|
27
|
+
const getCookie = ({ name, cookieDocument }) => (0, exports.getAllCookies)(cookieDocument)[name];
|
|
28
28
|
exports.getCookie = getCookie;
|
|
29
29
|
/**
|
|
30
30
|
* Sets a cookie with the specified name and value
|
|
@@ -32,28 +32,27 @@ exports.getCookie = getCookie;
|
|
|
32
32
|
* @returns
|
|
33
33
|
*/
|
|
34
34
|
function setCookie({ name, value, expiryDays = 1, }) {
|
|
35
|
-
if (typeof window ===
|
|
35
|
+
if (typeof window === "undefined") {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
const d = new Date();
|
|
39
39
|
d.setTime(d.getTime() + expiryDays * 24 * 60 * 60 * 1000);
|
|
40
40
|
const expires = `expires=${!value || expiryDays < 0 ? const_1.expireDate : d.toUTCString()}`;
|
|
41
|
-
document.cookie = `${name}=${!value ?
|
|
41
|
+
document.cookie = `${name}=${!value ? "" : value};${expires};path=/; SameSite=Strict; Secure`;
|
|
42
42
|
}
|
|
43
43
|
/** delete all non httponly cookies */
|
|
44
44
|
function wipeCookies(name) {
|
|
45
|
-
if (typeof window ===
|
|
46
|
-
(0, log_1.warn)(
|
|
45
|
+
if (typeof window === "undefined") {
|
|
46
|
+
(0, log_1.warn)("cant wipe cookies on server");
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
let currentCount = 0;
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
51
50
|
while (true) {
|
|
52
51
|
if ((0, exports.getCookie)({
|
|
53
52
|
name: name + currentCount,
|
|
54
53
|
cookieDocument: document.cookie,
|
|
55
54
|
})) {
|
|
56
|
-
setCookie({ name: name + currentCount, value:
|
|
55
|
+
setCookie({ name: name + currentCount, value: "", expiryDays: -1 });
|
|
57
56
|
currentCount += 1;
|
|
58
57
|
}
|
|
59
58
|
else {
|
|
@@ -31,21 +31,21 @@ function useCookie(p) {
|
|
|
31
31
|
}
|
|
32
32
|
const useCookieString = (p) => useCookie({
|
|
33
33
|
...p,
|
|
34
|
-
parse: (s) => s ??
|
|
34
|
+
parse: (s) => s ?? "",
|
|
35
35
|
stringify: (s) => s,
|
|
36
|
-
defaultValue: p.defaultValue ??
|
|
36
|
+
defaultValue: p.defaultValue ?? "",
|
|
37
37
|
});
|
|
38
38
|
exports.useCookieString = useCookieString;
|
|
39
39
|
const useCookieNumber = (p) => useCookie({
|
|
40
40
|
...p,
|
|
41
41
|
parse: (s) => (!s ? undefined : Number.parseFloat(s)),
|
|
42
|
-
stringify: (s) => (!s ?
|
|
42
|
+
stringify: (s) => (!s ? "" : s.toString()),
|
|
43
43
|
defaultValue: p.defaultValue,
|
|
44
44
|
});
|
|
45
45
|
exports.useCookieNumber = useCookieNumber;
|
|
46
46
|
const useCookieBoolean = (p) => useCookie({
|
|
47
47
|
...p,
|
|
48
|
-
parse: (s) => s ===
|
|
48
|
+
parse: (s) => s === "true",
|
|
49
49
|
stringify: (s) => s.toString(),
|
|
50
50
|
});
|
|
51
51
|
exports.useCookieBoolean = useCookieBoolean;
|
package/dist/ui/helpers/date.js
CHANGED
|
@@ -12,25 +12,25 @@ const plural_1 = require("./plural");
|
|
|
12
12
|
const dateDiffToString = (lowDate, highDate) => {
|
|
13
13
|
const d = (0, date_1.dateDiff)(lowDate, highDate ?? new Date());
|
|
14
14
|
if (isNaN(d.totalYears)) {
|
|
15
|
-
return
|
|
15
|
+
return "";
|
|
16
16
|
}
|
|
17
|
-
let ts = `${d.totalYears} ${(0, plural_1.plural)(
|
|
17
|
+
let ts = `${d.totalYears} ${(0, plural_1.plural)("yr", d.totalYears)} ago `;
|
|
18
18
|
if (d.totalMinutes < 60) {
|
|
19
|
-
ts = `${d.totalMinutes} ${(0, plural_1.plural)(
|
|
19
|
+
ts = `${d.totalMinutes} ${(0, plural_1.plural)("min", d.totalMinutes)} ago `;
|
|
20
20
|
}
|
|
21
21
|
else if (d.totalHours < 24) {
|
|
22
|
-
ts = `${d.totalHours} ${(0, plural_1.plural)(
|
|
22
|
+
ts = `${d.totalHours} ${(0, plural_1.plural)("hr", d.totalHours)} ago `;
|
|
23
23
|
}
|
|
24
24
|
else if (d.totalDays < 365) {
|
|
25
|
-
ts = `${d.totalDays} ${(0, plural_1.plural)(
|
|
25
|
+
ts = `${d.totalDays} ${(0, plural_1.plural)("day", d.totalDays)} ago `;
|
|
26
26
|
}
|
|
27
27
|
return ts;
|
|
28
28
|
};
|
|
29
29
|
exports.dateDiffToString = dateDiffToString;
|
|
30
30
|
const getDMY = (date, opt) => {
|
|
31
31
|
const date1 = (0, date_1.addDays)(date, opt?.dayOffset ?? 0);
|
|
32
|
-
const d = String(date1.getDate()).padStart(2,
|
|
33
|
-
const m = String(date1.getMonth() + 1).padStart(2,
|
|
32
|
+
const d = String(date1.getDate()).padStart(2, "0");
|
|
33
|
+
const m = String(date1.getMonth() + 1).padStart(2, "0"); // January is 0!
|
|
34
34
|
const y = date1.getFullYear();
|
|
35
35
|
if (opt?.short) {
|
|
36
36
|
return `${y.toString().substring(2, 4)}-${m}-${d}`;
|
|
@@ -45,6 +45,6 @@ const isDate = (d) => {
|
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
return new Date(d).toString() !==
|
|
48
|
+
return new Date(d).toString() !== "Invalid Date";
|
|
49
49
|
};
|
|
50
50
|
exports.isDate = isDate;
|
package/dist/ui/helpers/dom.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export declare const convertRemToPixels: (rem: number) => number;
|
|
|
5
5
|
* @param p
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const filterDataProps: (p:
|
|
8
|
+
export declare const filterDataProps: (p: Record<string, unknown>) => Record<string, unknown>;
|
|
9
9
|
export declare const isRightClick: (event: MouseEvent | TouchEvent) => boolean;
|
package/dist/ui/helpers/dom.js
CHANGED
|
@@ -10,8 +10,8 @@ const domContains = (e, x, y) => {
|
|
|
10
10
|
};
|
|
11
11
|
exports.domContains = domContains;
|
|
12
12
|
const convertRemToPixels = (rem) => {
|
|
13
|
-
let fontSize =
|
|
14
|
-
if (typeof window !==
|
|
13
|
+
let fontSize = "16px";
|
|
14
|
+
if (typeof window !== "undefined") {
|
|
15
15
|
fontSize = getComputedStyle(document.documentElement).fontSize;
|
|
16
16
|
}
|
|
17
17
|
return rem * parseFloat(fontSize);
|
|
@@ -22,24 +22,14 @@ exports.convertRemToPixels = convertRemToPixels;
|
|
|
22
22
|
* @param p
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
25
|
const filterDataProps = (p) => {
|
|
27
26
|
const x = Object.entries(p)
|
|
28
|
-
.filter((r) => r[0].startsWith(
|
|
27
|
+
.filter((r) => r[0].startsWith("data-"))
|
|
29
28
|
.map((r) => r);
|
|
30
29
|
return (0, array_1.arrayToObject)(x, (s) => s[0], (s) => s[1]);
|
|
31
30
|
};
|
|
32
31
|
exports.filterDataProps = filterDataProps;
|
|
33
32
|
const isRightClick = (event) => {
|
|
34
|
-
|
|
35
|
-
let isRightMB = false;
|
|
36
|
-
if ('which' in event)
|
|
37
|
-
// Gecko (Firefox), WebKit (Safari/Chrome) & Opera
|
|
38
|
-
isRightMB = event.which == 3;
|
|
39
|
-
else if ('button' in event)
|
|
40
|
-
// IE, Opera
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
isRightMB = event.button == 2;
|
|
43
|
-
return isRightMB;
|
|
33
|
+
return "button" in event && event.button === 2;
|
|
44
34
|
};
|
|
45
35
|
exports.isRightClick = isRightClick;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export type * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export type * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
1
|
+
export type * from "./cognito";
|
|
2
|
+
export * from "./cookie";
|
|
3
|
+
export * from "./date";
|
|
4
|
+
export * from "./debounce";
|
|
5
|
+
export * from "./dom";
|
|
6
|
+
export * from "./extractAttributes";
|
|
7
|
+
export type * from "./jwt";
|
|
8
|
+
export * from "./openDialog";
|
|
9
|
+
export * from "./plural";
|
|
10
|
+
export * from "./routes";
|
|
11
|
+
export * from "./serviceWorker";
|
|
12
|
+
export * from "./useContextMenu";
|
|
13
|
+
export * from "./useElementAttribute";
|
|
14
|
+
export * from "./useGranularHook";
|
|
15
|
+
export * from "./useInterval";
|
|
16
|
+
export * from "./useIsInViewport";
|
|
17
|
+
export * from "./useLocalStorage";
|
|
18
|
+
export * from "./useLockBodyScroll";
|
|
19
|
+
export * from "./useOnClickOutside";
|
|
20
|
+
export * from "./useOnScroll";
|
|
21
|
+
export * from "./useOverloadPageSearch";
|
|
22
|
+
export * from "./useQueryString";
|
|
23
|
+
export * from "./useResize";
|
|
24
|
+
export * from "./useTimeout";
|
|
25
|
+
export * from "./useTooltip";
|
|
26
|
+
export * from "./utils";
|
package/dist/ui/helpers/jwt.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ export interface IdJwt {
|
|
|
18
18
|
at_hash: string;
|
|
19
19
|
aud: string;
|
|
20
20
|
auth_time: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
"cognito:groups": string[];
|
|
22
|
+
"cognito:preferred_role": string;
|
|
23
|
+
"cognito:username": string;
|
|
24
24
|
email: string;
|
|
25
25
|
exp: number;
|
|
26
26
|
iat: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ReactNode } from
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
2
|
type DialogAction = {
|
|
3
3
|
label: string;
|
|
4
4
|
onClick?: () => void;
|
|
5
|
-
variant?:
|
|
5
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
|
6
6
|
};
|
|
7
7
|
type DialogConfig = {
|
|
8
8
|
key: string;
|
|
@@ -41,13 +41,13 @@ const button_1 = require("../components/shadcn/button");
|
|
|
41
41
|
const dialog_1 = require("../components/shadcn/dialog");
|
|
42
42
|
const openDialog = (config) => {
|
|
43
43
|
return new Promise((resolve) => {
|
|
44
|
-
const idName =
|
|
45
|
-
if (document.body.querySelectorAll(
|
|
46
|
-
(0, log_1.error)(
|
|
44
|
+
const idName = "dialog-" + config.key;
|
|
45
|
+
if (document.body.querySelectorAll("#" + idName).length !== 0) {
|
|
46
|
+
(0, log_1.error)("Dialog already open:" + idName);
|
|
47
47
|
resolve(undefined);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const wrapper = document.body.appendChild(document.createElement(
|
|
50
|
+
const wrapper = document.body.appendChild(document.createElement("div"));
|
|
51
51
|
wrapper.id = idName;
|
|
52
52
|
const root = (0, client_1.createRoot)(wrapper);
|
|
53
53
|
const onAction = (actionLabel) => {
|
|
@@ -60,14 +60,14 @@ const openDialog = (config) => {
|
|
|
60
60
|
wrapper.remove();
|
|
61
61
|
}
|
|
62
62
|
catch (e) {
|
|
63
|
-
(0, log_1.error)(
|
|
63
|
+
(0, log_1.error)("Error unmounting dialog", e);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
const DialogComponent = () => {
|
|
68
68
|
const [open, setOpen] = (0, react_1.useState)(true);
|
|
69
69
|
(0, react_1.useEffect)(() => {
|
|
70
|
-
if (
|
|
70
|
+
if ("asyncAction" in config) {
|
|
71
71
|
void config.asyncAction().then(() => {
|
|
72
72
|
onAction(undefined);
|
|
73
73
|
});
|
|
@@ -83,10 +83,10 @@ const openDialog = (config) => {
|
|
|
83
83
|
react_1.default.createElement(dialog_1.DialogTitle, null, config.title),
|
|
84
84
|
react_1.default.createElement(dialog_1.DialogDescription, null),
|
|
85
85
|
config.content({ onClose: () => onAction() }),
|
|
86
|
-
|
|
86
|
+
"actions" in config && (react_1.default.createElement(dialog_1.DialogFooter, null, config.actions.map((action) => (react_1.default.createElement(button_1.Button, { key: action.label, onClick: () => {
|
|
87
87
|
action.onClick?.();
|
|
88
88
|
onAction(action);
|
|
89
|
-
}, variant: action.variant ||
|
|
89
|
+
}, variant: action.variant || "default", className: "cursor-pointer" }, action.label))))))));
|
|
90
90
|
};
|
|
91
91
|
root.render(react_1.default.createElement(DialogComponent, null));
|
|
92
92
|
});
|
|
@@ -6,33 +6,32 @@ const i18n_1 = require("../../common/helpers/i18n");
|
|
|
6
6
|
const object_1 = require("../../common/helpers/object");
|
|
7
7
|
const object_2 = require("../../common/helpers/string/object");
|
|
8
8
|
const url_1 = require("../../common/helpers/string/url");
|
|
9
|
-
const calculateServerHref = ({ host, pathname
|
|
9
|
+
const calculateServerHref = ({ host, pathname }) => {
|
|
10
10
|
if (!host) {
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
|
-
let href =
|
|
14
|
-
if (host.includes(
|
|
15
|
-
href +=
|
|
13
|
+
let href = "";
|
|
14
|
+
if (host.includes("localhost")) {
|
|
15
|
+
href += "http://";
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
href +=
|
|
18
|
+
href += "https://";
|
|
19
19
|
}
|
|
20
20
|
href += host + pathname;
|
|
21
21
|
return decodeURIComponent(href);
|
|
22
22
|
};
|
|
23
23
|
const getRenderLanguage = (host) => {
|
|
24
24
|
if (!host) {
|
|
25
|
-
return
|
|
25
|
+
return "en";
|
|
26
26
|
}
|
|
27
|
-
const l = i18n_1.AllLang.find((l) => host.startsWith(l +
|
|
27
|
+
const l = i18n_1.AllLang.find((l) => host.startsWith(l + "."));
|
|
28
28
|
if (l) {
|
|
29
29
|
return l;
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return "en";
|
|
32
32
|
};
|
|
33
33
|
exports.getRenderLanguage = getRenderLanguage;
|
|
34
|
-
const getQuery = (url) => (0, object_2.stringToObject)((0, common_1.trimSide)(decodeURIComponent(url.search.replace(/\+/g,
|
|
35
|
-
'', '=', '&');
|
|
34
|
+
const getQuery = (url) => (0, object_2.stringToObject)((0, common_1.trimSide)(decodeURIComponent(url.search.replace(/\+/g, "%20")), true, "?") || "", "=", "&");
|
|
36
35
|
const getClientReqHref = () => {
|
|
37
36
|
const nu = new URL(window.location.href);
|
|
38
37
|
const url = (0, url_1.stripUrl)(nu);
|
|
@@ -47,11 +46,11 @@ exports.getClientReqHref = getClientReqHref;
|
|
|
47
46
|
* @returns
|
|
48
47
|
*/
|
|
49
48
|
const getClientOrServerReqHref = ({ url, query, userAgent, }) => {
|
|
50
|
-
if (typeof window !==
|
|
49
|
+
if (typeof window !== "undefined") {
|
|
51
50
|
return (0, exports.getClientReqHref)();
|
|
52
51
|
}
|
|
53
52
|
if (!url) {
|
|
54
|
-
throw new Error(
|
|
53
|
+
throw new Error("no href");
|
|
55
54
|
}
|
|
56
55
|
return {
|
|
57
56
|
url,
|
|
@@ -59,7 +58,7 @@ const getClientOrServerReqHref = ({ url, query, userAgent, }) => {
|
|
|
59
58
|
...query,
|
|
60
59
|
...getQuery(url),
|
|
61
60
|
},
|
|
62
|
-
userAgent: userAgent ??
|
|
61
|
+
userAgent: userAgent ?? "?",
|
|
63
62
|
lang: (0, exports.getRenderLanguage)(url.host),
|
|
64
63
|
};
|
|
65
64
|
};
|
|
@@ -70,14 +69,14 @@ exports.getClientOrServerReqHref = getClientOrServerReqHref;
|
|
|
70
69
|
*/
|
|
71
70
|
const getServerReq = ({ pathname, query, headers, }) => {
|
|
72
71
|
const href = calculateServerHref({
|
|
73
|
-
host: headers.host ||
|
|
72
|
+
host: headers.host || "testhost",
|
|
74
73
|
pathname,
|
|
75
74
|
});
|
|
76
75
|
const parsedQuery = Object.keys(query).length === 0 ? {} : (0, object_1.castStringlyObject)(query);
|
|
77
76
|
const ret = (0, exports.getClientOrServerReqHref)({
|
|
78
77
|
url: !href ? undefined : new URL(href),
|
|
79
78
|
query: parsedQuery,
|
|
80
|
-
userAgent: headers[
|
|
79
|
+
userAgent: headers["user-agent"]?.toLowerCase(),
|
|
81
80
|
});
|
|
82
81
|
return ret;
|
|
83
82
|
};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.uninstallServiceWorkers = uninstallServiceWorkers;
|
|
4
4
|
const async_1 = require("../../common/helpers/async");
|
|
5
5
|
async function uninstallServiceWorkers() {
|
|
6
|
-
if (typeof navigator ===
|
|
6
|
+
if (typeof navigator === "undefined") {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
await navigator.serviceWorker
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.useContextMenu = void 0;
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const useContextMenu = ({ ref
|
|
7
|
-
const [xPos, setXPos] = (0, react_1.useState)(
|
|
8
|
-
const [yPos, setYPos] = (0, react_1.useState)(
|
|
6
|
+
const useContextMenu = ({ ref }) => {
|
|
7
|
+
const [xPos, setXPos] = (0, react_1.useState)("0px");
|
|
8
|
+
const [yPos, setYPos] = (0, react_1.useState)("0px");
|
|
9
9
|
const [showMenu, setShowMenu] = (0, react_1.useState)(false);
|
|
10
10
|
const handleContextMenu = (0, react_1.useCallback)((e) => {
|
|
11
11
|
if (!e.target) {
|
|
@@ -26,15 +26,14 @@ const useContextMenu = ({ ref, }) => {
|
|
|
26
26
|
setShowMenu(false);
|
|
27
27
|
}, [showMenu]);
|
|
28
28
|
(0, react_1.useEffect)(() => {
|
|
29
|
-
document.addEventListener(
|
|
30
|
-
document.addEventListener(
|
|
29
|
+
document.addEventListener("click", handleClick);
|
|
30
|
+
document.addEventListener("contextmenu", handleContextMenu);
|
|
31
31
|
return () => {
|
|
32
32
|
try {
|
|
33
|
-
document.addEventListener(
|
|
34
|
-
document.removeEventListener(
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
document.addEventListener("click", handleClick);
|
|
34
|
+
document.removeEventListener("contextmenu", handleContextMenu);
|
|
36
35
|
}
|
|
37
|
-
catch
|
|
36
|
+
catch {
|
|
38
37
|
//
|
|
39
38
|
}
|
|
40
39
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.useElementAttribute = useElementAttribute;
|
|
5
5
|
const react_1 = require("react");
|
|
@@ -19,17 +19,15 @@ function useElementAttribute({ enabled, key, value, element, }) {
|
|
|
19
19
|
else {
|
|
20
20
|
element.removeAttribute(key);
|
|
21
21
|
}
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
22
|
}
|
|
24
|
-
catch
|
|
23
|
+
catch {
|
|
25
24
|
//
|
|
26
25
|
}
|
|
27
26
|
return () => {
|
|
28
27
|
try {
|
|
29
28
|
element.removeAttribute(key);
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
29
|
}
|
|
32
|
-
catch
|
|
30
|
+
catch {
|
|
33
31
|
//
|
|
34
32
|
}
|
|
35
33
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DependencyList, EffectCallback } from
|
|
1
|
+
import type { DependencyList, EffectCallback } from "react";
|
|
2
2
|
type HookWithDependencies<C, R> = (callback: C, deps: DependencyList) => R;
|
|
3
3
|
export declare const useGranularHook: <T extends HookWithDependencies<C, ReturnType<T>>, C>(hook: T, callback: C, primaryDeps: DependencyList, secondaryDeps: DependencyList) => ReturnType<T>;
|
|
4
4
|
export declare const useGranularEffect: (effect: EffectCallback, primaryDeps: DependencyList, secondaryDeps: DependencyList) => void;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.useGranularEffect = exports.useGranularHook = void 0;
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
|
|
7
7
|
const ref = (0, react_1.useRef)(null);
|
|
8
|
-
if (!ref.current ||
|
|
9
|
-
!primaryDeps.every((w, i) => Object.is(w, ref.current?.[i])))
|
|
8
|
+
if (!ref.current || !primaryDeps.every((w, i) => Object.is(w, ref.current?.[i])))
|
|
10
9
|
ref.current = [...primaryDeps, ...secondaryDeps];
|
|
11
10
|
return hook(callback, ref.current);
|
|
12
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useIsomorphicLayoutEffect: typeof
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
3
3
|
export default useIsomorphicLayoutEffect;
|
|
4
4
|
export declare function useInterval<T>(callback: () => T,
|
|
5
5
|
/** ms delay */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.useIsomorphicLayoutEffect = void 0;
|
|
5
5
|
exports.useInterval = useInterval;
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
exports.useIsomorphicLayoutEffect = typeof window !==
|
|
7
|
+
exports.useIsomorphicLayoutEffect = typeof window !== "undefined" ? react_1.useLayoutEffect : react_1.useEffect;
|
|
8
8
|
exports.default = exports.useIsomorphicLayoutEffect;
|
|
9
9
|
function useInterval(callback,
|
|
10
10
|
/** ms delay */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RefObject } from
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
2
|
export declare function useIsInViewport(ref: RefObject<HTMLElement>): boolean;
|
|
@@ -8,7 +8,6 @@ function useIsInViewport(ref) {
|
|
|
8
8
|
const observer = new IntersectionObserver((entries) => {
|
|
9
9
|
setIsInViewport(entries[0].isIntersecting);
|
|
10
10
|
});
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
12
11
|
if (ref.current) {
|
|
13
12
|
observer.observe(ref.current);
|
|
14
13
|
}
|
|
@@ -7,20 +7,20 @@ const date_1 = require("../../common/helpers/date");
|
|
|
7
7
|
const log_1 = require("../../common/helpers/log");
|
|
8
8
|
const object_1 = require("../../common/helpers/object");
|
|
9
9
|
const clearLocalStorageItem = (key) => {
|
|
10
|
-
if (typeof window ===
|
|
10
|
+
if (typeof window === "undefined") {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
window.localStorage.removeItem(key);
|
|
15
15
|
}
|
|
16
16
|
catch (e) {
|
|
17
|
-
(0, log_1.warn)(
|
|
17
|
+
(0, log_1.warn)("error clearing local storage:", e);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
exports.clearLocalStorageItem = clearLocalStorageItem;
|
|
21
21
|
const clearAllLocalStorage = (except) => {
|
|
22
22
|
try {
|
|
23
|
-
if (typeof window ===
|
|
23
|
+
if (typeof window === "undefined") {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
for (let i = 0; i < localStorage.length; i += 1) {
|
|
@@ -32,13 +32,13 @@ const clearAllLocalStorage = (except) => {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
catch (e) {
|
|
35
|
-
(0, log_1.warn)(
|
|
35
|
+
(0, log_1.warn)("error clearing local storage:", e);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
exports.clearAllLocalStorage = clearAllLocalStorage;
|
|
39
39
|
const setLocalStorageItem = (key, value, ttl) => {
|
|
40
40
|
try {
|
|
41
|
-
if (typeof window ===
|
|
41
|
+
if (typeof window === "undefined") {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const set = {
|
|
@@ -54,7 +54,7 @@ const setLocalStorageItem = (key, value, ttl) => {
|
|
|
54
54
|
};
|
|
55
55
|
exports.setLocalStorageItem = setLocalStorageItem;
|
|
56
56
|
const getLocalStorageItem = (key, initialValue, ttl) => {
|
|
57
|
-
if (typeof window ===
|
|
57
|
+
if (typeof window === "undefined") {
|
|
58
58
|
return initialValue;
|
|
59
59
|
}
|
|
60
60
|
const itemraw = window.localStorage.getItem(key);
|