ag-common 0.0.419 → 0.0.421

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 (178) hide show
  1. package/dist/api/helpers/api.js +35 -34
  2. package/dist/api/helpers/aws.js +13 -9
  3. package/dist/api/helpers/cloudfront.js +24 -7
  4. package/dist/api/helpers/dynamo.js +134 -85
  5. package/dist/api/helpers/dynamoInfra.js +19 -14
  6. package/dist/api/helpers/enforceDynamoProvisionCap.js +18 -14
  7. package/dist/api/helpers/index.js +30 -14
  8. package/dist/api/helpers/openApiHelpers.js +37 -34
  9. package/dist/api/helpers/s3.js +126 -81
  10. package/dist/api/helpers/ses.js +28 -9
  11. package/dist/api/helpers/sqs.js +26 -9
  12. package/dist/api/helpers/ssm.js +14 -8
  13. package/dist/api/helpers/sts.js +34 -16
  14. package/dist/api/helpers/validateOpenApi.js +103 -92
  15. package/dist/api/helpers/validations.js +46 -29
  16. package/dist/api/index.js +18 -2
  17. package/dist/api/openapi-prefix.js +38 -25
  18. package/dist/api/types/aws.js +2 -1
  19. package/dist/api/types/index.js +17 -1
  20. package/dist/common/const.js +5 -2
  21. package/dist/common/helpers/array.js +19 -8
  22. package/dist/common/helpers/async.js +28 -10
  23. package/dist/common/helpers/binary.js +10 -5
  24. package/dist/common/helpers/date.js +25 -14
  25. package/dist/common/helpers/email.js +11 -5
  26. package/dist/common/helpers/func.js +7 -3
  27. package/dist/common/helpers/generator.js +24 -9
  28. package/dist/common/helpers/groupBy.js +9 -3
  29. package/dist/common/helpers/hashCode.js +9 -3
  30. package/dist/common/helpers/i18n.js +17 -9
  31. package/dist/common/helpers/index.js +34 -18
  32. package/dist/common/helpers/log.js +28 -16
  33. package/dist/common/helpers/math.js +21 -9
  34. package/dist/common/helpers/memo.js +7 -3
  35. package/dist/common/helpers/object.js +35 -20
  36. package/dist/common/helpers/random.js +10 -4
  37. package/dist/common/helpers/secondsInNearest.js +7 -2
  38. package/dist/common/helpers/sleep.js +5 -1
  39. package/dist/common/helpers/string/base64.js +7 -2
  40. package/dist/common/helpers/string/chunk.js +5 -1
  41. package/dist/common/helpers/string/contains.js +7 -2
  42. package/dist/common/helpers/string/getExtendedStringSegment.js +9 -5
  43. package/dist/common/helpers/string/index.js +26 -10
  44. package/dist/common/helpers/string/json.js +5 -1
  45. package/dist/common/helpers/string/object.js +5 -1
  46. package/dist/common/helpers/string/surround.js +5 -1
  47. package/dist/common/helpers/string/trim.js +7 -2
  48. package/dist/common/helpers/string/truncate.js +5 -1
  49. package/dist/common/helpers/string/url.js +9 -4
  50. package/dist/common/index.js +18 -2
  51. package/dist/index.js +19 -3
  52. package/dist/ui/components/BorderGradient/index.js +25 -18
  53. package/dist/ui/components/Button/index.js +25 -17
  54. package/dist/ui/components/Chevron/index.js +16 -9
  55. package/dist/ui/components/Close/index.js +13 -6
  56. package/dist/ui/components/Confirm/Dialog.js +25 -9
  57. package/dist/ui/components/Confirm/Modal.js +27 -20
  58. package/dist/ui/components/Confirm/index.js +19 -3
  59. package/dist/ui/components/Confirm/types.js +2 -1
  60. package/dist/ui/components/DropdownList/Base.js +64 -33
  61. package/dist/ui/components/DropdownList/Dialog.js +24 -8
  62. package/dist/ui/components/DropdownList/index.js +18 -2
  63. package/dist/ui/components/DropdownList/types.js +2 -1
  64. package/dist/ui/components/FlexColumn/index.js +14 -4
  65. package/dist/ui/components/FlexRow/index.js +14 -4
  66. package/dist/ui/components/HeadersRaw/index.js +27 -20
  67. package/dist/ui/components/HorizontalScrollBar/index.js +34 -6
  68. package/dist/ui/components/Icon/index.js +16 -9
  69. package/dist/ui/components/Image/index.js +28 -10
  70. package/dist/ui/components/InfiniteScroll/index.js +50 -18
  71. package/dist/ui/components/KebabDots/index.js +13 -6
  72. package/dist/ui/components/Loader/index.js +39 -9
  73. package/dist/ui/components/Modal/Dialog.js +23 -7
  74. package/dist/ui/components/Modal/Modal.js +49 -19
  75. package/dist/ui/components/Modal/index.js +19 -3
  76. package/dist/ui/components/Modal/types.js +2 -1
  77. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +34 -26
  78. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +19 -12
  79. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +11 -6
  80. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +15 -8
  81. package/dist/ui/components/OpenApiCodeBlock/curl/index.js +21 -14
  82. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +15 -8
  83. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +8 -3
  84. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +34 -27
  85. package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +18 -11
  86. package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +17 -7
  87. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +15 -6
  88. package/dist/ui/components/OpenApiCodeBlock/index.js +18 -2
  89. package/dist/ui/components/OpenApiCodeBlock/types.js +2 -1
  90. package/dist/ui/components/PieChart/index.js +18 -11
  91. package/dist/ui/components/ProgressBar/index.js +45 -15
  92. package/dist/ui/components/Prompt/Dialog.js +23 -7
  93. package/dist/ui/components/Prompt/Modal.js +55 -25
  94. package/dist/ui/components/Prompt/index.js +18 -2
  95. package/dist/ui/components/RowOrColumn/index.js +17 -7
  96. package/dist/ui/components/Search/AutoHideSearchBox.js +56 -24
  97. package/dist/ui/components/Search/Base.js +52 -21
  98. package/dist/ui/components/Search/Dialog.js +26 -10
  99. package/dist/ui/components/Search/Inline.js +10 -3
  100. package/dist/ui/components/Search/Modal.js +17 -10
  101. package/dist/ui/components/Search/SearchBox.js +58 -26
  102. package/dist/ui/components/Search/index.js +23 -7
  103. package/dist/ui/components/Search/types.js +2 -1
  104. package/dist/ui/components/Sidebar/index.js +25 -18
  105. package/dist/ui/components/SparkLine/index.js +27 -17
  106. package/dist/ui/components/Table/index.js +22 -15
  107. package/dist/ui/components/TextEdit/CheckboxEdit.js +51 -21
  108. package/dist/ui/components/TextEdit/ColourEdit.js +44 -17
  109. package/dist/ui/components/TextEdit/LengthBox.js +12 -5
  110. package/dist/ui/components/TextEdit/ListboxEdit.js +42 -15
  111. package/dist/ui/components/TextEdit/RadioGroup.js +43 -13
  112. package/dist/ui/components/TextEdit/TextEdit.js +78 -48
  113. package/dist/ui/components/TextEdit/common.js +17 -11
  114. package/dist/ui/components/TextEdit/index.js +22 -6
  115. package/dist/ui/components/TextEdit/types.js +2 -1
  116. package/dist/ui/components/TextWithButton/index.js +40 -10
  117. package/dist/ui/components/TimelineChart/index.js +24 -14
  118. package/dist/ui/components/Toast/Cross.js +16 -9
  119. package/dist/ui/components/Toast/Tick.js +11 -4
  120. package/dist/ui/components/Toast/Warning.js +15 -8
  121. package/dist/ui/components/Toast/base.js +65 -33
  122. package/dist/ui/components/Toast/index.js +18 -2
  123. package/dist/ui/components/Toast/types.js +2 -1
  124. package/dist/ui/components/UserImage/index.js +48 -17
  125. package/dist/ui/components/index.js +46 -30
  126. package/dist/ui/helpers/axiosHelper.js +39 -25
  127. package/dist/ui/helpers/browserHelpers.js +22 -7
  128. package/dist/ui/helpers/callOpenApi/cached.js +37 -18
  129. package/dist/ui/helpers/callOpenApi/direct.js +59 -46
  130. package/dist/ui/helpers/callOpenApi/helpers.js +40 -25
  131. package/dist/ui/helpers/callOpenApi/hook.js +36 -47
  132. package/dist/ui/helpers/callOpenApi/index.js +21 -5
  133. package/dist/ui/helpers/callOpenApi/types.js +2 -1
  134. package/dist/ui/helpers/cognito.js +2 -1
  135. package/dist/ui/helpers/cookie/const.js +5 -2
  136. package/dist/ui/helpers/cookie/get.js +14 -13
  137. package/dist/ui/helpers/cookie/index.js +21 -5
  138. package/dist/ui/helpers/cookie/raw.js +16 -9
  139. package/dist/ui/helpers/cookie/set.js +15 -10
  140. package/dist/ui/helpers/cookie/use.js +16 -23
  141. package/dist/ui/helpers/date.js +15 -10
  142. package/dist/ui/helpers/debounce.js +10 -5
  143. package/dist/ui/helpers/dom.js +13 -6
  144. package/dist/ui/helpers/extractAttributes.js +7 -2
  145. package/dist/ui/helpers/index.js +41 -25
  146. package/dist/ui/helpers/jwt.js +2 -1
  147. package/dist/ui/helpers/plural.js +5 -1
  148. package/dist/ui/helpers/routes.js +24 -17
  149. package/dist/ui/helpers/serviceWorker.js +23 -8
  150. package/dist/ui/helpers/useContextMenu.js +14 -9
  151. package/dist/ui/helpers/useElementAttribute.js +7 -3
  152. package/dist/ui/helpers/useGranularHook.js +10 -5
  153. package/dist/ui/helpers/useInterval.js +12 -8
  154. package/dist/ui/helpers/useLocalStorage.js +32 -24
  155. package/dist/ui/helpers/useLockBodyScroll.js +7 -3
  156. package/dist/ui/helpers/useOnClickOutside.js +12 -7
  157. package/dist/ui/helpers/useOnScroll.js +21 -15
  158. package/dist/ui/helpers/useOverloadPageSearch.js +7 -3
  159. package/dist/ui/helpers/useQueryString.js +20 -14
  160. package/dist/ui/helpers/useResize.js +19 -17
  161. package/dist/ui/helpers/useTimeout.js +9 -5
  162. package/dist/ui/icons/ChevronRight.js +9 -3
  163. package/dist/ui/icons/CrossIcon.js +12 -5
  164. package/dist/ui/icons/Door.js +10 -4
  165. package/dist/ui/icons/HorizontalDots.js +9 -3
  166. package/dist/ui/icons/Magnify.js +10 -3
  167. package/dist/ui/icons/Pencil.js +12 -5
  168. package/dist/ui/icons/Save.js +11 -4
  169. package/dist/ui/icons/Undo.js +12 -5
  170. package/dist/ui/icons/UserOutline.js +9 -3
  171. package/dist/ui/icons/index.js +25 -9
  172. package/dist/ui/index.js +20 -4
  173. package/dist/ui/styles/colours.js +12 -7
  174. package/dist/ui/styles/common.js +22 -14
  175. package/dist/ui/styles/index.js +20 -4
  176. package/dist/ui/styles/media.js +10 -7
  177. package/dist/ui/styles/standaloneStyles.js +16 -10
  178. package/package.json +2 -2
