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.
Files changed (179) hide show
  1. package/dist/api/helpers/api.js +34 -35
  2. package/dist/api/helpers/aws.js +9 -13
  3. package/dist/api/helpers/cloudfront.js +7 -24
  4. package/dist/api/helpers/dynamo.js +85 -134
  5. package/dist/api/helpers/dynamoInfra.js +14 -19
  6. package/dist/api/helpers/enforceDynamoProvisionCap.js +14 -18
  7. package/dist/api/helpers/index.js +14 -30
  8. package/dist/api/helpers/openApiHelpers.d.ts +2 -3
  9. package/dist/api/helpers/openApiHelpers.js +34 -37
  10. package/dist/api/helpers/s3.js +81 -126
  11. package/dist/api/helpers/ses.js +9 -28
  12. package/dist/api/helpers/sqs.js +9 -26
  13. package/dist/api/helpers/ssm.js +8 -14
  14. package/dist/api/helpers/sts.js +16 -34
  15. package/dist/api/helpers/validateOpenApi.js +92 -103
  16. package/dist/api/helpers/validations.js +29 -46
  17. package/dist/api/index.js +2 -18
  18. package/dist/api/openapi-prefix.js +25 -38
  19. package/dist/api/types/aws.js +1 -2
  20. package/dist/api/types/index.js +1 -17
  21. package/dist/common/const.js +2 -5
  22. package/dist/common/helpers/array.js +8 -19
  23. package/dist/common/helpers/async.js +10 -28
  24. package/dist/common/helpers/binary.js +5 -10
  25. package/dist/common/helpers/date.js +14 -25
  26. package/dist/common/helpers/email.js +5 -11
  27. package/dist/common/helpers/func.js +3 -7
  28. package/dist/common/helpers/generator.js +9 -24
  29. package/dist/common/helpers/groupBy.js +3 -9
  30. package/dist/common/helpers/hashCode.js +3 -9
  31. package/dist/common/helpers/i18n.js +9 -17
  32. package/dist/common/helpers/index.js +18 -34
  33. package/dist/common/helpers/log.js +16 -28
  34. package/dist/common/helpers/math.js +9 -21
  35. package/dist/common/helpers/memo.js +3 -7
  36. package/dist/common/helpers/object.js +20 -35
  37. package/dist/common/helpers/random.js +4 -10
  38. package/dist/common/helpers/secondsInNearest.js +2 -7
  39. package/dist/common/helpers/sleep.js +1 -5
  40. package/dist/common/helpers/string/base64.js +2 -7
  41. package/dist/common/helpers/string/chunk.js +1 -5
  42. package/dist/common/helpers/string/contains.js +2 -7
  43. package/dist/common/helpers/string/getExtendedStringSegment.js +5 -9
  44. package/dist/common/helpers/string/index.js +10 -26
  45. package/dist/common/helpers/string/json.js +1 -5
  46. package/dist/common/helpers/string/object.js +1 -5
  47. package/dist/common/helpers/string/surround.js +1 -5
  48. package/dist/common/helpers/string/trim.js +2 -7
  49. package/dist/common/helpers/string/truncate.js +1 -5
  50. package/dist/common/helpers/string/url.js +4 -9
  51. package/dist/common/index.js +2 -18
  52. package/dist/index.js +3 -19
  53. package/dist/ui/components/BorderGradient/index.js +18 -25
  54. package/dist/ui/components/Button/index.js +17 -25
  55. package/dist/ui/components/Chevron/index.js +9 -16
  56. package/dist/ui/components/Close/index.js +6 -13
  57. package/dist/ui/components/Confirm/Dialog.js +9 -25
  58. package/dist/ui/components/Confirm/Modal.js +20 -27
  59. package/dist/ui/components/Confirm/index.js +3 -19
  60. package/dist/ui/components/Confirm/types.js +1 -2
  61. package/dist/ui/components/DropdownList/Base.js +33 -64
  62. package/dist/ui/components/DropdownList/Dialog.js +8 -24
  63. package/dist/ui/components/DropdownList/index.js +2 -18
  64. package/dist/ui/components/DropdownList/types.js +1 -2
  65. package/dist/ui/components/FlexColumn/index.js +4 -14
  66. package/dist/ui/components/FlexRow/index.js +4 -14
  67. package/dist/ui/components/HeadersRaw/index.js +20 -27
  68. package/dist/ui/components/HorizontalScrollBar/index.js +6 -34
  69. package/dist/ui/components/Icon/index.js +9 -16
  70. package/dist/ui/components/Image/index.js +10 -28
  71. package/dist/ui/components/InfiniteScroll/index.js +18 -50
  72. package/dist/ui/components/KebabDots/index.js +6 -13
  73. package/dist/ui/components/Loader/index.js +9 -39
  74. package/dist/ui/components/Modal/Dialog.js +7 -23
  75. package/dist/ui/components/Modal/Modal.js +19 -49
  76. package/dist/ui/components/Modal/index.js +3 -19
  77. package/dist/ui/components/Modal/types.js +1 -2
  78. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +26 -34
  79. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +12 -19
  80. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +6 -11
  81. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +8 -15
  82. package/dist/ui/components/OpenApiCodeBlock/curl/index.js +14 -21
  83. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +8 -15
  84. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +3 -8
  85. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +27 -34
  86. package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +11 -18
  87. package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +7 -17
  88. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +6 -15
  89. package/dist/ui/components/OpenApiCodeBlock/index.js +2 -18
  90. package/dist/ui/components/OpenApiCodeBlock/types.js +1 -2
  91. package/dist/ui/components/PieChart/index.js +11 -18
  92. package/dist/ui/components/ProgressBar/index.js +15 -45
  93. package/dist/ui/components/Prompt/Dialog.js +7 -23
  94. package/dist/ui/components/Prompt/Modal.js +25 -55
  95. package/dist/ui/components/Prompt/index.js +2 -18
  96. package/dist/ui/components/RowOrColumn/index.js +7 -17
  97. package/dist/ui/components/Search/AutoHideSearchBox.js +24 -56
  98. package/dist/ui/components/Search/Base.js +21 -52
  99. package/dist/ui/components/Search/Dialog.js +10 -26
  100. package/dist/ui/components/Search/Inline.js +3 -10
  101. package/dist/ui/components/Search/Modal.js +10 -17
  102. package/dist/ui/components/Search/SearchBox.js +26 -58
  103. package/dist/ui/components/Search/index.js +7 -23
  104. package/dist/ui/components/Search/types.js +1 -2
  105. package/dist/ui/components/Sidebar/index.js +18 -25
  106. package/dist/ui/components/SparkLine/index.js +17 -27
  107. package/dist/ui/components/Table/index.js +15 -22
  108. package/dist/ui/components/TextEdit/CheckboxEdit.js +21 -51
  109. package/dist/ui/components/TextEdit/ColourEdit.js +17 -44
  110. package/dist/ui/components/TextEdit/LengthBox.js +5 -12
  111. package/dist/ui/components/TextEdit/ListboxEdit.js +15 -42
  112. package/dist/ui/components/TextEdit/RadioGroup.js +13 -43
  113. package/dist/ui/components/TextEdit/TextEdit.js +48 -78
  114. package/dist/ui/components/TextEdit/common.js +11 -17
  115. package/dist/ui/components/TextEdit/index.js +6 -22
  116. package/dist/ui/components/TextEdit/types.js +1 -2
  117. package/dist/ui/components/TextWithButton/index.js +10 -40
  118. package/dist/ui/components/TimelineChart/index.js +14 -24
  119. package/dist/ui/components/Toast/Cross.js +9 -16
  120. package/dist/ui/components/Toast/Tick.js +4 -11
  121. package/dist/ui/components/Toast/Warning.js +8 -15
  122. package/dist/ui/components/Toast/base.js +33 -65
  123. package/dist/ui/components/Toast/index.js +2 -18
  124. package/dist/ui/components/Toast/types.js +1 -2
  125. package/dist/ui/components/UserImage/index.js +17 -48
  126. package/dist/ui/components/index.js +30 -46
  127. package/dist/ui/helpers/axiosHelper.js +25 -39
  128. package/dist/ui/helpers/browserHelpers.js +7 -22
  129. package/dist/ui/helpers/callOpenApi/cached.js +18 -37
  130. package/dist/ui/helpers/callOpenApi/direct.js +46 -59
  131. package/dist/ui/helpers/callOpenApi/helpers.js +25 -40
  132. package/dist/ui/helpers/callOpenApi/hook.js +47 -36
  133. package/dist/ui/helpers/callOpenApi/index.js +5 -21
  134. package/dist/ui/helpers/callOpenApi/types.js +1 -2
  135. package/dist/ui/helpers/cognito.js +1 -2
  136. package/dist/ui/helpers/cookie/const.js +2 -5
  137. package/dist/ui/helpers/cookie/get.js +13 -14
  138. package/dist/ui/helpers/cookie/index.js +5 -21
  139. package/dist/ui/helpers/cookie/raw.js +9 -16
  140. package/dist/ui/helpers/cookie/set.js +10 -15
  141. package/dist/ui/helpers/cookie/use.js +23 -16
  142. package/dist/ui/helpers/date.js +10 -15
  143. package/dist/ui/helpers/debounce.js +5 -10
  144. package/dist/ui/helpers/dom.js +6 -13
  145. package/dist/ui/helpers/extractAttributes.js +2 -7
  146. package/dist/ui/helpers/index.js +25 -41
  147. package/dist/ui/helpers/jwt.js +1 -2
  148. package/dist/ui/helpers/plural.js +1 -5
  149. package/dist/ui/helpers/routes.js +17 -24
  150. package/dist/ui/helpers/serviceWorker.js +8 -23
  151. package/dist/ui/helpers/useContextMenu.js +9 -14
  152. package/dist/ui/helpers/useElementAttribute.js +3 -7
  153. package/dist/ui/helpers/useGranularHook.js +5 -10
  154. package/dist/ui/helpers/useInterval.js +8 -12
  155. package/dist/ui/helpers/useLocalStorage.js +24 -32
  156. package/dist/ui/helpers/useLockBodyScroll.js +3 -7
  157. package/dist/ui/helpers/useOnClickOutside.js +7 -12
  158. package/dist/ui/helpers/useOnScroll.js +15 -21
  159. package/dist/ui/helpers/useOverloadPageSearch.js +3 -7
  160. package/dist/ui/helpers/useQueryString.js +14 -20
  161. package/dist/ui/helpers/useResize.js +8 -12
  162. package/dist/ui/helpers/useTimeout.js +5 -9
  163. package/dist/ui/icons/ChevronRight.js +3 -9
  164. package/dist/ui/icons/CrossIcon.js +5 -12
  165. package/dist/ui/icons/Door.js +4 -10
  166. package/dist/ui/icons/HorizontalDots.js +3 -9
  167. package/dist/ui/icons/Magnify.js +3 -10
  168. package/dist/ui/icons/Pencil.js +5 -12
  169. package/dist/ui/icons/Save.js +4 -11
  170. package/dist/ui/icons/Undo.js +5 -12
  171. package/dist/ui/icons/UserOutline.js +3 -9
  172. package/dist/ui/icons/index.js +9 -25
  173. package/dist/ui/index.js +4 -20
  174. package/dist/ui/styles/colours.js +7 -12
  175. package/dist/ui/styles/common.js +14 -22
  176. package/dist/ui/styles/index.js +4 -20
  177. package/dist/ui/styles/media.js +7 -10
  178. package/dist/ui/styles/standaloneStyles.js +10 -16
  179. package/package.json +18 -17
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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, }) => { var _a; return (_a = (0, exports.getAllCookies)(cookieDocument)) === null || _a === void 0 ? void 0 : _a[name]; };
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 ? const_1.expireDate : d.toUTCString()}`;
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
- (0, log_1.warn)('cant wipe cookies on server');
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 ((0, exports.getCookie)({
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setCookieString = exports.setCookieRawWrapper = void 0;
4
- const base64_1 = require("../../../common/helpers/string/base64");
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
- (0, raw_1.wipeCookies)(p.name);
17
+ wipeCookies(p.name);
21
18
  if (!p.value) {
22
19
  return;
23
20
  }
24
- const str = (0, base64_1.toBase64)(stringify(p.value));
25
- const chunks = (0, chunk_1.chunkString)(str, const_1.maxCookieLen);
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
- (0, raw_1.setCookie)(Object.assign(Object.assign({}, p), { name: p.name + index1, value: chunk }));
25
+ setCookie({ ...p, name: p.name + index1, value: chunk });
29
26
  }
30
27
  }
31
- exports.setCookieRawWrapper = setCookieRawWrapper;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCookieBoolean = exports.useCookieNumber = exports.useCookieString = exports.useCookie = void 0;
4
- const react_1 = require("react");
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] = (0, react_1.useState)((0, get_1.getCookieRawWrapper)(Object.assign(Object.assign({}, p), { parse })) || p.defaultValue);
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
- (0, set_1.setCookieRawWrapper)(Object.assign(Object.assign({}, p), { stringify, value }));
23
+ setCookieRawWrapper({ ...p, stringify, value });
27
24
  setCookie(value);
28
25
  };
29
26
  return [cookie, setState];
30
27
  }
31
- exports.useCookie = useCookie;
32
- const useCookieString = (p) => useCookie(Object.assign(Object.assign({}, p), { parse: (s) => s || '', stringify: (s) => s, defaultValue: p.defaultValue || '' }));
33
- exports.useCookieString = useCookieString;
34
- const useCookieNumber = (p) => useCookie(Object.assign(Object.assign({}, p), { parse: (s) => (!s ? undefined : Number.parseFloat(s)), stringify: (s) => (!s ? '' : s.toString()), defaultValue: p.defaultValue }));
35
- exports.useCookieNumber = useCookieNumber;
36
- const useCookieBoolean = (p) => useCookie(Object.assign(Object.assign({}, p), { parse: (s) => s === 'true', stringify: (s) => s.toString() }));
37
- exports.useCookieBoolean = useCookieBoolean;
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
+ });
@@ -1,40 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 = (0, date_1.dateDiff)(lowDate, highDate !== null && highDate !== void 0 ? highDate : new Date());
13
+ const d = dateDiff(lowDate, highDate ?? new Date());
17
14
  if (isNaN(d.totalYears)) {
18
15
  return '';
19
16
  }
20
- let ts = `${d.totalYears} ${(0, plural_1.plural)('yr', d.totalYears)} ago `;
17
+ let ts = `${d.totalYears} ${plural('yr', d.totalYears)} ago `;
21
18
  if (d.totalMinutes < 60) {
22
- ts = `${d.totalMinutes} ${(0, plural_1.plural)('min', d.totalMinutes)} ago `;
19
+ ts = `${d.totalMinutes} ${plural('min', d.totalMinutes)} ago `;
23
20
  }
24
21
  else if (d.totalHours < 24) {
25
- ts = `${d.totalHours} ${(0, plural_1.plural)('hr', d.totalHours)} ago `;
22
+ ts = `${d.totalHours} ${plural('hr', d.totalHours)} ago `;
26
23
  }
27
24
  else if (d.totalDays < 365) {
28
- ts = `${d.totalDays} ${(0, plural_1.plural)('day', d.totalDays)} ago `;
25
+ ts = `${d.totalDays} ${plural('day', d.totalDays)} ago `;
29
26
  }
30
27
  return ts;
31
28
  };
32
- exports.dateDiffToString = dateDiffToString;
33
- const getDMY = (date, dayOffset) => {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debounce = exports.useDebounce = void 0;
4
- const react_1 = require("react");
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;
@@ -1,36 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.domContains = domContains;
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 (0, array_1.arrayToObject)(x, (s) => s[0], (s) => s[1]);
25
+ return arrayToObject(x, (s) => s[0], (s) => s[1]);
31
26
  };
32
- exports.filterDataProps = filterDataProps;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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;
@@ -1,41 +1,25 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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("./axiosHelper"), exports);
18
- __exportStar(require("./browserHelpers"), exports);
19
- __exportStar(require("./callOpenApi"), exports);
20
- __exportStar(require("./cognito"), exports);
21
- __exportStar(require("./cookie"), exports);
22
- __exportStar(require("./date"), exports);
23
- __exportStar(require("./debounce"), exports);
24
- __exportStar(require("./dom"), exports);
25
- __exportStar(require("./extractAttributes"), exports);
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';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getServerReq = exports.getClientOrServerReqHref = void 0;
4
- const url_1 = require("url");
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 = (_c = (_b = (_a = url.host) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
26
- const prefix = host.trim().length !== 0 && ((_d = prefixReg.exec(host)) === null || _d === void 0 ? void 0 : _d[1]);
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 (0, i18n_1.getValidatedLang)(prefix);
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 = (0, url_1.parse)(href);
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: Object.assign(Object.assign({}, query), (0, object_2.stringToObject)(parsed.query || '', '=', '&')),
58
+ query: { ...query, ...stringToObject(parsed.query || '', '=', '&') },
63
59
  };
64
60
  return {
65
61
  url,
66
- userAgent: userAgent !== null && userAgent !== void 0 ? userAgent : '?',
67
- darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false,
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 (((_a = headers['x-forwarded-proto']) === null || _a === void 0 ? void 0 : _a.includes('https')) || encrypted) {
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
- : (0, object_1.castStringlyObject)(query);
90
- const ret = (0, exports.getClientOrServerReqHref)({
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: (_b = headers['user-agent']) === null || _b === void 0 ? void 0 : _b.toLowerCase(),
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
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useContextMenu = void 0;
4
- const react_1 = require("react");
5
- const useContextMenu = ({ ref, }) => {
6
- const [xPos, setXPos] = (0, react_1.useState)('0px');
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
- var _a;
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 = (0, react_1.useCallback)(() => {
17
+ const handleClick = useCallback(() => {
22
18
  if (!showMenu) {
23
19
  return;
24
20
  }
25
21
  setShowMenu(false);
26
22
  }, [showMenu]);
27
- (0, react_1.useEffect)(() => {
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
- "use strict";
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
- (0, react_1.useEffect)(() => {
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useGranularEffect = exports.useGranularHook = void 0;
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) => { var _a; return Object.is(w, (_a = ref.current) === null || _a === void 0 ? void 0 : _a[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
- exports.useGranularHook = useGranularHook;
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);