@@ -1,11 +1,14 @@
1
- import { warn } from '../../../common/helpers/log';
2
- import { expireDate } from './const';
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");
3
6
  /**
4
7
  * parse cookie string into key values
5
8
  * @param cookieString
6
9
  * @returns
7
10
  */
8
- export const getAllCookies = (cookieString) => {
11
+ const getAllCookies = (cookieString) => {
9
12
  const cookieKeyValuePairs = {};
10
13
  if (!cookieString) {
11
14
  return cookieKeyValuePairs;
@@ -17,32 +20,35 @@ export const getAllCookies = (cookieString) => {
17
20
  }
18
21
  return cookieKeyValuePairs;
19
22
  };
23
+ exports.getAllCookies = getAllCookies;
20
24
  /** get a cookie by name*/
21
- export const getCookie = ({ name, cookieDocument, }) => getAllCookies(cookieDocument)?.[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;
22
27
  /**
23
28
  * expiryDays <0 will delete
24
29
  * @param param0
25
30
  * @returns
26
31
  */
27
- export function setCookie({ name, value, expiryDays = 1, }) {
32
+ function setCookie({ name, value, expiryDays = 1, }) {
28
33
  if (typeof window === undefined) {
29
34
  return;
30
35
  }
31
36
  const d = new Date();
32
37
  d.setTime(d.getTime() + expiryDays * 24 * 60 * 60 * 1000);
33
- const expires = `expires=${!value || expiryDays < 0 ? expireDate : d.toUTCString()}`;
38
+ const expires = `expires=${!value || expiryDays < 0 ? const_1.expireDate : d.toUTCString()}`;
34
39
  document.cookie = `${name}=${!value ? '' : value};${expires};path=/; SameSite=Strict; Secure`;
35
40
  }
41
+ exports.setCookie = setCookie;
36
42
  /** delete all non httponly cookies */
37
- export function wipeCookies(name) {
43
+ function wipeCookies(name) {
38
44
  if (typeof window === 'undefined') {
39
- warn('cant wipe cookies on server');
45
+ (0, log_1.warn)('cant wipe cookies on server');
40
46
  return;
41
47
  }
42
48
  let currentCount = 0;
43
49
  // eslint-disable-next-line no-constant-condition
44
50
  while (true) {
45
- if (getCookie({
51
+ if ((0, exports.getCookie)({
46
52
  name: name + currentCount,
47
53
  cookieDocument: '',
48
54
  })) {
@@ -54,3 +60,4 @@ export function wipeCookies(name) {
54
60
  }
55
61
  }
56
62
  }
63
+ exports.wipeCookies = wipeCookies;
@@ -1,28 +1,33 @@
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';
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");
5
8
  /**
6
9
  * json+b64 incoming. chunk. write chunks
7
10
  * @param p
8
11
  * @returns
9
12
  */
10
- export function setCookieRawWrapper(p) {
13
+ function setCookieRawWrapper(p) {
11
14
  const stringify = (s) => {
12
15
  if (p.stringify) {
13
16
  return p.stringify(s);
14
17
  }
15
18
  return JSON.stringify(s);
16
19
  };
17
- wipeCookies(p.name);
20
+ (0, raw_1.wipeCookies)(p.name);
18
21
  if (!p.value) {
19
22
  return;
20
23
  }
21
- const str = toBase64(stringify(p.value));
22
- const chunks = chunkString(str, maxCookieLen);
24
+ const str = (0, base64_1.toBase64)(stringify(p.value));
25
+ const chunks = (0, chunk_1.chunkString)(str, const_1.maxCookieLen);
23
26
  for (const index1 in chunks) {
24
27
  const chunk = chunks[index1];
25
- setCookie({ ...p, name: p.name + index1, value: chunk });
28
+ (0, raw_1.setCookie)(Object.assign(Object.assign({}, p), { name: p.name + index1, value: chunk }));
26
29
  }
27
30
  }
28
- export const setCookieString = (p) => setCookieRawWrapper({ ...p, stringify: (s) => s });
31
+ exports.setCookieRawWrapper = setCookieRawWrapper;
32
+ const setCookieString = (p) => setCookieRawWrapper(Object.assign(Object.assign({}, p), { stringify: (s) => s }));
33
+ exports.setCookieString = setCookieString;
@@ -1,7 +1,10 @@
1
- import { useState } from 'react';
2
- import { getCookieRawWrapper } from './get';
3
- import { setCookieRawWrapper } from './set';
4
- export function useCookie(p) {
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) {
5
8
  const parse = (s) => {
6
9
  if (!s) {
7
10
  return p.defaultValue;
@@ -17,28 +20,18 @@ export function useCookie(p) {
17
20
  }
18
21
  return JSON.stringify(s);
19
22
  };
20
- const [cookie, setCookie] = useState(getCookieRawWrapper({ ...p, parse }) || p.defaultValue);
23
+ const [cookie, setCookie] = (0, react_1.useState)((0, get_1.getCookieRawWrapper)(Object.assign(Object.assign({}, p), { parse })) || p.defaultValue);
21
24
  const setState = (valueRaw) => {
22
25
  const value = (valueRaw instanceof Function ? valueRaw(cookie) : valueRaw);
23
- setCookieRawWrapper({ ...p, stringify, value });
26
+ (0, set_1.setCookieRawWrapper)(Object.assign(Object.assign({}, p), { stringify, value }));
24
27
  setCookie(value);
25
28
  };
26
29
  return [cookie, setState];
27
30
  }
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
- });
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;
@@ -1,35 +1,40 @@
1
- import { addDays, dateDiff } from '../../common/helpers/date';
2
- import { plural } from './plural';
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");
3
6
  /**
4
7
  * returns appropriate time diff string
5
8
  * @param lowDate
6
9
  * @param highDate defaults to Date.Now
7
10
  * @returns
8
11
  */
9
- export const dateDiffToString = (lowDate, highDate) => {
12
+ const dateDiffToString = (lowDate, highDate) => {
10
13
  if (!lowDate) {
11
14
  return '';
12
15
  }
13
- const d = dateDiff(lowDate, highDate ?? new Date());
16
+ const d = (0, date_1.dateDiff)(lowDate, highDate !== null && highDate !== void 0 ? highDate : new Date());
14
17
  if (isNaN(d.totalYears)) {
15
18
  return '';
16
19
  }
17
- let ts = `${d.totalYears} ${plural('yr', d.totalYears)} ago `;
20
+ let ts = `${d.totalYears} ${(0, plural_1.plural)('yr', d.totalYears)} ago `;
18
21
  if (d.totalMinutes < 60) {
19
- ts = `${d.totalMinutes} ${plural('min', d.totalMinutes)} ago `;
22
+ ts = `${d.totalMinutes} ${(0, plural_1.plural)('min', d.totalMinutes)} ago `;
20
23
  }
21
24
  else if (d.totalHours < 24) {
22
- ts = `${d.totalHours} ${plural('hr', d.totalHours)} ago `;
25
+ ts = `${d.totalHours} ${(0, plural_1.plural)('hr', d.totalHours)} ago `;
23
26
  }
24
27
  else if (d.totalDays < 365) {
25
- ts = `${d.totalDays} ${plural('day', d.totalDays)} ago `;
28
+ ts = `${d.totalDays} ${(0, plural_1.plural)('day', d.totalDays)} ago `;
26
29
  }
27
30
  return ts;
28
31
  };
29
- export const getDMY = (date, dayOffset) => {
30
- const date1 = addDays(date, dayOffset || 0);
32
+ exports.dateDiffToString = dateDiffToString;
33
+ const getDMY = (date, dayOffset) => {
34
+ const date1 = (0, date_1.addDays)(date, dayOffset || 0);
31
35
  const d = String(date1.getDate()).padStart(2, '0');
32
36
  const m = String(date1.getMonth() + 1).padStart(2, '0'); // January is 0!
33
37
  const y = date1.getFullYear();
34
38
  return `${y}-${m}-${d}`;
35
39
  };
40
+ exports.getDMY = getDMY;
@@ -1,7 +1,10 @@
1
- import { useEffect, useState } from 'react';
2
- export function useDebounce(value, delay) {
3
- const [debouncedValue, setDebouncedValue] = useState(value);
4
- useEffect(() => {
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)(() => {
5
8
  const handler = setTimeout(() => {
6
9
  setDebouncedValue(value);
7
10
  }, delay);
@@ -11,11 +14,13 @@ export function useDebounce(value, delay) {
11
14
  }, [delay, value]);
12
15
  return debouncedValue;
13
16
  }
17
+ exports.useDebounce = useDebounce;
14
18
  const hashMap = {};
15
- export function debounce(callback, { key, time, }) {
19
+ function debounce(callback, { key, time, }) {
16
20
  clearTimeout(hashMap[key]);
17
21
  hashMap[key] = setTimeout(() => {
18
22
  delete hashMap[key];
19
23
  callback();
20
24
  }, time);
21
25
  }
26
+ exports.debounce = debounce;
@@ -1,30 +1,36 @@
1
- import { arrayToObject } from '../../common/helpers/array';
2
- export const domContains = (e, x, y) => {
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) => {
3
6
  if (!e) {
4
7
  return false;
5
8
  }
6
9
  return e.x <= x && x <= e.x + e.width && e.y <= y && y <= e.y + e.height;
7
10
  };
8
- export const convertRemToPixels = (rem) => {
11
+ exports.domContains = domContains;
12
+ const convertRemToPixels = (rem) => {
9
13
  let fontSize = '16px';
10
14
  if (typeof window !== 'undefined') {
11
15
  fontSize = getComputedStyle(document.documentElement).fontSize;
12
16
  }
13
17
  return rem * parseFloat(fontSize);
14
18
  };
19
+ exports.convertRemToPixels = convertRemToPixels;
15
20
  /**
16
21
  * can use to nested wrap styledcomponent components, but persist data- attributes
17
22
  * @param p
18
23
  * @returns
19
24
  */
20
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- export const filterDataProps = (p) => {
26
+ const filterDataProps = (p) => {
22
27
  const x = Object.entries(p)
23
28
  .filter((r) => r[0].startsWith('data-'))
24
29
  .map((r) => r);
25
- return arrayToObject(x, (s) => s[0], (s) => s[1]);
30
+ return (0, array_1.arrayToObject)(x, (s) => s[0], (s) => s[1]);
26
31
  };
27
- export const isRightClick = (event) => {
32
+ exports.filterDataProps = filterDataProps;
33
+ const isRightClick = (event) => {
28
34
  //
29
35
  let isRightMB = false;
30
36
  if ('which' in event)
@@ -36,3 +42,4 @@ export const isRightClick = (event) => {
36
42
  isRightMB = event.button == 2;
37
43
  return isRightMB;
38
44
  };
45
+ exports.isRightClick = isRightClick;
@@ -1,5 +1,9 @@
1
- export const extractAttributes = ({ idName }) => {
2
- if (!document?.getElementById(idName)?.attributes) {
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)) {
3
7
  return {};
4
8
  }
5
9
  const ret = {};
@@ -10,3 +14,4 @@ export const extractAttributes = ({ idName }) => {
10
14
  });
11
15
  return ret;
12
16
  };
17
+ exports.extractAttributes = extractAttributes;
@@ -1,25 +1,41 @@
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
+ "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 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,7 @@
1
- export function plural(word, count) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.plural = void 0;
4
+ function plural(word, count) {
2
5
  if (!word || !count) {
3
6
  return word;
4
7
  }
@@ -7,3 +10,4 @@ export function plural(word, count) {
7
10
  }
8
11
  return word;
9
12
  }
13
+ exports.plural = plural;
@@ -1,7 +1,10 @@
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';
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");
5
8
  const calculateServerHref = ({ host, pathname, }) => {
6
9
  if (!host) {
7
10
  return undefined;
@@ -17,20 +20,21 @@ const calculateServerHref = ({ host, pathname, }) => {
17
20
  return decodeURIComponent(href);
18
21
  };
19
22
  const getRenderLanguage = ({ defaultHost, url, }) => {
23
+ var _a, _b, _c, _d;
20
24
  const prefixReg = new RegExp(`(.*?).(local|${defaultHost.toLowerCase()})`, 'gim');
21
- const host = url.host?.toLowerCase()?.trim() ?? '';
22
- const prefix = host.trim().length !== 0 && prefixReg.exec(host)?.[1];
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]);
23
27
  if (!prefix) {
24
28
  return 'en';
25
29
  }
26
- return getValidatedLang(prefix);
30
+ return (0, i18n_1.getValidatedLang)(prefix);
27
31
  };
28
32
  /**
29
33
  * get parsed url. use on client/SSR. defaults to window location if possible
30
34
  * @param param0
31
35
  * @returns
32
36
  */
33
- export const getClientOrServerReqHref = ({ url: { href, query, protocol }, forceServer = false, userAgent, darkMode, defaultHost, }) => {
37
+ const getClientOrServerReqHref = ({ url: { href, query, protocol }, forceServer = false, userAgent, darkMode, defaultHost, }) => {
34
38
  if (typeof window !== 'undefined') {
35
39
  if (!forceServer) {
36
40
  href = window.location.href;
@@ -46,7 +50,7 @@ export const getClientOrServerReqHref = ({ url: { href, query, protocol }, force
46
50
  if (!href) {
47
51
  throw new Error('no href');
48
52
  }
49
- const parsed = parse(href);
53
+ const parsed = (0, url_1.parse)(href);
50
54
  const url = {
51
55
  hash: parsed.hash || '',
52
56
  host: parsed.host || '',
@@ -55,41 +59,44 @@ export const getClientOrServerReqHref = ({ url: { href, query, protocol }, force
55
59
  path: `${parsed.path}${parsed.hash || ''}`,
56
60
  pathname: parsed.pathname || '',
57
61
  protocol: protocol || '',
58
- query: { ...query, ...stringToObject(parsed.query || '', '=', '&') },
62
+ query: Object.assign(Object.assign({}, query), (0, object_2.stringToObject)(parsed.query || '', '=', '&')),
59
63
  };
60
64
  return {
61
65
  url,
62
- userAgent: userAgent ?? '?',
63
- darkMode: darkMode ?? false,
66
+ userAgent: userAgent !== null && userAgent !== void 0 ? userAgent : '?',
67
+ darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false,
64
68
  lang: getRenderLanguage({ url, defaultHost }),
65
69
  defaultHost,
66
70
  };
67
71
  };
72
+ exports.getClientOrServerReqHref = getClientOrServerReqHref;
68
73
  /**
69
74
  * get server side parsed url
70
75
  * @param param0 * @returns
71
76
  */
72
- export const getServerReq = ({ defaultHost, pathname, query, headers, encrypted, }) => {
77
+ const getServerReq = ({ defaultHost, pathname, query, headers, encrypted, }) => {
78
+ var _a, _b;
73
79
  const href = calculateServerHref({
74
80
  host: headers.host || defaultHost,
75
81
  pathname,
76
82
  });
77
83
  let protocol = 'http:';
78
- if (headers['x-forwarded-proto']?.includes('https') || encrypted) {
84
+ if (((_a = headers['x-forwarded-proto']) === null || _a === void 0 ? void 0 : _a.includes('https')) || encrypted) {
79
85
  protocol = 'https:';
80
86
  }
81
87
  const parsedQuery = !query || Object.keys(query).length === 0
82
88
  ? undefined
83
- : castStringlyObject(query);
84
- const ret = getClientOrServerReqHref({
89
+ : (0, object_1.castStringlyObject)(query);
90
+ const ret = (0, exports.getClientOrServerReqHref)({
85
91
  url: {
86
92
  href,
87
93
  query: parsedQuery,
88
94
  protocol,
89
95
  },
90
96
  forceServer: true,
91
- userAgent: headers['user-agent']?.toLowerCase(),
97
+ userAgent: (_b = headers['user-agent']) === null || _b === void 0 ? void 0 : _b.toLowerCase(),
92
98
  defaultHost,
93
99
  });
94
100
  return ret;
95
101
  };
102
+ exports.getServerReq = getServerReq;
@@ -1,9 +1,24 @@
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()));
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
+ });
9
23
  }
24
+ exports.uninstallServiceWorkers = uninstallServiceWorkers;
@@ -1,12 +1,16 @@
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(
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)(
7
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
11
  (e) => {
9
- if (!ref.current?.contains(e.target)) {
12
+ var _a;
13
+ if (!((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
10
14
  return;
11
15
  }
12
16
  e.preventDefault();
@@ -14,13 +18,13 @@ export const useContextMenu = ({ ref, }) => {
14
18
  setYPos(`${e.pageY}px`);
15
19
  setShowMenu(true);
16
20
  }, [ref]);
17
- const handleClick = useCallback(() => {
21
+ const handleClick = (0, react_1.useCallback)(() => {
18
22
  if (!showMenu) {
19
23
  return;
20
24
  }
21
25
  setShowMenu(false);
22
26
  }, [showMenu]);
23
- useEffect(() => {
27
+ (0, react_1.useEffect)(() => {
24
28
  document.addEventListener('click', handleClick);
25
29
  document.addEventListener('contextmenu', handleContextMenu);
26
30
  return () => {
@@ -30,3 +34,4 @@ export const useContextMenu = ({ ref, }) => {
30
34
  });
31
35
  return { xPos, yPos, showMenu };
32
36
  };
37
+ exports.useContextMenu = useContextMenu;
@@ -1,10 +1,13 @@
1
- import { useEffect } from 'react';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useElementAttribute = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * add and remove an attribute on an element
4
7
  * @param param0
5
8
  */
6
- export function useElementAttribute({ enabled, key, value, element, }) {
7
- useEffect(() => {
9
+ function useElementAttribute({ enabled, key, value, element, }) {
10
+ (0, react_1.useEffect)(() => {
8
11
  if (!element) {
9
12
  return;
10
13
  }
@@ -17,3 +20,4 @@ export function useElementAttribute({ enabled, key, value, element, }) {
17
20
  return () => element.removeAttribute(key);
18
21
  }, [element, enabled, key, value]);
19
22
  }
23
+ exports.useElementAttribute = useElementAttribute;
@@ -1,9 +1,14 @@
1
- import { useEffect, useRef } from 'react';
2
- export const useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
3
- const ref = useRef();
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)();
4
7
  if (!ref.current ||
5
- !primaryDeps.every((w, i) => Object.is(w, ref.current?.[i])))
8
+ !primaryDeps.every((w, i) => { var _a; return Object.is(w, (_a = ref.current) === null || _a === void 0 ? void 0 : _a[i]); }))
6
9
  ref.current = [...primaryDeps, ...secondaryDeps];
7
10
  return hook(callback, ref.current);
8
11
  };
9
- export const useGranularEffect = (effect, primaryDeps, secondaryDeps) => useGranularHook(useEffect, effect, primaryDeps, secondaryDeps);
12
+ exports.useGranularHook = useGranularHook;
13
+ const useGranularEffect = (effect, primaryDeps, secondaryDeps) => (0, exports.useGranularHook)(react_1.useEffect, effect, primaryDeps, secondaryDeps);
14
+ exports.useGranularEffect = useGranularEffect;